Skip to content

Commit c8a4319

Browse files
committed
Update README.md
clarify that the audio file reader works for WAV and MP3 files
1 parent 577d9d2 commit c8a4319

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ _"I'm sorry Dave... I'm afraid I can't do that"_
2121
* Source code for the WAV reading method is at the bottom of this page.
2222

2323
```cs
24-
(double[] audio, int sampleRate) = ReadWavMono("hal.wav");
24+
(double[] audio, int sampleRate) = ReadMono("hal.wav");
2525
var sg = new SpectrogramGenerator(sampleRate, fftSize: 4096, stepSize: 500, maxFreq: 3000);
2626
sg.Add(audio);
2727
sg.SaveImage("hal.png");
@@ -81,7 +81,7 @@ Review the source code of the demo application for additional details and consid
8181
This example demonstrates how to convert a MP3 file to a spectrogram image. A sample MP3 audio file in the [data folder](data) contains the audio track from Ken Barker's excellent piano performance of George Frideric Handel's Suite No. 5 in E major for harpsichord ([_The Harmonious Blacksmith_](https://en.wikipedia.org/wiki/The_Harmonious_Blacksmith)). This audio file is included [with permission](dev/Handel%20-%20Air%20and%20Variations.txt), and the [original video can be viewed on YouTube](https://www.youtube.com/watch?v=Mza-xqk770k).
8282

8383
```cs
84-
(double[] audio, int sampleRate) = ReadWavMono("song.wav");
84+
(double[] audio, int sampleRate) = ReadMono("song.wav");
8585

8686
int fftSize = 16384;
8787
int targetWidthPx = 3000;
@@ -117,7 +117,7 @@ Spectrogram (2993, 817)
117117
These examples demonstrate the identical spectrogram analyzed with a variety of different colormaps. Spectrogram colormaps can be changed by calling the `SetColormap()` method:
118118

119119
```cs
120-
(double[] audio, int sampleRate) = ReadWavMono("hal.wav");
120+
(double[] audio, int sampleRate) = ReadMono("hal.wav");
121121
var sg = new SpectrogramGenerator(sampleRate, fftSize: 8192, stepSize: 200, maxFreq: 3000);
122122
sg.Add(audio);
123123
sg.SetColormap(Colormap.Jet);
@@ -141,7 +141,7 @@ Cropped Linear Scale (0-3kHz) | Mel Scale (0-22 kHz)
141141
Amplitude perception in humans, like frequency perception, is logarithmic. Therefore, Mel spectrograms typically display log-transformed spectral power and are presented using Decibel units.
142142

143143
```cs
144-
(double[] audio, int sampleRate) = ReadWavMono("hal.wav");
144+
(double[] audio, int sampleRate) = ReadMono("hal.wav");
145145
var sg = new SpectrogramGenerator(sampleRate, fftSize: 4096, stepSize: 500, maxFreq: 3000);
146146
sg.Add(audio);
147147

@@ -153,12 +153,12 @@ Bitmap bmp = sg.GetBitmapMel(melSizePoints: 250);
153153
bmp.Save("halMel.png", ImageFormat.Png);
154154
```
155155

156-
## Read data from a WAV File
156+
## Read Data from an Audio File
157157

158158
You should customize your file-reading method to suit your specific application. I frequently use the NAudio package to read data from WAV and MP3 files. This function reads audio data from a mono WAV file and will be used for the examples on this page.
159159

160160
```cs
161-
(double[] audio, int sampleRate) ReadWavMono(string filePath, double multiplier = 16_000)
161+
(double[] audio, int sampleRate) ReadMono(string filePath, double multiplier = 16_000)
162162
{
163163
using var afr = new NAudio.Wave.AudioFileReader(filePath);
164164
int sampleRate = afr.WaveFormat.SampleRate;

0 commit comments

Comments
 (0)