Created
December 31, 2025 18:11
-
-
Save richardanaya/d533a4c541a844a2f2d4c189652e1791 to your computer and use it in GitHub Desktop.
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 characters
| #!/bin/bash | |
| PIANOTEQ_EXEC="$HOME/piano/x86-64bit/Pianoteq 9" | |
| # Usage check | |
| if [ -z "$1" ]; then | |
| echo "Usage: play_piano <filename.mid> [\"Preset Name\"] [output_filename]" | |
| exit 1 | |
| fi | |
| MIDI_FILE="$1" | |
| PRESET_NAME="$2" | |
| OUTPUT_FILE="$3" | |
| if [ ! -f "$MIDI_FILE" ]; then | |
| echo "Error: File '$MIDI_FILE' not found." | |
| exit 1 | |
| fi | |
| # Base command | |
| CMD=("$PIANOTEQ_EXEC" "--headless" "--midi" "$MIDI_FILE") | |
| # Add preset if provided (Second Argument) | |
| if [ -n "$PRESET_NAME" ]; then | |
| CMD+=("--preset" "$PRESET_NAME") | |
| fi | |
| # Check for output file (Third Argument) | |
| if [ -n "$OUTPUT_FILE" ]; then | |
| # If a 3rd argument exists, we RENDER to file | |
| if [[ "$OUTPUT_FILE" == *.flac ]]; then | |
| CMD+=("--flac" "$OUTPUT_FILE") | |
| elif [[ "$OUTPUT_FILE" == *.mp3 ]]; then | |
| CMD+=("--mp3" "$OUTPUT_FILE") | |
| else | |
| CMD+=("--wav" "$OUTPUT_FILE") | |
| fi | |
| echo "Rendering to $OUTPUT_FILE..." | |
| else | |
| # If no 3rd argument, we PLAY live | |
| CMD+=("--play-and-quit") | |
| echo "Playing..." | |
| fi | |
| # Execute | |
| "${CMD[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment