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
Sine osc in ASM using fsin opcode?
10 posts
• Page 1 of 1
Sine osc in ASM using fsin opcode?
There is bug in stock sine osc so I was trying to optimize basic sine code to asm using fsin opcode. While feeding with single note/freq it works fine but using two or more (simple chord) cause problem. I'm still trying to learn asm so I donn't know what I'm missing here. Here is asm code:
- Code: Select all
streamin freq;streamin phase;streamout out;
float temp=0.0;float a=0;float F1=1;float F2=2;
float PI2=6.2831853;
movaps xmm0,a;addps xmm0,freq;
movaps a,xmm0;
movaps xmm2,xmm0;
cmpps xmm0,F1,6;andps xmm0,F2;
subps xmm2,xmm0;movaps a,xmm2;
addps xmm2,phase;mulps xmm2,PI2;
movaps temp,xmm2;
fld temp[0];
mov eax,temp[0];
fsin;
fstp temp[0];
movaps xmm0,temp;
movaps out,xmm0;
-
TrojakEW - Posts: 111
- Joined: Sat Dec 25, 2010 10:12 am
- Location: Slovakia
Re: Sine osc in ASM using fsin opcode?
Hi Trojak,
The reason is that for poly and mono4 signals, each block of code is responsible for four voices, using the four parallel "channels" of the SSE commands.
The floating point unit commands can only work on one channel at a time (in your case only channel[0]) - that's fine for mono signals, as they only make use of channel[0]. But for poly/mono4 signals, you have to explicity process each channel in turn, otherwise three out of every four notes won't get processed.
You can fix this very simply, by cutting and pasting the FPU sine code until you have four of them, and then edit the channel numbers on the copies to add channels [1],[2] and [3].
PS) The move to eax isn't needed AFAIK, the FPU only communicates via the stack.
The reason is that for poly and mono4 signals, each block of code is responsible for four voices, using the four parallel "channels" of the SSE commands.
The floating point unit commands can only work on one channel at a time (in your case only channel[0]) - that's fine for mono signals, as they only make use of channel[0]. But for poly/mono4 signals, you have to explicity process each channel in turn, otherwise three out of every four notes won't get processed.
You can fix this very simply, by cutting and pasting the FPU sine code until you have four of them, and then edit the channel numbers on the copies to add channels [1],[2] and [3].
- Code: Select all
fld temp[0];
fsin;
fstp temp[0];
fld temp[1];
fsin;
fstp temp[1];
fld temp[2];
fsin;
fstp temp[2];
fld temp[3];
fsin;
fstp temp[3];
PS) The move to eax isn't needed AFAIK, the FPU only communicates via the stack.
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: Sine osc in ASM using fsin opcode?
Thanks. It works but it's actually slower then original asm or code. I thought than using fsin can be faster but no luck. Is there any other faster way to use sin in asm? Like quick rounding or quick abs trick (thanks for that too I learned that from you ). It's not only question for use in this example but for overall use in asm.
-
TrojakEW - Posts: 111
- Joined: Sat Dec 25, 2010 10:12 am
- Location: Slovakia
Re: Sine osc in ASM using fsin opcode?
It depends on the frequency range that you need. For LFO, there are quiet good hacks, like self oscillating filter or taylor series...
BTW: what is your problem with the stock sine osc? I did some decoding on this, before Malc made the optimizations in "SNOWFLAKE", and haven't discovered any odds.
BTW: what is your problem with the stock sine osc? I did some decoding on this, before Malc made the optimizations in "SNOWFLAKE", and haven't discovered any odds.
-
MyCo - Posts: 718
- Joined: Tue Jul 13, 2010 12:33 pm
- Location: Germany
Re: Sine osc in ASM using fsin opcode?
Sine OSC in snowflake act similar to my first fsin atempt. It work good with single input but strange with multiple/chord. It also start at -1octave compared to previous or coded one.
-
TrojakEW - Posts: 111
- Joined: Sat Dec 25, 2010 10:12 am
- Location: Slovakia
Re: Sine osc in ASM using fsin opcode?
Perhaps you should submit a bug report then, with specific examples & outputs please?TrojakEW wrote:Sine OSC in snowflake act similar to my first fsin atempt. It work good with single input but strange with multiple/chord. It also start at -1octave compared to previous or coded one.
It is not uncommon for old bugs be swapped out with new ones, so I don't disbelieve you. The more narrow you can make your request, the better chance you will see it fixed.
- infuzion
- Posts: 109
- Joined: Tue Jul 13, 2010 11:55 am
- Location: Kansas City, USA, Earth, Sol
Re: Sine osc in ASM using fsin opcode?
Well there is no need for any specific example or schematic. For me problem occur always when stock sine osc is used. It doesn't matter what setup I use. If it is simple schematic just with one sine osc or example synth.
Well MAYBE it is matter of CPU type. I have athlon 64 x2 4200 and only that one so I can't test if the problem occur on other CPU.
Well MAYBE it is matter of CPU type. I have athlon 64 x2 4200 and only that one so I can't test if the problem occur on other CPU.
-
TrojakEW - Posts: 111
- Joined: Sat Dec 25, 2010 10:12 am
- Location: Slovakia
Re: Sine osc in ASM using fsin opcode?
TrojakEW wrote:Sine OSC in snowflake act similar to my first fsin atempt. It work good with single input but strange with multiple/chord.
Confirmed - There IS a bug in the new stock sine oscillator.
Try playing chords on this simple example synth with the selector set to the sine oscillator...
...all four SSE channels are using the same frequency value as the first channel, so you just get repeats of the same note instead of multiple pitches.
Bug report sent to the dev's.
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: Sine osc in ASM using fsin opcode?
Yes, looks like a copy&paste mistake in the code. All 4 channels use the same table index.
-
MyCo - Posts: 718
- Joined: Tue Jul 13, 2010 12:33 pm
- Location: Germany
Re: Sine osc in ASM using fsin opcode?
Thanks for isolating this Troggie!trogluddite wrote:TrojakEW wrote:Sine OSC in snowflake act similar to my first fsin atempt. It work good with single input but strange with multiple/chord.
Confirmed - There IS a bug in the new stock sine oscillator.
Try playing chords on this simple example synth with the selector set to the sine oscillator...
...all four SSE channels are using the same frequency value as the first channel, so you just get repeats of the same note instead of multiple pitches. Bug report sent to the dev's.
This is why I refuse to pay to beta-test for people anymore... It should be the other way around!
- infuzion
- Posts: 109
- Joined: Tue Jul 13, 2010 11:55 am
- Location: Kansas City, USA, Earth, Sol
10 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests