Browse Source

fix for bug 766594 - posh sampler not saving correctly

master
edgeeffect 22 years ago
parent
commit
35edfd7256
4 changed files with 111 additions and 106 deletions
  1. +1
    -1
      SpiralSound/Plugins/GUI/WS_RevSaw.h
  2. +100
    -94
      SpiralSound/Plugins/PoshSamplerPlugin/PoshSamplerPlugin.C
  3. +1
    -1
      SpiralSound/SpiralInfo.C
  4. +9
    -10
      main.cpp

+ 1
- 1
SpiralSound/Plugins/GUI/WS_RevSaw.h View File

@@ -44,4 +44,4 @@ static unsigned char *image_RevSaw[] = {
(unsigned char*)" ",
(unsigned char*)" "};
#endif
#endif

+ 100
- 94
SpiralSound/Plugins/PoshSamplerPlugin/PoshSamplerPlugin.C View File

@@ -64,28 +64,28 @@ m_Recording(false)
m_PluginInfo.Height=215;
m_PluginInfo.NumInputs=21;
m_PluginInfo.NumOutputs=9;
m_PluginInfo.PortTips.push_back("Sample 1 Pitch");
m_PluginInfo.PortTips.push_back("Sample 1 Trigger");
m_PluginInfo.PortTips.push_back("Sample 2 Pitch");
m_PluginInfo.PortTips.push_back("Sample 2 Trigger");
m_PluginInfo.PortTips.push_back("Sample 3 Pitch");
m_PluginInfo.PortTips.push_back("Sample 3 Trigger");
m_PluginInfo.PortTips.push_back("Sample 4 Pitch");
m_PluginInfo.PortTips.push_back("Sample 4 Trigger");
m_PluginInfo.PortTips.push_back("Sample 5 Pitch");
m_PluginInfo.PortTips.push_back("Sample 5 Trigger");
m_PluginInfo.PortTips.push_back("Sample 6 Pitch");
m_PluginInfo.PortTips.push_back("Sample 6 Trigger");
m_PluginInfo.PortTips.push_back("Sample 7 Pitch");
m_PluginInfo.PortTips.push_back("Sample 7 Trigger");
m_PluginInfo.PortTips.push_back("Sample 8 Pitch");
m_PluginInfo.PortTips.push_back("Sample 8 Trigger");
m_PluginInfo.PortTips.push_back("Sample 1 Pitch");
m_PluginInfo.PortTips.push_back("Sample 1 Trigger");
m_PluginInfo.PortTips.push_back("Sample 2 Pitch");
m_PluginInfo.PortTips.push_back("Sample 2 Trigger");
m_PluginInfo.PortTips.push_back("Sample 3 Pitch");
m_PluginInfo.PortTips.push_back("Sample 3 Trigger");
m_PluginInfo.PortTips.push_back("Sample 4 Pitch");
m_PluginInfo.PortTips.push_back("Sample 4 Trigger");
m_PluginInfo.PortTips.push_back("Sample 5 Pitch");
m_PluginInfo.PortTips.push_back("Sample 5 Trigger");
m_PluginInfo.PortTips.push_back("Sample 6 Pitch");
m_PluginInfo.PortTips.push_back("Sample 6 Trigger");
m_PluginInfo.PortTips.push_back("Sample 7 Pitch");
m_PluginInfo.PortTips.push_back("Sample 7 Trigger");
m_PluginInfo.PortTips.push_back("Sample 8 Pitch");
m_PluginInfo.PortTips.push_back("Sample 8 Trigger");
m_PluginInfo.PortTips.push_back("Input");
m_PluginInfo.PortTips.push_back("Sample trigger pitch");
m_PluginInfo.PortTips.push_back("Sample 1 Start Pos");
m_PluginInfo.PortTips.push_back("Sample 2 Start Pos");
m_PluginInfo.PortTips.push_back("Sample 2 Start Pos");
m_PluginInfo.PortTips.push_back("Sample 3 Start Pos");
m_PluginInfo.PortTips.push_back("Mixed Output");
m_PluginInfo.PortTips.push_back("Mixed Output");
m_PluginInfo.PortTips.push_back("Sample 1 Output");
m_PluginInfo.PortTips.push_back("Sample 2 Output");
m_PluginInfo.PortTips.push_back("Sample 3 Output");
@@ -94,16 +94,18 @@ m_Recording(false)
m_PluginInfo.PortTips.push_back("Sample 6 Output");
m_PluginInfo.PortTips.push_back("Sample 7 Output");
m_PluginInfo.PortTips.push_back("Sample 8 Output");
for (int n=0; n<NUM_SAMPLES; n++)
{
Sample* NewSample = new Sample;
m_SampleVec.push_back(NewSample);
SampleDesc* NewDesc = new SampleDesc;
char temp[256];
sprintf(temp,"PoshSampler%d_%d",SpiralPlugin_GetID(),n);
NewDesc->Pathname = temp;
// Andy's fix for bug 766594
// sprintf (temp, "PoshSampler%d_%d", SpiralPlugin_GetID(), n);
sprintf (temp, "PoshSampler%d_%d", GetID(), n);
NewDesc->Pathname = temp;
NewDesc->Volume = 1.0f;
NewDesc->Velocity = 1.0f;
NewDesc->Pitch = 1.0f;
@@ -111,7 +113,7 @@ m_Recording(false)
NewDesc->SamplePos = -1;
NewDesc->Loop = false;
NewDesc->PingPong = false;
NewDesc->Note = n;
NewDesc->Note = n;
NewDesc->Octave = 0;
NewDesc->TriggerUp = true;
NewDesc->SamplePos = -1;
@@ -120,13 +122,13 @@ m_Recording(false)
NewDesc->PlayStart = 0;
NewDesc->LoopStart = 0;
NewDesc->LoopEnd = INT_MAX;
m_SampleDescVec.push_back(NewDesc);
}
m_Version=3;
m_Current = 0;
m_AudioCH->Register("Num",&m_GUIArgs.Num);
m_AudioCH->Register("Value",&m_GUIArgs.Value);
m_AudioCH->Register("Bool",&m_GUIArgs.Boole);
@@ -138,7 +140,7 @@ m_Recording(false)
m_AudioCH->Register("PlayPos",&m_CurrentPlayPos,ChannelHandler::OUTPUT);
m_AudioCH->RegisterData("SampleBuffer",ChannelHandler::OUTPUT_REQUEST,&m_SampleBuffer,TRANSBUF_SIZE);
m_AudioCH->Register("SampleSize",&m_SampleSize,ChannelHandler::OUTPUT_REQUEST);
}

