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


C++ AudioChunk::silence方法代码示例

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


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

示例1: pull

void Signal::pull(AudioChunk &chunk) const
{
	if (!data) {chunk.silence(); return;}

	if (data->trans) data->trans->pull(chunk);
	else data->stream->pull(chunk);
}
开发者ID:bradparks,项目名称:Plum,代码行数:7,代码来源:signal.cpp

示例2: pull

			virtual void pull(AudioChunk &chunk)
			{
				if (!chunk.length())   return;
				if (!valid || finished) {chunk.silence(); return;}

				int samples, have = 0, need = chunk.length();

				//Create pointers to 16-bit data
				short *d16[PG_MAX_CHANNELS];
				for (Uint32 i = 0; i < chunk.format().channels; ++i)
					d16[i] = (short*) chunk.start(i);

				while (true)
				{
					samples = stb_vorbis_get_samples_short(ogg,
						chunk.format().channels, d16, (need-have));

					if (samples < 0)
					{
						finished = true;
						//cout << " VORBIS ERROR" << endl;
						break;
					}
					if (samples == 0)
					{
						//File's end
						if (loop)
						{
							stb_vorbis_seek_start(ogg);
							continue;
						}
						else
						{
							finished = true;
							break;
						}
					}

					for (Uint32 i=0; i < chunk.format().channels; ++i)
						d16[i] += samples;
					have += samples;
					//if (have > need) cout << "VORBIS OVERDRAW" << endl;

					//std::cout << "OGG pull: " << have << "/" << need << std::endl;

					if (have >= need) break;
				}

				//Cutoff marker if necessary
				if (have < need) chunk.cutoff(have);

				//Upsample data to 24-bit Sint32s
				for (Uint32 i=0; i < chunk.format().channels; ++i)
				{
					Sint32 *start = chunk.start(i), *op = start + have;
					short *ip = d16[i];
					while (op!=start) {*(--op) = 256 * Sint32(*(--ip));}
				}
			}
开发者ID:eledot,项目名称:Plum,代码行数:59,代码来源:pg_codec_ogg_stb.cpp

示例3: pull

		virtual void pull(AudioChunk &chunk)
		{
			//This is possible at startup; race conditions are bad.
			if (!back) chunk.silence();

			//Shorthand.
			Uint32 frame = back->mikeFrame, length = back->mikeLength;
			const Sint32 *data = back->mikeData;

			//How much information is available?
			if (readFrame != frame) {readFrame = frame; prog = 0;}
			Uint32 want = chunk.length(), get = std::min(length-prog, want);

			//Read what we can from the buffer
			std::memcpy((void*)chunk.start(0), (const void*)(data+prog), 4*get);
			prog += get;

			//Fill your cup too full and it will spill...
			if (get < want)
				std::memset((void*)(chunk.start(0)+get), 0, 4*(want-get));
		}
开发者ID:bradparks,项目名称:Plum,代码行数:21,代码来源:scheduler.cpp


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