Music Scripts

Scripts for editing music and sounds. music-scripts is a Debian package that contains scripts to manipulate .mid und .wav files. The package is for preparing and analyzing music-related experiments at the institute. The package and its contents can be used under the GPL2 license. If you have change requests, please send them via a ticket.

Permanent Link: topicbacklinks

Scripts

All scripts have a --help option with examples.

Expand all Collapse all

wavcue -- Extract WAV markings


The script writes the position of cue markings of WAV files in a certain format. The format is to 100% identical with the old wavcue.

Back to FAQ start


inscue -- Include WAV markings


inscue uses a file in a format like wavcue and includes it into cue sheets or multiple WAV files.

Back to FAQ start


mid2notes -- Convert MIDI to text


With this you can convert notes from a .mid= file into text. This will look like this for example:

user@host> mid2notes test.mid
5.18854166666667 0.130208333333333 73 0 60
5.61770833333333 0.507291666666667 73 0 70
6.15416666666667 0.158333333333333 74 0 57
6.28541666666667 0.314583333333333 73 0 70

Each line consists of
  • start time (onset) of the note in seconds in relation to the start of the .mid file,
  • duration of the tone in seconds,
  • pitch as MIDI code (C -2 is 0) (It is possible to get the output C-2 instead of 0 with the option -f text-pitch.),
  • patch number (= instrument number) of the note (0 means piano) and
  • volume of the tone.

You can either process these lines or manipulate them and convert them into a MIDI file again, with notes2mid.

Hint:
  • It is possible to let the first note start at 0s with --nogap.


Back to FAQ start


notes2mid -- Convert Text to MIDI


The program uses the same format like mid2notes. Because each note has an absolute start time, the lines do not need to be sorted.

Here is an example:

user@host> mid2notes song.mid > song.txt
user@host> notes2mid song.txt -o song2.mid

After these commands the files song.mid and song2.mid should sound exactly the same.

Hint:
  • It is possible to let the first note start at 0s with --nogap.


Back to FAQ start


mid2wav -- Convert MIDI to WAV (MIDI renderer)


The program uses the software synthesizer Timidity++. Example:

user@host > mid2wav myfile.mid

or like this:

user@host > cd /thousands/of/songs
user@host > for f in *.mid; do mid2wav "$i";done

Hints:
  • It is possible to add a cue marking to the beginning of each note in the .wav file with the option -n.
  • The format of the cue marking can be manipulated with the -f option.
  • For the cue marking can include a minimum volume for notes ( Velocity ). Quieter notes do not get cue markings. Use the -l option.
  • It is possible to use a custom configuration file for Timidity with --config. With this you can set a different sound font (Patch set), for example like this:
    user@host > mid2wav --config /etc/timidity/freepats.cfg
    With this line you choose the package freepats as source for patches, which is useful for using high-quality piano sounds for example.


Back to FAQ start


middump -- Everything about MIDI files


This script shows all events of a MIDI file, like the start of a note. The format can be easily processed with Perl or other shell scripts.

Hint:
  • The option --absolute forces middump to use absolute times in MIDI time calculation instead of outputting delta value.


Back to FAQ start


wavinfo -- Format information about WAV files


wavinfo displays information like sample rate, length in seconds or number of bits per sample about .wav files.

Back to FAQ start


wav2erts -- Generate ERTS-suitable .voc files


The program calls sox to turn a .wav into .voc files. However, numerous pitfalls are avoided. The .voc file should work fine on ERTS.

Back to FAQ start


wavcuesplit -- Split .wav files


This program can split .wav files into smaller files by their cue markings.

user@host > ==wavcuesplit

Principle: Set cue markings in a program like rezound at the beginning and end of a piece that you want to crop. The first name of the marking is used for the file name. The large .wav file will be saved with the markings and subsequently edited with wavsplit to get many small .wav files.

Hints:
  • It is possible to append a piece of silence to all cut-out sections for the front and back. The parameters -b and -a can be used to specify the exact length in ms for the front and back.
  • Use wavcuesplit with --numerical=PREFIX= to name the file yourself. The filenames have the format PREFIX[number].wav, where the number starts with 1 and is incremented. Examples:
    Create WAV files that names begin with test:
    user@host > wavcuesplit --numerical test big_wav.wav
    In this example WAV files will be created, that are named with [Nummer].wav (starting with 1):
    user@host > wavcuesplit --numerical "" big_wav.wav


Back to FAQ start


insfreq -- Add sinus tones to cue markings


(Customization)

Tones with a given frequency can be included into a .wav file using this script. The tones are assigned to a separate channel. The source material is a .wav file, that contains cue markings and a special data file that defines at which cue marker which pitch is to be inserted.

Example:

user@host> wavinfo channels test.wav
1
user@host> wavcue test.wav
  0.000000      0.000000 test     none     test.wav
  8.007279      0.000000 foo      none     test.wav
  14.142698     0.000000 bar      none     test.wav
user@host> cat freq.txt
foo - 1000
bar - 4000
user@host> insfreq --length 10p --level 50 test.wav < freq.txt
I: Initializing signal playground... (779257 samples)
I: writing 2 notes...
I: merging tracks...
user@host> wavinfo channels test.wav
2

Hints:
  • The length of tones can be controlled with --length. Valid inputs are the number of milliseconds, for example 10ms, or the number of periods, for example 10p, the tone should be audible.


Back to FAQ start


mid2mid -- Manipulate .mid files


Certain properties of .mid files can be changed with this script. The following is possible:
  • For experiments useless MIDI events can be removed, like:
    • Lyric events
    • Text events
    • Change in tempo after the last note
  • MIDI file types can be can be transferred into each other. mid2mid can read MIDI file types zero to two and can output 0 (default) and 1.

Hint:
  • Type 2 MIDI files cannot be edited, they are always converted into type 0 or 1.
  • With --select [track number] the track to be used for the output file can be selected for a type 2 MIDI file. The default is track 0.


Back to FAQ start


cueclean -- Remove cue markers


To clean a WAV file of all cue markers:

user@host > cueclean wav_mit_cues.wav wav_ohne_cues.wav

To convert large amounts of files:

user@host > for i in cued_wavs/*.wav;do cueclean "$i" cueless_wavs;done

This command line processes all WAV files in the cued_wavs folder and saves them with the same filename in the folder cueless_wavs.

Limitations:
  • The script reads the .wav files completely into the working memory, so it only works if the .wav files fit into the memory.


Back to FAQ start


This topic: EDV/FuerUser > WebHome > SoftwareLinux > MusicScripts
Topic revision: 05 Aug 2024, wherbst
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback