Creating a .wav File in C#

前端 未结 4 1306
青春惊慌失措
青春惊慌失措 2021-02-05 15:25

As an excuse to learn C#, I have been trying to code a simple project: creating audio files. To start, I want to make sure that I can write files that meet the WAVE format. I ha

4条回答
  •  感情败类
    2021-02-05 15:35

    The simplest way possible, you can simply change:

    wr.Write("RIFF");
    

    to:

    wr.Write("RIFF".ToArray());
    

    Writing a string in a binary file, it will include the length of the string so that it can be deserialized back into a string later. In this case you just want the four bytes to be written as four bytes, and converting it to a char array will do just that.

提交回复
热议问题