@@ -34,51 +34,35 @@ static const int S2_INPUT = 19; | |||||
static const int S3_INPUT = 20; | static const int S3_INPUT = 20; | ||||
extern "C" { | extern "C" { | ||||
SpiralPlugin* SpiralPlugin_CreateInstance() | |||||
{ | |||||
return new PoshSamplerPlugin; | |||||
} | |||||
char** SpiralPlugin_GetIcon() | |||||
{ | |||||
return SpiralIcon_xpm; | |||||
} | |||||
int SpiralPlugin_GetID() | |||||
{ | |||||
return 32; | |||||
} | |||||
string SpiralPlugin_GetGroupName() | |||||
{ | |||||
return "Delay/Sampling"; | |||||
} | |||||
SpiralPlugin* SpiralPlugin_CreateInstance() { return new PoshSamplerPlugin; } | |||||
char** SpiralPlugin_GetIcon() { return SpiralIcon_xpm; } | |||||
int SpiralPlugin_GetID() { return 32; } | |||||
string SpiralPlugin_GetGroupName() { return "Delay/Sampling"; } | |||||
} | } | ||||
/////////////////////////////////////////////////////// | /////////////////////////////////////////////////////// | ||||
static void | |||||
InitializeSampleDescription(SampleDesc* NewDesc, const string &Pathname, int Note) | |||||
{ | |||||
if (NewDesc) { | |||||
NewDesc->Pathname = Pathname; | |||||
NewDesc->Volume = 1.0f; | |||||
NewDesc->Velocity = 1.0f; | |||||
NewDesc->Pitch = 1.0f; | |||||
NewDesc->PitchMod = 1.0f; | |||||
NewDesc->SamplePos = -1; | |||||
NewDesc->Loop = false; | |||||
NewDesc->PingPong = false; | |||||
NewDesc->Note = Note; | |||||
NewDesc->Octave = 0; | |||||
NewDesc->TriggerUp = true; | |||||
NewDesc->SamplePos = -1; | |||||
NewDesc->SampleRate = 44100; | |||||
NewDesc->Stereo = false; | |||||
NewDesc->PlayStart = 0; | |||||
NewDesc->LoopStart = 0; | |||||
NewDesc->LoopEnd = INT_MAX; | |||||
} | |||||
static void InitializeSampleDescription (SampleDesc* NewDesc, const string &Pathname, int Note) { | |||||
if (NewDesc) { | |||||
NewDesc->Pathname = Pathname; | |||||
NewDesc->Volume = 1.0f; | |||||
NewDesc->Velocity = 1.0f; | |||||
NewDesc->Pitch = 1.0f; | |||||
NewDesc->PitchMod = 1.0f; | |||||
NewDesc->SamplePos = -1; | |||||
NewDesc->Loop = false; | |||||
NewDesc->PingPong = false; | |||||
NewDesc->Note = Note; | |||||
NewDesc->Octave = 0; | |||||
NewDesc->TriggerUp = true; | |||||
NewDesc->SamplePos = -1; | |||||
NewDesc->SampleRate = 44100; | |||||
NewDesc->Stereo = false; | |||||
NewDesc->PlayStart = 0; | |||||
NewDesc->LoopStart = 0; | |||||
NewDesc->LoopEnd = INT_MAX; | |||||
NewDesc->ReTrig = true; | |||||
} | |||||
} | } | ||||
PoshSamplerPlugin::PoshSamplerPlugin() : | PoshSamplerPlugin::PoshSamplerPlugin() : | ||||
@@ -119,22 +103,17 @@ m_Recording(false) | |||||
m_PluginInfo.PortTips.push_back("Sample 6 Output"); | m_PluginInfo.PortTips.push_back("Sample 6 Output"); | ||||
m_PluginInfo.PortTips.push_back("Sample 7 Output"); | m_PluginInfo.PortTips.push_back("Sample 7 Output"); | ||||
m_PluginInfo.PortTips.push_back("Sample 8 Output"); | m_PluginInfo.PortTips.push_back("Sample 8 Output"); | ||||
for (int n=0; n<NUM_SAMPLES; n++) | |||||
{ | |||||
for (int n=0; n<NUM_SAMPLES; n++) { | |||||
Sample* NewSample = new Sample; | Sample* NewSample = new Sample; | ||||
m_SampleVec.push_back(NewSample); | m_SampleVec.push_back(NewSample); | ||||
SampleDesc* NewDesc = new SampleDesc; | SampleDesc* NewDesc = new SampleDesc; | ||||
char temp[256]; | char temp[256]; | ||||
sprintf (temp, "PoshSampler%d_%d", GetID(), n); | sprintf (temp, "PoshSampler%d_%d", GetID(), n); | ||||
InitializeSampleDescription(NewDesc, temp, n); | InitializeSampleDescription(NewDesc, temp, n); | ||||
m_SampleDescVec.push_back(NewDesc); | m_SampleDescVec.push_back(NewDesc); | ||||
} | } | ||||
m_Version=3; | |||||
m_Version = 4; | |||||
m_Current = 0; | m_Current = 0; | ||||
m_AudioCH->Register("Num",&m_GUIArgs.Num); | m_AudioCH->Register("Num",&m_GUIArgs.Num); | ||||
m_AudioCH->Register("Value",&m_GUIArgs.Value); | m_AudioCH->Register("Value",&m_GUIArgs.Value); | ||||
m_AudioCH->Register("Bool",&m_GUIArgs.Boole); | m_AudioCH->Register("Bool",&m_GUIArgs.Boole); | ||||
@@ -146,268 +125,236 @@ m_Recording(false) | |||||
m_AudioCH->Register("PlayPos",&m_CurrentPlayPos,ChannelHandler::OUTPUT); | m_AudioCH->Register("PlayPos",&m_CurrentPlayPos,ChannelHandler::OUTPUT); | ||||
m_AudioCH->RegisterData("SampleBuffer",ChannelHandler::OUTPUT_REQUEST,&m_SampleBuffer,TRANSBUF_SIZE); | m_AudioCH->RegisterData("SampleBuffer",ChannelHandler::OUTPUT_REQUEST,&m_SampleBuffer,TRANSBUF_SIZE); | ||||
m_AudioCH->Register("SampleSize",&m_SampleSize,ChannelHandler::OUTPUT_REQUEST); | m_AudioCH->Register("SampleSize",&m_SampleSize,ChannelHandler::OUTPUT_REQUEST); | ||||
} | } | ||||
PoshSamplerPlugin::~PoshSamplerPlugin() | |||||
{ | |||||
for (vector<Sample*>::iterator i=m_SampleVec.begin(); | |||||
i!=m_SampleVec.end(); i++) | |||||
{ | |||||
delete(*i); | |||||
} | |||||
for (vector<SampleDesc*>::iterator i=m_SampleDescVec.begin(); | |||||
i!=m_SampleDescVec.end(); i++) | |||||
{ | |||||
delete(*i); | |||||
} | |||||
PoshSamplerPlugin::~PoshSamplerPlugin() { | |||||
for (vector<Sample*>::iterator i=m_SampleVec.begin(); i!=m_SampleVec.end(); i++) | |||||
delete(*i); | |||||
for (vector<SampleDesc*>::iterator i=m_SampleDescVec.begin(); i!=m_SampleDescVec.end(); i++) | |||||
delete(*i); | |||||
} | } | ||||
PluginInfo &PoshSamplerPlugin::Initialise(const HostInfo *Host) | |||||
{ | |||||
return SpiralPlugin::Initialise(Host);; | |||||
PluginInfo &PoshSamplerPlugin::Initialise (const HostInfo *Host) { | |||||
return SpiralPlugin::Initialise (Host); | |||||
} | } | ||||
SpiralGUIType *PoshSamplerPlugin::CreateGUI() | |||||
{ | |||||
return new PoshSamplerPluginGUI(m_PluginInfo.Width, | |||||
m_PluginInfo.Height, | |||||
this,m_AudioCH,m_HostInfo); | |||||
SpiralGUIType *PoshSamplerPlugin::CreateGUI() { | |||||
return new PoshSamplerPluginGUI (m_PluginInfo.Width, m_PluginInfo.Height, this, m_AudioCH, m_HostInfo); | |||||
} | } | ||||
void PoshSamplerPlugin::Reset() | |||||
{ | |||||
ResetPorts(); | |||||
m_Current = 0; | |||||
for (int s=0; s<NUM_SAMPLES; s++) | |||||
{ | |||||
m_SampleDescVec[s]->Pitch = m_InitialPitch[s] * m_SampleDescVec[s]->SampleRate/(float)m_HostInfo->SAMPLERATE; | |||||
m_SampleDescVec[s]->LoopEnd=m_SampleVec[s]->GetLength()-1; | |||||
} | |||||
void PoshSamplerPlugin::Reset() { | |||||
ResetPorts(); | |||||
m_Current = 0; | |||||
for (int s=0; s<NUM_SAMPLES; s++) { | |||||
m_SampleDescVec[s]->Pitch = m_InitialPitch[s] * m_SampleDescVec[s]->SampleRate / (float)m_HostInfo->SAMPLERATE; | |||||
m_SampleDescVec[s]->LoopEnd = m_SampleVec[s]->GetLength() - 1; | |||||
} | |||||
} | } | ||||
void PoshSamplerPlugin::Execute() | |||||
{ | |||||
static bool Pong=false; | |||||
for (int s=0; s<NUM_SAMPLES+1; s++) | |||||
{ | |||||
GetOutputBuf(s)->Zero(); | |||||
} | |||||
float Freq=0; | |||||
for (int n=0; n<m_HostInfo->BUFSIZE; n++) | |||||
{ | |||||
Freq=GetInputPitch(NOTETRIG,n); | |||||
for (int s=0; s<NUM_SAMPLES; s++) | |||||
{ | |||||
SampleDesc* S=m_SampleDescVec[s]; | |||||
// if we have a sample here | |||||
if (m_SampleVec[s]->GetLength()) | |||||
{ | |||||
// Convert the CV input into a useable trigger | |||||
if (GetInput(s*2+1,n)>0 || feq(Freq,NoteTable[S->Note],0.01f)) | |||||
{ | |||||
if (S->TriggerUp) | |||||
{ | |||||
if (s==0 && InputExists(S1_INPUT)) | |||||
S->PlayStart=(long int)((GetInput(S1_INPUT,n)*0.5+0.5f)*(S->LoopEnd-S->LoopStart))+S->LoopStart; | |||||
if (s==1 && InputExists(S2_INPUT)) | |||||
S->PlayStart=(long int)((GetInput(S2_INPUT,n)*0.5+0.5f)*(S->LoopEnd-S->LoopStart))+S->LoopStart; | |||||
if (s==2 && InputExists(S3_INPUT)) | |||||
S->PlayStart=(long int)((GetInput(S3_INPUT,n)*0.5+0.5f)*(S->LoopEnd-S->LoopStart))+S->LoopStart; | |||||
if (S->PlayStart<0) S->PlayStart=0; | |||||
S->SamplePos=S->PlayStart; | |||||
S->TriggerUp=false; | |||||
S->Velocity=GetInput(s*2+1,n); | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
S->TriggerUp=true; | |||||
// end it if it's looping | |||||
if (S->Loop) | |||||
{ | |||||
S->SamplePos=-1; | |||||
} | |||||
} | |||||
// if the sample has ended | |||||
if (S->SamplePos>=S->LoopEnd || S->SamplePos>=m_SampleVec[s]->GetLength()) | |||||
{ | |||||
if (S->Loop) | |||||
{ | |||||
if (S->PingPong) Pong=true; | |||||
else S->SamplePos=S->LoopStart; | |||||
} | |||||
else | |||||
{ | |||||
S->SamplePos=-1; | |||||
} | |||||
} | |||||
// if the sample has ended ponging | |||||
if (Pong && S->SamplePos<=S->LoopStart) | |||||
{ | |||||
Pong=false; | |||||
} | |||||
if (S->SamplePos!=-1) | |||||
{ | |||||
if (InputExists(s*2)) | |||||
{ | |||||
// Get the pitch from the CV | |||||
float PlayFreq=GetInputPitch(s*2,n); | |||||
// assumtion: base frequency = 440 (middle A) | |||||
S->Pitch = PlayFreq/440; | |||||
S->Pitch *= S->SampleRate/(float)m_HostInfo->SAMPLERATE; | |||||
} | |||||
// mix the sample to the output. | |||||
MixOutput(0,n,(*m_SampleVec[s])[S->SamplePos]*S->Volume*S->Velocity); | |||||
// copy the sample to it's individual output. | |||||
SetOutput(s+1,n,((*m_SampleVec[s])[S->SamplePos]*S->Volume)); | |||||
float Freq=S->Pitch; | |||||
if (S->Octave>0) Freq*=1<<(S->Octave); | |||||
if (S->Octave<0) Freq/=1<<(-S->Octave); | |||||
if (Pong) S->SamplePos-=Freq*S->PitchMod; | |||||
else S->SamplePos+=Freq*S->PitchMod; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
// record | |||||
static int LastRecording=false; | |||||
if(m_Recording && InputExists(REC_INPUT)) | |||||
{ | |||||
int s=0;//GUI->GetCurrentSample(); | |||||
if (!LastRecording) m_SampleVec[s]->Clear(); | |||||
// new sample | |||||
if (m_SampleVec[s]->GetLength()==0) | |||||
{ | |||||
*m_SampleVec[s]=*GetInput(REC_INPUT); | |||||
m_SampleDescVec[s]->SampleRate=m_HostInfo->SAMPLERATE; | |||||
m_SampleDescVec[s]->Stereo=false; | |||||
m_SampleDescVec[s]->Pitch *= 1.0f; | |||||
m_InitialPitch[s] = m_SampleDescVec[s]->Pitch; | |||||
m_SampleDescVec[s]->LoopEnd=m_SampleVec[s]->GetLength(); | |||||
} | |||||
else | |||||
{ | |||||
m_SampleVec[s]->Add(*GetInput(REC_INPUT)); | |||||
m_SampleDescVec[s]->LoopEnd=m_SampleVec[s]->GetLength(); | |||||
} | |||||
} | |||||
LastRecording=m_Recording; | |||||
if (m_SampleDescVec[m_Current]->SamplePos>0) | |||||
{ | |||||
m_CurrentPlayPos=(long)m_SampleDescVec[m_Current]->SamplePos; | |||||
} | |||||
void PoshSamplerPlugin::Execute() { | |||||
static bool Pong = false; | |||||
for (int s=0; s<NUM_SAMPLES+1; s++) GetOutputBuf (s)->Zero(); | |||||
float Freq = 0; | |||||
for (int n=0; n<m_HostInfo->BUFSIZE; n++) { | |||||
Freq = GetInputPitch (NOTETRIG, n); | |||||
for (int s=0; s<NUM_SAMPLES; s++) { | |||||
SampleDesc *S = m_SampleDescVec[s]; | |||||
// if we have a sample here | |||||
if (m_SampleVec[s]->GetLength()) { | |||||
// Convert the CV input into a useable trigger | |||||
if (S->ReTrig || (S->SamplePos == -1)) { | |||||
if (GetInput (s*2 + 1, n) > 0 || feq (Freq, NoteTable[S->Note], 0.01f)) { | |||||
if (S->TriggerUp) { | |||||
if (s==0 && InputExists (S1_INPUT)) | |||||
S->PlayStart = (long int)((GetInput (S1_INPUT, n) * 0.5 + 0.5f) * (S->LoopEnd-S->LoopStart)) + S->LoopStart; | |||||
if (s==1 && InputExists (S2_INPUT)) | |||||
S->PlayStart = (long int)((GetInput (S2_INPUT, n) * 0.5 + 0.5f) * (S->LoopEnd-S->LoopStart)) + S->LoopStart; | |||||
if (s==2 && InputExists (S3_INPUT)) | |||||
S->PlayStart = (long int)((GetInput (S3_INPUT, n) * 0.5 + 0.5f) * (S->LoopEnd-S->LoopStart)) + S->LoopStart; | |||||
if (S->PlayStart < 0) S->PlayStart = 0; | |||||
S->SamplePos = S->PlayStart; | |||||
S->TriggerUp = false; | |||||
S->Velocity = GetInput (s * 2 + 1, n); | |||||
} | |||||
} | |||||
else { | |||||
S->TriggerUp = true; | |||||
// end it if it's looping | |||||
if (S->Loop) S->SamplePos = -1; | |||||
} | |||||
} | |||||
// if the sample has ended | |||||
if (S->SamplePos >= S->LoopEnd || S->SamplePos >= m_SampleVec[s]->GetLength()) { | |||||
if (S->Loop) { | |||||
if (S->PingPong) Pong = true; | |||||
else S->SamplePos = S->LoopStart; | |||||
} | |||||
else { | |||||
S->SamplePos = -1; | |||||
} | |||||
} | |||||
// if the sample has ended ponging | |||||
if (Pong && S->SamplePos <= S->LoopStart) | |||||
Pong = false; | |||||
if (S->SamplePos != -1) { | |||||
if (InputExists (s * 2)) { | |||||
// Get the pitch from the CV | |||||
float PlayFreq = GetInputPitch (s * 2, n); | |||||
// assumtion: base frequency = 440 (middle A) | |||||
S->Pitch = PlayFreq / 440; | |||||
S->Pitch *= S->SampleRate / (float)m_HostInfo->SAMPLERATE; | |||||
} | |||||
// mix the sample to the output. | |||||
MixOutput (0, n, (*m_SampleVec[s])[S->SamplePos] * S->Volume * S->Velocity); | |||||
// copy the sample to it's individual output. | |||||
SetOutput (s + 1, n, ((*m_SampleVec[s])[S->SamplePos] * S->Volume)); | |||||
float Freq = S->Pitch; | |||||
if (S->Octave > 0) Freq *= 1 << (S->Octave); | |||||
if (S->Octave < 0) Freq /= 1 << (-S->Octave); | |||||
if (Pong) S->SamplePos -= Freq * S->PitchMod; | |||||
else S->SamplePos += Freq * S->PitchMod; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
// record | |||||
static int LastRecording = false; | |||||
if (m_Recording && InputExists (REC_INPUT)) { | |||||
int s = 0; //GUI->GetCurrentSample(); | |||||
if (!LastRecording) m_SampleVec[s]->Clear(); | |||||
// new sample | |||||
if (m_SampleVec[s]->GetLength() == 0) { | |||||
*m_SampleVec[s] =* GetInput (REC_INPUT); | |||||
m_SampleDescVec[s]->SampleRate = m_HostInfo->SAMPLERATE; | |||||
m_SampleDescVec[s]->Stereo = false; | |||||
m_SampleDescVec[s]->Pitch *= 1.0f; | |||||
m_InitialPitch[s] = m_SampleDescVec[s]->Pitch; | |||||
m_SampleDescVec[s]->LoopEnd = m_SampleVec[s]->GetLength(); | |||||
} | |||||
else { | |||||
m_SampleVec[s]->Add (*GetInput (REC_INPUT)); | |||||
m_SampleDescVec[s]->LoopEnd = m_SampleVec[s]->GetLength(); | |||||
} | |||||
} | |||||
LastRecording = m_Recording; | |||||
if (m_SampleDescVec[m_Current]->SamplePos > 0) { | |||||
m_CurrentPlayPos = (long)m_SampleDescVec[m_Current]->SamplePos; | |||||
} | |||||
} | } | ||||
void PoshSamplerPlugin::ExecuteCommands() | |||||
{ | |||||
if (m_AudioCH->IsCommandWaiting()) | |||||
{ | |||||
switch(m_AudioCH->GetCommand()) | |||||
{ | |||||
case (LOAD) : LoadSample(m_GUIArgs.Num,m_GUIArgs.Name); break; | |||||
case (SAVE) : SaveSample(m_GUIArgs.Num,m_GUIArgs.Name); break; | |||||
case (SETVOL) : SetVolume(m_GUIArgs.Num,m_GUIArgs.Value); break; | |||||
case (SETPITCH) : SetPitch(m_GUIArgs.Num,m_GUIArgs.Value); break; | |||||
case (SETLOOP) : SetLoop(m_GUIArgs.Num,m_GUIArgs.Boole); break; | |||||
case (SETPING) : SetPingPong(m_GUIArgs.Num,m_GUIArgs.Boole); break; | |||||
case (SETNOTE) : SetNote(m_GUIArgs.Num,m_GUIArgs.Int); break; | |||||
case (SETOCT) : SetOctave(m_GUIArgs.Num,m_GUIArgs.Int); break; | |||||
case (SETPLAYPOINTS): | |||||
{ | |||||
SetPlayStart(m_GUIArgs.Num,m_GUIArgs.Start); | |||||
SetLoopStart(m_GUIArgs.Num,m_GUIArgs.LoopStart); | |||||
SetLoopEnd(m_GUIArgs.Num,m_GUIArgs.End); | |||||
} break; | |||||
case (SETREC) : SetRecord(m_GUIArgs.Boole); break; | |||||
case (CUT) : Cut(m_GUIArgs.Num,m_GUIArgs.Start,m_GUIArgs.End); break; | |||||
case (COPY) : Copy(m_GUIArgs.Num,m_GUIArgs.Start,m_GUIArgs.End); break; | |||||
case (PASTE) : Paste(m_GUIArgs.Num,m_GUIArgs.Start,m_GUIArgs.End); break; | |||||
case (MIX) : Mix(m_GUIArgs.Num,m_GUIArgs.Start,m_GUIArgs.End); break; | |||||
case (CROP) : Crop(m_GUIArgs.Num,m_GUIArgs.Start,m_GUIArgs.End); break; | |||||
case (REV) : Reverse(m_GUIArgs.Num,m_GUIArgs.Start,m_GUIArgs.End); break; | |||||
case (AMP) : Amp(m_GUIArgs.Num,m_GUIArgs.Start,m_GUIArgs.End); break; | |||||
case (SETCURRENT) : m_Current = m_GUIArgs.Num; break; | |||||
case (GETSAMPLE) : | |||||
{ | |||||
m_AudioCH->SetupBulkTransfer((void*)m_SampleVec[m_Current]->GetBuffer()); | |||||
m_SampleSize=m_SampleVec[m_Current]->GetLengthInBytes(); | |||||
} break; | |||||
}; | |||||
} | |||||
void PoshSamplerPlugin::ExecuteCommands() { | |||||
if (m_AudioCH->IsCommandWaiting()) { | |||||
switch (m_AudioCH->GetCommand()) { | |||||
case LOAD: | |||||
LoadSample(m_GUIArgs.Num,m_GUIArgs.Name); | |||||
break; | |||||
case SAVE: | |||||
SaveSample(m_GUIArgs.Num,m_GUIArgs.Name); | |||||
break; | |||||
case SETVOL: | |||||
m_SampleDescVec[m_GUIArgs.Num]->Volume=m_GUIArgs.Value; | |||||
break; | |||||
case SETPITCH: | |||||
m_SampleDescVec[m_GUIArgs.Num]->PitchMod=m_GUIArgs.Value; | |||||
break; | |||||
case SETLOOP: | |||||
m_SampleDescVec[m_GUIArgs.Num]->Loop=m_GUIArgs.Boole; | |||||
break; | |||||
case SETPING: | |||||
m_SampleDescVec[m_GUIArgs.Num]->PingPong=m_GUIArgs.Boole; | |||||
break; | |||||
case SETNOTE: | |||||
m_SampleDescVec[m_GUIArgs.Num]->Note=m_GUIArgs.Int; | |||||
break; | |||||
case SETOCT: | |||||
m_SampleDescVec[m_GUIArgs.Num]->Octave=m_GUIArgs.Int-6; | |||||
break; | |||||
case SETPLAYPOINTS: | |||||
m_SampleDescVec[m_GUIArgs.Num]->PlayStart=m_GUIArgs.Start; | |||||
m_SampleDescVec[m_GUIArgs.Num]->LoopStart=m_GUIArgs.LoopStart; | |||||
m_SampleDescVec[m_GUIArgs.Num]->LoopEnd=m_GUIArgs.End; | |||||
break; | |||||
case SETREC: | |||||
m_Recording=m_GUIArgs.Boole; | |||||
break; | |||||
case CUT: | |||||
Cut (m_GUIArgs.Num, m_GUIArgs.Start, m_GUIArgs.End); | |||||
break; | |||||
case COPY: | |||||
Copy (m_GUIArgs.Num, m_GUIArgs.Start, m_GUIArgs.End); | |||||
break; | |||||
case PASTE: | |||||
Paste (m_GUIArgs.Num, m_GUIArgs.Start, m_GUIArgs.End); | |||||
break; | |||||
case MIX: | |||||
Mix (m_GUIArgs.Num, m_GUIArgs.Start, m_GUIArgs.End); | |||||
break; | |||||
case CROP: | |||||
Crop (m_GUIArgs.Num, m_GUIArgs.Start, m_GUIArgs.End); | |||||
break; | |||||
case REV: | |||||
Reverse (m_GUIArgs.Num, m_GUIArgs.Start, m_GUIArgs.End); | |||||
break; | |||||
case AMP: | |||||
Amp (m_GUIArgs.Num, m_GUIArgs.Start, m_GUIArgs.End); | |||||
break; | |||||
case SETCURRENT: | |||||
m_Current = m_GUIArgs.Num; | |||||
break; | |||||
case GETSAMPLE: | |||||
m_AudioCH->SetupBulkTransfer ((void*)m_SampleVec[m_Current]->GetBuffer()); | |||||
m_SampleSize = m_SampleVec[m_Current]->GetLengthInBytes(); | |||||
break; | |||||
case SETRETRIG: | |||||
m_SampleDescVec[m_GUIArgs.Num]->ReTrig=m_GUIArgs.Boole; | |||||
break; | |||||
}; | |||||
} | |||||
} | } | ||||
void PoshSamplerPlugin::StreamOut(ostream &s) | |||||
{ | |||||
s<<m_Version<<" "; | |||||
for (int n=0; n<NUM_SAMPLES; n++) | |||||
{ | |||||
s<<m_SampleDescVec[n]->Volume<<" "<< | |||||
m_SampleDescVec[n]->PitchMod<<" "<< | |||||
m_SampleDescVec[n]->Loop<<" "<< | |||||
m_SampleDescVec[n]->PingPong<<" "<< | |||||
m_SampleDescVec[n]->Note<<" "<< | |||||
m_SampleDescVec[n]->Octave<<" "<< | |||||
m_SampleDescVec[n]->SamplePos<<" "<< | |||||
m_SampleDescVec[n]->PlayStart<<" "<< | |||||
m_SampleDescVec[n]->LoopStart<<" "<< | |||||
m_SampleDescVec[n]->LoopEnd<<" "<< | |||||
m_SampleDescVec[n]->Note<<" "; | |||||
} | |||||
void PoshSamplerPlugin::StreamOut (ostream &s) { | |||||
s << m_Version << " "; | |||||
for (int n=0; n<NUM_SAMPLES; n++) { | |||||
s << m_SampleDescVec[n]->Volume << " " << | |||||
m_SampleDescVec[n]->PitchMod << " " << | |||||
m_SampleDescVec[n]->Loop << " " << | |||||
m_SampleDescVec[n]->PingPong << " " << | |||||
m_SampleDescVec[n]->Note << " " << | |||||
m_SampleDescVec[n]->Octave << " " << | |||||
m_SampleDescVec[n]->SamplePos << " " << | |||||
m_SampleDescVec[n]->PlayStart << " " << | |||||
m_SampleDescVec[n]->LoopStart << " " << | |||||
m_SampleDescVec[n]->LoopEnd << " " << | |||||
m_SampleDescVec[n]->Note << " " << | |||||
m_SampleDescVec[n]->ReTrig << " "; | |||||
} | |||||
} | } | ||||
void PoshSamplerPlugin::StreamIn(istream &s) | |||||
{ | |||||
int version; | |||||
s>>version; | |||||
for (int n=0; n<NUM_SAMPLES; n++) | |||||
{ | |||||
s>>m_SampleDescVec[n]->Volume>> | |||||
m_SampleDescVec[n]->PitchMod>> | |||||
m_SampleDescVec[n]->Loop>> | |||||
m_SampleDescVec[n]->PingPong>> | |||||
m_SampleDescVec[n]->Note>> | |||||
m_SampleDescVec[n]->Octave>> | |||||
m_SampleDescVec[n]->SamplePos>> | |||||
m_SampleDescVec[n]->PlayStart>> | |||||
m_SampleDescVec[n]->LoopStart>> | |||||
m_SampleDescVec[n]->LoopEnd>> | |||||
m_SampleDescVec[n]->Note; | |||||
if (version<3) | |||||
{ | |||||
int size; | |||||
s>>size; | |||||
s.ignore(1); | |||||
char Buf[4096]; | |||||
s.get(Buf,size+1); | |||||
} | |||||
} | |||||
void PoshSamplerPlugin::StreamIn (istream &s) { | |||||
int version; | |||||
s >> version; | |||||
for (int n=0; n<NUM_SAMPLES; n++) { | |||||
s >> m_SampleDescVec[n]->Volume >> | |||||
m_SampleDescVec[n]->PitchMod >> | |||||
m_SampleDescVec[n]->Loop >> | |||||
m_SampleDescVec[n]->PingPong >> | |||||
m_SampleDescVec[n]->Note >> | |||||
m_SampleDescVec[n]->Octave >> | |||||
m_SampleDescVec[n]->SamplePos >> | |||||
m_SampleDescVec[n]->PlayStart >> | |||||
m_SampleDescVec[n]->LoopStart >> | |||||
m_SampleDescVec[n]->LoopEnd >> | |||||
m_SampleDescVec[n]->Note; | |||||
if (version < 3) { | |||||
int size; | |||||
s >> size; | |||||
s.ignore (1); | |||||
char Buf[4096]; | |||||
s.get (Buf, size+1); | |||||
} | |||||
if (version > 3) s >> m_SampleDescVec[n]->ReTrig; | |||||
else m_SampleDescVec[n]->ReTrig = true; | |||||
} | |||||
} | } | ||||
void PoshSamplerPlugin::LoadSample(int n, const string &Name) | void PoshSamplerPlugin::LoadSample(int n, const string &Name) | ||||
@@ -14,123 +14,84 @@ | |||||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
* along with this program; if not, write to the Free Software | * along with this program; if not, write to the Free Software | ||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | |||||
#include "../SpiralPlugin.h" | |||||
#include <FL/Fl_Pixmap.H> | |||||
*/ | |||||
#ifndef PoshSamplerPLUGIN | #ifndef PoshSamplerPLUGIN | ||||
#define PoshSamplerPLUGIN | #define PoshSamplerPLUGIN | ||||
#include "../SpiralPlugin.h" | |||||
#include <FL/Fl_Pixmap.H> | |||||
static const int NUM_SAMPLES = 8; | static const int NUM_SAMPLES = 8; | ||||
static const int TRANSBUF_SIZE = 0x10000; | static const int TRANSBUF_SIZE = 0x10000; | ||||
struct SampleDesc | |||||
{ | |||||
std::string Pathname; | |||||
float Volume; | |||||
float Velocity; | |||||
float Pitch; | |||||
float PitchMod; | |||||
bool Loop; | |||||
bool PingPong; | |||||
int Note; | |||||
int Octave; | |||||
bool TriggerUp; | |||||
float SamplePos; | |||||
int SampleRate; | |||||
bool Stereo; | |||||
long PlayStart; | |||||
long LoopStart; | |||||
long LoopEnd; | |||||
struct SampleDesc { | |||||
std::string Pathname; | |||||
float Volume, Velocity, Pitch, PitchMod; | |||||
bool Loop, PingPong; | |||||
int Note, Octave; | |||||
bool TriggerUp; | |||||
float SamplePos; | |||||
int SampleRate; | |||||
bool Stereo; | |||||
long PlayStart, LoopStart, LoopEnd; | |||||
bool ReTrig; | |||||
}; | }; | ||||
class PoshSamplerPlugin : public SpiralPlugin | |||||
{ | |||||
public: | |||||
PoshSamplerPlugin(); | |||||
virtual ~PoshSamplerPlugin(); | |||||
virtual PluginInfo &Initialise(const HostInfo *Host); | |||||
virtual SpiralGUIType *CreateGUI(); | |||||
virtual void Execute(); | |||||
virtual void Reset(); | |||||
virtual void ExecuteCommands(); | |||||
virtual void StreamOut(std::ostream &s); | |||||
virtual void StreamIn(std::istream &s); | |||||
virtual bool SaveExternalFiles(const std::string &Dir); | |||||
virtual void LoadExternalFiles(const std::string &Dir, int withID=-1); | |||||
enum GUICommands{NONE,LOAD,SAVE,SETVOL,SETPITCH,SETLOOP,SETPING,SETNOTE,SETOCT, | |||||
SETPLAYPOINTS,SETREC,CUT,COPY,PASTE,CROP,MIX,REV,AMP,SETCURRENT, | |||||
GETSAMPLE}; | |||||
struct GUIArgs | |||||
{ | |||||
int Num; | |||||
float Value; | |||||
bool Boole; | |||||
int Int; | |||||
long Start; | |||||
long End; | |||||
long LoopStart; | |||||
char Name[256]; | |||||
}; | |||||
void LoadSample(int n, const std::string &Name); | |||||
void SaveSample(int n, const std::string &Name); | |||||
Sample* GetSample(int n) { return m_SampleVec[n]; } | |||||
float GetVolume(int n) { return m_SampleDescVec[n]->Volume; } | |||||
float GetPitch(int n) { return m_SampleDescVec[n]->PitchMod; } | |||||
bool GetLoop(int n) { return m_SampleDescVec[n]->Loop; } | |||||
bool GetPingPong(int n) { return m_SampleDescVec[n]->PingPong; } | |||||
int GetNote(int n) { return m_SampleDescVec[n]->Note; } | |||||
int GetOctave(int n) { return m_SampleDescVec[n]->Octave+6; } | |||||
long GetPlayStart(int n) { return m_SampleDescVec[n]->PlayStart; } | |||||
long GetLoopStart(int n) { return m_SampleDescVec[n]->LoopStart; } | |||||
long GetLoopEnd(int n) { return m_SampleDescVec[n]->LoopEnd; } | |||||
std::vector<Sample*> m_SampleVec; | |||||
std::vector<SampleDesc*> m_SampleDescVec; | |||||
private: | |||||
void SetVolume(int n, float s) { m_SampleDescVec[n]->Volume=s; } | |||||
void SetPitch(int n, float s) { m_SampleDescVec[n]->PitchMod=s; } | |||||
void SetLoop(int n, bool s) { m_SampleDescVec[n]->Loop=s; } | |||||
void SetPingPong(int n, bool s){ m_SampleDescVec[n]->PingPong=s; } | |||||
void SetNote(int n, int s) { m_SampleDescVec[n]->Note=s; } | |||||
void SetOctave(int n, int s) { m_SampleDescVec[n]->Octave=s-6; } | |||||
void SetPlayStart(int n, long s) { m_SampleDescVec[n]->PlayStart=s; } | |||||
void SetLoopStart(int n, long s) { m_SampleDescVec[n]->LoopStart=s; } | |||||
void SetLoopEnd(int n, long s) { m_SampleDescVec[n]->LoopEnd=s; } | |||||
void SetRecord(bool s) { m_Recording=s; } | |||||
void Cut(int n, long s, long e); | |||||
void Copy(int n, long s, long e); | |||||
void Paste(int n, long s, long e); | |||||
void Mix(int n, long s, long e); | |||||
void Crop(int n, long s, long e); | |||||
void Reverse(int n, long s, long e); | |||||
void Amp(int n, long s, long e); | |||||
int m_Current; | |||||
GUIArgs m_GUIArgs; | |||||
Sample m_CopyBuffer; | |||||
bool m_Recording; | |||||
char m_SampleBuffer[TRANSBUF_SIZE]; | |||||
long m_SampleSize; | |||||
long m_CurrentPlayPos; | |||||
float m_InitialPitch[NUM_SAMPLES]; | |||||
class PoshSamplerPlugin : public SpiralPlugin { | |||||
public: | |||||
PoshSamplerPlugin(); | |||||
virtual ~PoshSamplerPlugin(); | |||||
virtual PluginInfo &Initialise (const HostInfo *Host); | |||||
virtual SpiralGUIType *CreateGUI(); | |||||
virtual void Execute(); | |||||
virtual void Reset(); | |||||
virtual void ExecuteCommands(); | |||||
virtual void StreamOut (std::ostream &s); | |||||
virtual void StreamIn (std::istream &s); | |||||
virtual bool SaveExternalFiles (const std::string &Dir); | |||||
virtual void LoadExternalFiles (const std::string &Dir, int withID=-1); | |||||
enum GUICommands {NONE, LOAD, SAVE, SETVOL, SETPITCH, SETLOOP, SETPING, SETNOTE, SETOCT, | |||||
SETPLAYPOINTS, SETREC, CUT, COPY, PASTE, CROP, MIX, REV, AMP, SETCURRENT, | |||||
GETSAMPLE, SETRETRIG}; | |||||
struct GUIArgs { | |||||
int Num; | |||||
float Value; | |||||
bool Boole; | |||||
int Int; | |||||
long Start, End, LoopStart; | |||||
char Name[256]; | |||||
}; | |||||
void LoadSample (int n, const std::string &Name); | |||||
void SaveSample (int n, const std::string &Name); | |||||
Sample* GetSample (int n) { return m_SampleVec[n]; } | |||||
float GetVolume (int n) { return m_SampleDescVec[n]->Volume; } | |||||
float GetPitch (int n) { return m_SampleDescVec[n]->PitchMod; } | |||||
bool GetReTrig (int n) { return m_SampleDescVec[n]->ReTrig; } | |||||
bool GetLoop (int n) { return m_SampleDescVec[n]->Loop; } | |||||
bool GetPingPong (int n) { return m_SampleDescVec[n]->PingPong; } | |||||
int GetNote (int n) { return m_SampleDescVec[n]->Note; } | |||||
int GetOctave (int n) { return m_SampleDescVec[n]->Octave+6; } | |||||
long GetPlayStart (int n) { return m_SampleDescVec[n]->PlayStart; } | |||||
long GetLoopStart (int n) { return m_SampleDescVec[n]->LoopStart; } | |||||
long GetLoopEnd (int n) { return m_SampleDescVec[n]->LoopEnd; } | |||||
std::vector<Sample*> m_SampleVec; | |||||
std::vector<SampleDesc*> m_SampleDescVec; | |||||
private: | |||||
void Cut (int n, long s, long e); | |||||
void Copy (int n, long s, long e); | |||||
void Paste (int n, long s, long e); | |||||
void Mix (int n, long s, long e); | |||||
void Crop (int n, long s, long e); | |||||
void Reverse (int n, long s, long e); | |||||
void Amp (int n, long s, long e); | |||||
int m_Current; | |||||
GUIArgs m_GUIArgs; | |||||
Sample m_CopyBuffer; | |||||
bool m_Recording; | |||||
char m_SampleBuffer[TRANSBUF_SIZE]; | |||||
long m_SampleSize, m_CurrentPlayPos; | |||||
float m_InitialPitch[NUM_SAMPLES]; | |||||
}; | }; | ||||
#endif | #endif |
@@ -255,7 +255,7 @@ void Fl_WaveDisplay::ZoomIn() | |||||
void Fl_WaveDisplay::ZoomOut() | void Fl_WaveDisplay::ZoomOut() | ||||
{ | { | ||||
int Zoom=(int)((m_ViewEnd-m_ViewStart)*0.03f); | int Zoom=(int)((m_ViewEnd-m_ViewStart)*0.03f); | ||||
m_ViewStart-=Zoom; | |||||
m_ViewStart-=Zoom; | |||||
m_ViewEnd+=Zoom; | m_ViewEnd+=Zoom; | ||||
redraw(); | redraw(); | ||||
} | } | ||||
@@ -265,10 +265,10 @@ void Fl_WaveDisplay::ZoomOut() | |||||
PoshSamplerPluginGUI::PoshSamplerPluginGUI(int w, int h,PoshSamplerPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | PoshSamplerPluginGUI::PoshSamplerPluginGUI(int w, int h,PoshSamplerPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | ||||
SpiralPluginGUI(w,h,o,ch), | SpiralPluginGUI(w,h,o,ch), | ||||
m_UpdateMe(false) | m_UpdateMe(false) | ||||
{ | |||||
int n=0; | |||||
{ | |||||
int n=0; | |||||
m_Load = new Fl_Button(5, 20, 70, 20, "Load"); | |||||
m_Load = new Fl_Button(5, 20, 50, 20, "Load"); | |||||
m_Load->labelsize(10); | m_Load->labelsize(10); | ||||
m_Load->box (FL_PLASTIC_UP_BOX); | m_Load->box (FL_PLASTIC_UP_BOX); | ||||
m_Load->color (Info->GUI_COLOUR); | m_Load->color (Info->GUI_COLOUR); | ||||
@@ -276,7 +276,7 @@ m_UpdateMe(false) | |||||
m_Load->callback((Fl_Callback*)cb_Load); | m_Load->callback((Fl_Callback*)cb_Load); | ||||
add(m_Load); | add(m_Load); | ||||
m_Save = new Fl_Button(5, 40, 70, 20, "Save"); | |||||
m_Save = new Fl_Button(55, 20, 50, 20, "Save"); | |||||
m_Save->labelsize(10); | m_Save->labelsize(10); | ||||
m_Save->box (FL_PLASTIC_UP_BOX); | m_Save->box (FL_PLASTIC_UP_BOX); | ||||
m_Save->color (Info->GUI_COLOUR); | m_Save->color (Info->GUI_COLOUR); | ||||
@@ -284,7 +284,7 @@ m_UpdateMe(false) | |||||
m_Save->callback((Fl_Callback*)cb_Save); | m_Save->callback((Fl_Callback*)cb_Save); | ||||
add(m_Save); | add(m_Save); | ||||
m_Record = new Fl_Button(5, 60, 70, 20, "Record"); | |||||
m_Record = new Fl_Button(105, 20, 50, 20, "Record"); | |||||
m_Record->type (FL_TOGGLE_BUTTON); | m_Record->type (FL_TOGGLE_BUTTON); | ||||
m_Record->box (FL_PLASTIC_UP_BOX); | m_Record->box (FL_PLASTIC_UP_BOX); | ||||
m_Record->color (FL_RED); | m_Record->color (FL_RED); | ||||
@@ -294,7 +294,7 @@ m_UpdateMe(false) | |||||
m_Record->callback((Fl_Callback*)cb_Record); | m_Record->callback((Fl_Callback*)cb_Record); | ||||
add(m_Record); | add(m_Record); | ||||
m_Loop = new Fl_Button(80, 20, 70, 20, "Loop"); | |||||
m_Loop = new Fl_Button(5, 40, 75, 20, "Loop"); | |||||
m_Loop->type (FL_TOGGLE_BUTTON); | m_Loop->type (FL_TOGGLE_BUTTON); | ||||
m_Loop->labelsize(10); | m_Loop->labelsize(10); | ||||
m_Loop->box (FL_PLASTIC_UP_BOX); | m_Loop->box (FL_PLASTIC_UP_BOX); | ||||
@@ -303,8 +303,7 @@ m_UpdateMe(false) | |||||
m_Loop->callback((Fl_Callback*)cb_Loop); | m_Loop->callback((Fl_Callback*)cb_Loop); | ||||
add(m_Loop); | add(m_Loop); | ||||
m_PingPong = new Fl_Button(80, 40, 70, 20, "PingPong"); | |||||
m_PingPong->labelsize(10); | |||||
m_PingPong = new Fl_Button(80, 40, 75, 20, "PingPong"); | |||||
m_PingPong->type (FL_TOGGLE_BUTTON); | m_PingPong->type (FL_TOGGLE_BUTTON); | ||||
m_PingPong->labelsize(10); | m_PingPong->labelsize(10); | ||||
m_PingPong->box (FL_PLASTIC_UP_BOX); | m_PingPong->box (FL_PLASTIC_UP_BOX); | ||||
@@ -313,8 +312,7 @@ m_UpdateMe(false) | |||||
m_PingPong->callback((Fl_Callback*)cb_PingPong); | m_PingPong->callback((Fl_Callback*)cb_PingPong); | ||||
add(m_PingPong); | add(m_PingPong); | ||||
m_PosMarker = new Fl_Button(80, 60, 70, 20, "PosMarker"); | |||||
m_PosMarker->labelsize(10); | |||||
m_PosMarker = new Fl_Button(5, 60, 75, 20, "PosMarker"); | |||||
m_PosMarker->type (FL_TOGGLE_BUTTON); | m_PosMarker->type (FL_TOGGLE_BUTTON); | ||||
m_PosMarker->labelsize(10); | m_PosMarker->labelsize(10); | ||||
m_PosMarker->box (FL_PLASTIC_UP_BOX); | m_PosMarker->box (FL_PLASTIC_UP_BOX); | ||||
@@ -324,6 +322,16 @@ m_UpdateMe(false) | |||||
m_PosMarker->callback((Fl_Callback*)cb_PosMarker); | m_PosMarker->callback((Fl_Callback*)cb_PosMarker); | ||||
add(m_PosMarker); | add(m_PosMarker); | ||||
m_Retrig = new Fl_Button (80, 60, 75, 20, "Re-Trigger"); | |||||
m_Retrig->type (FL_TOGGLE_BUTTON); | |||||
m_Retrig->labelsize (10); | |||||
m_Retrig->box (FL_PLASTIC_UP_BOX); | |||||
m_Retrig->color (Info->GUI_COLOUR); | |||||
m_Retrig->selection_color (Info->GUI_COLOUR); | |||||
m_Retrig->value (1); | |||||
m_Retrig->callback ((Fl_Callback*)cb_Retrig); | |||||
add (m_Retrig); | |||||
m_Volume = new Fl_Knob(160, 20, 50, 50, "Volume"); | m_Volume = new Fl_Knob(160, 20, 50, 50, "Volume"); | ||||
m_Volume->color(Info->GUI_COLOUR); | m_Volume->color(Info->GUI_COLOUR); | ||||
m_Volume->type(Fl_Knob::LINELIN); | m_Volume->type(Fl_Knob::LINELIN); | ||||
@@ -487,11 +495,11 @@ void PoshSamplerPluginGUI::Update() | |||||
void PoshSamplerPluginGUI::UpdateValues(SpiralPlugin *o) | void PoshSamplerPluginGUI::UpdateValues(SpiralPlugin *o) | ||||
{ | { | ||||
PoshSamplerPlugin *Plugin = (PoshSamplerPlugin*)o; | PoshSamplerPlugin *Plugin = (PoshSamplerPlugin*)o; | ||||
m_Volume->value(Plugin->GetVolume((int)m_SampleNum->value())); | m_Volume->value(Plugin->GetVolume((int)m_SampleNum->value())); | ||||
m_Pitch->value(Plugin->GetPitch((int)m_SampleNum->value())); | m_Pitch->value(Plugin->GetPitch((int)m_SampleNum->value())); | ||||
m_Note->value(Plugin->GetNote((int)m_SampleNum->value())); | m_Note->value(Plugin->GetNote((int)m_SampleNum->value())); | ||||
m_Loop->value(Plugin->GetLoop((int)m_SampleNum->value())); | m_Loop->value(Plugin->GetLoop((int)m_SampleNum->value())); | ||||
m_Retrig->value(Plugin->GetReTrig((int)m_SampleNum->value())); | |||||
m_UpdateMe=true; | m_UpdateMe=true; | ||||
m_Display->SetPlayStart(Plugin->GetPlayStart((int)m_SampleNum->value())); | m_Display->SetPlayStart(Plugin->GetPlayStart((int)m_SampleNum->value())); | ||||
m_Display->SetLoopStart(Plugin->GetLoopStart((int)m_SampleNum->value())); | m_Display->SetLoopStart(Plugin->GetLoopStart((int)m_SampleNum->value())); | ||||
@@ -522,7 +530,7 @@ void PoshSamplerPluginGUI::cb_Load(Fl_Button* o, void* v) | |||||
inline void PoshSamplerPluginGUI::cb_Save_i(Fl_Button* o, void* v) | inline void PoshSamplerPluginGUI::cb_Save_i(Fl_Button* o, void* v) | ||||
{ | { | ||||
char *fn=fl_file_chooser("Save sample", "{*.wav,*.WAV}", NULL); | char *fn=fl_file_chooser("Save sample", "{*.wav,*.WAV}", NULL); | ||||
if (fn && fn!='\0') | if (fn && fn!='\0') | ||||
{ | { | ||||
strcpy(m_TextBuf,fn); | strcpy(m_TextBuf,fn); | ||||
@@ -535,7 +543,7 @@ void PoshSamplerPluginGUI::cb_Save(Fl_Button* o, void* v) | |||||
{ ((PoshSamplerPluginGUI*)(o->parent()))->cb_Save_i(o,v);} | { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Save_i(o,v);} | ||||
inline void PoshSamplerPluginGUI::cb_Volume_i(Fl_Knob* o, void* v) | inline void PoshSamplerPluginGUI::cb_Volume_i(Fl_Knob* o, void* v) | ||||
{ | |||||
{ | |||||
m_GUICH->Set("Value",(float)o->value()); | m_GUICH->Set("Value",(float)o->value()); | ||||
m_GUICH->Set("Num",(int)m_SampleNum->value()); | m_GUICH->Set("Num",(int)m_SampleNum->value()); | ||||
m_GUICH->SetCommand(PoshSamplerPlugin::SETVOL); | m_GUICH->SetCommand(PoshSamplerPlugin::SETVOL); | ||||
@@ -544,7 +552,7 @@ void PoshSamplerPluginGUI::cb_Volume(Fl_Knob* o, void* v) | |||||
{ ((PoshSamplerPluginGUI*)(o->parent()))->cb_Volume_i(o,v);} | { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Volume_i(o,v);} | ||||
inline void PoshSamplerPluginGUI::cb_Pitch_i(Fl_Knob* o, void* v) | inline void PoshSamplerPluginGUI::cb_Pitch_i(Fl_Knob* o, void* v) | ||||
{ | |||||
{ | |||||
m_GUICH->Set("Value",(float)o->value()); | m_GUICH->Set("Value",(float)o->value()); | ||||
m_GUICH->Set("Num",(int)m_SampleNum->value()); | m_GUICH->Set("Num",(int)m_SampleNum->value()); | ||||
m_GUICH->SetCommand(PoshSamplerPlugin::SETPITCH); | m_GUICH->SetCommand(PoshSamplerPlugin::SETPITCH); | ||||
@@ -553,7 +561,7 @@ void PoshSamplerPluginGUI::cb_Pitch(Fl_Knob* o, void* v) | |||||
{ ((PoshSamplerPluginGUI*)(o->parent()))->cb_Pitch_i(o,v);} | { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Pitch_i(o,v);} | ||||
inline void PoshSamplerPluginGUI::cb_Octave_i(Fl_Knob* o, void* v) | inline void PoshSamplerPluginGUI::cb_Octave_i(Fl_Knob* o, void* v) | ||||
{ | |||||
{ | |||||
m_GUICH->Set("Int",(int)o->value()); | m_GUICH->Set("Int",(int)o->value()); | ||||
m_GUICH->Set("Num",(int)m_SampleNum->value()); | m_GUICH->Set("Num",(int)m_SampleNum->value()); | ||||
m_GUICH->SetCommand(PoshSamplerPlugin::SETOCT); | m_GUICH->SetCommand(PoshSamplerPlugin::SETOCT); | ||||
@@ -562,7 +570,7 @@ void PoshSamplerPluginGUI::cb_Octave(Fl_Knob* o, void* v) | |||||
{ ((PoshSamplerPluginGUI*)(o->parent()))->cb_Octave_i(o,v);} | { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Octave_i(o,v);} | ||||
inline void PoshSamplerPluginGUI::cb_Loop_i(Fl_Button* o, void* v) | inline void PoshSamplerPluginGUI::cb_Loop_i(Fl_Button* o, void* v) | ||||
{ | |||||
{ | |||||
m_GUICH->Set("Bool",(bool)o->value()); | m_GUICH->Set("Bool",(bool)o->value()); | ||||
m_GUICH->Set("Num",(int)m_SampleNum->value()); | m_GUICH->Set("Num",(int)m_SampleNum->value()); | ||||
m_GUICH->SetCommand(PoshSamplerPlugin::SETLOOP); | m_GUICH->SetCommand(PoshSamplerPlugin::SETLOOP); | ||||
@@ -570,8 +578,17 @@ inline void PoshSamplerPluginGUI::cb_Loop_i(Fl_Button* o, void* v) | |||||
void PoshSamplerPluginGUI::cb_Loop(Fl_Button* o, void* v) | void PoshSamplerPluginGUI::cb_Loop(Fl_Button* o, void* v) | ||||
{ ((PoshSamplerPluginGUI*)(o->parent()))->cb_Loop_i(o,v);} | { ((PoshSamplerPluginGUI*)(o->parent()))->cb_Loop_i(o,v);} | ||||
inline void PoshSamplerPluginGUI::cb_Retrig_i (Fl_Button *o, void *v) { | |||||
m_GUICH->Set("Bool",(bool)o->value()); | |||||
m_GUICH->Set("Num",(int)m_SampleNum->value()); | |||||
m_GUICH->SetCommand(PoshSamplerPlugin::SETRETRIG); | |||||
} | |||||
void PoshSamplerPluginGUI::cb_Retrig (Fl_Button *o, void *v) { | |||||
((PoshSamplerPluginGUI*)(o->parent()))->cb_Retrig_i (o, v); | |||||
} | |||||
inline void PoshSamplerPluginGUI::cb_PingPong_i(Fl_Button* o, void* v) | inline void PoshSamplerPluginGUI::cb_PingPong_i(Fl_Button* o, void* v) | ||||
{ | |||||
{ | |||||
m_GUICH->Set("Bool",(bool)o->value()); | m_GUICH->Set("Bool",(bool)o->value()); | ||||
m_GUICH->Set("Num",(int)m_SampleNum->value()); | m_GUICH->Set("Num",(int)m_SampleNum->value()); | ||||
m_GUICH->SetCommand(PoshSamplerPlugin::SETPING); | m_GUICH->SetCommand(PoshSamplerPlugin::SETPING); | ||||
@@ -71,95 +71,70 @@ class Fl_WaveDisplay : public Fl_Widget | |||||
}; | }; | ||||
class PoshSamplerPluginGUI : public SpiralPluginGUI | |||||
{ | |||||
public: | |||||
PoshSamplerPluginGUI(int w, int h, PoshSamplerPlugin *o,ChannelHandler *ch, const HostInfo *Info); | |||||
virtual void UpdateValues(SpiralPlugin *o); | |||||
virtual void Update(); | |||||
void SetPlayPos(long s) { m_Display->SetPlayPos(s); } | |||||
int GetCurrentSample() { return (int)m_SampleNum->value(); } | |||||
protected: | |||||
const std::string GetHelpText(const std::string &loc); | |||||
private: | |||||
void UpdateSampleDisplay(int num); | |||||
char m_TextBuf[256]; | |||||
int Numbers[NUM_SAMPLES]; | |||||
bool m_UpdateMe; | |||||
Fl_Button* m_Load; | |||||
Fl_Button* m_Save; | |||||
Fl_Button* m_PosMarker; | |||||
Fl_Knob* m_Volume; | |||||
Fl_Knob* m_Pitch; | |||||
Fl_Knob* m_Octave; | |||||
Fl_Button* m_Loop; | |||||
Fl_Button* m_PingPong; | |||||
Fl_Button* m_Record; | |||||
Fl_Counter* m_Note; | |||||
Fl_WaveDisplay* m_Display; | |||||
Fl_Counter* m_SampleNum; | |||||
Fl_Button* m_ZoomIn; | |||||
Fl_Button* m_ZoomOut; | |||||
Fl_Button* m_Cut; | |||||
Fl_Button* m_Copy; | |||||
Fl_Button* m_Paste; | |||||
Fl_Button* m_Mix; | |||||
Fl_Button* m_Crop; | |||||
Fl_Button* m_Reverse; | |||||
Fl_Button* m_Amp; | |||||
//// Callbacks //// | |||||
inline void cb_Load_i(Fl_Button* o, void* v); | |||||
static void cb_Load(Fl_Button* o, void* v); | |||||
inline void cb_Save_i(Fl_Button* o, void* v); | |||||
static void cb_Save(Fl_Button* o, void* v); | |||||
inline void cb_PosMarker_i(Fl_Button* o, void* v); | |||||
static void cb_PosMarker(Fl_Button* o, void* v); | |||||
inline void cb_Record_i(Fl_Button* o, void* v); | |||||
static void cb_Record(Fl_Button* o, void* v); | |||||
inline void cb_Volume_i(Fl_Knob* o, void* v); | |||||
static void cb_Volume(Fl_Knob* o, void* v); | |||||
inline void cb_Pitch_i(Fl_Knob* o, void* v); | |||||
static void cb_Pitch(Fl_Knob* o, void* v); | |||||
inline void cb_Octave_i(Fl_Knob* o, void* v); | |||||
static void cb_Octave(Fl_Knob* o, void* v); | |||||
inline void cb_Loop_i(Fl_Button* o, void* v); | |||||
static void cb_Loop(Fl_Button* o, void* v); | |||||
inline void cb_PingPong_i(Fl_Button* o, void* v); | |||||
static void cb_PingPong(Fl_Button* o, void* v); | |||||
inline void cb_Note_i(Fl_Counter* o, void* v); | |||||
static void cb_Note(Fl_Counter* o, void* v); | |||||
inline void cb_SampleNum_i(Fl_Counter* o, void* v); | |||||
static void cb_SampleNum(Fl_Counter* o, void* v); | |||||
inline void cb_Cut_i(Fl_Button* o, void* v); | |||||
static void cb_Cut(Fl_Button* o, void* v); | |||||
inline void cb_Copy_i(Fl_Button* o, void* v); | |||||
static void cb_Copy(Fl_Button* o, void* v); | |||||
inline void cb_Paste_i(Fl_Button* o, void* v); | |||||
static void cb_Paste(Fl_Button* o, void* v); | |||||
inline void cb_Mix_i(Fl_Button* o, void* v); | |||||
static void cb_Mix(Fl_Button* o, void* v); | |||||
inline void cb_Crop_i(Fl_Button* o, void* v); | |||||
static void cb_Crop(Fl_Button* o, void* v); | |||||
inline void cb_Reverse_i(Fl_Button* o, void* v); | |||||
static void cb_Reverse(Fl_Button* o, void* v); | |||||
inline void cb_Amp_i(Fl_Button* o, void* v); | |||||
static void cb_Amp(Fl_Button* o, void* v); | |||||
inline void cb_ZoomIn_i(Fl_Button* o, void* v); | |||||
static void cb_ZoomIn(Fl_Button* o, void* v); | |||||
inline void cb_ZoomOut_i(Fl_Button* o, void* v); | |||||
static void cb_ZoomOut(Fl_Button* o, void* v); | |||||
inline void cb_WaveDisplay_i(Fl_WaveDisplay* o, void* v); | |||||
static void cb_WaveDisplay(Fl_WaveDisplay* o, void* v); | |||||
class PoshSamplerPluginGUI : public SpiralPluginGUI { | |||||
public: | |||||
PoshSamplerPluginGUI (int w, int h, PoshSamplerPlugin *o, ChannelHandler *ch, const HostInfo *Info); | |||||
virtual void UpdateValues (SpiralPlugin *o); | |||||
virtual void Update(); | |||||
void SetPlayPos (long s) { m_Display->SetPlayPos(s); } | |||||
int GetCurrentSample() { return (int)m_SampleNum->value(); } | |||||
protected: | |||||
const std::string GetHelpText(const std::string &loc); | |||||
private: | |||||
void UpdateSampleDisplay(int num); | |||||
char m_TextBuf[256]; | |||||
int Numbers[NUM_SAMPLES]; | |||||
bool m_UpdateMe; | |||||
Fl_Knob *m_Volume, *m_Pitch, *m_Octave; | |||||
Fl_Button *m_Load, *m_Save, *m_Record, *m_Loop, *m_PingPong, *m_PosMarker, *m_Retrig; | |||||
Fl_Button *m_ZoomIn, *m_ZoomOut, *m_Cut, *m_Copy, *m_Paste, *m_Mix, *m_Crop, *m_Reverse, *m_Amp; | |||||
Fl_Counter *m_Note, *m_SampleNum; | |||||
Fl_WaveDisplay *m_Display; | |||||
//// Callbacks //// | |||||
inline void cb_Load_i (Fl_Button *o, void *v); | |||||
static void cb_Load (Fl_Button *o, void *v); | |||||
inline void cb_Save_i (Fl_Button *o, void *v); | |||||
static void cb_Save (Fl_Button *o, void *v); | |||||
inline void cb_Record_i (Fl_Button *o, void *v); | |||||
static void cb_Record (Fl_Button *o, void *v); | |||||
inline void cb_Loop_i (Fl_Button *o, void *v); | |||||
static void cb_Loop (Fl_Button *o, void *v); | |||||
inline void cb_PingPong_i (Fl_Button *o, void *v); | |||||
static void cb_PingPong (Fl_Button *o, void *v); | |||||
inline void cb_PosMarker_i (Fl_Button *o, void *v); | |||||
static void cb_PosMarker (Fl_Button *o, void *v); | |||||
inline void cb_Retrig_i (Fl_Button *o, void *v); | |||||
static void cb_Retrig (Fl_Button *o, void *v); | |||||
inline void cb_Volume_i (Fl_Knob *o, void *v); | |||||
static void cb_Volume (Fl_Knob *o, void *v); | |||||
inline void cb_Pitch_i (Fl_Knob *o, void *v); | |||||
static void cb_Pitch (Fl_Knob *o, void *v); | |||||
inline void cb_Octave_i (Fl_Knob *o, void *v); | |||||
static void cb_Octave (Fl_Knob *o, void *v); | |||||
inline void cb_Note_i (Fl_Counter *o, void *v); | |||||
static void cb_Note (Fl_Counter *o, void *v); | |||||
inline void cb_SampleNum_i (Fl_Counter *o, void *v); | |||||
static void cb_SampleNum (Fl_Counter *o, void *v); | |||||
inline void cb_Cut_i (Fl_Button *o, void *v); | |||||
static void cb_Cut (Fl_Button *o, void *v); | |||||
inline void cb_Copy_i (Fl_Button *o, void *v); | |||||
static void cb_Copy (Fl_Button *o, void *v); | |||||
inline void cb_Paste_i (Fl_Button *o, void *v); | |||||
static void cb_Paste (Fl_Button *o, void *v); | |||||
inline void cb_Mix_i (Fl_Button *o, void *v); | |||||
static void cb_Mix (Fl_Button *o, void *v); | |||||
inline void cb_Crop_i (Fl_Button *o, void *v); | |||||
static void cb_Crop (Fl_Button *o, void *v); | |||||
inline void cb_Reverse_i (Fl_Button *o, void *v); | |||||
static void cb_Reverse (Fl_Button *o, void *v); | |||||
inline void cb_Amp_i (Fl_Button *o, void *v); | |||||
static void cb_Amp (Fl_Button *o, void *v); | |||||
inline void cb_ZoomIn_i (Fl_Button *o, void *v); | |||||
static void cb_ZoomIn (Fl_Button *o, void *v); | |||||
inline void cb_ZoomOut_i (Fl_Button *o, void *v); | |||||
static void cb_ZoomOut (Fl_Button *o, void *v); | |||||
inline void cb_WaveDisplay_i (Fl_WaveDisplay *o, void *v); | |||||
static void cb_WaveDisplay (Fl_WaveDisplay *o, void *v); | |||||
}; | }; | ||||
#endif | #endif |