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

stream routing matrix in dsp code!?

DSP related issues, mathematics, processing and techniques

Re: stream routing matrix in dsp code!?

Postby Nubeat7 » Tue Nov 25, 2014 2:28 pm

as the use of the asm multiplexers is getting pretty expensive when building up a 20x20 matrix with at least 20 connections, i tried to do this also with using arrays, the problem is that i cannot assign an array element from 2 sources, i mean i cannot add 2 values when feeding an array element, or i couldn't find a way to do this.
Last edited by Nubeat7 on Sun Aug 02, 2015 6:48 am, edited 1 time in total.
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: stream routing matrix in dsp code!?

Postby Nubeat7 » Tue Nov 25, 2014 3:28 pm

i try to describe the issue a little bit better, first i get the connection values into a idx variable (i can do this seperated for each connection)

then i would need to check which one of these have the same value and add all related inputs into one variable which then will be assigned to the target array

Code: Select all
memin c[4]; //set nr of connections!!

streamin sco0;streamin sco1;streamin sco2;streamin sco3;

streamout trg0; streamout trg1; streamout trg2;
streamout trg3; streamout trg4; streamout trg5;

int I0=0;   int I1=1;   int I2=2;   int I3=3;
int I4=4;   int I5=5;   int I6=6;   int I7=7; 

int Idx0=0;  int Idx1=0;  int Idx2=0;  int Idx3=0;
float t[6];// set nr of targets!!

//get  idx to assign the target array
mov eax,I0[0]; shl eax,4;movaps xmm0,c[eax];movaps Idx0,xmm0;
mov eax,I1[0]; shl eax,4;movaps xmm1,c[eax];movaps Idx1,xmm1;
mov eax,I2[0]; shl eax,4;movaps xmm2,c[eax];movaps Idx2,xmm2;
mov eax,I3[0]; shl eax,4;movaps xmm3,c[eax];movaps Idx3,xmm3;

/*here i would need to find out which indexes are the same add the related
connections into a variable and assign it to the target array*/
movaps xmm0,sco0;mov eax,Idx0[0]; shl eax,4;movaps t[eax],xmm0;
movaps xmm1,sco1;mov eax,Idx1[0]; shl eax,4;movaps t[eax],xmm1;
movaps xmm2,sco2;mov eax,Idx2[0]; shl eax,4;movaps t[eax],xmm2;
movaps xmm3,sco3;mov eax,Idx3[0]; shl eax,4;movaps t[eax],xmm3;

//read target array and output
mov eax,I0[0];shl eax,4;movaps xmm0,t[eax];movaps trg0,xmm0;
mov eax,I1[0];shl eax,4;movaps xmm1,t[eax];movaps trg1,xmm1;
mov eax,I2[0];shl eax,4;movaps xmm2,t[eax];movaps trg2,xmm2;
mov eax,I3[0];shl eax,4;movaps xmm3,t[eax];movaps trg3,xmm3;
mov eax,I4[0];shl eax,4;movaps xmm4,t[eax];movaps trg4,xmm4;
mov eax,I5[0];shl eax,4;movaps xmm5,t[eax];movaps trg5,xmm5;


so if idx0 and idx1 are the same, i would need to add sco0 and sco1 and then assign it to the targets array
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: stream routing matrix in dsp code!?

Postby KG_is_back » Tue Nov 25, 2014 3:43 pm

This is how I would do it through assembly. Create a Memory buffer. Clear this buffer in stage1 (at the very beginning of execution). Then each time I put in value I put it as matrix[i]=matrix[i]+input. The only problem is synchronizing the writing and reading. Writing must happen first, otherwise you will get zero when reading.
Attachments
routing matrix stream.fsm
(2.98 KiB) Downloaded 1114 times
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: stream routing matrix in dsp code!?

Postby Nubeat7 » Tue Nov 25, 2014 6:04 pm

KG_is_back wrote:This is how I would do it through assembly. Create a Memory buffer. Clear this buffer in stage1 (at the very beginning of execution). Then each time I put in value I put it as matrix[i]=matrix[i]+input. The only problem is synchronizing the writing and reading. Writing must happen first, otherwise you will get zero when reading.


thanks KG, its a bit advanced for my understanding, if i understand it right the buffersize stands for max source entries
is this right?

and what i also not understand is the stage 1 thing it needs to be executed everytime a connection index is changing or?

about the fakt that it has to be written before read why not pack all into one module then, first we write into the buffer and then we read from... so the order should be right or?

any way there is something wron in the logic or i don't understand how to use it but for the cablepatcher it would not fit as it is, for each cable connection i have a from source index and a to target index but i cant use it in your example to get the right values to the target outputs..
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: stream routing matrix in dsp code!?

Postby KG_is_back » Tue Nov 25, 2014 11:04 pm

The stage1 thing empties the array on each new sample. It you'd remove this, then each sample each value in the buffer would increase by the value that is put in - which we obviously don't want.

Nubeat7 wrote:about the fakt that it has to be written before read why not pack all into one module then, first we write into the buffer and then we read from... so the order should be right or?


Yes, that is the way to go, I suppose. I may try that later on.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: stream routing matrix in dsp code!?

Postby Nubeat7 » Sun Dec 14, 2014 12:11 pm

has anyone some better ideas to do this matrix in ASM? the bus system is not really usable because it makes real troubles when changing presets, and also when opening the editor the first time in the DAW (it does a recompile then!? which results in audiodropouts, no idea why)..

so the only way to make it work properly is to build this up with ASM, sadly the solution i posted above really sucks a lot of cpu ( about the double amount of the bus system and produces unstable spikes)