PoshSamplerPlugin::~PoshSamplerPlugin()
@@ -148,7 +150,7 @@ PoshSamplerPlugin::~PoshSamplerPlugin()
{
delete(*i);
}
for (vector<SampleDesc*>::iterator i=m_SampleDescVec.begin();
i!=m_SampleDescVec.end(); i++)
{
@@ -157,7 +159,7 @@ PoshSamplerPlugin::~PoshSamplerPlugin()
}

PluginInfo &PoshSamplerPlugin::Initialise(const HostInfo *Host)
{
{
return SpiralPlugin::Initialise(Host);;
}

@@ -182,122 +184,122 @@ void PoshSamplerPlugin::Execute()
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(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))
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
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->Loop)
{
if (S->PingPong) Pong=true;
else S->SamplePos=S->LoopStart;
}
else
else
{
S->SamplePos=-1;
}
}
// if the sample has ended ponging
if (Pong && S->SamplePos<=S->LoopStart)
{
Pong=false;
}

if (S->SamplePos!=-1)
{
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 = 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);
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));
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
// 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)
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_SampleDescVec[s]->LoopEnd=m_SampleVec[s]->GetLength();
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;
}
}
@@ -316,11 +318,11 @@ void PoshSamplerPlugin::ExecuteCommands()
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):
case (SETPLAYPOINTS):
{
SetPlayStart(m_GUIArgs.Num,m_GUIArgs.Start);
SetLoopStart(m_GUIArgs.Num,m_GUIArgs.LoopStart);
SetLoopEnd(m_GUIArgs.Num,m_GUIArgs.End);
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;
@@ -331,7 +333,7 @@ void PoshSamplerPlugin::ExecuteCommands()
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) :
case (GETSAMPLE) :
{
m_AudioCH->SetupBulkTransfer((void*)m_SampleVec[m_Current]->GetBuffer());
m_SampleSize=m_SampleVec[m_Current]->GetLengthInBytes();
@@ -344,11 +346,11 @@ 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]->Loop<<" "<<
m_SampleDescVec[n]->PingPong<<" "<<
m_SampleDescVec[n]->Note<<" "<<
m_SampleDescVec[n]->Octave<<" "<<
m_SampleDescVec[n]->SamplePos<<" "<<
@@ -363,13 +365,13 @@ 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]->Loop>>
m_SampleDescVec[n]->PingPong>>
m_SampleDescVec[n]->Note>>
m_SampleDescVec[n]->Octave>>
m_SampleDescVec[n]->SamplePos>>
@@ -377,15 +379,15 @@ void PoshSamplerPlugin::StreamIn(istream &s)
m_SampleDescVec[n]->LoopStart>>
m_SampleDescVec[n]->LoopEnd>>
m_SampleDescVec[n]->Note;
if (version<3)
{
int size;
{
int size;
s>>size;
s.ignore(1);
char Buf[4096];
s.get(Buf,size+1);
}
s.get(Buf,size+1);
}
}
}

