当前位置: 首页>>代码示例>>C++>>正文


C++ WavAudioFormat::createReaderFor方法代码示例

本文整理汇总了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());
}
开发者ID:JoshMarler,项目名称:beatbox-vox,代码行数:54,代码来源:PluginProcessor.cpp

示例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;
    }
开发者ID:skhanker,项目名称:music-tutor,代码行数:26,代码来源:PHISynth.cpp

示例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;
}
开发者ID:imekon,项目名称:juce-samples,代码行数:29,代码来源:SampleItem.cpp

示例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++);
}
开发者ID:zenAudio,项目名称:beatmatic-xcode,代码行数:17,代码来源:drummachine.cpp

示例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;
}
开发者ID:bystam,项目名称:remote-goat,代码行数:41,代码来源:PluginProcessor.cpp

示例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
                                          ));
    }
开发者ID:AmirooR,项目名称:JUCE,代码行数:22,代码来源:AudioSynthesiserDemo.cpp

示例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);
}
开发者ID:EQ4,项目名称:DSPFiltersDemo,代码行数:39,代码来源:MainPanel.cpp


注:本文中的WavAudioFormat::createReaderFor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。