any suggestions would be very helpful

@KG did you find some time to work on your solution? i couldn't make it work for the cablepatcher :(

thx
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: stream routing matrix in dsp code!?

Postby KG_is_back » Sun Dec 14, 2014 7:59 pm

Nubeat7 wrote:@KG did you find some time to work on your solution? i couldn't make it work for the cablepatcher thx


Not yet. Sadly, passing pointers to ASM code is very unstable and may cause unpredictable crashes on startup, recompile, etc. It is also very hard to maintain proper execution order.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: stream routing matrix in dsp code!?

Postby martinvicanek » Sun Dec 14, 2014 10:21 pm

Here is my attempt, based on your (Nubeat7) original schematic but here all in one ASM box. I also found arrays to be inefficient and hard to optimise, although I suspect they would have better scaling properties for large matrices. Anyway, this example already provides an 8x8 matrix in Mono4.
Attachments
streamRoutingMatrix.fsm
(4.11 KiB) Downloaded 1085 times
User avatar
martinvicanek
 
Posts: 1318
Joined: Sat Jun 22, 2013 8:28 pm

Re: stream routing matrix in dsp code!?

Postby Nubeat7 » Mon Dec 15, 2014 1:03 am

thanks martin, your array version is the one i was looking for :)
about the optimizing, i think when doing it like i did in the previous versions it can be done pretty good, i think the best way would be to use integer inputs for the connection indexes.

i did this with saving them in a mem array, but like this they also have to be read from mem, single int inputs would be preferable then (also when this means that each connection has an input then)
but how could i prepare the int indexes for the asm code?
i tried to change KG's "int array to mem of 32 bit" into a int array to single int outputs for asm but it didn't work like this, is there a way to do this?

Code: Select all
def event i,v
  @fromSource.each_with_index do |x,id|
    output id,x.pack('l*').unpack('F*') #asm int in
  end
end



this would be the optimized asm code for it.. but still with converting the indexes to integers..
and we also could get rid of the initializing the targets with 0 or?
Code: Select all
streamin source0; streamin source1;
streamin idxs0;   streamin idxs1;
streamin idxt0;   streamin idxt1;
streamout target0;streamout target1;

float t[2];float s[2];
float tmp=0;float idxs=0;float idxt=0;
int I0=0;  int I1=1;

//init source array
movaps xmm0,source0; mov eax,I0[0]; shl eax,4; movaps s[eax],xmm0;
movaps xmm1,source1; mov eax,I1[0]; shl eax,4; movaps s[eax],xmm1;

// connection 0
movaps xmm0,idxs0;cvtps2dq xmm0,xmm0;movaps idxs,xmm0;//wanna get rid of this
movaps xmm1,idxt0;cvtps2dq xmm1,xmm1;movaps idxt,xmm1;//and use int idx inputs

mov eax,idxs[0]; shl eax,4; movaps xmm0,s[eax]; movaps tmp,xmm0;
mov eax,idxt[0]; shl eax,4; movaps t[eax],xmm0;

// connection 1
movaps xmm0,idxs1;cvtps2dq xmm0,xmm0;movaps idxs,xmm0;//wanna get rid of this
movaps xmm1,idxt1;cvtps2dq xmm1,xmm1;movaps idxt,xmm1;//and use int idx inputs

mov eax,idxs[0]; shl eax,4; movaps xmm0,s[eax];
mov eax,idxt[0]; shl eax,4; movaps xmm1,t[eax];
addps xmm0,xmm1;
movaps tmp,xmm0;
mov eax,idxt[0]; shl eax,4; movaps t[eax],xmm0;

//assign outputs
mov eax,I0[0]; shl eax,4; movaps xmm0,t[eax]; movaps target0,xmm0;
mov eax,I1[0]; shl eax,4; movaps xmm1,t[eax]; movaps target1,xmm1;
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: stream routing matrix in dsp code!?

Postby martinvicanek » Mon Dec 15, 2014 8:38 am

Here is a sligthly more optimized version:
Code: Select all
streamin source0; streamin source1;
streamin idxs0;   streamin idxs1;
streamin idxt0;   streamin idxt1;
streamout target0;streamout target1;

float t[2];float s[2];
int I0=0;  int I1=16;   // 16 Bytes alignment already in

//init source array
movaps xmm0,source0; mov eax,I0[0]; movaps s[eax],xmm0;
movaps xmm1,source1; mov eax,I1[0]; movaps s[eax],xmm1;

// connection 0
cvtps2dq xmm0,idxs0; //wanna get rid of this
cvtps2dq xmm1,idxt0; //and use int idx inputs

movd eax,xmm0; shl eax,4; movaps xmm2,s[eax];
movd eax,xmm1; shl eax,4; movaps t[eax],xmm2;

// connection 1
cvtps2dq xmm0,idxs1; //wanna get rid of this
cvtps2dq xmm1,idxt1; //and use int idx inputs

movd eax,xmm0; shl eax,4; movaps xmm2,s[eax];
movd eax,xmm1; shl eax,4; movaps xmm3,t[eax];
addps xmm2,xmm3; movaps t[eax],xmm2;

//assign outputs
mov eax,I0[0]; movaps xmm0,t[eax]; movaps target0,xmm0;
mov eax,I1[0]; movaps xmm1,t[eax]; movaps target1,xmm1;
User avatar
martinvicanek
 
Posts: 1318
Joined: Sat Jun 22, 2013 8:28 pm

PreviousNext

Return to DSP

Who is online

Users browsing this forum: No registered users and 15 guests