Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WaveFormRendering.md Updated #1004

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Docs/WaveFormRendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,18 @@ myRendererSettings.TopHeight = 32;
myRendererSettings.BottomHeight = 32;
```

Now we just need to create our `WaveFormRenderer` and give it a path to the file we want to render, and pass in the peak provider we've chosen and the renderer settings:
Now we just need to create our `WaveFormRenderer` and create a instance of `AudioFileReader` for the file we want to render, and pass in the peak provider we've chosen and the renderer settings:

```C#
var renderer = new WaveFormRenderer();
var audioFilePath = "myfile.mp3";
var image = renderer.Render(audioFilePath, myPeakProvider, myRendererSettings);
var audioFileReader = new AudioFileReader("myfile.mp3");
var image = renderer.Render(audioFileReader, myPeakProvider, myRendererSettings);
```

Note: `AudioFileReader` is able to use one of the following audio filetypes `.mp3`, `.wav`, `aiff` and `aif`. If the audio filetype doesn't match on one of the listed befor, `AudioFileReader` will use the class `MediaFoundationReader` which mostly will end in a exception of `WaveFormRenderer` when try to render the wave.
Its recommended to convert the audio filetype to one of the listed types befor first.


With that image we could render it to a WinForms picturebox:
```c#
pictureBox1.Image = image;
Expand All @@ -76,4 +80,4 @@ Or we could save it to a PNG file which you'd want to do if you were rendering o
image.Save("myfile.png", ImageFormat.Png);
```