|
@@ -78,14 +78,20 @@ laPropContainer* LA_PC_IDN_SYNTH_TRIGGER;
|
|
#define SAMPLE_RATE (MAIN.Audio->AudioSampleRate)
|
|
#define SAMPLE_RATE (MAIN.Audio->AudioSampleRate)
|
|
|
|
|
|
void IDN_InputInit(laSynthNodeInput* n, int NoCreate){
|
|
void IDN_InputInit(laSynthNodeInput* n, int NoCreate){
|
|
- INITPACKET(n->rTime); INITPACKET(n->rTrigger);
|
|
|
|
- if(NoCreate){ return; }
|
|
|
|
|
|
+ INITPACKET(n->rTime); INITPACKET(n->rTrigger); //INITPACKET(n->rSamplesL); INITPACKET(n->rSamplesR);
|
|
|
|
+ if(NoCreate){
|
|
|
|
+ if(!n->OutL) n->OutL=laCreateOutSocket(n,"L",LA_PROP_FLOAT|LA_PROP_ARRAY);
|
|
|
|
+ if(!n->OutR) n->OutR=laCreateOutSocket(n,"R",LA_PROP_FLOAT|LA_PROP_ARRAY);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
n->OutTime=laCreateOutSocket(n,"TIME",LA_PROP_FLOAT|LA_PROP_ARRAY);
|
|
n->OutTime=laCreateOutSocket(n,"TIME",LA_PROP_FLOAT|LA_PROP_ARRAY);
|
|
n->OutTrigger=laCreateOutSocket(n,"TRIGGER",LA_PROP_FLOAT|LA_PROP_ARRAY);
|
|
n->OutTrigger=laCreateOutSocket(n,"TRIGGER",LA_PROP_FLOAT|LA_PROP_ARRAY);
|
|
strSafeSet(&n->Base.Name,"Input");
|
|
strSafeSet(&n->Base.Name,"Input");
|
|
}
|
|
}
|
|
void IDN_InputDestroy(laSynthNodeInput* n){
|
|
void IDN_InputDestroy(laSynthNodeInput* n){
|
|
- laDestroyOutSocket(n->OutTime); laDestroyOutSocket(n->OutTrigger); strSafeDestroy(&n->Base.Name); memFree(n->rTime); memFree(n->rTrigger);
|
|
|
|
|
|
+ laDestroyOutSocket(n->OutTime); laDestroyOutSocket(n->OutTrigger);
|
|
|
|
+ laDestroyOutSocket(n->OutL); laDestroyOutSocket(n->OutR); strSafeDestroy(&n->Base.Name);
|
|
|
|
+ memFree(n->rTime); memFree(n->rTrigger); memFree(n->rSamplesL); memFree(n->rSamplesL);
|
|
}
|
|
}
|
|
int IDN_InputVisit(laSynthNodeInput* n, laNodeVisitInfo* vi){
|
|
int IDN_InputVisit(laSynthNodeInput* n, laNodeVisitInfo* vi){
|
|
LA_GUARD_THIS_NODE(n,vi);
|
|
LA_GUARD_THIS_NODE(n,vi);
|
|
@@ -101,6 +107,7 @@ int IDN_InputEval(laSynthNodeInput* n){
|
|
}
|
|
}
|
|
if(ss->EvalSamples==0){ n->rTrigger[0] = 10; }else{ n->rTrigger[0]=0; }
|
|
if(ss->EvalSamples==0){ n->rTrigger[0] = 10; }else{ n->rTrigger[0]=0; }
|
|
n->OutTime->Data=n->rTime; n->OutTrigger->Data=n->rTrigger; n->OutTime->ArrLen=LA_SYNTH_PLEN; n->OutTrigger->ArrLen=LA_SYNTH_PLEN;
|
|
n->OutTime->Data=n->rTime; n->OutTrigger->Data=n->rTrigger; n->OutTime->ArrLen=LA_SYNTH_PLEN; n->OutTrigger->ArrLen=LA_SYNTH_PLEN;
|
|
|
|
+ n->OutL->Data=MAIN.Audio->InputSamples; n->OutR->Data=MAIN.Audio->InputSamples; n->OutL->ArrLen=LA_SYNTH_PLEN; n->OutR->ArrLen=LA_SYNTH_PLEN;
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
void IDN_InputCopy(laSynthNodeInput* new, laSynthNodeInput* old, int DoRematch){
|
|
void IDN_InputCopy(laSynthNodeInput* new, laSynthNodeInput* old, int DoRematch){
|
|
@@ -112,7 +119,13 @@ void laui_InputNode(laUiList *uil, laPropPack *This, laPropPack *Extra, laColumn
|
|
LA_BASE_NODE_HEADER(uil,c,This);
|
|
LA_BASE_NODE_HEADER(uil,c,This);
|
|
|
|
|
|
laUiItem* b=laBeginRow(uil,c,0,0);
|
|
laUiItem* b=laBeginRow(uil,c,0,0);
|
|
- laUiItem* ui=laShowLabel(uil,c,"Synth",0,0); ui->Expand=1; ui->Flags|=LA_TEXT_ALIGN_RIGHT;
|
|
|
|
|
|
+ laUiItem* ui=laShowLabel(uil,c,"Capture",0,0); ui->Expand=1; ui->Flags|=LA_TEXT_ALIGN_RIGHT;
|
|
|
|
+ laShowNodeSocket(uil,c,This,"out_l",0)->Flags|=LA_UI_SOCKET_LABEL_E;
|
|
|
|
+ laShowNodeSocket(uil,c,This,"out_r",0)->Flags|=LA_UI_SOCKET_LABEL_E;
|
|
|
|
+ laEndRow(uil,b);
|
|
|
|
+
|
|
|
|
+ b=laBeginRow(uil,c,0,0);
|
|
|
|
+ ui=laShowLabel(uil,c,"Synth",0,0); ui->Expand=1; ui->Flags|=LA_TEXT_ALIGN_RIGHT;
|
|
laShowNodeSocket(uil,c,This,"out_time",0)->Flags|=LA_UI_SOCKET_LABEL_E;
|
|
laShowNodeSocket(uil,c,This,"out_time",0)->Flags|=LA_UI_SOCKET_LABEL_E;
|
|
laShowNodeSocket(uil,c,This,"out_trigger",0)->Flags|=LA_UI_SOCKET_LABEL_E;
|
|
laShowNodeSocket(uil,c,This,"out_trigger",0)->Flags|=LA_UI_SOCKET_LABEL_E;
|
|
laEndRow(uil,b);
|
|
laEndRow(uil,b);
|
|
@@ -794,7 +807,7 @@ int laEvalSingleSynth(laSynth* ss){
|
|
}
|
|
}
|
|
int laEvalSynthGraphs(){
|
|
int laEvalSynthGraphs(){
|
|
laSynth* ss; int any=0;
|
|
laSynth* ss; int any=0;
|
|
- memset(MAIN.Audio->AudioSamples,0,sizeof(real)*LA_SYNTH_PLEN);
|
|
|
|
|
|
+ memset(MAIN.Audio->OutputSamples,0,sizeof(real)*LA_SYNTH_PLEN);
|
|
for(laAudioChannel* ac=MAIN.Audio->Channels.pFirst;ac;ac=ac->Item.pNext){
|
|
for(laAudioChannel* ac=MAIN.Audio->Channels.pFirst;ac;ac=ac->Item.pNext){
|
|
memset(ac->Samples,0,sizeof(real)*LA_SYNTH_PLEN);
|
|
memset(ac->Samples,0,sizeof(real)*LA_SYNTH_PLEN);
|
|
}
|
|
}
|
|
@@ -805,26 +818,29 @@ int laEvalSynthGraphs(){
|
|
|
|
|
|
for(laAudioChannel* ac=MAIN.Audio->Channels.pFirst;ac;ac=ac->Item.pNext){
|
|
for(laAudioChannel* ac=MAIN.Audio->Channels.pFirst;ac;ac=ac->Item.pNext){
|
|
for(int i=0;i<LA_SYNTH_PLEN;i++){
|
|
for(int i=0;i<LA_SYNTH_PLEN;i++){
|
|
- MAIN.Audio->AudioSamples[i] += ac->Samples[i]*(ac->Volume/10);
|
|
|
|
|
|
+ MAIN.Audio->OutputSamples[i] += ac->Samples[i]*(ac->Volume/10);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return any;
|
|
return any;
|
|
}
|
|
}
|
|
|
|
|
|
void laaudio_DataCallback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount){
|
|
void laaudio_DataCallback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount){
|
|
- float* out=pOutput; int Paused; int any=0;
|
|
|
|
|
|
+ float* out=pOutput,*in=pInput; int Paused; int any=0;
|
|
laSpinLock(&MAIN.Audio->AudioStatusLock);
|
|
laSpinLock(&MAIN.Audio->AudioStatusLock);
|
|
Paused = MAIN.Audio->Paused;
|
|
Paused = MAIN.Audio->Paused;
|
|
laSpinUnlock(&MAIN.Audio->AudioStatusLock);
|
|
laSpinUnlock(&MAIN.Audio->AudioStatusLock);
|
|
|
|
|
|
- if(Paused){ memset(out,0,sizeof(float)*LA_SYNTH_PLEN); return; }
|
|
|
|
|
|
+ if(Paused){ memset(out,0,sizeof(float)*LA_SYNTH_PLEN);
|
|
|
|
+ memset(MAIN.Audio->InputSamples,0,sizeof(float)*LA_SYNTH_PLEN); return;
|
|
|
|
+ }
|
|
|
|
|
|
for(int i=0;i<frameCount;i++){
|
|
for(int i=0;i<frameCount;i++){
|
|
if(MAIN.Audio->NextAudioSample>=LA_SYNTH_PLEN){
|
|
if(MAIN.Audio->NextAudioSample>=LA_SYNTH_PLEN){
|
|
MAIN.Audio->NextAudioSample=0;
|
|
MAIN.Audio->NextAudioSample=0;
|
|
if(laEvalSynthGraphs()){ any=1; }
|
|
if(laEvalSynthGraphs()){ any=1; }
|
|
}
|
|
}
|
|
- out[i]=MAIN.Audio->AudioSamples[MAIN.Audio->NextAudioSample]/10;
|
|
|
|
|
|
+ out[i]=MAIN.Audio->OutputSamples[MAIN.Audio->NextAudioSample]/10;
|
|
|
|
+ MAIN.Audio->InputSamples[MAIN.Audio->NextAudioSample] = in[i] * 10;
|
|
MAIN.Audio->NextAudioSample++;
|
|
MAIN.Audio->NextAudioSample++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -836,8 +852,11 @@ void la_SelectAudioDevice(laAudioDevice* ad){
|
|
ma_device_uninit(&MAIN.Audio->AudioDevice);
|
|
ma_device_uninit(&MAIN.Audio->AudioDevice);
|
|
if(!ad) return;
|
|
if(!ad) return;
|
|
int SampleRate=48000;
|
|
int SampleRate=48000;
|
|
- ma_device_config config = ma_device_config_init(ma_device_type_playback);
|
|
|
|
- config.playback.pDeviceID= 0;
|
|
|
|
|
|
+ ma_device_config config = ma_device_config_init(ma_device_type_duplex);
|
|
|
|
+ config.capture.pDeviceID = ad->MiniAudioID;
|
|
|
|
+ config.capture.format = ma_format_f32;
|
|
|
|
+ config.capture.channels = 1;
|
|
|
|
+ config.playback.pDeviceID= ad->MiniAudioID;
|
|
config.playback.format = ma_format_f32;
|
|
config.playback.format = ma_format_f32;
|
|
config.playback.channels = 1;
|
|
config.playback.channels = 1;
|
|
config.sampleRate = SampleRate;
|
|
config.sampleRate = SampleRate;
|
|
@@ -881,11 +900,14 @@ void laInitMiniAudio(){
|
|
laRefreshAudioDevices();
|
|
laRefreshAudioDevices();
|
|
|
|
|
|
laSpinInit(&MAIN.Audio->AudioStatusLock);
|
|
laSpinInit(&MAIN.Audio->AudioStatusLock);
|
|
- INITPACKET(MAIN.Audio->AudioSamples);
|
|
|
|
|
|
+ INITPACKET(MAIN.Audio->InputSamples);
|
|
|
|
+ INITPACKET(MAIN.Audio->OutputSamples);
|
|
|
|
|
|
la_SelectAudioDevice(MAIN.Audio->AudioDevices.pFirst);
|
|
la_SelectAudioDevice(MAIN.Audio->AudioDevices.pFirst);
|
|
}
|
|
}
|
|
void laDeinitAudio(){
|
|
void laDeinitAudio(){
|
|
|
|
+ memFree(MAIN.Audio->InputSamples);
|
|
|
|
+ memFree(MAIN.Audio->OutputSamples);
|
|
laSpinDestroy(&MAIN.Audio->AudioStatusLock);
|
|
laSpinDestroy(&MAIN.Audio->AudioStatusLock);
|
|
ma_device_stop(&MAIN.Audio->AudioDevice);
|
|
ma_device_stop(&MAIN.Audio->AudioDevice);
|
|
ma_device_uninit(&MAIN.Audio->AudioDevice);
|
|
ma_device_uninit(&MAIN.Audio->AudioDevice);
|
|
@@ -1258,6 +1280,8 @@ void laInitAudio(){
|
|
laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
|
|
laAddSubGroup(pc,"base","Base","Base node","la_base_node",0,0,0,0,0,0,0,0,0,0,0,LA_UDF_LOCAL);
|
|
laAddSubGroup(pc,"out_time", "Out Time","Time output","la_out_socket",0,0,0,offsetof(laSynthNodeInput,OutTime),0,0,0,0,0,0,0,LA_UDF_SINGLE);
|
|
laAddSubGroup(pc,"out_time", "Out Time","Time output","la_out_socket",0,0,0,offsetof(laSynthNodeInput,OutTime),0,0,0,0,0,0,0,LA_UDF_SINGLE);
|
|
laAddSubGroup(pc,"out_trigger", "Out Trigger","Trigger output","la_out_socket",0,0,0,offsetof(laSynthNodeInput,OutTrigger),0,0,0,0,0,0,0,LA_UDF_SINGLE);
|
|
laAddSubGroup(pc,"out_trigger", "Out Trigger","Trigger output","la_out_socket",0,0,0,offsetof(laSynthNodeInput,OutTrigger),0,0,0,0,0,0,0,LA_UDF_SINGLE);
|
|
|
|
+ laAddSubGroup(pc,"out_l", "Out Left","Capture left","la_out_socket",0,0,0,offsetof(laSynthNodeInput,OutL),0,0,0,0,0,0,0,LA_UDF_SINGLE);
|
|
|
|
+ laAddSubGroup(pc,"out_r", "Out Right","Capture right","la_out_socket",0,0,0,offsetof(laSynthNodeInput,OutR),0,0,0,0,0,0,0,LA_UDF_SINGLE);
|
|
|
|
|
|
pc=laAddPropertyContainer("la_node_synth_pulse", "Synth Pulse Node", "Pulse generate node for synth",0,laui_PulseNode,sizeof(laSynthNodePulse),lapost_Node,0,1);
|
|
pc=laAddPropertyContainer("la_node_synth_pulse", "Synth Pulse Node", "Pulse generate node for synth",0,laui_PulseNode,sizeof(laSynthNodePulse),lapost_Node,0,1);
|
|
LA_PC_IDN_PULSE=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
|
|
LA_PC_IDN_PULSE=pc; laPropContainerExtraFunctions(pc,0,0,0,0,laui_DefaultNodeOperationsPropUiDefine);
|