Skip to content

Commit 008b936

Browse files
committed
update documentation
1 parent eb191b4 commit 008b936

File tree

14 files changed

+122
-53
lines changed

14 files changed

+122
-53
lines changed

README.md

Lines changed: 63 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,78 +3,91 @@
33

44
![](data/mozart.jpg)
55

6-
**Quickstart:** The code below converts a WAV file to a spectrograph and saves it as an image. This code analyzed [Mozart's Piano Sonata No. 11 in A major](https://www.youtube.com/watch?v=aeEmGvm7kDk) to produce the picture above.
6+
## Quickstart
7+
8+
### Song to Spectrogram
9+
The code below converts a WAV file to a spectrograph and saves it as an image. This code analyzed [Mozart's Piano Sonata No. 11 in A major](https://www.youtube.com/watch?v=aeEmGvm7kDk) to produce the picture above.
710

811
```cs
9-
var spec = new Spectrogram.Spectrogram(fftSize: 2048);
10-
float[] values = Spectrogram.WavFile.Read("mozart.wav");
11-
spec.Add(values);
12-
spec.SaveImage("mozart.jpg");
12+
// load audio and process FFT
13+
var spec = new Spectrogram.Spectrogram(sampleRate: 8000, fftSize: 2048, step: 700);
14+
float[] values = Spectrogram.Tools.ReadWav("mozart.wav");
15+
spec.AddExtend(values);
16+
17+
// convert FFT to an image and save it
18+
Bitmap bmp = spec.GetBitmap(intensity: 2, freqHigh: 2500);
19+
spec.SaveBitmap(bmp, "mozart.jpg");
1320
```
1421

15-
## Realtime Audio Monitor
22+
### Human Voice
23+
This code analyzes audio from HAL's famous quote, "I'm sorry Dave, I'm afraid I can't do that". The output is can be rendered using different colormaps.
1624

17-
A demo program is included which monitors the sound card and continuously creates spectrograms from microphone input. It runs fast enough that the entire bitmap can be recreated on each render. This means brightness and color adjustments can be applied to the whole image, not just new parts.
25+
```cs
26+
// load audio and process FFT
27+
var spec = new Spectrogram.Spectrogram(sampleRate: 15000, fftSize: 4096, step: 400);
28+
float[] values = Spectrogram.Tools.ReadMp3("cant-do-that.mp3");
29+
spec.AddExtend(values);
30+
31+
// convert FFT to an image and save it
32+
Bitmap bmp = spec.GetBitmap(intensity: .2, freqHigh: 1000,
33+
colormap: Spectrogram.Colormap.grayscaleInverted);
34+
spec.SaveBitmap(bmp, "cant-do-that-grayscale-inverted.jpg");
35+
```
36+
colormap | sample output
37+
---|---
38+
**Grayscale Inverted** is used in many scientific publications when analyzing things like human voices and bird sounds|![](/data/cant-do-that-grayscale-inverted.jpg)
39+
**Grayscale** provides highest contrast output but does not benefit from color vision|![](/data/cant-do-that-grayscale.jpg)
40+
**Viridis** is the default colormap. It was specifically designed to represent 2D data in a way [ideally suited for human vision](https://www.youtube.com/watch?v=xAoljeRJ3lU).|![](/data/cant-do-that.jpg)
41+
**vdGreen** is the default colormap used for [QRSS-VD](https://github.com/swharden/QRSS-VD), a very old software project of mine. |![](/data/cant-do-that-green.jpg)
1842

19-
![](data/screenshot4.gif)
43+
### QRSS Analysis
2044

21-
This demo is available as a click-to-run EXE in [/dev/compiled-demos/](/dev/compiled-demos/)
45+
Experimenters with ultra-narrowband radio transmissions often use continuous wave frequency-shifting radio transmitters to send data at very low rates over very long distances using very little power. See [_What is QRSS?_](https://www.qsl.net/m0ayf/What-is-QRSS.html) for more information.
2246

23-
## QRSS Spectrograph
47+
The following code produces a QRSS spectrogram from an MP3 file. This program took less than 5 seconds to analyze 30 minutes of audio, producing the image below.
2448

25-
This library may be useful for displaying QRSS signals. I added some QRSS audio to the [/data](/data) folder to practice analyzing.
49+
```cs
50+
// load audio and process FFT
51+
var spec = new Spectrogram.Spectrogram(sampleRate: 8000, fftSize: 16384, step: 8000);
52+
float[] values = Spectrogram.Tools.ReadMp3("qrss-w4hbk.mp3");
53+
spec.AddExtend(values);
54+
55+
// convert FFT to an image and save it
56+
Bitmap bmp = spec.GetBitmap(intensity: 1.5, freqLow: 1100, freqHigh: 1500,
57+
showTicks: true, tickSpacingHz: 50, tickSpacingSec: 60);
58+
spec.SaveBitmap(bmp, "qrss.png");
59+
```
2660

27-
![](data/qrss.jpg)
2861

29-
The image above is from 10 minutes of audio processed by the program below. The entire program took less than 2 seconds to run.
62+
![](data/qrss.png)
3063

31-
```cs
32-
var spec = new Spectrogram.Spectrogram(
33-
fftSize: 8192,
34-
stepSize: 5000,
35-
intensity: 2,
36-
pixelLower: 1250,
37-
pixelUpper: 1500
38-
);
39-
40-
float[] values = Spectrogram.WavFile.Read("qrss.wav");
41-
spec.Add(values);
42-
spec.SaveImage("qrss.jpg");
43-
```
64+
## Demo Applications
65+
This project comes with a few interactive applications which serve as useful references for some of the ways this Spectrogram library can be used.
4466

45-
#### New to QRSS?
46-
* [What is QRSS?](https://www.qsl.net/m0ayf/What-is-QRSS.html)
47-
* [QRSS and you](http://www.ka7oei.com/qrss1.html)
48-
* [QRSS (slow CW)](https://sites.google.com/site/qrssinfo/QRSS-Slow-CW)
67+
### Download Demo EXE Files
68+
If you want to see what this library can do without downloading source code, click-to-run (EXE) demos are available in **[SpectrogramDemo.zip](/dev/compiled-demos/SpectrogramDemo.zip)**
4969

50-
## Waterfall
51-
This demo program was created to demonstrate Spectrogram and ScottPlot working together.
70+
### Audio Monitor
5271

53-
![](data/screenshot7.gif)
72+
A demo program is included which monitors the sound card and continuously creates spectrograms from microphone input. It runs fast enough that the entire bitmap can be recreated on each render. This means brightness and color adjustments can be applied to the whole image, not just new parts.
5473

55-
## Developer Notes
74+
![](data/screenshot4.gif)
5675

57-
![](/dev/graphics/theory-of-operation.png)
76+
### Waterfall with Graphs
77+
This demo program was created to demonstrate Spectrogram and ScottPlot working together.
5878

59-
### TODO:
60-
* ~~render horizontally or vertically~~
61-
* ~~create bitmaps in real time from audio input~~
62-
* ~~advanced color (LUT) options~~
63-
* ~~advanced intensity options (nonlinear scaling)~~
64-
* create a user control to display a spectrogram
65-
* create a user control to adjust spectrogram settings
66-
* ~~options for bitmap to scroll or to statically repeat~~
67-
* create a way to convert between frequency and pixel position
68-
* optional display of axis labels (scales with ticks)
79+
![](data/screenshot7.gif)
80+
81+
## Resources
6982

7083
### Similar Software
7184
* Argo ([website](http://digilander.libero.it/i2phd/argo/)) - closed-source QRSS viewer for Windows
7285
* SpectrumLab ([website](http://www.qsl.net/dl4yhf/spectra1.html)) - closed-source spectrum analyzer for Windows
7386
* QrssPIG ([GitLab](https://gitlab.com/hb9fxx/qrsspig)) - open-source spectrograph for Raspberry Pi (C++)
74-
* Lopora ([website](http://www.qsl.net/pa2ohh/11lop.htm)) - open-source spectrograph (Python 3)
87+
* Lopora ([GitHub](https://github.com/swharden/Lopora)) - open-source spectrograph (Python 3)
7588
* QRSS VD ([GitHub](https://github.com/swharden/QRSS-VD)) - open source spectrograph (Python 2)
7689

77-
### Spectrogram vs ~~Spectrograph~~
78-
* A spectrogram is an image
79-
* A spectrograph is a machine
80-
* Stop using the word spectrograph in software!
90+
### QRSS Information
91+
* [What is QRSS?](https://www.qsl.net/m0ayf/What-is-QRSS.html)
92+
* [QRSS and you](http://www.ka7oei.com/qrss1.html)
93+
* [QRSS (slow CW)](https://sites.google.com/site/qrssinfo/QRSS-Slow-CW)
13.8 KB
Loading

data/cant-do-that-grayscale.jpg

13.7 KB
Loading

data/cant-do-that-green.jpg

13.5 KB
Loading

data/cant-do-that.jpg

15.1 KB
Loading

data/cant-do-that.mp3

40.8 KB
Binary file not shown.

data/mozart.jpg

-588 KB
Loading

data/qrss.jpg

-45 KB
Binary file not shown.

data/qrss.png

1.98 MB
Loading
49.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)