mirror of
https://github.com/jorio/Pomme.git
synced 2024-06-10 06:29:31 +00:00
Support snd resources with non-0 sustain loop start frame
This commit is contained in:
parent
38d2be66b6
commit
15d3606631
|
@ -175,8 +175,21 @@ static void InstallSoundInChannel(SndChannelPtr chan, const Ptr sampledSoundHead
|
|||
{
|
||||
impl.source.SetLoop(true);
|
||||
|
||||
if (info.loopStart != 0)
|
||||
TODO2("Warning: looping on a portion of the snd isn't supported yet");
|
||||
// Set sustain loop start frame
|
||||
if ((int) info.loopStart >= impl.source.length)
|
||||
{
|
||||
TODO2("Warning: Illegal sustain loop start frame");
|
||||
}
|
||||
else
|
||||
{
|
||||
impl.source.sustainOffset = info.loopStart;
|
||||
}
|
||||
|
||||
// Check sustain loop end frame
|
||||
if ((int) info.loopEnd != impl.source.length)
|
||||
{
|
||||
TODO2("Warning: Unsupported sustain loop end frame");
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
|
|
|
@ -247,6 +247,7 @@ void Source::Init(int theSampleRate, int theLength)
|
|||
{
|
||||
this->samplerate = theSampleRate;
|
||||
this->length = theLength;
|
||||
this->sustainOffset = 0;
|
||||
SetGain(1);
|
||||
SetPan(0);
|
||||
SetPitch(1);
|
||||
|
@ -592,7 +593,7 @@ void WavStream::FillBuffer(int16_t* dst, int fillLength)
|
|||
// Loop back and continue filling buffer if we didn't fill the buffer
|
||||
if (fillLength > 0)
|
||||
{
|
||||
idx = 0;
|
||||
idx = sustainOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ namespace cmixer
|
|||
int16_t pcmbuf[BUFFER_SIZE]; // Internal buffer with raw stereo PCM
|
||||
int samplerate; // Stream's native samplerate
|
||||
int length; // Stream's length in frames
|
||||
int sustainOffset; // Offset of the sustain loop in frames
|
||||
int end; // End index for the current play-through
|
||||
int state; // Current state (playing|paused|stopped)
|
||||
int64_t position; // Current playhead position (fixed point)
|
||||
|
|
Loading…
Reference in New Issue
Block a user