Last active
June 5, 2025 15:00
-
-
Save adde88/09e51b527915684b39deb3e3b0fe54f4 to your computer and use it in GitHub Desktop.
Revisions
-
adde88 revised this gist
Jun 5, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ INPUT_FILE="$1" FREQ="$2" # Constants PIFMADV_PATH="/root/PiFmAdv/src" PIFM_EXEC="$PIFMADV_PATH/pi_fm_adv" TMP_WAV="/tmp/tmp_fm_audio.wav" -
adde88 revised this gist
Jun 5, 2025 . No changes.There are no files selected for viewing
-
adde88 revised this gist
Jun 5, 2025 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,8 @@ #!/bin/bash # Author: Andreas Nilsen # Email: [email protected] # Github: https://www.github.com/adde88 # License: GPL-3 # Check arguments if [[ $# -ne 2 ]]; then -
adde88 created this gist
Jun 5, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,63 @@ #!/bin/bash # Check arguments if [[ $# -ne 2 ]]; then echo "Usage: $0 /path/to/file.{wav,mp3,m4a,ogg} frequency_in_MHz" echo "Example: $0 /home/pi/audio.mp3 100.1" exit 1 fi # Input arguments INPUT_FILE="$1" FREQ="$2" # Constants PIFMADV_PATH="/root/PiFmAdv" PIFM_EXEC="$PIFMADV_PATH/pi_fm_adv" TMP_WAV="/tmp/tmp_fm_audio.wav" # Check PiFmAdv binary if [[ ! -f "$PIFM_EXEC" ]]; then echo "Error: pi_fm_adv not found at $PIFM_EXEC" exit 2 fi # Check input file if [[ ! -f "$INPUT_FILE" ]]; then echo "Error: Input file $INPUT_FILE not found" exit 3 fi # Get file extension (lowercased) EXT="${INPUT_FILE##*.}" EXT="${EXT,,}" # Handle file conversion if needed case "$EXT" in wav) FINAL_FILE="$INPUT_FILE" ;; mp3|m4a|ogg) echo "[*] Converting $EXT to WAV..." ffmpeg -y -i "$INPUT_FILE" -ar 22050 -ac 1 "$TMP_WAV" >/dev/null 2>&1 if [[ ! -f "$TMP_WAV" ]]; then echo "Error: Failed to convert to WAV." exit 4 fi FINAL_FILE="$TMP_WAV" ;; *) echo "Error: Unsupported file format '$EXT'. Supported: wav, mp3, m4a, ogg" exit 5 ;; esac # Transmit using PiFmAdv echo "[*] Starting FM transmission on $FREQ MHz..." sudo "$PIFM_EXEC" -f "$FREQ" -music "$FINAL_FILE" # Cleanup if temporary file was used if [[ "$FINAL_FILE" == "$TMP_WAV" ]]; then echo "[*] Cleaning up temporary WAV file..." rm -f "$TMP_WAV" fi