update from Merge
This commit is contained in:
parent
4ff00bfb95
commit
000261ace5
|
@ -4,9 +4,16 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
#include "hook.h"
|
#include "hook.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern unsigned char OutLEDs[MAX_LEDS*3];
|
||||||
|
extern int UsedLEDs;
|
||||||
|
|
||||||
|
|
||||||
struct RecorderPlugin
|
struct RecorderPlugin
|
||||||
{
|
{
|
||||||
int is_recording;
|
int is_recording;
|
||||||
|
@ -29,11 +36,12 @@ void StopRecording( struct RecorderPlugin * rp )
|
||||||
|
|
||||||
rp->TimeSinceStart = 0;
|
rp->TimeSinceStart = 0;
|
||||||
rp->DunBoop = 0;
|
rp->DunBoop = 0;
|
||||||
fclose( rp->fRec );
|
if( rp->fRec ) fclose( rp->fRec );
|
||||||
fclose( rp->fPlay );
|
if( rp->fPlay) fclose( rp->fPlay );
|
||||||
rp->is_recording = 0;
|
rp->is_recording = 0;
|
||||||
rp->fRec = 0;
|
rp->fRec = 0;
|
||||||
rp->fPlay = 0;
|
rp->fPlay = 0;
|
||||||
|
printf( "Stopped.\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartRecording( struct RecorderPlugin * rp )
|
void StartRecording( struct RecorderPlugin * rp )
|
||||||
|
@ -44,6 +52,8 @@ void StartRecording( struct RecorderPlugin * rp )
|
||||||
rp->DunBoop = 0;
|
rp->DunBoop = 0;
|
||||||
rp->is_recording = 1;
|
rp->is_recording = 1;
|
||||||
|
|
||||||
|
printf( "Starting Recording: /%s/%s/\n", rp->In_Filename, rp->Out_Filename );
|
||||||
|
|
||||||
if( rp->In_Filename[0] == 0 )
|
if( rp->In_Filename[0] == 0 )
|
||||||
{
|
{
|
||||||
//Nothing
|
//Nothing
|
||||||
|
@ -56,6 +66,7 @@ void StartRecording( struct RecorderPlugin * rp )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Warning: Could not play filename: %s\n", rp->In_Filename );
|
fprintf( stderr, "Warning: Could not play filename: %s\n", rp->In_Filename );
|
||||||
}
|
}
|
||||||
|
printf( "Play file opened.\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( rp->Out_Filename[0] == 0 )
|
if( rp->Out_Filename[0] == 0 )
|
||||||
|
@ -65,10 +76,11 @@ void StartRecording( struct RecorderPlugin * rp )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
struct stat buf;
|
||||||
|
char cts[1024];
|
||||||
int i;
|
int i;
|
||||||
for( i = 0; i < 999; i++ )
|
for( i = 0; i < 999; i++ )
|
||||||
{
|
{
|
||||||
char cts[1024];
|
|
||||||
if( i == 0 )
|
if( i == 0 )
|
||||||
{
|
{
|
||||||
snprintf( cts, 1023, "%s", rp->Out_Filename );
|
snprintf( cts, 1023, "%s", rp->Out_Filename );
|
||||||
|
@ -78,9 +90,17 @@ void StartRecording( struct RecorderPlugin * rp )
|
||||||
snprintf( cts, 1023, "%s.%03d", rp->Out_Filename, i );
|
snprintf( cts, 1023, "%s.%03d", rp->Out_Filename, i );
|
||||||
}
|
}
|
||||||
|
|
||||||
rp->fRec = fopen( cts, "wb" );
|
if( stat( cts, &buf ) != 0 )
|
||||||
if( rp->fRec ) break;
|
break;
|
||||||
}
|
}
|
||||||
|
printf( "Found rec file %s\n", cts );
|
||||||
|
rp->fRec = fopen( cts, "wb" );
|
||||||
|
if( !rp->fRec )
|
||||||
|
{
|
||||||
|
fprintf( stderr, "Error: cannot start recording file \"%s\"\n", cts );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf( "Recording...\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +108,7 @@ void StartRecording( struct RecorderPlugin * rp )
|
||||||
static void RecordEvent(void * v, int samples, float * samps, int channel_ct)
|
static void RecordEvent(void * v, int samples, float * samps, int channel_ct)
|
||||||
{
|
{
|
||||||
struct RecorderPlugin * rp = (struct RecorderPlugin*)v;
|
struct RecorderPlugin * rp = (struct RecorderPlugin*)v;
|
||||||
|
|
||||||
if( !rp->fRec || !rp->is_recording ) return;
|
if( !rp->fRec || !rp->is_recording ) return;
|
||||||
|
|
||||||
if( rp->DunBoop || !rp->fPlay )
|
if( rp->DunBoop || !rp->fPlay )
|
||||||
|
@ -105,15 +126,20 @@ static void PlaybackEvent(void * v, int samples, float * samps, int channel_ct)
|
||||||
struct RecorderPlugin * rp = (struct RecorderPlugin*)v;
|
struct RecorderPlugin * rp = (struct RecorderPlugin*)v;
|
||||||
if( !rp->fPlay ) return;
|
if( !rp->fPlay ) return;
|
||||||
|
|
||||||
|
int r = fread( samps, channel_ct * sizeof( float ), samples, rp->fPlay );
|
||||||
|
if( r != samples )
|
||||||
|
{
|
||||||
|
StopRecording( rp );
|
||||||
|
}
|
||||||
|
rp->TimeSinceStart += samples;
|
||||||
|
|
||||||
if( rp->TimeSinceStart < rp->BypassLength )
|
if( rp->TimeSinceStart < rp->BypassLength )
|
||||||
{
|
{
|
||||||
int r = fread( samps, channel_ct * sizeof( float ), samples, rp->fPlay );
|
if( rp->is_recording )
|
||||||
if( r != samples )
|
force_white = 1;
|
||||||
{
|
else
|
||||||
StopRecording( rp );
|
force_white = 0;
|
||||||
}
|
|
||||||
|
|
||||||
rp->TimeSinceStart += samples;
|
|
||||||
if( rp->TimeSinceStart > rp->BypassLength )
|
if( rp->TimeSinceStart > rp->BypassLength )
|
||||||
{
|
{
|
||||||
rp->DunBoop = 1;
|
rp->DunBoop = 1;
|
||||||
|
@ -127,6 +153,10 @@ static void PlaybackEvent(void * v, int samples, float * samps, int channel_ct)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
force_white = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MKeyEvent( void * v, int keycode, int down )
|
static void MKeyEvent( void * v, int keycode, int down )
|
||||||
|
@ -146,7 +176,18 @@ static void DPOUpdate(void * id, struct NoteFinder*nf)
|
||||||
static void DPOParams(void * id )
|
static void DPOParams(void * id )
|
||||||
{
|
{
|
||||||
struct RecorderPlugin * d = (struct RecorderPlugin*)id;
|
struct RecorderPlugin * d = (struct RecorderPlugin*)id;
|
||||||
|
d->is_recording = 0;
|
||||||
|
d->fRec = 0;
|
||||||
|
d->fPlay = 0;
|
||||||
|
d->DunBoop = 0;
|
||||||
|
d->TimeSinceStart = 0;
|
||||||
|
|
||||||
|
memset( d->In_Filename, 0, PARAM_BUFF ); RegisterValue( "player_filename", PABUFFER, d->In_Filename, PARAM_BUFF );
|
||||||
|
memset( d->Out_Filename, 0, PARAM_BUFF ); RegisterValue( "recorder_filename", PABUFFER, d->Out_Filename, PARAM_BUFF );
|
||||||
|
|
||||||
d->sps = 0; RegisterValue( "samplerate", PAINT, &d->sps, sizeof( d->sps ) );
|
d->sps = 0; RegisterValue( "samplerate", PAINT, &d->sps, sizeof( d->sps ) );
|
||||||
|
d->BypassLength = 0; RegisterValue( "recorder_bypass", PAINT, &d->BypassLength, sizeof( d->BypassLength ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct DriverInstances * RecorderPlugin(const char * parameters)
|
static struct DriverInstances * RecorderPlugin(const char * parameters)
|
||||||
|
|
4
hook.c
4
hook.c
|
@ -25,6 +25,7 @@ void HookKeyEvent( void (*KeyE)( void * v, int key, int down ), void * v )
|
||||||
{
|
{
|
||||||
KeyEvents[i].KeyE = KeyE;
|
KeyEvents[i].KeyE = KeyE;
|
||||||
KeyEvents[i].v = v;
|
KeyEvents[i].v = v;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +55,7 @@ struct SoundEvent
|
||||||
void (*SoundE)( void * v, int samples, float * samps, int channel_ct );
|
void (*SoundE)( void * v, int samples, float * samps, int channel_ct );
|
||||||
void * v;
|
void * v;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SoundEvent SoundEvents[2][MAX_SOUND_EVENTS];
|
struct SoundEvent SoundEvents[2][MAX_SOUND_EVENTS];
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +66,6 @@ void SoundEventHappened( int samples, float * samps, int is_out, int channel_ct
|
||||||
{
|
{
|
||||||
if( SoundEvents[is_out][i].SoundE )
|
if( SoundEvents[is_out][i].SoundE )
|
||||||
{
|
{
|
||||||
printf( "%d\n", i );
|
|
||||||
SoundEvents[is_out][i].SoundE( SoundEvents[is_out][i].v, samples, samps, channel_ct );
|
SoundEvents[is_out][i].SoundE( SoundEvents[is_out][i].v, samples, samps, channel_ct );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,6 +80,7 @@ void HookSoundInEvent( void (*SoundE)( void * v, int samples, float * samps, int
|
||||||
{
|
{
|
||||||
SoundEvents[is_out][i].SoundE = SoundE;
|
SoundEvents[is_out][i].SoundE = SoundE;
|
||||||
SoundEvents[is_out][i].v = v;
|
SoundEvents[is_out][i].v = v;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
21
main.c
21
main.c
|
@ -123,11 +123,13 @@ void SoundCB( float * out, float * in, int samplesr, int * samplesp, struct Soun
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float f = in[i*channelin+sample_channel];
|
float f = in[i*channelin+sample_channel];
|
||||||
if( f > -1 && f < 1 )
|
|
||||||
{
|
if( f > 1 || f < -1 )
|
||||||
|
{
|
||||||
f = (f>0)?1:-1;
|
f = (f>0)?1:-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//printf( "Sound fault B %d/%d\n", i, samplesr );
|
//printf( "Sound fault B %d/%d\n", i, samplesr );
|
||||||
sound[soundhead] = f;
|
sound[soundhead] = f;
|
||||||
soundhead = (soundhead+1)%SOUNDCBSIZE;
|
soundhead = (soundhead+1)%SOUNDCBSIZE;
|
||||||
|
@ -135,8 +137,8 @@ void SoundCB( float * out, float * in, int samplesr, int * samplesp, struct Soun
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundEventHappened( samplesr, in, channelin, 0 );
|
SoundEventHappened( samplesr, in, 0, channelin );
|
||||||
SoundEventHappened( samplesr, out, sd->channelsPlay, 1 );
|
SoundEventHappened( samplesr, out, 1, sd->channelsPlay );
|
||||||
*samplesp = samplesr;
|
*samplesp = samplesr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,13 +336,24 @@ int main(int argc, char ** argv)
|
||||||
RunNoteFinder( nf, sound, (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();
|
||||||
|
|
||||||
for( i = 0; i < MAX_OUT_DRIVERS; i++ )
|
for( i = 0; i < MAX_OUT_DRIVERS; i++ )
|
||||||
|
{
|
||||||
|
|
||||||
|
if( force_white )
|
||||||
|
{
|
||||||
|
memset( OutLEDs, 0x7f, MAX_LEDS*3 );
|
||||||
|
}
|
||||||
|
|
||||||
if( outdriver[i] )
|
if( outdriver[i] )
|
||||||
outdriver[i]->Func( outdriver[i]->id, nf );
|
outdriver[i]->Func( outdriver[i]->id, nf );
|
||||||
|
}
|
||||||
|
|
||||||
VisTimeEnd = OGGetAbsoluteTime();
|
VisTimeEnd = OGGetAbsoluteTime();
|
||||||
|
|
||||||
|
|
||||||
if( !headless )
|
if( !headless )
|
||||||
{
|
{
|
||||||
//Handle outputs.
|
//Handle outputs.
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int force_white = 0;
|
||||||
unsigned char OutLEDs[MAX_LEDS*3];
|
unsigned char OutLEDs[MAX_LEDS*3];
|
||||||
int UsedLEDs;
|
int UsedLEDs;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ struct NoteFinder;
|
||||||
|
|
||||||
#define MAX_LEDS 32678
|
#define MAX_LEDS 32678
|
||||||
|
|
||||||
|
extern int force_white;
|
||||||
extern unsigned char OutLEDs[MAX_LEDS*3];
|
extern unsigned char OutLEDs[MAX_LEDS*3];
|
||||||
extern int UsedLEDs;
|
extern int UsedLEDs;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue