DSP code question
Posted: Wed Oct 19, 2016 6:12 pm
Ok, hopefully this is quickly answered.
I found a wave player module that uses a "precise counter"-module to play a wave file based on a boolean. if true there's no playing, if false it plays the wave in loop.
The dsp code of the counter-module is like that:
where
step == wave's rate / sample rate
retrigger either true or false
length is in samples
loop is !retrigger (boolean not)
I could set loop to always be false, and it then plays the wave one time while retrigger is false. But I can't find out what I would need to change so that the wave is played in its full length on a trigger and automatically resets the counter, so that the next trigger starts playing again at 0, no matter at what time I hit the trigger?
Ideas? Any help will get a big thank you!
EDIT:
If my question isn't really clear, here's what I look for
1) A trigger instead of a boolean starts playing the wave
2) If I do nothing the wave plays one time until its end
3) If I trigger again, no matter if the wave is currently playing or not, the wave starts again at sample 0
EDIT 2: There's a line missing
this is the feedback from subInt, after it has been processed.
I found a wave player module that uses a "precise counter"-module to play a wave file based on a boolean. if true there's no playing, if false it plays the wave in loop.
The dsp code of the counter-module is like that:
Code: Select all
streamin step;
streamin retrigger;
streamin length;
streamin loop;
streamout subInt;
subInt = ((indexInt+step)>length)&(loop>0)&length;
subInt = (retrigger!=1)&(step-subInt) - (retrigger==1)&(indexInt);where
step == wave's rate / sample rate
retrigger either true or false
length is in samples
loop is !retrigger (boolean not)
I could set loop to always be false, and it then plays the wave one time while retrigger is false. But I can't find out what I would need to change so that the wave is played in its full length on a trigger and automatically resets the counter, so that the next trigger starts playing again at 0, no matter at what time I hit the trigger?
Ideas? Any help will get a big thank you!
EDIT:
If my question isn't really clear, here's what I look for
1) A trigger instead of a boolean starts playing the wave
2) If I do nothing the wave plays one time until its end
3) If I trigger again, no matter if the wave is currently playing or not, the wave starts again at sample 0
EDIT 2: There's a line missing
Code: Select all
streamin indexInt;this is the feedback from subInt, after it has been processed.