English 中文(简体)
• 强化声音效应(瓦夫)和向孤立的储存储蓄
原标题:Concatenating SoundEffects (wav) and saving to isolated storage

我有了一个艰难时刻,试图找到妥善解决这一地雷问题的办法。

我有3个声音效应,其标记是电话内容,所有方面都相同。

  • sound1.wav
  • sound2.wav
  • sound3.wav

我希望用户能够按照任何命令,或者无论他们喜欢多少次,选择编织物的游戏顺序,然后根据他们的选择,产生新的编织物,可以储存起来,从孤立的储存中回收。

So Thank You Walt Ritscher with the help so far, but as you will eventually see my coding skills are fragmented at best. What I m trying to convey in the following code is that a user will be prompted to select any/all of the sounds with a tap event, and his selections will determine what the new soundeffect will sound like (it s order, etc) However there is still a lot I don t know about and here is the code I came up with (while not on my coding computer);

//SO I have this master list of sounds to use, indicated in this block of code:
//sound1.wav, sound2.wav, sound3.wav
// my wav files are marked as resources
// get the wav file from the DLL
var streamInfo1 = Application.GetResourceStream(
    new Uri(sound1.wav, UriKind.Relative));
var streamInfo2 = Application.GetResourceStream(
    new Uri(sound2.wav, UriKind.Relative));
var streamInfo3 = Application.GetResourceStream(
    new Uri(sound3.wav, UriKind.Relative));

//With the above declarations made, I run each one as a stream as a variable.
var stream1 = streamInfo1.Stream as UnmanagedMemoryStream;
var stream2 = streamInfo2.Stream as UnmanagedMemoryStream;
var stream3 = streamInfo3.Stream as UnmanagedMemoryStream;



//The user can choose the sounds in any order, and repeat if desired.
//Let us assume the user chose in this order:
//sound1.wav + sound1.wav + sound2.wav +sound3.wav


for (int i = 0; i < 10; i++)
{
  var bytesA = new byte[stream1.Length];
  var bytesB = new byte[stream1.Length];
  var bytesC = new byte[stream2.Length];
}

// read the bytes from the stream into the array
stream1.Read(bytesA, 0, (int)stream1.Length);
stream2.Read(bytesB, 0, (int)stream1.Length);
stream3.Read(bytesC, 0, (int)stream2.Length);

var combined = new byte[bytesA.Length + bytesA.Length + bytesB.Length] + bytesC.Length]];

// copy the bytes into the combined array
System.Buffer.BlockCopy(bytesA, 0, combined, 0, bytesA.Length);
System.Buffer.BlockCopy(bytesB, 0, combined, bytesA.Length, bytesB.Length);

var outputStream = new MemoryStream();
outputStream.Write(combined, 0, combined.Length);

// substitute your own sample rate
var effect = new SoundEffect(
      buffer: outputStream.ToArray(),
      sampleRate: 48000,
      channels: AudioChannels.Mono);
var instance = effect.CreateInstance();
instance.Play();

// save stream to IsolatedStorage
最佳回答

基本上,你们必须从溪流中吸收tes,并融入新的沥青阵列。 然后将这一阵列储存在未经管理的MemoryStream。

   // my wav files are marked as resources
   // get the wav file from the DLL
   var streamInfo1 = Application.GetResourceStream(
        new Uri(loopWav, UriKind.Relative));
   var streamInfo2 = Application.GetResourceStream(
        new Uri(beatWav, UriKind.Relative));

    var stream1 = streamInfo1.Stream as UnmanagedMemoryStream;
    var stream2 = streamInfo2.Stream as UnmanagedMemoryStream;

    var bytesA = new byte[stream1.Length];
    var bytesB = new byte[stream2.Length];

    // read the bytes from the stream into the array
    stream1.Read(bytesA, 0, (int)stream1.Length);
    stream2.Read(bytesB, 0, (int)stream2.Length);

    var combined = new byte[bytesA.Length + bytesB.Length];

    // copy the bytes into the combined array
    System.Buffer.BlockCopy(bytesA, 0, combined, 0, bytesA.Length);
    System.Buffer.BlockCopy(bytesB, 0, combined, bytesA.Length, bytesB.Length);

    var outputStream = new MemoryStream();
    outputStream.Write(combined, 0, combined.Length);

    // substitute your own sample rate
    var effect = new SoundEffect(
          buffer: outputStream.ToArray(),
          sampleRate: 48000,
          channels: AudioChannels.Mono);


    var instance = effect.CreateInstance();
    instance.Play();

    // save stream to IsolatedStorage

I ve written more about WP7 audio for CoDe Magazine.

问题回答

暂无回答




相关问题
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. ...

热门标签