Skip to content

A sample code to play with my spectrogram algorithm via web service

License

Notifications You must be signed in to change notification settings

bohdantrotsenko/spectrum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spectrum

A sample code to play with my spectrogram algorithm via web service.

Please refer to https://www.trotsenko.com.ua for the description of my invention (spectrogram algorithm).

Prerequisites

Step 0. Build spectrogram -> pictures converter

go install github.com/bohdantrotsenko/spectrum@latest

Step 1. Prepare data

ffmpeg -i your_media_file -t 0:2:00 -ar 96000 -ac 1 -sample_fmt s16 temp.wav

where -t 0:2:00 limits duration to two minutes, -ar 96000 sets audio sampling rate to 96khz, -ac 1 makes it mono and -sample_fmt s16 sets format to 16bit PCM. You can also specify e.g. -ss 0:0:15 to set the starting point in your_media_file and use other options.

Step 2. Transform

curl --data-binary @temp.wav https://fra.trotsenko.com.ua/v1 > temp.bin

Note that the service logs IP addresses and hashsums of the payload.

temp.bin will have a sequence of arrays.

Each array contains 456 bytes, each corresponding to frequencies (24.499715, 24.856071, ..., 17485.357994)
(note the geometrical progression).
Each array corresponds to 40 samples of input as is normalized.

Step 3. See it on video

cat temp.bin | spectrum | ffmpeg -y -i temp.wav -r 30 -i - -c:v libx264 -pix_fmt yuv420p -crf 17 -vf fps=30 -profile:v high -level 4.2 -c:a aac temp.mp4

You can then open temp.mp4 for viewing.

About

A sample code to play with my spectrogram algorithm via web service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages