|
01-22-2017, 08:38 AM
|
#1
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
Periodic noise or silence for demo products?
I need to add periodic noise or silence to my products but i can't figure it out.
I want 2 seconds noise or silence for every minute.
Can you help me about it?
Thanks.
|
|
|
01-22-2017, 08:57 AM
|
#2
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,334
|
|
|
|
01-22-2017, 11:15 AM
|
#3
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
Quote:
Originally Posted by vitalker
|
Hmm...Thanks in advice but i didn't understand how can i implement it to my products.
|
|
|
01-22-2017, 01:11 PM
|
#4
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
|
Well, I would simply add double mTimer to my plug-in class, and init it with 0 in the constructor. Then in ProcessDoubleReplacing() I would update the timer i.e. mTimer += nFrames/GetSampleRate(). Then if mTimer >= 60 I would start adding noise to the outputs. And when mTimer >= 62 I would reset it back to 2 i.e. mTimer -= 60.
I would probably also add some sort of fade in/out, so the noise burst comes in easy, and maybe optimize the timer by using int instead of double.
|
|
|
01-22-2017, 01:25 PM
|
#5
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
Quote:
Originally Posted by Tale
Well, I would simply add double mTimer to my plug-in class, and init it with 0 in the constructor. Then in ProcessDoubleReplacing() I would update the timer i.e. mTimer += nFrames/GetSampleRate(). Then if mTimer >= 60 I would start adding noise to the outputs. And when mTimer >= 62 I would reset it back to 2 i.e. mTimer -= 60.
I would probably also add some sort of fade in/out, so the noise burst comes in easy, and maybe optimize the timer by using int instead of double.
|
Thanks in advice!
I tried what you say but no luck.I guess i didn't understand correctly.
Actually i will reset parameters for every two minutes.It's easier than adding noise.
For example;
(mGainM = Mid freq. gain)
if mTimer >= 60
mGainM = 0
Can you write simple code for this,please?
|
|
|
01-22-2017, 01:33 PM
|
#6
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
|
Code:
void MyPlug::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
mTimer += nFrames/GetSampleRate(); // seconds
if (mTimer >= 2*60) // 2 minutes
{
mTimer = 0;
// Reset parameters here.
}
// Process audio here.
}
|
|
|
01-22-2017, 01:56 PM
|
#7
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
Quote:
Originally Posted by Tale
Code:
void MyPlug::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
mTimer += nFrames/GetSampleRate(); // seconds
if (mTimer >= 2*60) // 2 minutes
{
mTimer = 0;
// Reset parameters here.
}
// Process audio here.
}
|
Worked great!Thanks!
But only i have issue about time.
I have to change 2*60 to 4*60000 to reset parameter for every 2 minutes.
|
|
|
01-22-2017, 02:27 PM
|
#8
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
|
Quote:
Originally Posted by Tunca
But only i have issue about time.
I have to change 2*60 to 4*60000 to reset parameter for every 2 minutes.
|
Well, mTimer is in (fractional) seconds, so that doesn't make sense... Unless you are perhaps incrementing mTimer inside your sample loop (with nFrames =~ 2048). I would keep this outside the sample loop, because it is faster and cleaner, and I guess you won't need sample accuracy for this anyway.
|
|
|
01-22-2017, 02:59 PM
|
#9
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
Quote:
Originally Posted by Tale
Well, mTimer is in (fractional) seconds, so that doesn't make sense... Unless you are perhaps incrementing mTimer inside your sample loop (with nFrames =~ 2048). I would keep this outside the sample loop, because it is faster and cleaner, and I guess you won't need sample accuracy for this anyway.
|
What you mean with "keeping this outside the sample loop"?
I added this into "ProcessDoubleReplacing".
By the way will time change with different samplerates?For example i tried with 44.1k and 1024 buf.size.If i change buf.size or samplerate,will mTimer change?
|
|
|
01-22-2017, 10:01 PM
|
#10
|
Human being with feelings
Join Date: Nov 2012
Location: 'straya
Posts: 9,409
|
Quote:
Originally Posted by Tale
Well, I would simply add double mTimer to my plug-in class, and init it with 0 in the constructor. Then in ProcessDoubleReplacing() I would update the timer i.e. mTimer += nFrames/GetSampleRate(). Then if mTimer >= 60 I would start adding noise to the outputs. And when mTimer >= 62 I would reset it back to 2 i.e. mTimer -= 60.
I would probably also add some sort of fade in/out, so the noise burst comes in easy, and maybe optimize the timer by using int instead of double.
|
Sure, if you like that simple approach, but with a lot of the music out there now this is gonna be a lot of peoples favourite part of the song, I don't think we should be cutting corners here...
|
|
|
01-23-2017, 12:03 AM
|
#11
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
|
Quote:
Originally Posted by Tunca
What you mean with "keeping this outside the sample loop"?
|
In ProcessDoubleReplacing(), before (or after) The for(i=0;i<nFrames;++i) loop, but not inside that loop.
Quote:
Originally Posted by Tunca
By the way will time change with different samplerates?For example i tried with 44.1k and 1024 buf.size.If i change buf.size or samplerate,will mTimer change?
|
No it won't, that is why you divide by sample rate when incrementing the timer (and why the timer needs to be floating point).
EDIT: Higlighted divide, because I suspect you may have forgot this (because that would explain why your timer is increasing too fast).
Last edited by Tale; 01-23-2017 at 12:22 AM.
Reason: Higlighted divide
|
|
|
01-23-2017, 01:28 AM
|
#12
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,334
|
Quote:
Originally Posted by Tunca
Hmm...Thanks in advice but i didn't understand how can i implement it to my products.
|
Oh, sorry, man. It's my fault.
|
|
|
01-24-2017, 07:33 AM
|
#13
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
I figured it out!
Now i can reset all parameters when i want.
Thanks for all helps,masters!
|
|
|
01-25-2017, 01:48 AM
|
#14
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
By the way what about random parameter reset instead of periodic?
|
|
|
01-25-2017, 06:35 AM
|
#15
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
|
http://www.cplusplus.com/reference/cstdlib/rand/
Maybe not a great pseudorandom number generator, but probably good enough for randomizing parameters.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 02:16 PM.
|