From 24590903b97bfb170b6ca336e5e25e82c20cfb8d Mon Sep 17 00:00:00 2001 From: Marcin Kondej Date: Mon, 23 Aug 2021 00:15:18 +0200 Subject: [PATCH] Readme updated, mp3 usage example added --- README.md | 26 +++++++++++++------------- fm_transmitter.cpp | 9 ++++----- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index aa1a458..245960e 100644 --- a/README.md +++ b/README.md @@ -46,21 +46,21 @@ echo "performance"| sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_govern ``` 3. Using lower FM broadcasting frequencies (below 93 MHz) when transmitting. ### Supported audio formats -You can transmitt uncompressed WAV (.wav) files directly or read audio data from stdin, eg.: -``` -sudo apt-get install sox -sox acoustic_guitar_duet.wav -r 22050 -c 1 -b 16 -t wav - | sudo ./fm_transmitter -f 100.6 - -``` -Please note only uncompressed WAV files are supported. If you receive the "corrupted data" error try converting the file, eg. by using FFMPEG: -``` -ffmpeg -i not_wav_song.webm -f wav -bitexact -acodec pcm_s16le -ar 22050 -ac 1 song.wav -sudo ./fm_transmitter -f 100.6 song.wav -``` -Or you could also use SoX: +You can transmitt uncompressed WAV (.wav) files directly or read audio data from stdin, eg. using MP3 file: ``` sudo apt-get install sox libsox-fmt-mp3 -sox my-audio.mp3 -r 22050 -c 1 -b 16 -t wav my-converted-audio.wav -sudo ./fm_transmitter -f 100.6 my-converted-audio.wav +sox example.mp3 -r 22050 -c 1 -b 16 -t wav - | sudo ./fm_transmitter -f 100.6 - +``` +Please note only uncompressed WAV files are supported. If you receive the "corrupted data" error try converting the file, eg. by using SoX: +``` +sudo apt-get install sox libsox-fmt-mp3 +sox example.mp3 -r 22050 -c 1 -b 16 -t wav converted-example.wav +sudo ./fm_transmitter -f 100.6 converted-example.wav +``` +Or you could also use FFMPEG: +``` +ffmpeg -i example.webm -f wav -bitexact -acodec pcm_s16le -ar 22050 -ac 1 converted-example.wav +sudo ./fm_transmitter -f 100.6 converted-example.wav ``` ### Microphone support In order to use a microphone live input use the `arecord` command, eg.: diff --git a/fm_transmitter.cpp b/fm_transmitter.cpp index d52c754..0c7231b 100644 --- a/fm_transmitter.cpp +++ b/fm_transmitter.cpp @@ -32,9 +32,8 @@ */ #include "transmitter.hpp" -#include -#include #include +#include #include bool stop = false; @@ -62,13 +61,13 @@ int main(int argc, char** argv) loop = true; break; case 'f': - frequency = ::atof(optarg); + frequency = std::stof(optarg); break; case 'd': - dmaChannel = ::atof(optarg); + dmaChannel = std::stoi(optarg); break; case 'b': - bandwidth = ::atof(optarg); + bandwidth = std::stof(optarg); break; case 'v': std::cout << EXECUTABLE << " version: " << VERSION << std::endl;