3

I want to be able to stream a byte array directly to my speakers so that I can create sound.

I don't know where to begin.

Is it a DLL import or a memory stream?

What I want to send an array like this:

byte[] bt = {12,32,43,74,23,53,24,54,234,253,153};// example array
user1395152
  • 355
  • 2
  • 4
  • 13

1 Answers1

4

You can use the SoundPlayer and play from a MemoryStream:

byte[] bt = {12,32,43,74,23,53,24,54,234,253,153};// example array
var ms = new MemoryStream(bt);
var sound = new System.Media.SoundPlayer();
sound.Stream = ms;
sound.Play();
Jon B
  • 51,025
  • 31
  • 133
  • 161
  • I guess one needs to construct a WAV file as bytes for this? (+1) – usr Dec 24 '12 at 21:28
  • [Here](http://stackoverflow.com/questions/7152034/convert-short-to-stream-which-can-be-played-as-audio) is an example of a memory stream that automatically makes the WAV header for you. – Phylliida Jun 30 '16 at 19:56