Page 1 of 1

can i unpack audio inside the code module?

Posted: Mon Jan 05, 2015 8:43 pm
by Freddymusic
So i have 2 stereo audio in one pack. When the sounds go into the code module, i want to "unpack" in the code module becouse i want to merge the filter code with the follower code. I use a lot of pack-unpack module now and maybe i could save some cpu power in my vocoder. I am not FS user i work with SM. Is it possible with the FS? THX :)

Re: can i unpack audio inside the code module?

Posted: Mon Jan 05, 2015 9:25 pm
by KG_is_back
No, it is not possible to separate/shuffle channels inside code module. That is true both for SM and FS, since the code component wasn't updated since then.

It is however possible in assembler and there are several ways to do that, depending on what you are looking for. Also some ways are much cheaper on CPU than the pack/unpack primitives. Problem is, Code is harder to look at/debug in assembler (even crashes are very likely when you are not careful).

I can provide more specific answers, if you specify more precisely what you are trying to do exactly.

Re: can i unpack audio inside the code module?

Posted: Tue Jan 06, 2015 1:21 am
by Freddymusic
this is a vocoder example. Maybe i can replace the pack/unpack module with an ASM, but if i want to merge the filter with the follower isn't possible for me just in asm. The merge isn't important for me, but i think if i replace the pack/ unpack modules it will be faster.
http://www.tbklub.hu/bitsonic/capture.jpg

Re: can i unpack audio inside the code module?

Posted: Tue Jan 06, 2015 2:04 am
by KG_is_back
Indeed situation like this can be significantly improved using ASM instead of pack/unpack.

There is an instruction called "shufps". It has the ability to shuffle SSE channels in any way desired.

this ASM code should do the trick:

Code: Select all

streamin in1;
streamin in2;
streamout out1;
streamout out2;

movaps xmm0,in1;
movaps xmm1,xmm0;
movaps xmm2,in2;
shufps xmm0,xmm2,68;
shufps xmm1,xmm2,238;
movaps out1,xmm0;
movaps out2,xmm1;


As you can see, the code has two inputs. channels of the second input are being put into third and fourth channels of the outputs respectively. This way, you can make use of all 4 channels in your envelope follower, effectively reducing its size to half.

If you are interested in optimizing your code within schematics (possibly even by using assembler) you may have a look at few articles at http://flowstone.guru/. There is also a download section with dozens of useful Flowstone schematics and also links to some of the best osm schematics.

Re: can i unpack audio inside the code module?

Posted: Tue Jan 06, 2015 10:10 am
by Freddymusic
Thank you Kirk, i hope i can make it in an optimized asm.

Re: can i unpack audio inside the code module?

Posted: Tue Jan 06, 2015 3:26 pm
by KG_is_back
From what I can see from the image, the code is close to optimal already. With assembler you may save some unnecessary reading from/to memory by removing several intermediate variables. I still have the synthmaker free version, so possibly I can help you a little more.