If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
DSP code question
12 posts
• Page 1 of 2 • 1, 2
DSP code question
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.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: DSP code question
The code seems to be missing a few lines. Specifically, it misses the declaration of "indexInt" and misses the lines that give it value. Because of that It seems hard deciphering what the code actually does.
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: DSP code question
I thought I'd narrowed it down, so that people don't have to look at a complete schematic. But maybe it's better. See attachment.
- Attachments
-
- wave_player(stripped).fsm
- (3.42 KiB) Downloaded 938 times
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: DSP code question
The module is written in somewhat awkward way. It may be easier to just write new one from scratch:
EDIT: disregard this.... I thought the code outputs index, but it really a bit more complicated... give me a minute to figure it out.
- Code: Select all
streamin step; //samplerate/wavSamplerate aka. how fast should the wave be played
streamboolin trigger;
streamin length;
streamboolin loop;
streamout index;
index=(index+step); //increase index by 1 step
//if index exceeds "length" and "loop" mode is on, subtract "length" to reset to start
//the line may be deleted if looping should be disabled at all time
index= index - length&(index>length)&loop;
//resets index to zero when trigger arrives. It also stays zero while trigger is on.
index=index & (trigger==0);
EDIT: disregard this.... I thought the code outputs index, but it really a bit more complicated... give me a minute to figure it out.
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: DSP code question
as far as I can tell, the module should restart the wave from the beginning when retrigger is hit.
There seems to be some funny behaviour related to the selector... When I connected mono-to-float module to the counter, it does exactly what you expect. When I disconnect it, it does not retrigger - just continues where it ended... If I disable the selectors it works fine...
There seems to be some funny behaviour related to the selector... When I connected mono-to-float module to the counter, it does exactly what you expect. When I disconnect it, it does not retrigger - just continues where it ended... If I disable the selectors it works fine...
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: DSP code question
Confirmed, sort of.
If I remove the selectors (why are they in there anyway?), I can start the wave from the beginning, whenever I set the boolean to false. However, whenever I set the boolean to true, it stops playing immediatly. A trigger doesn't work at all.
If I remove the selectors (why are they in there anyway?), I can start the wave from the beginning, whenever I set the boolean to false. However, whenever I set the boolean to true, it stops playing immediatly. A trigger doesn't work at all.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: DSP code question
I think this is what you are after? You need an envelope with a bit of a release to keep the signal alive until the sample plays, and in the voicing set it to mono (1 voice) and retrigger, so that the sample starts again when you press a key again.
- Attachments
-
- wavplayer.fsm
- (166.81 KiB) Downloaded 909 times
- adamszabo
- Posts: 667
- Joined: Sun Jul 11, 2010 7:21 am
Re: DSP code question
adamszabo wrote:I think this is what you are after? You need an envelope with a bit of a release to keep the signal alive until the sample plays, and in the voicing set it to mono (1 voice) and retrigger, so that the sample starts again when you press a key again.
Almost done
But I really don't look for a rompler or so, I just need a preview option. Say, a list of samples, you click one and it plays (in its original pitch and length). But I think I can work it out with your example, and if not, I'll ask here again
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: DSP code question
Just tested it with a fixed note event sent by a trigger and a sample of about 3 seconds length. It doesn't even start to play. With the keyboard it plays if I hold the key long enough. Ah, I can't get it to work.
The example I posted plays the whole sample, no matter how long it is, but it only is controllable with a boolean.
The best of both worlds would be fine
The example I posted plays the whole sample, no matter how long it is, but it only is controllable with a boolean.
The best of both worlds would be fine
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: DSP code question
here is a player which plays the sample just one time until the end just with one trigger
hope it helps..
it has no retrigger while it is playing, and also the trigger - playstart - thing could be done better i think..
its always tricky to use triggers in stream
EDIT: it has retrigger now too
hope it helps..
it has no retrigger while it is playing, and also the trigger - playstart - thing could be done better i think..
its always tricky to use triggers in stream
EDIT: it has retrigger now too
- Attachments
-
- player.fsm
- (562.83 KiB) Downloaded 923 times
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
12 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 37 guests