add targeted channel support
This commit is contained in:
parent
7096d7ae8b
commit
346c724b1f
|
@ -32,6 +32,8 @@ rec = 1
|
||||||
channels = 2
|
channels = 2
|
||||||
samplerate = 44100
|
samplerate = 44100
|
||||||
sound_source = PULSE
|
sound_source = PULSE
|
||||||
|
#-1 indicates left and right, 0 left, 1 right.
|
||||||
|
sample_channel = 1
|
||||||
sourcename = alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
|
sourcename = alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
|
||||||
|
|
||||||
##################################
|
##################################
|
||||||
|
|
35
main.c
35
main.c
|
@ -22,6 +22,7 @@ int set_screenx = 640; REGISTER_PARAM( set_screenx, PINT );
|
||||||
int set_screeny = 480; REGISTER_PARAM( set_screeny, PINT );
|
int set_screeny = 480; REGISTER_PARAM( set_screeny, PINT );
|
||||||
char sound_source[16]; REGISTER_PARAM( sound_source, PBUFFER );
|
char sound_source[16]; REGISTER_PARAM( sound_source, PBUFFER );
|
||||||
int cpu_autolimit = 1; REGISTER_PARAM( cpu_autolimit, PINT );
|
int cpu_autolimit = 1; REGISTER_PARAM( cpu_autolimit, PINT );
|
||||||
|
int sample_channel = -1;REGISTER_PARAM( sample_channel, PINT );
|
||||||
|
|
||||||
struct NoteFinder * nf;
|
struct NoteFinder * nf;
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ struct NoteFinder * nf;
|
||||||
|
|
||||||
double VisTimeEnd, VisTimeStart;
|
double VisTimeEnd, VisTimeStart;
|
||||||
int soundhead = 0;
|
int soundhead = 0;
|
||||||
float sound[MAX_CHANNELS][SOUNDCBSIZE];
|
float sound[SOUNDCBSIZE];
|
||||||
int show_debug = 0;
|
int show_debug = 0;
|
||||||
int show_debug_basic = 1;
|
int show_debug_basic = 1;
|
||||||
|
|
||||||
|
@ -73,13 +74,27 @@ void SoundCB( float * out, float * in, int samplesr, int * samplesp, struct Soun
|
||||||
int j;
|
int j;
|
||||||
for( i = 0; i < samplesr; i++ )
|
for( i = 0; i < samplesr; i++ )
|
||||||
{
|
{
|
||||||
for( j = 0; j < process_channels; j++ )
|
if( sample_channel < 0 )
|
||||||
{
|
{
|
||||||
float f = in[i*channelin+j];
|
float fo = 0;
|
||||||
if( f < -1 || f > 1 ) continue;
|
for( j = 0; j < process_channels; j++ )
|
||||||
sound[j][soundhead] = in[i*channelin+j];
|
{
|
||||||
|
float f = in[i*channelin+j];
|
||||||
|
if( f < -1 || f > 1 ) continue;
|
||||||
|
fo += f;
|
||||||
|
}
|
||||||
|
fo /= process_channels;
|
||||||
|
sound[soundhead] = fo;
|
||||||
|
soundhead = (soundhead+1)%SOUNDCBSIZE;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float f = in[i*channelin+sample_channel];
|
||||||
|
if( f < -1 || f > 1 ) continue;
|
||||||
|
sound[soundhead] = f;
|
||||||
|
soundhead = (soundhead+1)%SOUNDCBSIZE;
|
||||||
}
|
}
|
||||||
soundhead = (soundhead+1)%SOUNDCBSIZE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +194,7 @@ int main(int argc, char ** argv)
|
||||||
CNFGColor( 0xFFFFFF );
|
CNFGColor( 0xFFFFFF );
|
||||||
CNFGGetDimensions( &screenx, &screeny );
|
CNFGGetDimensions( &screenx, &screeny );
|
||||||
|
|
||||||
RunNoteFinder( nf, sound[0], (soundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE, SOUNDCBSIZE );
|
RunNoteFinder( nf, sound, (soundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE, SOUNDCBSIZE );
|
||||||
//Done all ColorChord work.
|
//Done all ColorChord work.
|
||||||
|
|
||||||
VisTimeStart = OGGetAbsoluteTime();
|
VisTimeStart = OGGetAbsoluteTime();
|
||||||
|
@ -233,13 +248,13 @@ int main(int argc, char ** argv)
|
||||||
//Let's draw the o-scope.
|
//Let's draw the o-scope.
|
||||||
int thissoundhead = soundhead;
|
int thissoundhead = soundhead;
|
||||||
thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE;
|
thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE;
|
||||||
int lasty = sound[0][thissoundhead] * 128 + 128; thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE;
|
int lasty = sound[thissoundhead] * 128 + 128; thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE;
|
||||||
int thisy = sound[0][thissoundhead] * 128 + 128; thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE;
|
int thisy = sound[thissoundhead] * 128 + 128; thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE;
|
||||||
for( i = 0; i < screenx; i++ )
|
for( i = 0; i < screenx; i++ )
|
||||||
{
|
{
|
||||||
CNFGTackSegment( i, lasty, i+1, thisy );
|
CNFGTackSegment( i, lasty, i+1, thisy );
|
||||||
lasty = thisy;
|
lasty = thisy;
|
||||||
thisy = sound[0][thissoundhead] * 128 + 128; thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE;
|
thisy = sound[thissoundhead] * 128 + 128; thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue