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:
Bart van Strien
2017-10-04 13:56:14 +02:00
parent 9e4374935d
commit ac12424bab
4 changed files with 59 additions and 5 deletions
+16
View File
@@ -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