本文整理汇总了C++中SoundPlayer::Play方法的典型用法代码示例。如果您正苦于以下问题:C++ SoundPlayer::Play方法的具体用法?C++ SoundPlayer::Play怎么用?C++ SoundPlayer::Play使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoundPlayer
的用法示例。
在下文中一共展示了SoundPlayer::Play方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
SoundPlayer soundPlayer = SoundPlayer();
Mp3Decoder mp3Decoder = Mp3Decoder();
MicRecorder micRecorder = MicRecorder();
unsigned char buffer[BUFSIZE*50] = {};
unsigned char recBuffer[BUFSIZE*50] = {};
// Put path to file here
std::string path = "smw_coin.mp3";
// TODO: Manage more than int16_t encoding format, mono and 44.1kHz
Mp3Format mp3Format = mp3Decoder.Open(path);
//std::cout << "encoding: " << mp3Format.encoding << std::endl;
//std::cout << "channels: " << mp3Format.channels << std::endl;
//std::cout << "rate: " << mp3Format.rate << std::endl;
int decodeNumber = 0;
int decodedQty = 0;
while ((decodedQty = mp3Decoder.Decode(buffer+decodeNumber*BUFSIZE, BUFSIZE)) > 0) {
soundPlayer.Play(buffer+decodeNumber*BUFSIZE, decodedQty);
// Record some data in the buffer
micRecorder.Record(recBuffer+decodeNumber*BUFSIZE, decodedQty);
decodeNumber++;
}
unsigned int samplesQty = (decodeNumber-1)*BUFSIZE/sizeof(int16_t)+decodedQty;
mp3Decoder.Close();
// Process the signals as wanted here
int delay = SignalProcessor::GetDelay((int16_t*)buffer, (int16_t*)recBuffer, samplesQty);
SignalProcessor::Delay((int16_t*)buffer, samplesQty, delay);
SignalProcessor::Scale((int16_t*)buffer, samplesQty, 1, 2);
SignalProcessor::Subtract((int16_t*)recBuffer, (int16_t*)buffer, samplesQty);
// Play back for more fun
for (unsigned int i = 0; i < decodeNumber; i++) {
soundPlayer.Play(recBuffer+i*BUFSIZE, BUFSIZE);
}
printToFile(samplesQty, {(int16_t*)buffer, (int16_t*)recBuffer});
}
示例2: PlaySound_
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void EffectNodeImplemented::PlaySound_(Instance& instance, SoundTag tag, Manager* manager)
{
SoundPlayer* player = manager->GetSoundPlayer();
if( player == NULL )
{
return;
}
if( Sound.WaveId >= 0 )
{
SoundPlayer::InstanceParameter parameter;
parameter.Data = m_effect->GetWave( Sound.WaveId );
parameter.Volume = Sound.Volume.getValue( *manager );
parameter.Pitch = Sound.Pitch.getValue( *manager );
parameter.Pan = Sound.Pan.getValue( *manager );
parameter.Mode3D = (Sound.PanType == ParameterSoundPanType_3D);
Vector3D::Transform( parameter.Position,
Vector3D(0.0f, 0.0f, 0.0f), instance.GetGlobalMatrix43() );
parameter.Distance = Sound.Distance;
player->Play( tag, parameter );
}
}