From 5a155ba096f35d8f7f48fd02cf14c585ef88d9f4 Mon Sep 17 00:00:00 2001 From: aj_genius Date: Sun, 17 Aug 2003 04:22:50 +0000 Subject: [PATCH] ensure sample gets initialized on load from file, fixes occasional bug where loading multiple wavs keeps increases the pitch --- .../PoshSamplerPlugin/PoshSamplerPlugin.C | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/SpiralSound/Plugins/PoshSamplerPlugin/PoshSamplerPlugin.C b/SpiralSound/Plugins/PoshSamplerPlugin/PoshSamplerPlugin.C index 63a2377..0357599 100644 --- a/SpiralSound/Plugins/PoshSamplerPlugin/PoshSamplerPlugin.C +++ b/SpiralSound/Plugins/PoshSamplerPlugin/PoshSamplerPlugin.C @@ -56,6 +56,30 @@ string SpiralPlugin_GetGroupName() /////////////////////////////////////////////////////// +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; + } +} + PoshSamplerPlugin::PoshSamplerPlugin() : m_Recording(false) { @@ -102,27 +126,8 @@ m_Recording(false) SampleDesc* NewDesc = new SampleDesc; char temp[256]; - // 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; - NewDesc->PitchMod = 1.0f; - NewDesc->SamplePos = -1; - NewDesc->Loop = false; - NewDesc->PingPong = false; - NewDesc->Note = n; - 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; - + InitializeSampleDescription(NewDesc, temp, n); m_SampleDescVec.push_back(NewDesc); } @@ -398,7 +403,7 @@ void PoshSamplerPlugin::LoadSample(int n, const string &Name) { m_SampleVec[n]->Allocate(Wav.GetSize()); Wav.Load(*m_SampleVec[n]); - m_SampleDescVec[n]->Pathname=Name; + InitializeSampleDescription(m_SampleDescVec[n], Name, n); m_SampleDescVec[n]->SampleRate=Wav.GetSamplerate(); m_SampleDescVec[n]->Stereo=Wav.IsStereo(); m_SampleDescVec[n]->Pitch *= m_SampleDescVec[n]->SampleRate/(float)m_HostInfo->SAMPLERATE;