本文整理汇总了C++中audio::SeekableAudioStream类的典型用法代码示例。如果您正苦于以下问题:C++ SeekableAudioStream类的具体用法?C++ SeekableAudioStream怎么用?C++ SeekableAudioStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SeekableAudioStream类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: playSoundBuffer
uint Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffer, int volume,
sndHandleType handleType, bool loop) {
if (!buffer._stream && !buffer._data) {
warning("Empty stream");
return 0;
}
// Create a new SeekableReadStream which will be automatically disposed
// after the sample stops playing. Do not dispose the original
// data/stream though.
// Beware that if the sample comes from an archive (i.e., is stored in
// buffer._stream), then you must NOT play it more than once at the
// same time, because streams are not thread-safe. Playing it
// repeatedly is OK. Currently this is ensured by that archives are
// only used for dubbing, which is only played from one place in
// script.cpp, which blocks until the dubbed sentence has finished
// playing.
Common::SeekableReadStream *stream;
const int skip = buffer._format == RAW80 ? 80 : 0;
if (buffer._stream) {
stream = new Common::SeekableSubReadStream(
buffer._stream, skip, buffer._stream->size() /* end */, DisposeAfterUse::NO);
} else {
stream = new Common::MemoryReadStream(
buffer._data + skip, buffer._length - skip /* length */, DisposeAfterUse::NO);
}
Audio::SeekableAudioStream *reader = NULL;
switch (buffer._format) {
case RAW:
case RAW80:
reader = Audio::makeRawStream(stream, buffer._frequency, Audio::FLAG_UNSIGNED, DisposeAfterUse::YES);
break;
#ifdef USE_MAD
case MP3:
reader = Audio::makeMP3Stream(stream, DisposeAfterUse::YES);
break;
#endif
#ifdef USE_VORBIS
case OGG:
reader = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
break;
#endif
#ifdef USE_FLAC
case FLAC:
reader = Audio::makeFLACStream(stream, DisposeAfterUse::YES);
break;
#endif
default:
error("Unsupported compression format %d", static_cast<int> (buffer._format));
delete stream;
return 0;
}
const uint length = reader->getLength().msecs();
const Audio::Mixer::SoundType soundType = (handleType == kVoiceHandle) ?
Audio::Mixer::kSpeechSoundType : Audio::Mixer::kSFXSoundType;
Audio::AudioStream *audio_stream = Audio::makeLoopingAudioStream(reader, loop ? 0 : 1);
_mixer->playStream(soundType, handle, audio_stream, -1, volume);
return length;
}
开发者ID:BenCastricum,项目名称:scummvm,代码行数:60,代码来源:sound.cpp
示例2: startVOCPlay
void SoundManager::startVOCPlay(const Common::String &filename) {
Common::File f;
if (!f.open(filename))
error("Could not find voc file - %s", filename.c_str());
Audio::SeekableAudioStream *audioStream = Audio::makeVOCStream(f.readStream(f.size()),
Audio::FLAG_UNSIGNED, DisposeAfterUse::YES);
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, audioStream);
audioStream->seek(Audio::Timestamp(_vocOffset * 1000, 11025));
}
开发者ID:Cruel,项目名称:scummvm,代码行数:11,代码来源:sound.cpp
示例3: voicePlay
int32 Sound::voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volume, bool isSfx) {
Audio::SeekableAudioStream *audioStream = getVoiceStream(file);
if (!audioStream) {
return 0;
}
int playTime = audioStream->getLength().msecs();
playVoiceStream(audioStream, handle, volume, isSfx);
return playTime;
}
开发者ID:Templier,项目名称:scummvm-test,代码行数:11,代码来源:sound.cpp
示例4: openSound
bool AIFFTrack::openSound(const Common::String &filename, const Common::String &soundName, const Audio::Timestamp *start) {
Common::SeekableReadStream *file = g_resourceloader->openNewStreamFile(filename, true);
if (!file) {
Debug::debug(Debug::Sound, "Stream for %s not open", soundName.c_str());
return false;
}
_soundName = soundName;
Audio::SeekableAudioStream *aiffStream = Audio::makeAIFFStream(file, DisposeAfterUse::YES);
_stream = aiffStream;
if (start)
aiffStream->seek(*start);
if (!_stream)
return false;
_handle = new Audio::SoundHandle();
return true;
}
开发者ID:JoseJX,项目名称:residualvm,代码行数:16,代码来源:aifftrack.cpp
示例5:
bool Win32AudioCDManager::play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate,
Audio::Mixer::SoundType soundType) {
// Prefer emulation
if (DefaultAudioCDManager::play(track, numLoops, startFrame, duration, onlyEmulate, soundType))
return true;
// If we're set to only emulate, or have no CD drive, return here
if (onlyEmulate || _driveHandle == INVALID_HANDLE_VALUE)
return false;
// HACK: For now, just assume that track number is right
// That only works because ScummVM uses the wrong track number anyway
if (track >= (int)_tocEntries.size() - 1) {
warning("No such track %d", track);
return false;
}
// Bail if the track isn't an audio track
if ((_tocEntries[track].Control & 0x04) != 0) {
warning("Track %d is not audio", track);
return false;
}
// Create the AudioStream and play it
debug(1, "Playing CD track %d", track);
Audio::SeekableAudioStream *audioStream = new Win32AudioCDStream(_driveHandle, _tocEntries[track], _tocEntries[track + 1]);
Audio::Timestamp start = Audio::Timestamp(0, startFrame, 75);
Audio::Timestamp end = (duration == 0) ? audioStream->getLength() : Audio::Timestamp(0, startFrame + duration, 75);
// Fake emulation since we're really playing an AudioStream
_emulating = true;
_mixer->playStream(
soundType,
&_handle,
Audio::makeLoopingAudioStream(audioStream, start, end, (numLoops < 1) ? numLoops + 1 : numLoops),
-1,
_cd.volume,
_cd.balance,
DisposeAfterUse::YES,
true);
return true;
}
开发者ID:BenCastricum,项目名称:scummvm,代码行数:46,代码来源:win32-audiocd.cpp
示例6: play
void DefaultAudioCDManager::play(int track, int numLoops, int startFrame, int duration, bool only_emulate) {
if (numLoops != 0 || startFrame != 0) {
_cd.track = track;
_cd.numLoops = numLoops;
_cd.start = startFrame;
_cd.duration = duration;
// Try to load the track from a compressed data file, and if found, use
// that. If not found, attempt to start regular Audio CD playback of
// the requested track.
char trackName[2][16];
sprintf(trackName[0], "track%d", track);
sprintf(trackName[1], "track%02d", track);
Audio::SeekableAudioStream *stream = 0;
for (int i = 0; !stream && i < 2; ++i)
stream = Audio::SeekableAudioStream::openStreamFile(trackName[i]);
// Stop any currently playing emulated track
_mixer->stopHandle(_handle);
if (stream != 0) {
Audio::Timestamp start = Audio::Timestamp(0, startFrame, 75);
Audio::Timestamp end = duration ? Audio::Timestamp(0, startFrame + duration, 75) : stream->getLength();
/*
FIXME: Seems numLoops == 0 and numLoops == 1 both indicate a single repetition,
while all other positive numbers indicate precisely the number of desired
repetitions. Finally, -1 means infinitely many
*/
_emulating = true;
_mixer->playStream(Audio::Mixer::kMusicSoundType, &_handle,
Audio::makeLoopingAudioStream(stream, start, end, (numLoops < 1) ? numLoops + 1 : numLoops), -1, _cd.volume, _cd.balance);
} else {
_emulating = false;
if (!only_emulate)
playCD(track, numLoops, startFrame, duration);
}
}
}
开发者ID:AdamRi,项目名称:scummvm-pink,代码行数:40,代码来源:default-audiocd.cpp
示例7: getSeekableAudioStream
bool VideoDecoder::SeekableAudioTrack::seek(const Audio::Timestamp &time) {
Audio::SeekableAudioStream *stream = getSeekableAudioStream();
assert(stream);
return stream->seek(time);
}
开发者ID:86400,项目名称:scummvm,代码行数:5,代码来源:video_decoder.cpp
示例8: load
//.........这里部分代码省略.........
// Default sound type is 16-bit signed PCM, used in ITE
byte rawFlags = Audio::FLAG_16BITS;
if (_vm->getGameId() == GID_ITE) {
if (context->fileType() & GAME_MACBINARY) {
// ITE Mac has sound in the Mac snd format
resourceType = kSoundMacSND;
} else if (_vm->getFeatures() & GF_8BIT_UNSIGNED_PCM) { // older ITE demos
rawFlags |= Audio::FLAG_UNSIGNED;
rawFlags &= ~Audio::FLAG_16BITS;
} else if (!uncompressedSound && !scumm_stricmp(context->fileName(), "voicesd.rsc")) {
// Voice files in newer ITE demo versions are OKI ADPCM (VOX) encoded.
resourceType = kSoundVOX;
}
}
buffer.stream = 0;
// Check for LE sounds
if (!context->isBigEndian())
rawFlags |= Audio::FLAG_LITTLE_ENDIAN;
switch (resourceType) {
case kSoundPCM: {
// In ITE CD German, some voices are absent and contain just 5 zero bytes.
// Round down to an even number when the audio is 16-bit so makeRawStream
// will accept the data (needs to be an even size for 16-bit data).
// See bug #1256701
if ((soundResourceLength & 1) && (rawFlags & Audio::FLAG_16BITS))
soundResourceLength &= ~1;
Audio::SeekableAudioStream *audStream = Audio::makeRawStream(READ_STREAM(soundResourceLength), 22050, rawFlags);
buffer.stream = audStream;
buffer.streamLength = audStream->getLength();
result = true;
} break;
case kSoundVOX:
buffer.stream = Audio::makeADPCMStream(READ_STREAM(soundResourceLength), DisposeAfterUse::YES, soundResourceLength, Audio::kADPCMOki, 22050, 1);
buffer.streamLength = Audio::Timestamp(0, soundResourceLength * 2, buffer.stream->getRate());
result = true;
break;
case kSoundMacSND: {
Audio::SeekableAudioStream *audStream = Audio::makeMacSndStream(READ_STREAM(soundResourceLength), DisposeAfterUse::YES);
buffer.stream = audStream;
buffer.streamLength = audStream->getLength();
result = true;
} break;
case kSoundAIFF: {
Audio::SeekableAudioStream *audStream = Audio::makeAIFFStream(READ_STREAM(soundResourceLength), DisposeAfterUse::YES);
buffer.stream = audStream;
buffer.streamLength = audStream->getLength();
result = true;
} break;
case kSoundVOC: {
Audio::SeekableAudioStream *audStream = Audio::makeVOCStream(READ_STREAM(soundResourceLength), Audio::FLAG_UNSIGNED, DisposeAfterUse::YES);
buffer.stream = audStream;
buffer.streamLength = audStream->getLength();
result = true;
} break;
case kSoundWAV:
case kSoundShorten:
if (resourceType == kSoundWAV) {
result = Audio::loadWAVFromStream(readS, size, rate, rawFlags);
#ifdef ENABLE_SAGA2
开发者ID:alcherk,项目名称:scummvm,代码行数:67,代码来源:sndres.cpp
注:本文中的audio::SeekableAudioStream类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论