Page 1 of 3

stream routing matrix in dsp code!?

Posted: Sat Nov 22, 2014 9:17 pm
by Nubeat7
hi all, i would need some help with this stream routing matrix written in FS dsp code,

as you know i did a cablepatcher, but its problem is that it recompiles with every patching process which results in audioclicks and dropouts, sure you could trigger a clear audio for a short time everytime the wiring changes, but this still would have audio dropouts (just without crackles and noises) when changing the wiring...

so i decided to work on a dsp code based routing matrix to avoid using busses and recompiling which would allow you to rewire while playing sound..

best way way to do this? maybe some better solutions in assembler using loops or jmpz? or using the new mem features..

Re: stream routing matrix in dsp code!?

Posted: Sat Nov 22, 2014 10:34 pm
by tester
I think what you are trying to do is not that hard at all. It's like using few dozens of "multiply" primitive (the same thing done in code can be done with a combination of green stuff and multipliers and wireless nodes). Maybe it would save some CPU (blue comparator vs blue multiplier), but hard to say. KG wrote about these cycles per operation type?

But... Using the code/asm, you could use hop, depending on how fast the reconnection should be. ASM would give you the advantage of switching between channels internally (in hoped version as well).

The best for you would be to have dynamic amount of inputs/outputs, depending on how many you would like to use. But this reminds me, that KG posted somewhere how to disable ASM processing prior to wire when wire is not used; it was suposed to be similar to selectors, just without the recompiling part on schematic side.

Re: stream routing matrix in dsp code!?

Posted: Sun Nov 23, 2014 1:41 am
by Nubeat7
i don't think that you want to use multipliers when you have 20 sources, 30 targets and 50 connections,
the multiplexers i think are pretty cheap (also if you have 50 with 30 outputs??), but not sure about the sources array?

anyway i did some optimizing on the array assign and reading (thx KG for your ASM optimization tutorial), i think the reading also could be hopped,

while doing this i got the idea to use the mem in for the source connection inputs after these would be an array of int values any way but after feeding it into a mem they are float values and would need to get converted to integers..

Re: stream routing matrix in dsp code!?

Posted: Sun Nov 23, 2014 2:07 am
by tester
1.6% per sum of 100 actively working multipliers (i5 2.6gHz) in this design.
Mono4 could be maybe faster.

Re: stream routing matrix in dsp code!?

Posted: Sun Nov 23, 2014 3:59 am
by tester
But maybe you are right. Test2 consumes 100% (as expected). :mrgreen:

Selector prevents crashing (in earlier FS versions). Sound on -> selector on -> selector off -> sound off. This solution (via delay) saved many of my SM projects in the past.

Re: stream routing matrix in dsp code!?

Posted: Sun Nov 23, 2014 12:33 pm
by Nubeat7
ok i've found a way to convert the index mem to integer when reading it, i think thats the fastest way to do it.

just one question, would there be maybe a faster or better way to directly create a index array which already stores the indexes as integers? what i mean is that there is still the conversion from the memin array values (floats) with the fistp opcode..

atm i use the "int to mem" primitive but maybe i could do this in assambler too in some faster way as the primitive does it and also have the values already as integers?

i also still don't know if the whole idea is really the fastest way?

any suggestion would be great.

Re: stream routing matrix in dsp code!?

Posted: Sun Nov 23, 2014 4:26 pm
by KG_is_back
Nubeat7 wrote:atm i use the "int to mem" primitive but maybe i could do this in assambler too in some faster way as the primitive does it and also have the values already as integers?

I have module that dirrectly sotrs integers into mem (the values in the mem are 32bit integers instead of 32bit floats).

It is in the Clock Core at FS guru.

Re: stream routing matrix in dsp code!?

Posted: Sun Nov 23, 2014 5:06 pm
by Nubeat7
thanks KG, got it, i used this now:

Code: Select all

push eax;mov eax,I0[0];shl eax,4;movaps xmm0,c[eax];pop eax;
movaps Idx,xmm0;
push eax;mov eax,Idx[0];shl eax,4;movaps xmm0,s[eax];pop eax;
movaps sco0,xmm0;

its no conversion needed anymore just the movaps..

is this the right way or is there a shorter way to just assign Idx[0] already in the first read array part?

Re: stream routing matrix in dsp code!?

Posted: Sun Nov 23, 2014 5:19 pm
by KG_is_back
Nubeat7 wrote:thanks KG, got it, i used this now:

Code: Select all

push eax;mov eax,I0[0];shl eax,4;movaps xmm0,c[eax];pop eax;
movaps Idx,xmm0;
push eax;mov eax,Idx[0];shl eax,4;movaps xmm0,s[eax];pop eax;
movaps sco0,xmm0;

its no conversion needed anymore just the movaps..

is this the right way or is there a shorter way to just assign Idx[0] already in the first read array part?


This is the fastest way. Only thing you can improve is to delete unneeded pops and pushes. The pop in the first part and push in the second part are not needed. Most likely push and pop are not needed at all - you need to have it there only if you need the previous value of eax later in the code.

Re: stream routing matrix in dsp code!?

Posted: Mon Nov 24, 2014 12:27 am
by Nubeat7
thank you KG for having a look at it, also thanks for your great tutorial on asm, this helped a lot :)