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


C++ WaveFile::Output2方法代码示例

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


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

示例1: main

int main(int argc, char *argv[])
{
#if defined(USE_MSXML)
	CoInitialize(0);
#endif

	const char *fname = "data.xml";
	if (argc > 1)
		fname = argv[1];

	InitSynthesizer();

	mix.SetChannels(2);
	mix.MasterVolume(1.0, 1.0);
	mix.ChannelOn(0, 1);
	mix.ChannelOn(1, 1);
	mix.ChannelVolume(0, 1.0);
	mix.ChannelVolume(1, 1.0);
#ifdef ADD_REVERB
	mix.SetFxChannels(1);
	mix.FxInit(0, &rvrb, 0.1);
	mix.FxLevel(0, 0, 0.2);
	mix.FxLevel(0, 1, 0.2);
	rvrb.InitReverb(1.0, 2.0);
#endif

	inMgr.Init(&mix, &wvf);

	inMgr.AddType("Tone", ToneInstr::ToneFactory, ToneInstr::ToneEventFactory);
	inMgr.AddType("ToneFM", ToneFM::ToneFMFactory, ToneFM::ToneFMEventFactory);
	inMgr.AddType("AddSynth", AddSynth::AddSynthFactory, AddSynth::AddSynthEventFactory);
	inMgr.AddType("SubSynth", SubSynth::SubSynthFactory, SubSynth::SubSynthEventFactory);
	inMgr.AddType("FMSynth", FMSynth::FMSynthFactory, FMSynth::FMSynthEventFactory);
	inMgr.AddType("MatrixSynth", MatrixSynth::MatrixSynthFactory, MatrixSynth::MatrixSynthEventFactory);
	inMgr.AddType("WFSynth", WFSynth::WFSynthFactory, WFSynth::WFSynthEventFactory);
	inMgr.AddType("Chuffer", Chuffer::ChufferFactory, Chuffer::ChufferEventFactory);
	inMgr.AddType("ModSynth", ModSynth::ModSynthFactory, ModSynth::ModSynthEventFactory);
	inMgr.AddType("BuzzSynth", BuzzSynth::InstrFactory, BuzzSynth::EventFactory);
	InstrMapEntry *ime = 0;
	while ((ime = inMgr.EnumType(ime)) != 0)
		ime->dumpTmplt = DestroyTemplate;

	XmlSynthDoc doc;
	XmlSynthElem rootNode(&doc);
	if (!doc.Open(fname, &rootNode))
	{
		printf("Cannot open file %s\n", fname);
		exit(1);
	}

	// Optional: use LoadInstrLib(inMgr, fname)
	// but we want to discover the inum values
	// and add sequences programaticaly...

	XmlSynthElem elem(&doc);
	XmlSynthElem *inst = rootNode.FirstChild(&elem);
	while (inst != NULL)
	{
		if (inst->TagMatch("instr"))
		{
			InstrConfig *ent = inMgr.LoadInstr(inst);
			if (strcmp(ent->instrType->GetType(), "WFSynth") == 0)
				AddEvent(ent->inum, 48, 1.0);
			else
				AddSequence(ent->inum, 0.25);
		}

		inst = elem.NextSibling(&elem);
	}
	doc.Close();

	if (wvf.OpenWaveFile("example10.wav", 2))
	{
		printf("Cannot open wavefile for output\n");
		exit(1);
	}
	seq.Sequence(inMgr);

#ifdef ADD_REVERB
	// drain the reverb...
	AmpValue lv;
	AmpValue rv;
	long n = synthParams.isampleRate;
	while (n-- > 0)
	{
		mix.Out(&lv, &rv);
		wvf.Output2(lv, rv);
	}
#endif

	wvf.CloseWaveFile();

	///////////////////////////////////////////////////////////////
	// Code to test instrument save functions...
#define TEST_SAVE_INSTR 1
#ifdef TEST_SAVE_INSTR
	doc.NewDoc("instrlib", &rootNode);
	InstrConfig *inc = inMgr.EnumInstr(0);
	while (inc)
	{
//.........这里部分代码省略.........
开发者ID:travisgoodspeed,项目名称:basicsynth,代码行数:101,代码来源:main.cpp


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