Skip to content

Instantly share code, notes, and snippets.

@woudsma
Last active April 11, 2023 21:27
Show Gist options
  • Select an option

  • Save woudsma/7d6899d7bff50dee28adfd3c4f9ef8f0 to your computer and use it in GitHub Desktop.

Select an option

Save woudsma/7d6899d7bff50dee28adfd3c4f9ef8f0 to your computer and use it in GitHub Desktop.

Revisions

  1. woudsma revised this gist Apr 11, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions jomox-alphabase-convert-samples-ffmpeg.md
    Original file line number Diff line number Diff line change
    @@ -9,11 +9,11 @@ This guide is for UNIX (MacOS or Linux) users, the process would be similar on W
    ffmpeg -i $INPUT -acodec pcm_s16le -ac 1 -ar 48000 $OUTPUT

    # -i: This parameter specifies the input file to be processed.
    # $INPUT: This is a placeholder for the actual input file name.
    # $INPUT: This is a placeholder for the actual input file path.
    # -acodec pcm_s16le: This parameter specifies the audio codec to be used for the output file. In this case, pcm_s16le is a codec that specifies uncompressed 16-bit audio data.
    # -ac 1: This parameter specifies the number of audio channels to be used in the output file. In this case, 1 specifies a mono audio output.
    # -ar 48000: This parameter specifies the audio sampling rate to be used in the output file. In this case, 48000 specifies a sampling rate of 48 kHz.
    # $OUTPUT: This is a placeholder for the actual output file name.
    # $OUTPUT: This is a placeholder for the actual output file path.
    ```

    ---
  2. woudsma revised this gist Apr 11, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion jomox-alphabase-convert-samples-ffmpeg.md
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ This guide is for UNIX (MacOS or Linux) users, the process would be similar on W
    ffmpeg -i $INPUT -acodec pcm_s16le -ac 1 -ar 48000 $OUTPUT

    # -i: This parameter specifies the input file to be processed.
    # $INPUT: This is a placeholder for the actual input file name. It is likely that this command is part of a script or batch file, and the $INPUT variable is being replaced with the actual input file name at runtime.
    # $INPUT: This is a placeholder for the actual input file name.
    # -acodec pcm_s16le: This parameter specifies the audio codec to be used for the output file. In this case, pcm_s16le is a codec that specifies uncompressed 16-bit audio data.
    # -ac 1: This parameter specifies the number of audio channels to be used in the output file. In this case, 1 specifies a mono audio output.
    # -ar 48000: This parameter specifies the audio sampling rate to be used in the output file. In this case, 48000 specifies a sampling rate of 48 kHz.
  3. woudsma revised this gist Apr 11, 2023. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions jomox-alphabase-convert-samples-ffmpeg.md
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,18 @@ Samples need to be 16 bit / 48kHz mono wav files.
    - [Zsh](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH) (run `zsh --version` to check if it's installed already)
    - [FFmpeg](https://ffmpeg.org/) (`brew install ffmpeg`)

    This guide is for UNIX (MacOS or Linux) users, the process would be similar on Windows machines with FFmpeg though. The required FFmpeg options are:
    ```sh
    ffmpeg -i $INPUT -acodec pcm_s16le -ac 1 -ar 48000 $OUTPUT

    # -i: This parameter specifies the input file to be processed.
    # $INPUT: This is a placeholder for the actual input file name. It is likely that this command is part of a script or batch file, and the $INPUT variable is being replaced with the actual input file name at runtime.
    # -acodec pcm_s16le: This parameter specifies the audio codec to be used for the output file. In this case, pcm_s16le is a codec that specifies uncompressed 16-bit audio data.
    # -ac 1: This parameter specifies the number of audio channels to be used in the output file. In this case, 1 specifies a mono audio output.
    # -ar 48000: This parameter specifies the audio sampling rate to be used in the output file. In this case, 48000 specifies a sampling rate of 48 kHz.
    # $OUTPUT: This is a placeholder for the actual output file name.
    ```

    ---

    Helper function to convert an audio sample to Alpha Base compatible format:
  4. woudsma revised this gist Apr 11, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion jomox-alphabase-convert-samples-ffmpeg.md
    Original file line number Diff line number Diff line change
    @@ -48,7 +48,7 @@ for f in ./**/*.wav; do mv "$f" ${f//-16bit-48khz-mono/}; done

    Or optionally do it all at once. I personally like the above approach because I want to check things before removing/renaming/etc.

    I strongly recommend to make a copy/backup of the folder with the wavs that you want to convert. This script removes the old wavs with the `rm $f` command.
    I strongly recommend to make a copy/backup of the folder with the wavs that you want to convert. This script removes the original wavs with the `rm $f` command after converting them.
    ```sh
    # Go to your samples directory
    cd /path/to/samples-directory
  5. woudsma revised this gist Apr 11, 2023. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions jomox-alphabase-convert-samples-ffmpeg.md
    Original file line number Diff line number Diff line change
    @@ -47,6 +47,8 @@ for f in ./**/*.wav; do mv "$f" ${f//-16bit-48khz-mono/}; done
    ---

    Or optionally do it all at once. I personally like the above approach because I want to check things before removing/renaming/etc.

    I strongly recommend to make a copy/backup of the folder with the wavs that you want to convert. This script removes the old wavs with the `rm $f` command.
    ```sh
    # Go to your samples directory
    cd /path/to/samples-directory
  6. woudsma revised this gist Apr 11, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion jomox-alphabase-convert-samples-ffmpeg.md
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ rm ./**/*.asd

    # Convert all wavs to 16 bit / 48kHz mono wavs
    for f in ./**/*.wav; do wav2mono16bit48khzwav $f; done
    # Or:
    # Or if you have both mp3 and wav files:
    for f in ./**/*.{mp3,wav}; do wav2mono16bit48khzwav $f; done

    # Remove the old (non-mono) wavs
  7. woudsma created this gist Dec 30, 2022.
    63 changes: 63 additions & 0 deletions jomox-alphabase-convert-samples-ffmpeg.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,63 @@
    # Converting samples before import to JoMoX Alpha Base
    Samples need to be 16 bit / 48kHz mono wav files.
    #### Requirements:
    - [Zsh](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH) (run `zsh --version` to check if it's installed already)
    - [FFmpeg](https://ffmpeg.org/) (`brew install ffmpeg`)

    ---

    Helper function to convert an audio sample to Alpha Base compatible format:

    > Tested only with `zsh`. Add this function to your `~/.zshrc` file for example (and reload with `source ~/.zshrc`)
    ```sh
    function wav2mono16bit48khzwav() {
    INPUT=$1
    OUTPUT=${INPUT:r}-16bit-48khz-mono.wav
    ffmpeg -i $INPUT -acodec pcm_s16le -ac 1 -ar 48000 $OUTPUT
    }
    ```
    Usage: `wav2mono16bit48khzwav /path/to/sample.wav`
    Creates a file next to the original file named `sample-16bit-48khz-mono.wav`
    _Should_ also work with mp3 and other audio files as input

    ---

    To convert an entire directory including subdirectories with samples:
    > Note that the Alpha Base doesn't support subdirectories, all samples must either be placed in the SD card root, or you can store samples in directories. Those can't have subdirectories, so samples should be placed max 1 level deep
    ```sh
    # Go to your samples directory
    cd /path/to/samples-directory

    # (optional) Remove any .asd Ableton files if you want
    rm ./**/*.asd

    # Convert all wavs to 16 bit / 48kHz mono wavs
    for f in ./**/*.wav; do wav2mono16bit48khzwav $f; done
    # Or:
    for f in ./**/*.{mp3,wav}; do wav2mono16bit48khzwav $f; done

    # Remove the old (non-mono) wavs
    for f in ./**/*.wav; do test "${f#*16bit-48khz-mono}" = "$f" && rm $f; done

    # Rename all samples by removing "-16bit-48khz-mono" from the filename
    for f in ./**/*.wav; do mv "$f" ${f//-16bit-48khz-mono/}; done
    ```

    ---

    Or optionally do it all at once. I personally like the above approach because I want to check things before removing/renaming/etc.
    ```sh
    # Go to your samples directory
    cd /path/to/samples-directory

    # Convert and replace all samples with 16 bit / 48kHz mono wavs
    for f in ./**/*.wav; do
    OUTPUT=${f:r}-16bit-48khz-mono.wav
    ffmpeg -i $f -acodec pcm_s16le -ac 1 -ar 48000 $OUTPUT && rm $f && mv $OUTPUT ${f:r}.wav
    done
    ```

    ---

    Now you can copy the samples to the SD card for use on the Alpha Base 👍