@@ -399,7 +401,7 @@ void PoshSamplerPlugin::LoadSample(int n, const string &Name)
m_SampleDescVec[n]->Pathname=Name;
m_SampleDescVec[n]->SampleRate=Wav.GetSamplerate();
m_SampleDescVec[n]->Stereo=Wav.IsStereo();
m_SampleDescVec[n]->Pitch *= m_SampleDescVec[n]->SampleRate/(float)m_HostInfo->SAMPLERATE;
m_SampleDescVec[n]->Pitch *= m_SampleDescVec[n]->SampleRate/(float)m_HostInfo->SAMPLERATE;
m_SampleDescVec[n]->LoopEnd=m_SampleVec[n]->GetLength()-1;
}
}
@@ -407,7 +409,7 @@ void PoshSamplerPlugin::LoadSample(int n, const string &Name)
void PoshSamplerPlugin::SaveSample(int n, const string &Name)
{
if (m_SampleVec[n]->GetLength()==0) return;
WavFile Wav;
Wav.Open(Name,WavFile::WRITE,WavFile::MONO);
Wav.Save(*m_SampleVec[n]);
@@ -453,7 +455,7 @@ void PoshSamplerPlugin::Reverse(int n, long s, long e)

void PoshSamplerPlugin::Amp(int n, long s, long e)
{
if (m_SampleVec[n]->GetLength()==0) return;
if (m_SampleVec[n]->GetLength()==0) return;
for (int m=0; m<m_SampleVec[n]->GetLength(); m++)
{
m_SampleVec[n]->Set(m,(*m_SampleVec[n])[m]*m_SampleDescVec[n]->Volume);
@@ -464,19 +466,21 @@ void PoshSamplerPlugin::Amp(int n, long s, long e)
bool PoshSamplerPlugin::SaveExternalFiles(const string &Dir)
{
for (int n=0; n<NUM_SAMPLES; n++)
{
{
char temp[256];
sprintf(temp,"PoshSampler%d_%d.wav",SpiralPlugin_GetID(),n);
m_SampleDescVec[n]->Pathname = temp;
// Andy's fix for bug 766594
// sprintf (temp, "PoshSampler%d_%d.wav", SpiralPlugin_GetID(), n);
sprintf (temp, "PoshSampler%d_%d.wav", GetID(), n);
m_SampleDescVec[n]->Pathname = temp;
}

for (int n=0; n<NUM_SAMPLES; n++)
{
// if it's not empty
if (m_SampleVec[n]->GetLength()!=0)
{
{
SaveSample(n,Dir+m_SampleDescVec[n]->Pathname);
}
}
}
return true;
}
@@ -484,12 +488,14 @@ bool PoshSamplerPlugin::SaveExternalFiles(const string &Dir)
void PoshSamplerPlugin::LoadExternalFiles(const string &Dir)
{
for (int n=0; n<NUM_SAMPLES; n++)
{
{
char temp[256];
sprintf(temp,"PoshSampler%d_%d.wav",SpiralPlugin_GetID(),n);
m_SampleDescVec[n]->Pathname = temp;
// Andy's fix for bug 766594
// sprintf (temp, "PoshSampler%d_%d.wav", SpiralPlugin_GetID(), n);
sprintf (temp, "PoshSampler%d_%d.wav", GetID(), n);
m_SampleDescVec[n]->Pathname = temp;
}
for (int n=0; n<NUM_SAMPLES; n++)
{
LoadSample(n,Dir+m_SampleDescVec[n]->Pathname);


+ 1
- 1
SpiralSound/SpiralInfo.C View File

@@ -139,7 +139,7 @@ void SpiralInfo::StreamInPrefs (istream &s) {
if (st!="end") PLUGINVEC.push_back (st);
}
}
#if __APPLE__
// ignore custom paths, plugins are encapsulated in the app anyway
// this prevents the program to fail if the user move the application icon


+ 9
- 10
main.cpp View File

@@ -48,17 +48,17 @@ bool GUI = true;
/////////////////////////////////////////////////////////////

void watchdog (void *arg)
{
{
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);

watchdog_check = 0;
gui_watchdog_check = 0;
while (1)
{
usleep (10000000);
// gui watchdog goes off with modal dialog boxes
if (watchdog_check == 0)// || gui_watchdog_check== 0)
if (watchdog_check == 0)// || gui_watchdog_check== 0)
{
cerr<<"ssm watchdog: timeout - killing ssm"<<endl;
if (watchdog_check==0) cerr<<"diagnosis: audio hung?"<<endl;
@@ -75,15 +75,15 @@ void watchdog (void *arg)
void audioloop(void* o)
{
while(1)
{
if (!synth->CallbackMode())
{
if (!synth->CallbackMode())
{
// do funky stuff
synth->Update();

// put the brakes on if there is no blocking output running
if (!synth->IsBlockingOutputPluginReady()||
synth->IsPaused())
synth->IsPaused())
{
usleep(10000);
}
@@ -91,10 +91,10 @@ void audioloop(void* o)
else
{
// the engine is currently in callback mode, so we don't
// need to do anything unless we are switched back
// need to do anything unless we are switched back
usleep(1000000);
}
watchdog_check = 1;
}
}
@@ -125,14 +125,13 @@ int main(int argc, char **argv)
} else
printf("No base pathname\n");
#endif
srand(time(NULL));
srand(time(NULL));
SpiralInfo::Get()->LoadPrefs();

// get args
string cmd_filename="";
bool cmd_specd = false;
string cmd_pluginPath="";

// parse the args
if (argc>1)
{


Loading…
Cancel
Save