English 中文(简体)
A. 溪流的滚动波文档
原标题:Playing wave files from stream
  • 时间:2012-01-13 11:58:50
  •  标签:
  • c#
  • wav
  • wave

我必须设计一个具有声响的方案(来自WAV档案)。 我必须打.。 一旦完成,我就不得不改变该波卷宗的内容,并再次投入使用。 它就像一个不断变化的波浪。 我的想法是形成一个溪流,但问题在于何时才开始(使用ms)。 邮电和石头,WriteByte是一种错误,说“波头号是腐败的”。 我的法典如下:

MemoryStream ms = new MemoryStream(Sample1);
SoundPlayer myPlayer = new SoundPlayer(ms);
myPlayer.Play();                             //Wav file plays

for (int x = 0; x < 50; x++)
{
     ms.Position = 44 + x;
     ms.WriteByte(10);
}

myPlayer.Stop();
myPlayer.Play();                 //Header file corrupt

Is there maybe another way I can loop a stream, and change its contents while it is playing. For example, the stream is looping Sound1 and whenever a button is pressed, the stream s content is changed to play Sound2.

Thank you!

问题回答

我试图做你想要的同样的事情,也失败了。 看来,<代码>SoundPlayer将内容归入内部缓冲或直接保留音卡记忆。 当你第一次打电话到<代码>Load做上述事情。 将同一溪段移至同一类,也使我不满意,要求洛德强迫它重载内容。 我不知道他们如何执行这一类别,但我认为,你需要两个<代码>SoundPlayer的班级和(极有可能)的班级,你可以使用同一班次(尽管我认为你可以同时发挥这些班子的作用,不是因为共享的班子,而是因为其他问题)。 如果所生成的波浪不是大的,你也可以尝试使用一个单一<代码>SoundPlayer类别,并配有两个记忆流(我认为,如果你把不同的记忆流传到应当迫使其重载的类别)。 我没有测试任何拟议的解决办法。 只是记住,在将其通过到<代码>SoundPlayer类别(我怀疑这是头脑腐败问题的最初问题)之前,就已经缩小了溪流。 我对此进行了测试,但我认为它应当发挥作用。 更改<代码>Sample1的内容 至少根据我的知识,本应对记忆流产生任何影响。

如果上述情况失败,或者仅仅因为你像我这样表现不佳,我建议,如果能够进口或进口直接排放(部分管理直接X),并利用位于双赢的本地波功能和结构,实现你想要的东西。

回答含糊不清,但我没有时间彻底检验。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签