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
Sample accurate Array shifting.
24 posts
• Page 1 of 3 • 1, 2, 3
Sample accurate Array shifting.
I need to shift an array and have it sample accurate , how can i achieve this ?
Will Ruby spit out a shifted array at sample accuracy , I read in the manual that it should work at sample rate but I am not sure. I would be shifting the array at a maximum of 64 notes with a quantized LFO , possibly even with an unquantized lfo , although I might cap it at 128th notes when moving in a linear fashion.
Using the Shift array is not accurate , max 100 ticks , and will definitely not be accurate at faster then realtime rendering.
Any thoughts ?
Will Ruby spit out a shifted array at sample accuracy , I read in the manual that it should work at sample rate but I am not sure. I would be shifting the array at a maximum of 64 notes with a quantized LFO , possibly even with an unquantized lfo , although I might cap it at 128th notes when moving in a linear fashion.
Using the Shift array is not accurate , max 100 ticks , and will definitely not be accurate at faster then realtime rendering.
Any thoughts ?
-
lalalandsynth - Posts: 600
- Joined: Sat Oct 01, 2016 12:48 pm
Re: Sample accurate Array shifting.
I would be inclined to check out the memin option in DSP. You need to provide a mem component to feed it, and that data could be created from a float array. Shifting or rotating the array in DSP should be possible but I think Martin or someone would have to help with that. Plus you need to get at the data once shifted, but that should be possible by making a DSP multiplexor or having multiple streamouts for the appropriate mem indices.
One limitation is that the mem size is pre-defined when the DSP code is first active (new note in poly or forever in blue). So you can’t change the mem size on the fly and there’s no way to set a variable that defines it externally. You’d need multiple versions of the DSP code box, one for each mem size I think. Or maybe have a large mem size that takes the worst case into account, and rely on the code to address the appropriate range within the mem array.
I’m not really the one to offer Ruby advice, but I do know that if you need sample accuracy then you have to use Frames and that carries a high CPU overhead. Otherwise it lives in the green world so you don’t gain accuracy once it’s outside the RubyEdit code and back in the green world.
Cheers
Spogg
One limitation is that the mem size is pre-defined when the DSP code is first active (new note in poly or forever in blue). So you can’t change the mem size on the fly and there’s no way to set a variable that defines it externally. You’d need multiple versions of the DSP code box, one for each mem size I think. Or maybe have a large mem size that takes the worst case into account, and rely on the code to address the appropriate range within the mem array.
I’m not really the one to offer Ruby advice, but I do know that if you need sample accuracy then you have to use Frames and that carries a high CPU overhead. Otherwise it lives in the green world so you don’t gain accuracy once it’s outside the RubyEdit code and back in the green world.
Cheers
Spogg
-
Spogg - Posts: 3358
- Joined: Thu Nov 20, 2014 4:24 pm
- Location: Birmingham, England
Re: Sample accurate Array shifting.
I dare to say a few things, although I'm not on my safe place here.
The DSP code box offers arrays. They are generated with the square bracket.
However, I don't know if the DSP code box offers everything that is needed for above example to work (like addressing array elements through the use of variables for example). That's where the DSP pros have the word.
Regarding memin I have even less knowledge, but this is what I found in the manual:
Ruby uses frames to handle data in streams without leaving the streams. Those frames are the size of your audio buffer (DirectSound, ASIO, ASIO4ALL, etc.) and works beforehand, which adds another buffer on top (say ASIO introduces 3ms latency, then with active Ruby frames you'd be at 6 ms). Also, since Ruby is an interpreted language it is way slower than C or Assembler and adds quite a lot of cpu load. But technically it could be done with Ruby, yes.
The DSP code box offers arrays. They are generated with the square bracket.
- Code: Select all
float myArr[128];
- Code: Select all
myArr[3] = 0.5;
myArr[4] = myArr[3] + 0.12;
- Code: Select all
float counter = 126;
float buffer;
float myArr[128];
buffer = myArr[0]; //temporarily store first item of array
loop(127)
(
myArr[counter] = myArr[counter + 1];
counter = counter - 1
)
myArr[127] = buffer
However, I don't know if the DSP code box offers everything that is needed for above example to work (like addressing array elements through the use of variables for example). That's where the DSP pros have the word.
Regarding memin I have even less knowledge, but this is what I found in the manual:
I don't even pretend I'd understand this paragraph, but it says something about dynamic mem changes.You need to specify a maximum size for the mem data this is so that enough space is reserved for mem data in the compiled code. Whilst Mems do know their size we don't want to be recompiling everytime a mem changes so by declaring a maximum from the outset the Mem size can change dynamically without affecting anything
Ruby uses frames to handle data in streams without leaving the streams. Those frames are the size of your audio buffer (DirectSound, ASIO, ASIO4ALL, etc.) and works beforehand, which adds another buffer on top (say ASIO introduces 3ms latency, then with active Ruby frames you'd be at 6 ms). Also, since Ruby is an interpreted language it is way slower than C or Assembler and adds quite a lot of cpu load. But technically it could be done with Ruby, yes.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Sample accurate Array shifting.
Thanks guys !
To further explain the issue.
The array is initially created in Ruby and is 1024 values, I could possibly output that as frames and into DSP?
But now it goes into a FloatMem and into a Mem read interpolation to Blue.
Using a shift array on the output from the intitial Ruby and into the Floatmem I can shift it in both directions, 1024 in each direction. But , then I am in Greenland and have lost accuracy.
I dont need to vary the memsize , it can be fixed.
Shifting it in dsp is probably the answer !
I have double inaccuracy actually as i am also quantizing the LFO via greens , BUT ,that I can fix....possibly.
Working on this, its essential to two of my plugins so, needs to be fixed
To further explain the issue.
The array is initially created in Ruby and is 1024 values, I could possibly output that as frames and into DSP?
But now it goes into a FloatMem and into a Mem read interpolation to Blue.
Using a shift array on the output from the intitial Ruby and into the Floatmem I can shift it in both directions, 1024 in each direction. But , then I am in Greenland and have lost accuracy.
I dont need to vary the memsize , it can be fixed.
Shifting it in dsp is probably the answer !
I have double inaccuracy actually as i am also quantizing the LFO via greens , BUT ,that I can fix....possibly.
Working on this, its essential to two of my plugins so, needs to be fixed
Last edited by lalalandsynth on Tue Apr 16, 2019 5:15 pm, edited 1 time in total.
-
lalalandsynth - Posts: 600
- Joined: Sat Oct 01, 2016 12:48 pm
Re: Sample accurate Array shifting.
Here is the current version of the plugin, mostly finished except for the Shifting issue .
GIF.
https://imgur.com/xYAgCnP
GIF.
https://imgur.com/xYAgCnP
-
lalalandsynth - Posts: 600
- Joined: Sat Oct 01, 2016 12:48 pm
Re: Sample accurate Array shifting.
A couple of quick questions...
Do you want the Array to shift in order to open up space at one end for new data (losing the values that "fall off the end"), or do you want to do a rotation where values that "fall off the end" are inserted back into the empty space?
Will you always be shifting in the same direction, or do you need to be able to go both ways?
In any of these cases, DSP/Assembly is likely to be best, as using Ruby on a Frame of such a large size would be very slow, and using 'Frame to Mono' is out of the question as it assumes a Frame size that matches the audio buffer size. However, IIRC, there is a sneaky way to get the memory address of the raw sample data from a Frame, which might ease the translation from Ruby to Blue (though it has to be used somewhat, erm, carefully!)
Do you want the Array to shift in order to open up space at one end for new data (losing the values that "fall off the end"), or do you want to do a rotation where values that "fall off the end" are inserted back into the empty space?
Will you always be shifting in the same direction, or do you need to be able to go both ways?
In any of these cases, DSP/Assembly is likely to be best, as using Ruby on a Frame of such a large size would be very slow, and using 'Frame to Mono' is out of the question as it assumes a Frame size that matches the audio buffer size. However, IIRC, there is a sneaky way to get the memory address of the raw sample data from a Frame, which might ease the translation from Ruby to Blue (though it has to be used somewhat, erm, carefully!)
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: Sample accurate Array shifting.
The Array would indeed wrap around , so "rotation where values that "fall off the end" are inserted back into the empty space" I need to be able to shift in both directions so 1024 or -1024. Or preferably just like the Array shift works where I can go above the 1024 and it will just keep on shifting accordingly
Also , I might need to convert blue to float at sample rate as well , M2f is not accurate either.
Or be able to shift the array with both floats and blue.
Also , I might need to convert blue to float at sample rate as well , M2f is not accurate either.
Or be able to shift the array with both floats and blue.
-
lalalandsynth - Posts: 600
- Joined: Sat Oct 01, 2016 12:48 pm
Re: Sample accurate Array shifting.
lalalalandsynth wrote:The Array would indeed wrap around , so "rotation where values that "fall off the end" are inserted back into the empty space" I need to be able to shift in both directions so 1024 or -1024.
I was hoping you'd say that!
What I would do in that case is to treat the array as a circular buffer. Rather than shifting the data, leave it where it is and shift the read index in the opposite direction instead, wrapping it around the start/end as required. This might require some additional Ruby code, depending whether the GUI needs to interact with 'shifted' or 'unshifted' data, but it means that your blue sync problem then only needs accurate timing of a single blue offset value and a handful of DSP 'wrapping' calculations. This should be much easier to arrange and will be far more efficient than rotating the data.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: Sample accurate Array shifting.
Gui can display shifted data derived by green means , that is fine.
So you mean shift the index at the mem read/interpolator ?
If I could shift with blue I would be golden ,That would solve data coming from the Modulator (blue) which I can quantise into discrete array offsets .
I could then of course also shift with float with the offset knob.
To be clear, currently there are two way to shift the array , either with the offset knobs which is "static" unless automated and the Modulator/lfo . All of this is currently done in greenland which is unacceptable but If I could shift the array with blue , It seems everything would work.
So you mean shift the index at the mem read/interpolator ?
If I could shift with blue I would be golden ,That would solve data coming from the Modulator (blue) which I can quantise into discrete array offsets .
I could then of course also shift with float with the offset knob.
To be clear, currently there are two way to shift the array , either with the offset knobs which is "static" unless automated and the Modulator/lfo . All of this is currently done in greenland which is unacceptable but If I could shift the array with blue , It seems everything would work.
-
lalalandsynth - Posts: 600
- Joined: Sat Oct 01, 2016 12:48 pm
Re: Sample accurate Array shifting.
This is where the shifted array comes in via the Shift array prim.
And goes into the Mem read interpolator module.
Now I if could find a way to shift it here with blue?
Thoughts ?
Btw, I would be more then willing to pay for someones time to make it so that I can shift the array with blue.
I have 2 plugins dead in the water if I cannot solve this and I think its more then worth it to me
And goes into the Mem read interpolator module.
Now I if could find a way to shift it here with blue?
Thoughts ?
Btw, I would be more then willing to pay for someones time to make it so that I can shift the array with blue.
I have 2 plugins dead in the water if I cannot solve this and I think its more then worth it to me
-
lalalandsynth - Posts: 600
- Joined: Sat Oct 01, 2016 12:48 pm
24 posts
• Page 1 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 81 guests