sc/cm-cm [ Modules ]

[ Top ] [ Modules ]

NAME

 cm

 File:             cm-cm.lsp

 Class Hierarchy:  none (no classes defined)

 Version:          1.0.12

 Project:          slippery chicken (algorithmic composition)

 Purpose:          Definition of common-music functions etc. that need to be
                   in the cm package 

 Author:           Michael Edwards: m@michael-edwards.org

 Creation date:    26th March 2020 (abstracted out of cm.lsp)

 $$ Last modified:  16:16:33 Thu Mar 11 2021 CET

 SVN ID: $Id$

cm/midi-file-high-low [ Functions ]

[ Top ] [ cm ] [ Functions ]

DATE

 30-Dec-2010

DESCRIPTION

 Print the highest and lowest pitch in a specified MIDI file as a MIDI note
 number. 

 NB: This is a Common Music function and as such must be called with the
     package qualifier cm:: if used within slippery chicken.

ARGUMENTS

 - The path (including the name) to the MIDI file.

OPTIONAL ARGUMENTS

 - An integer or NIL to indicate which track in the specified MIDI file is
   to be accessed. If NIL, all tracks will be accessed. NB: CM (and
   therefore slippery-chicken too) generates some MIDI files by writing each
   channel to a different track, so the "track" would seem synonymous with
   "channel" here. 

RETURN VALUE

 Two integer values (using the values function) that are the highest and
 lowest pitches in the specified MIDI file.

EXAMPLE

(cm::midi-file-high-low "/tmp/multi-ps.mid")

=> 72, 60

SYNOPSIS

(defun midi-file-high-low (file &optional track)

cm/midi-file-one-note [ Functions ]

[ Top ] [ cm ] [ Functions ]

DESCRIPTION

 Write all midi notes in the file out to a new one-channel file using the
 single pitch <note> and channel number <channel>.

ARGUMENTS

 - A string that is the file path, including file-name and extension.
 - A note-name symbol or MIDI-note integer that is the pitch to write.
 - An integer that is the channel to which the output should be written
   (1-based) 

OPTIONAL ARGUMENTS

 - An integer that is the an existing MIDI channel in the original file. If
   this argument is given, only notes on this channel of the original file
   will be written (1-based).

RETURN VALUE

 The path to the new file.

EXAMPLE

(cm::midi-file-one-note "/tmp/multi-ps.mid" 'c4 1)

SYNOPSIS

(defun midi-file-one-note (file note channel &optional old-channel)

cm/parse-midi-file [ Functions ]

[ Top ] [ cm ] [ Functions ]

DESCRIPTION

 Return Common Music MIDI events in the specified file as a list.

 NB: This is a Common Music function and as such must be called with the
     package qualifier cm:: if used within slippery chicken.

ARGUMENTS

 - The path (including the file name) to the MIDI file.

OPTIONAL ARGUMENTS

 - An integer or NIL to indicate which track in the specified MIDI file is
   to be accessed. If NIL, all tracks will be accessed. NB: CM (and
   therefore slippery-chicken too) generates some MIDI files by writing each
   channel to a different track, so the "track" would seem synonymous with
   "channel" here. 

RETURN VALUE

 The CM data for the MIDI events in the specified file, and the number of
 events. 

EXAMPLE

(cm::parse-midi-file "/tmp/multi-ps.mid")

=>
(#i(midi-tempo-change time 0.0 usecs 357142)
 #i(midi-time-signature time 0.0 numerator 2 denominator 4 clocks 24 32nds 8)
 #i(midi time 0.0 keynum 36 duration 0.357142 amplitude 0.09448819 channel 15)
 #i(midi-tempo-change time 0.0 usecs 357142)
 #i(midi-time-signature time 0.0 numerator 2 denominator 4 clocks 24 32nds 8)
 #i(midi-tempo-change time 0.0 usecs 357142)
 #i(midi time 0.178571 keynum 66 duration 0.178571 amplitude 0.09448819 channel 15)
 #i(midi time 0.357142 keynum 68 duration 0.0892855 amplitude 0.09448819 channel 15)
 #i(midi time 0.357142 keynum 40 duration 0.357142 amplitude 0.09448819 channel 15)
 #i(midi time 0.6249985 keynum 66 duration 0.0892855 amplitude 0.09448819 channel 15)
 #i(midi-time-signature time 0.714284 numerator 3 denominator 4 clocks 24 32nds 8)

SYNOPSIS

(defun parse-midi-file (file &optional track)