From 75cc6a6e6001758554873ac111153856c34525c2 Mon Sep 17 00:00:00 2001 From: "peyrard.johann@gmail.com" Date: Thu, 27 Oct 2016 04:45:50 -0400 Subject: [PATCH] Reinsert the MonoMixer.{cpp,h} with the cache blocking SAMMONOMIXER. This code was removed in tag 0.74d because it modify the "note tuning" of the synth. The bad code was related to a value in a buffer16[index] which was return two time, so it impact the "note tuning". Change Machine class function tick : - int tick() + Sint16 tick() --- picoloop/Machine.cpp | 3 +- picoloop/Machine.h | 2 +- picoloop/Machine/Cursynth/CursynthMachine.cpp | 2 +- picoloop/Machine/Cursynth/CursynthMachine.h | 2 +- picoloop/Machine/Dbopl/DboplMachine.cpp | 2 +- picoloop/Machine/Dbopl/DboplMachine.h | 2 +- picoloop/Machine/MDADrum/MDADrumMachine.cpp | 2 +- picoloop/Machine/MDADrum/MDADrumMachine.h | 2 +- .../Machine/MidiOutSystem/MidiOutMachine.cpp | 2 +- .../Machine/MidiOutSystem/MidiOutMachine.h | 2 +- picoloop/Machine/Open303/Open303Machine.cpp | 2 +- picoloop/Machine/Open303/Open303Machine.h | 2 +- picoloop/Machine/PBSynth/PBSynthMachine.cpp | 2 +- picoloop/Machine/PBSynth/PBSynthMachine.h | 2 +- picoloop/Machine/Picodrum/PicodrumMachine.cpp | 2 +- picoloop/Machine/Picodrum/PicodrumMachine.h | 2 +- .../Machine/Picosynth/PicosynthMachine.cpp | 2 +- picoloop/Machine/Picosynth/PicosynthMachine.h | 2 +- .../Machine/Twytch/TwytchsynthMachine.cpp | 2 +- picoloop/Machine/Twytch/TwytchsynthMachine.h | 2 +- .../Makefile.PatternPlayer_debian_RtAudio | 2 +- picoloop/MonoMixer.cpp | 60 +++++++++++++++++-- picoloop/MonoMixer.h | 4 ++ 23 files changed, 82 insertions(+), 25 deletions(-) diff --git a/picoloop/Machine.cpp b/picoloop/Machine.cpp index 6077736e..4bd7d74d 100644 --- a/picoloop/Machine.cpp +++ b/picoloop/Machine.cpp @@ -47,9 +47,10 @@ void Machine::reset() } -int Machine::tick() +Sint16 Machine::tick() { DPRINTF("Machine::tick()"); + return 0; } diff --git a/picoloop/Machine.h b/picoloop/Machine.h index aaa5c0e9..cab84a65 100644 --- a/picoloop/Machine.h +++ b/picoloop/Machine.h @@ -179,7 +179,7 @@ class Machine virtual void init(); virtual void reset(); - virtual int tick(); + virtual Sint16 tick(); virtual int checkI(int what,int val); virtual int checkITwoVal(int what,int val1,int val2); diff --git a/picoloop/Machine/Cursynth/CursynthMachine.cpp b/picoloop/Machine/Cursynth/CursynthMachine.cpp index 4dc2c5b4..2cf1782a 100644 --- a/picoloop/Machine/Cursynth/CursynthMachine.cpp +++ b/picoloop/Machine/Cursynth/CursynthMachine.cpp @@ -393,7 +393,7 @@ void CursynthMachine::reset() } -int CursynthMachine::tick() +Sint16 CursynthMachine::tick() { float f_in; float f_out; diff --git a/picoloop/Machine/Cursynth/CursynthMachine.h b/picoloop/Machine/Cursynth/CursynthMachine.h index b74f2cee..aa447ed2 100644 --- a/picoloop/Machine/Cursynth/CursynthMachine.h +++ b/picoloop/Machine/Cursynth/CursynthMachine.h @@ -14,7 +14,7 @@ class CursynthMachine : public Machine void init(); void reset(); - int tick(); + Sint16 tick(); void setI(int what,int val); void setF(int what,float val); diff --git a/picoloop/Machine/Dbopl/DboplMachine.cpp b/picoloop/Machine/Dbopl/DboplMachine.cpp index c10ed43a..0328fff7 100644 --- a/picoloop/Machine/Dbopl/DboplMachine.cpp +++ b/picoloop/Machine/Dbopl/DboplMachine.cpp @@ -404,7 +404,7 @@ void dboplMachine::setI(int what,int val) } -int dboplMachine::tick() +Sint16 dboplMachine::tick() { Sint16 s_in; Sint16 s_out; diff --git a/picoloop/Machine/Dbopl/DboplMachine.h b/picoloop/Machine/Dbopl/DboplMachine.h index 56a8c6c2..78ec6897 100644 --- a/picoloop/Machine/Dbopl/DboplMachine.h +++ b/picoloop/Machine/Dbopl/DboplMachine.h @@ -27,7 +27,7 @@ class dboplMachine : public Machine void init(); void reset(); - int tick(); + Sint16 tick(); void setI(int what,int val); void setF(int what,float val); diff --git a/picoloop/Machine/MDADrum/MDADrumMachine.cpp b/picoloop/Machine/MDADrum/MDADrumMachine.cpp index 058af033..5f4bedfa 100644 --- a/picoloop/Machine/MDADrum/MDADrumMachine.cpp +++ b/picoloop/Machine/MDADrum/MDADrumMachine.cpp @@ -2216,7 +2216,7 @@ void MDADrumMachine::setI(int what,int val) } -int MDADrumMachine::tick() +Sint16 MDADrumMachine::tick() { int i=0; Sint16 s_in=0; diff --git a/picoloop/Machine/MDADrum/MDADrumMachine.h b/picoloop/Machine/MDADrum/MDADrumMachine.h index f38f5cf5..d489b6b6 100644 --- a/picoloop/Machine/MDADrum/MDADrumMachine.h +++ b/picoloop/Machine/MDADrum/MDADrumMachine.h @@ -29,7 +29,7 @@ class MDADrumMachine : public Machine void init(); void reset(); - int tick(); + Sint16 tick(); void setI(int what,int val); void setF(int what,float val); diff --git a/picoloop/Machine/MidiOutSystem/MidiOutMachine.cpp b/picoloop/Machine/MidiOutSystem/MidiOutMachine.cpp index 322120bf..d697433e 100644 --- a/picoloop/Machine/MidiOutSystem/MidiOutMachine.cpp +++ b/picoloop/Machine/MidiOutSystem/MidiOutMachine.cpp @@ -309,7 +309,7 @@ void MidiOutMachine::reset() } -int MidiOutMachine::tick() +Sint16 MidiOutMachine::tick() { float f_in; float f_out; diff --git a/picoloop/Machine/MidiOutSystem/MidiOutMachine.h b/picoloop/Machine/MidiOutSystem/MidiOutMachine.h index d90f1fc9..7630c7c2 100644 --- a/picoloop/Machine/MidiOutSystem/MidiOutMachine.h +++ b/picoloop/Machine/MidiOutSystem/MidiOutMachine.h @@ -14,7 +14,7 @@ class MidiOutMachine : public Machine void init(); void reset(); - int tick(); + Sint16 tick(); void setI(int what,int val); void setF(int what,float val); diff --git a/picoloop/Machine/Open303/Open303Machine.cpp b/picoloop/Machine/Open303/Open303Machine.cpp index c12edb63..d71fdf92 100644 --- a/picoloop/Machine/Open303/Open303Machine.cpp +++ b/picoloop/Machine/Open303/Open303Machine.cpp @@ -329,7 +329,7 @@ void Open303Machine::reset() } -int Open303Machine::tick() +Sint16 Open303Machine::tick() { double f_in; Sint16 s_out; diff --git a/picoloop/Machine/Open303/Open303Machine.h b/picoloop/Machine/Open303/Open303Machine.h index 95ab2b2e..b44dd430 100644 --- a/picoloop/Machine/Open303/Open303Machine.h +++ b/picoloop/Machine/Open303/Open303Machine.h @@ -14,7 +14,7 @@ class Open303Machine : public Machine void init(); void reset(); - int tick(); + Sint16 tick(); void setI(int what,int val); void setF(int what,float val); diff --git a/picoloop/Machine/PBSynth/PBSynthMachine.cpp b/picoloop/Machine/PBSynth/PBSynthMachine.cpp index 6d71feaa..8b57bd28 100644 --- a/picoloop/Machine/PBSynth/PBSynthMachine.cpp +++ b/picoloop/Machine/PBSynth/PBSynthMachine.cpp @@ -327,7 +327,7 @@ void PBSynthMachine::setI(int what,int val) } -int PBSynthMachine::tick() +Sint16 PBSynthMachine::tick() { Sint16 s_in; Sint32 s_in32; diff --git a/picoloop/Machine/PBSynth/PBSynthMachine.h b/picoloop/Machine/PBSynth/PBSynthMachine.h index b44ff58f..753f8cbf 100644 --- a/picoloop/Machine/PBSynth/PBSynthMachine.h +++ b/picoloop/Machine/PBSynth/PBSynthMachine.h @@ -20,7 +20,7 @@ class PBSynthMachine : public Machine void init(); void reset(); - int tick(); + Sint16 tick(); void setI(int what,int val); void setF(int what,float val); diff --git a/picoloop/Machine/Picodrum/PicodrumMachine.cpp b/picoloop/Machine/Picodrum/PicodrumMachine.cpp index 18161c71..42d400d5 100644 --- a/picoloop/Machine/Picodrum/PicodrumMachine.cpp +++ b/picoloop/Machine/Picodrum/PicodrumMachine.cpp @@ -279,7 +279,7 @@ void PicodrumMachine::reset() } -int PicodrumMachine::tick() +Sint16 PicodrumMachine::tick() { float f_in; float f_out; diff --git a/picoloop/Machine/Picodrum/PicodrumMachine.h b/picoloop/Machine/Picodrum/PicodrumMachine.h index d9e95d20..4a9ccc6b 100644 --- a/picoloop/Machine/Picodrum/PicodrumMachine.h +++ b/picoloop/Machine/Picodrum/PicodrumMachine.h @@ -16,7 +16,7 @@ class PicodrumMachine : public Machine void init(); void reset(); - int tick(); + Sint16 tick(); void setI(int what,int val); void setF(int what,float val); diff --git a/picoloop/Machine/Picosynth/PicosynthMachine.cpp b/picoloop/Machine/Picosynth/PicosynthMachine.cpp index 61b969ca..d4c54964 100644 --- a/picoloop/Machine/Picosynth/PicosynthMachine.cpp +++ b/picoloop/Machine/Picosynth/PicosynthMachine.cpp @@ -329,7 +329,7 @@ void PicosynthMachine::reset() } -int PicosynthMachine::tick() +Sint16 PicosynthMachine::tick() { float f_in; float f_out; diff --git a/picoloop/Machine/Picosynth/PicosynthMachine.h b/picoloop/Machine/Picosynth/PicosynthMachine.h index 11fa19da..a1d113d6 100644 --- a/picoloop/Machine/Picosynth/PicosynthMachine.h +++ b/picoloop/Machine/Picosynth/PicosynthMachine.h @@ -17,7 +17,7 @@ class PicosynthMachine : public Machine void init(); void reset(); - int tick(); + Sint16 tick(); void setI(int what,int val); void setF(int what,float val); diff --git a/picoloop/Machine/Twytch/TwytchsynthMachine.cpp b/picoloop/Machine/Twytch/TwytchsynthMachine.cpp index d9ad276b..49bb5240 100644 --- a/picoloop/Machine/Twytch/TwytchsynthMachine.cpp +++ b/picoloop/Machine/Twytch/TwytchsynthMachine.cpp @@ -520,7 +520,7 @@ void TwytchsynthMachine::reset() } -int TwytchsynthMachine::tick() +Sint16 TwytchsynthMachine::tick() { float f_in; float f_out; diff --git a/picoloop/Machine/Twytch/TwytchsynthMachine.h b/picoloop/Machine/Twytch/TwytchsynthMachine.h index be767fee..bbd6e58a 100644 --- a/picoloop/Machine/Twytch/TwytchsynthMachine.h +++ b/picoloop/Machine/Twytch/TwytchsynthMachine.h @@ -14,7 +14,7 @@ class TwytchsynthMachine : public Machine void init(); void reset(); - int tick(); + Sint16 tick(); void setI(int what,int val); void setF(int what,float val); diff --git a/picoloop/Makefile.PatternPlayer_debian_RtAudio b/picoloop/Makefile.PatternPlayer_debian_RtAudio index 2ed905d8..1de758d3 100644 --- a/picoloop/Makefile.PatternPlayer_debian_RtAudio +++ b/picoloop/Makefile.PatternPlayer_debian_RtAudio @@ -18,7 +18,7 @@ CFLAGS= -c -O3 -D__LINUX__ -DLINUX -I. -LSDL/lib -D__RTAUDIO__ -DLINUX_DESKTOP - CFLAGS= -c -O3 -D__LINUX__ -DLINUX -I. -LSDL/lib -D__RTAUDIO__ -DLINUX_DESKTOP -ggdb -DDUMP_AUDIO=1 -DFIXED CFLAGS= -c -std=c++11 -O3 -D__LINUX__ -DLINUX -I. -LSDL/lib -D__RTAUDIO__ -D __RTMIDI__ -DLINUX_DESKTOP -ggdb -DDUMP_AUDIO=1 -fpermissive CFLAGS= -c -std=c++11 -O3 -D__LINUX__ -DLINUX -I. -LSDL/lib -D__RTAUDIO__ -D __RTMIDI__ -DLINUX_DESKTOP -ggdb -DDUMP_AUDIO=1 -DDEBUGPRINTF -fpermissive -CFLAGS= -c -std=c++11 -O3 -D__LINUX__ -DLINUX -I. -LSDL/lib -D__RTAUDIO__ -D __RTMIDI__ -DPC_DESKTOP -ggdb -DDEBUGPRINTF -DSCREEN_MULT=2 -fpermissive +CFLAGS= -c -std=c++11 -O3 -D__LINUX__ -DLINUX -I. -LSDL/lib -D__RTAUDIO__ -D __RTMIDI__ -DPC_DESKTOP -ggdb -DDEBUGPRINTF -DSCREEN_MULT=2 -DDUMP_AUDIO=1 -fpermissive LDFLAGS=-lasound -lSDL -lSDL_gfx -lSDL_ttf -lpthread -pg LDFLAGS=-lasound -lSDL -lSDL_ttf -lpthread -pg diff --git a/picoloop/MonoMixer.cpp b/picoloop/MonoMixer.cpp index cc0b5470..ea65b390 100644 --- a/picoloop/MonoMixer.cpp +++ b/picoloop/MonoMixer.cpp @@ -6,12 +6,19 @@ MonoMixer::MonoMixer(): PD(), PS(), OPLM(), PBS(), CS(), O303(), TW(), MD(), MID #endif #if defined(__FPU__) && !defined(__RTMIDI__) -MonoMixer::MonoMixer(): PD(), PS(), OPLM(), PBS(), CS(), O303(), TW(), FXDelay(), FXDisabled() +MonoMixer::MonoMixer(): PD(), PS(), OPLM(), PBS(), CS(), O303(), TW(), FXDelay(), FXDisabled() +#endif + +#if !defined(__FPU__) && defined(__RTMIDI__) +MonoMixer::MonoMixer(): PD(), PS(), OPLM(), PBS(), MIDIOUTM(), FXDelay(), FXDisabled() #endif #if !defined(__FPU__) && !defined(__RTMIDI__) MonoMixer::MonoMixer(): PD(), PS(), OPLM(), PBS(), FXDelay(), FXDisabled() #endif + +#define SAMMONOMIXER 32 + { DPRINTF("MonoMixer::MonoMixer()"); amplitude=127; @@ -28,6 +35,10 @@ MonoMixer::MonoMixer(): PD(), PS(), OPLM(), PBS(), fx_depth=125; fx_speed=90; + + index=0; + buffer16=NULL; + buffer32=NULL; } MonoMixer::~MonoMixer() @@ -38,6 +49,8 @@ MonoMixer::~MonoMixer() void MonoMixer::init() { + int i=0; + PS.init(); PD.init(); OPLM.init(); @@ -87,6 +100,16 @@ void MonoMixer::init() if (machine_type==SYNTH_MIDIOUT) M=&MIDIOUTM; #endif + + if (buffer16==NULL) + buffer16=(Sint16*)malloc(sizeof(Sint16)*SAMMONOMIXER); + if (buffer32==NULL) + buffer32=(Sint32*)malloc(sizeof(Sint32)*SAMMONOMIXER); + for (i=0;itick(); //tick=FX.process(M->tick()); //tick=FXDelay.process(M->tick()); - tick=FX->process(M->tick()); - res32=tick*amplitude; + if (index+1tick(); + } + + for (i=0;iprocess(buffer32[i]); + + + for (i=0;i> 4; + if (buffer32[i]>32000) buffer32[i]=32000; + if (buffer32[i]<-32000) buffer32[i]=-32000; + } + for (i=0;iprocess(M->tick()); + //res32=tick*amplitude; // res32=tick*127; //res32=res32/127; - res32=res32>>4; + //res32=res32>>4; //if (res32>32000) res32=32000-(res32>>6); //if (res32<-32000) res32=-32000+(res32>>6); diff --git a/picoloop/MonoMixer.h b/picoloop/MonoMixer.h index 8d52c157..b0555b0f 100644 --- a/picoloop/MonoMixer.h +++ b/picoloop/MonoMixer.h @@ -64,6 +64,10 @@ class MonoMixer int fx_depth; int fx_speed; + + int index; + Sint16 * buffer16; + Sint32 * buffer32; };