本文整理汇总了C++中WavAudioFormat::createReaderFor方法的典型用法代码示例。如果您正苦于以下问题:C++ WavAudioFormat::createReaderFor方法的具体用法?C++ WavAudioFormat::createReaderFor怎么用?C++ WavAudioFormat::createReaderFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WavAudioFormat
的用法示例。
在下文中一共展示了WavAudioFormat::createReaderFor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialiseSynth
void BeatboxVoxAudioProcessor::initialiseSynth()
{
/** NOTE: - Quick and dirty sample drum synth for prototype
* In future versions will ideally allow user to select sample to use and
* also manage sample rate changes effect on loaded samples.
*/
WavAudioFormat wavFormat;
BigInteger kickNoteRange;
BigInteger snareNoteRange;
BigInteger hihatNoteRange;
BigInteger osdTestSoundNoteRange;
drumSynth.clearSounds();
osdTestSynth.clearSounds();
std::unique_ptr<AudioFormatReader> readerKickDrum(wavFormat.createReaderFor(new MemoryInputStream(BinaryData::bassdrum_wav,
BinaryData::bassdrum_wavSize,
false),
true));
std::unique_ptr<AudioFormatReader> readerSnareDrum(wavFormat.createReaderFor(new MemoryInputStream(BinaryData::snaredrum_wav,
BinaryData::snaredrum_wavSize,
false),
true));
std::unique_ptr<AudioFormatReader> readerHiHat(wavFormat.createReaderFor(new MemoryInputStream(BinaryData::hihat_wav,
BinaryData::hihat_wavSize,
false),
true));
std::unique_ptr<AudioFormatReader> readerOSDTestSound(wavFormat.createReaderFor(new MemoryInputStream(BinaryData::osdTestOne_wav,
BinaryData::osdTestOne_wavSize,
false),
true));
kickNoteRange.setBit(kickNoteNumber);
snareNoteRange.setBit(snareNoteNumber);
hihatNoteRange.setBit(hihatNoteNumber);
osdTestSoundNoteRange.setBit(osdTestSoundNoteNumber);
drumSynth.addSound(new SamplerSound("Kick Sound", *readerKickDrum, kickNoteRange, kickNoteNumber, 0.0, 0.0, 5.0));
drumSynth.addSound(new SamplerSound("Snare Sound", *readerSnareDrum, snareNoteRange, snareNoteNumber, 0.0, 0.0, 5.0));
drumSynth.addSound(new SamplerSound("HiHat Sound", *readerHiHat, hihatNoteRange, hihatNoteNumber, 0.0, 0.0, 5.0));
drumSynth.addVoice(new SamplerVoice());
drumSynth.addSound(new NoiseSound(noiseNoteNumber));
drumSynth.addVoice(new NoiseVoice());
osdTestSynth.addSound(new SamplerSound("OSD Test Sound", *readerOSDTestSound, osdTestSoundNoteRange, osdTestSoundNoteNumber, 0.0, 0.0, 5.0));
osdTestSynth.addVoice(new SamplerVoice());
}
示例2: setUsingSampledSound
void setUsingSampledSound()
{
synth.clearSounds();
WavAudioFormat wavFormat;
AudioFormatReader* audioReader
= wavFormat.createReaderFor (new MemoryInputStream (BinaryData::cello_wav,
BinaryData::cello_wavSize,
false),
true);
BitArray allNotes;
allNotes.setRange (0, 128, true);
synth.addSound (new SamplerSound (T("demo sound"),
*audioReader,
allNotes,
74, // root midi note
0.1, // attack time
0.1, // release time
10.0 // maximum sample length
));
delete audioReader;
}
示例3: file
SampleItem::SampleItem(const String &filename)
{
this->filename = filename;
File file(filename);
if (file.exists())
{
shortname = file.getFileNameWithoutExtension();
FileInputStream *stream = new FileInputStream(file);
WavAudioFormat format;
AudioFormatReader *reader = format.createReaderFor(stream, false);
if (reader)
{
formatName = reader->getFormatName();
sampleRate = (int)reader->sampleRate;
size = (int)reader->lengthInSamples;
bits = reader->bitsPerSample;
delete reader;
}
else
{
sampleRate = 0;
size = 0;
bits = 0;
}
}
playing = false;
}
示例4: setDrumSound
void DrumMachine::setDrumSound(String soundName, File sample) {
WavAudioFormat wavFormat;
ScopedPointer<AudioFormatReader> audioReader(wavFormat.createReaderFor(new FileInputStream(sample), true));
BigInteger notes;
notes.setRange(lastNote, 1, true);
synth.addSound(new SamplerSound(soundName, *audioReader, notes,
lastNote, // root midi note
0.0, // attack time
0.0, // release time
10.0 // maximum sample length
));
soundToNote.set(soundName, lastNote++);
}
示例5: update
void Sample::update(const String& path, WavAudioFormat& wavAudioFormat)
{
// Don't load a subsequent sample if a new sample is already loaded (but not yet played).
if (_readyToSwap)
return;
// Find audio file.
String fileName(path);
fileName = File::addTrailingSeparator(fileName);
fileName += _name;
fileName += EXT;
File file(fileName);
Time modification = file.getLastModificationTime();
if (modification <= _lastModification)
return;
// Read audio file. We only read the left channel, mono is good enough.
AudioFormatReader* reader = wavAudioFormat.createReaderFor(file.createInputStream(), true);
if (reader == nullptr)
return;
_lastModification = modification;
int64 start = reader->searchForLevel(0, reader->lengthInSamples, SAMPLE_START_THRESHOLD, 1.0, 0);
if (start == -1)
start = 0;
int count = (int)(reader->lengthInSamples - start);
_processor->writeTrace(String() << "Loading " << _name << " from disk (skip=" << start << ")");
int newIndex = !_bufferIndex;
AudioSampleBuffer* buffer = &(_buffers[newIndex]);
buffer->setSize(1, count);
reader->read(buffer, 0, count, start, true, false);
delete reader;
// Done.
_readyToSwap = true;
}
示例6: setUsingSampledSound
void setUsingSampledSound()
{
WavAudioFormat wavFormat;
ScopedPointer<AudioFormatReader> audioReader (wavFormat.createReaderFor (new MemoryInputStream (BinaryData::cello_wav,
BinaryData::cello_wavSize,
false),
true));
BigInteger allNotes;
allNotes.setRange (0, 128, true);
synth.clearSounds();
synth.addSound (new SamplerSound ("demo sound",
*audioReader,
allNotes,
74, // root midi note
0.1, // attack time
0.1, // release time
10.0 // maximum sample length
));
}
示例7: setAudio
void MainPanel::setAudio (int audioId)
{
AudioSource* source = 0;
switch (audioId)
{
case 1: // Amen Break
{
WavAudioFormat waf;
AudioFormatReader* afr = waf.createReaderFor (
new MemoryInputStream (binaries::amenbreakloop_wav,
binaries::amenbreakloop_wavSize,
false),
true);
source = new ResamplingReader (afr);
}
break;
case 2: // sine wave
{
ToneGeneratorAudioSource* tgas = new ToneGeneratorAudioSource ();
tgas->setFrequency (440);
tgas->setAmplitude (1.f);
source = tgas;
}
break;
case 3: // White Noise
source = new NoiseAudioSource;
break;
case 4: // Pink Noise
source = new NoiseAudioSource (true);
break;
};
MainApp::getInstance().getAudioOutput().setSource (source);
}