7
#include <stdsynthmodule.h>
8
#include <flowsystem.h>
9
#include "noatunarts.h"
16
class StereoVolumeControl_impl : virtual public StereoVolumeControl_skel,
17
virtual public StdSynthModule
21
StereoVolumeControl_impl() : mPercent(1.0)
24
/*attribute float scaleFactor;*/
25
void percent(float p) { mPercent=p; }
26
float percent() { return mPercent; }
28
void calculateBlock(unsigned long samples)
33
float *oright=outright;
35
register float p=mPercent;
37
float *end=left+samples;
52
class StereoVolumeControlSSE_impl : virtual public Noatun::StereoVolumeControlSSE_skel,
53
virtual public StdSynthModule
57
StereoVolumeControlSSE_impl() : mPercent(1.0)
60
/*attribute float scaleFactor;*/
61
void percent(float p) { mPercent=p; }
62
float percent() { return mPercent; }
64
void calculateBlock(unsigned long samples)
70
float *oright=outright;
72
// need to copy the data members to locals to get enough
73
// spare registers (malte)
75
long p = (long)(mPercent*100.0);
80
"fdivp \n" // percent / 100.0
82
"movss (%%esp), %%xmm1 \n"
83
"shufps $0x00, %%xmm1, %%xmm1 \n" // percentage in all of xmm1
85
"pushl %4 \n" // save sample count
87
"jz .l2 \n" // samples < 4
88
"xorl %%ecx, %%ecx \n"
92
"movups (%0, %%ecx, 8), %%xmm0 \n"
93
"mulps %%xmm1, %%xmm0 \n"
95
"movups %%xmm0, (%%eax, %%ecx, 8) \n"
97
"movups (%1, %%ecx, 8), %%xmm0 \n"
98
"mulps %%xmm1, %%xmm0 \n"
100
"movups %%xmm0, (%%eax, %%ecx, 8) \n"
107
"popl %4 \n" // restore sample count
111
// calculate remaining samples for samples % 4 != 0
114
"movss (%0, %%ecx, 4), %%xmm0 \n" // load left
115
"movss (%1, %%ecx, 4), %%xmm2 \n" // load right
116
"shufps $0x00, %%xmm2, %%xmm0 \n" // both channels in xmm0
117
"mulps %%xmm1, %%xmm0 \n"
119
"movss %%xmm0, (%%eax, %%ecx, 4) \n" // store left
120
"shufps $0x02, %%xmm0, %%xmm0 \n"
122
"movss %%xmm0, (%%eax, %%ecx, 4) \n" // store right
142
REGISTER_IMPLEMENTATION(StereoVolumeControlSSE_impl);
143
REGISTER_IMPLEMENTATION(StereoVolumeControl_impl);