mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Add optional channel parameter to SoundData:getSample/setSample (resolves #1346)
If omitted they work as before, if specified it handles the interleaving internally. --HG-- branch : minor
This commit is contained in:
@@ -223,6 +223,14 @@ void SoundData::setSample(int i, float sample)
|
||||
}
|
||||
}
|
||||
|
||||
void SoundData::setSample(int i, int channel, float sample)
|
||||
{
|
||||
if (channel < 1 || channel > channels)
|
||||
throw love::Exception("Attempt to set sample from out-of-range channel!");
|
||||
|
||||
return setSample(i * channels + (channel - 1), sample);
|
||||
}
|
||||
|
||||
float SoundData::getSample(int i) const
|
||||
{
|
||||
// Check range.
|
||||
@@ -242,5 +250,13 @@ float SoundData::getSample(int i) const
|
||||
}
|
||||
}
|
||||
|
||||
float SoundData::getSample(int i, int channel) const
|
||||
{
|
||||
if (channel < 1 || channel > channels)
|
||||
throw love::Exception("Attempt to get sample from out-of-range channel!");
|
||||
|
||||
return getSample(i * channels + (channel - 1));
|
||||
}
|
||||
|
||||
} // sound
|
||||
} // love
|
||||
|
||||
Reference in New Issue
Block a user