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


C++ AudioFormatReader::getFormatName方法代码示例

本文整理汇总了C++中AudioFormatReader::getFormatName方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioFormatReader::getFormatName方法的具体用法?C++ AudioFormatReader::getFormatName怎么用?C++ AudioFormatReader::getFormatName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AudioFormatReader的用法示例。


在下文中一共展示了AudioFormatReader::getFormatName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadSound

void JuceBoxAudioProcessor::loadSound()
{
	Logger::writeToLog("- loadSound().");
	synth.clearSounds();

	if (!sampleFile.existsAsFile()) {
		Logger::writeToLog("\"" + sampleFile.getFullPathName() + "\" doesn't exist.");
		return;
		}
	AudioFormatReader* reader = formatManager.createReaderFor(sampleFile);
	if (reader == NULL) {
		Logger::writeToLog("No reader for \"" + sampleFile.getFullPathName() + "\".");
		return;
		}
	Logger::writeToLog("Format: " + reader->getFormatName());
	Logger::writeToLog("Sample rate: " + String(reader->sampleRate));
	Logger::writeToLog("length: " + String(reader->lengthInSamples));
	Logger::writeToLog("numChannels: " + String(reader->numChannels));
	BigInteger notes;
	notes.setRange(0, 127, true);
	SamplerSound* sound =
		new SamplerSound(
			sampleFile.getFileNameWithoutExtension(),
			*reader,
			notes,
			72 /* C5 == middle C above A-440 */,
			0.0, 0.01,
			20.0 /* max time, hopefully 20s is enough for any sound */);
	synth.addSound(sound);
	delete reader;
}
开发者ID:stevefolta,项目名称:JuceBox,代码行数:31,代码来源:PluginProcessor.cpp

示例2: 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

示例3: AudioFormatReader

//==============================================================================
MemoryMappedAudioFormatReader::MemoryMappedAudioFormatReader (const File& f, const AudioFormatReader& reader,
                                                              int64 start, int64 length, int frameSize)
    : AudioFormatReader (nullptr, reader.getFormatName()), file (f),
      dataChunkStart (start), dataLength (length), bytesPerFrame (frameSize)
{
    sampleRate      = reader.sampleRate;
    bitsPerSample   = reader.bitsPerSample;
    lengthInSamples = reader.lengthInSamples;
    numChannels     = reader.numChannels;
    metadataValues  = reader.metadataValues;
    usesFloatingPointData = reader.usesFloatingPointData;
}
开发者ID:KimKomJohn,项目名称:JUCE,代码行数:13,代码来源:juce_AudioFormatReader.cpp

示例4: showResourceInfo

void CtrlrPanelResourceEditor::showResourceInfo(const int resourceIndex)
{
	CtrlrPanelResource *res = resources[resourceIndex];
	if (res == nullptr)
		return;

	String message;
	message << "Load time: " + res->getLoadedTime().toString(true, true, true, true) + "\n";
	message << "Data file: " + res->getFile().getFullPathName() + "\n";
	message << "Source file: " + res->getSourceFile().getFullPathName() + "\n";
	message << "Source hash: " + STR(res->getHashCode()) + "\n";
	AudioFormatReader *afr = res->asAudioFormat();
	if (afr)
	{
		message << "Type: Audio\n";
		message << "Format name: " << afr->getFormatName() << "\n";
		message << "Sample rate: " << afr->sampleRate << "\n";
		message << "Bits per sample: " << ((int)afr->bitsPerSample) << "\n";
		message << "Length in samples: " << afr->lengthInSamples << "\n";
		message << "Number of channels: " << ((int)afr->numChannels) << "\n";
		message << "Metadata:\n";
		message << "\t" << afr->metadataValues.getDescription();
	}


	if (!res->asImage().isNull())
	{
		Image i = res->asImage();
		message << "Type: Image\n";
		message << "Width: " + STR(i.getWidth()) + "\n";
		message << "Height: " + STR(i.getHeight()) + "\n";
		message << "Has alpha: " + STR(i.hasAlphaChannel()) + "\n";
	}

	DialogWindow::LaunchOptions lo;
	Label *l = new Label ("", message);
	l->setSize (400, 150);
	l->setJustificationType (Justification::centred);
	l->setFont (Font(12.0f));
	lo.content.set(l, true);
	lo.componentToCentreAround		= this;
	lo.dialogBackgroundColour		= Colours::whitesmoke;
	lo.dialogTitle					= "Resource information";
	lo.resizable					= true;
	lo.useBottomRightCornerResizer	= false;
	lo.useNativeTitleBar			= true;
	lo.launchAsync();
}
开发者ID:Srikrishna31,项目名称:ctrlr,代码行数:48,代码来源:CtrlrPanelResourceEditor.cpp


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