Support

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

For general discussion related FlowStone

DSP code question

Postby tulamide » 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:
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

Postby KG_is_back » Wed Oct 19, 2016 6:32 pm

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

Postby tulamide » Wed Oct 19, 2016 6:41 pm

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 937 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

Postby KG_is_back » Wed Oct 19, 2016 6:45 pm

The module is written in somewhat awkward way. It may be easier to just write new one from scratch:

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

Postby KG_is_back » Wed Oct 19, 2016 7:00 pm

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...
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: DSP code question

Postby tulamide » Wed Oct 19, 2016 7:20 pm

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.
"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

Postby adamszabo » Thu Oct 20, 2016 12:23 pm

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 908 times
adamszabo
 
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: DSP code question

Postby tulamide » Thu Oct 20, 2016 2:10 pm

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

Postby tulamide » Thu Oct 20, 2016 2:24 pm

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 :mrgreen:
"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

Postby Nubeat7 » Thu Oct 20, 2016 7:26 pm

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 :)
Attachments
player.fsm
(562.83 KiB) Downloaded 922 times
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Next

Return to General

Who is online

Users browsing this forum: Google [Bot] and 72 guests