Compare commits

..

23 Commits

Author SHA1 Message Date
sshlien
b9c48dc778 2024.02.11 2024-02-11 13:59:25 -05:00
sshlien
eac28d9489 2024-02-09 2024-02-09 16:24:21 -05:00
sshlien
135e70c5e6 2024.02.07 2024-02-07 21:41:42 -05:00
sshlien
79e7ac2d97 2024.01.15 2024-01-15 17:22:56 -05:00
sshlien
ad41b9b053 2024.01.02 2024-01-03 09:41:14 -05:00
sshlien
b3d18d9722 2023.12.28 2023-12-28 14:57:49 -05:00
sshlien
9fa917b1bd 2023.12.23 2023-12-23 17:06:59 -05:00
sshlien
0dd1e063ae 2023.12.17 2023-12-17 08:46:38 -05:00
sshlien
69c1f850cb 2023.11.26 2023-11-26 12:51:23 -05:00
sshlien
f470c694ac 2023.11.17 2023-11-17 13:51:31 -05:00
sshlien
633e8d8848 2023.11.14 2023-11-14 16:36:10 -05:00
sshlien
d93cb473dc 2023.11.08 2023-11-08 10:57:05 -05:00
sshlien
b24803bf86 2023.11.01 2023-10-31 07:17:35 -04:00
sshlien
4e0266179b 2023.10.25 2023-10-25 19:43:27 -04:00
sshlien
2bf0052eb8 2023.08.13 2023-09-13 17:36:44 -04:00
sshlien
1394cd96c5 2023.09.11 2023-09-11 09:41:32 -04:00
sshlien
8a2ec3a898 2023.09.06 2023-09-06 17:37:58 -04:00
sshlien
48c443fabd 2023.08.31 2023-08-31 08:44:52 -04:00
sshlien
3f405a1aba 2023.08.22 2023-08-22 09:21:59 -04:00
sshlien
5534c8935d 2023.06.25 2023-06-25 14:17:21 -04:00
Seymour Shlien
afe323d8b7 2023.05.30 2023-05-30 09:22:17 -04:00
Seymour Shlien
e49858809a 2023.03.15 2023-03-15 08:11:05 -04:00
Seymour Shlien
821240720d 2023.03.12 2023-03-12 13:45:41 -04:00
8 changed files with 1143 additions and 95 deletions

View File

@@ -1,3 +1,2 @@
February 08 2023
January 04 2024

View File

@@ -15079,3 +15079,151 @@ February 08 2023
midi2abc, mftext, midistats: modified midifile.c so that it indicates where
it encounters an unexpected byte in the input midi file.
March 24 2023
More functions for the percussion track was added to midistats.c to
support some future analysis.
June 25 2023
Midistats runs incorrectly if the midi file has no program channel
commands. When a program channel command is missing, the program should
be the acoutic piano (0) by default.
If more than one channel with the same program color, they should be
added together.
August 22 2023
Midistats improved the calculation of the number of rhythm patterns
in a channel (barChn[chan].rhythmPattern) by allowing for dithering
of note onset. Introduced dithermargin variable in function
stats_noteon(). In function, output_track_summary(), suppressed
notemeanpitch for percussion channel.
October 25 2023
Midistats returns track activity (note on/off) for every track.
November 1 2023
Midistats returns the control volume settings for every track,
identifies midi files whose note timings are not quantized.
November 2 2023
abc2midi bug: In the following example, not all notes are
tied correctly.
X:1
T: tied note
M: 2/4
L: 1/4
K: C
D2-|:D2 |[1CD-:|[2CD|
No fix is available.
November 8 2023
midistats: extended the size of arrays (midievents and pulsecounter) to
handle certain midi files. The function stats_interpret_pulseCounter()
can detect midi files containing triplets and nonquantized notes.
midicopy: extended to handle midi files with up to 150 tracks.
December 17 2023
midicopy: The midi program number is not set properly for a few the
midi files where the channel program numbers are set in a separate
track. Midicopy processes and copies the tracks sequentially, and
by the time it sees the channel program numbers in the separate
track it is already too late. It would be necessary to rewrite
midicopy so that it stores the entire midi file in memory prior to
copying it to disk.
midistats: Introducing a new option -nseqfor n where is a channel
number. See drums.txt for a description.
December 23 2023
abc2midi: gchord bug
The following example produces some strange artefacts on starting
the midi file for some players.
X:1
T:Test
L:1/8
Q:1/2=30
M:2/2
%%MIDI gchord GHIc
K:C
GAB | "C"c4 C4 |
Explanation: the output midi file plays a note with midi pitch 0
in the accompaniment channel. The problem originates in the dogchords()
function for switch case 'G': in genmidi.c. Since g_started is 0,
the second branch of the if statement is executed, but the pitch
value in gchordnotes[gchordnotes_size] contains 0.
Fix: the switch statement should not be executed since g_started is
0 (i.e. the gchord accompaniment does not start till "C" is encountered).
The switch statement is now bypassed when either g_started
or gchords is 0. The tests for gchords and g_started in all the
case statements were removed since they are unnecessary.
December 28 2023
abc2midi: tuplet bug
The following example produces the error
Warning in line-char 7-8 : Different length notes in tuple
X:1
T:Test
L:1/4
Q:1/4=90
M:3/4
K:D
(3[ac']/d'/[ac']/ [ac']/z/ |
Analysis: though it is legal to have different length notes (and
rests) in a tuple, this is clearly a bug. The message occurs in the
function event_note() in store.c. tnote_num and tnote_denom should
contain the expected length of the note in the tuple based on the
first note encountered in the tuple. The value of tnote_denom was
not adjusted by event_chordoff to compensate by the length value
specified at the end of the [ac'] chord, resulting in the problem.
January 15 2024
abc2midi bug: the following example produces a warning, but the
the output midi file is correct.
Warning in line-char 7-23 : Track 1 Bar 1 has 1 time units while the time signature has 2
X:1
T:Test trill
L:1/4
M:2/2
Q:1/2=60
K:Dm
!trill!"C"g4- | g2^c2 |
Analysis: this warning is produced by checkbar() in genmidi.c. This problem was
reported in this file on November 23 2012. The code for handling tied notes is
quite intricate and I do not understand it. I am hesitant in tampering with the code.

View File

@@ -1,4 +1,4 @@
.TH MIDISTATS 1 "9 December 2022"
.TH MIDISTATS 1 "11 February 2024"
.SH NAME
\fBmidistats\fP \- program to summarize the statistical properties of a midi file
.SH SYNOPSIS
@@ -26,7 +26,7 @@ applies.
program is followed by the channel number and the General Midi Program
number.
.PP
trkinfo is an array of 8 numbers which indicates the statistical properties
trkinfo is an array of 19 numbers which indicates the statistical properties
of the track of interest. The following data is given:
the channel number,
the first program assigned to this channel,
@@ -36,7 +36,18 @@ the sum of the MIDI pitches for all the notes,
the sum of the note durations in MIDI pulse units,
the number of control parameter messages,
the number of pressure messages.
and the number of distinct rhythm patterns for each channel
the number of distinct rhythm patterns for each channel
the number of pulses the channel was inactive
the minimum pitch value
the maximum pitch value
the minimum note length in pulses
the maximum note length in pulses
the number of gaps in the channel
the entropy of the pitch class histogram for that channel
the number of notes whose pitch were the same as the previous note
the number of notes whose pitch changed by less than 4 semitones
the number of notes whose pitch changed by 4 or more semitones
(In event of a chords the maximum pitches are compared.)
.PP
After processing all the individual tracks, the following information
applies to the entire midi file.
@@ -48,6 +59,8 @@ file.
.PP
pitchbends specifies the total number of pitchbends in this file.
.PP
pitchbendin c n specifies the number of pitchbends n in channel c
.PP
progs is a list of all the midi programs addressed
.PP
progsact the amount of activity for each of the above midi programs.
@@ -67,12 +80,30 @@ instruments.
pitches is a histogram for the 11 pitch classes (C, C#, D ...B)
that occur in the midi file.
.PP
key indicates the key of the music, the number of sharps (positive) or
flats (negative) in the key signature, and a measure of the confidence
in this key signature. The key was estimated from the above pitch histogram
by convolving with Craig Sapp's model. The peak of rmaj or rmin (below)
indicates the key. A correlation less than 0.4 indicates that the pitch
histogram does not follow the histogram of a major or minor scale.
(It may be the result of a mixture of two key signatures.)
.PP
rmaj the cross correlation coefficients with Craig Sapp's major key model
for each of the 11 keys (C, C#, D, ...,B).
.PP
rmaj the cross correlation coefficients with Craig Sapp's minor key model
for each of the 11 keys (C, C#, D, ...,B).
.PP
pitchact is a similar histogram but is weighted by the length of
the notes.
.PP
quietTime is used to compute the track/channel spread in midiexplorer.
It is computed by summing up all the midi pulses which occur
in gaps greater than 8 beats.
chanvol indicates the value of the control volume commands in the
midi file for each of the 16 channels. The maximum value is 127.
It scales the loudness of the notes (velocity) by its value.
.PP
chnact returns the amount of note activity in each channel.
.PP
trkact returns the number of notes in each track.
.PP
totalrhythmpatterns is the total number of bar rhythm patterns for
all channels except the percussion channel.
@@ -80,6 +111,211 @@ all channels except the percussion channel.
collisions. Midistats counts the bar rhythm patterns using a hashing
function. Presently collisions are ignored so occasionally two
distinct rhythm patterns are counted as one.
.PP
Midistats prints a number of arrays which may be useful in
determining where the music in the track is a melody line or
chordal rhythmic support. These arrays indicate the properties
for each of the 16 channels. (The percussion channel 9 contains
zeros.) In the case same channel occurs in several tracks, these
numbers are the totals for all track containing that channel.
Here is a description of these properties.
.PP
nnotes: the total number of notes in each channel
.br
nzeros: the number of notes whose previous note was the same pitch
.br
nsteps: the number of notes whose pitch difference with the previous
note was less than 4 semitones.
.br
njumps: the number of notes whose pitch difference with the previous
note was 4 or more semitones.
.br
rpats: the number of rhythmpatterns for each channels. This is a
duplication of data printed previously.
.br
pavg: the average pitch of all the notes for each channel.
.PP
In addition the midistats may return other codes that describe
other characteristics. They include
unquantized - the note onsets are not quantized
.br
triplets - 3 notes played in the time of 2 notes are present
.br
qnotes - the rhythm is basically simple
.br
clean_quantization - the note onsets are quantized into 1/4, 1/8, 1/16 time units.
.br
dithered_quantization - small variations in the quantized note onsets.
.br
Lyrics - lyrics are present in the meta data
.br
programcmd - there may be multiple program changes in a midi channel
.SH Advanced Percussion Analysis Tools
.PP
The MIDI file devotes channel 9 to the percussion instruments
and over 60 percussion instruments are defined in the MIDI
standard. Though there is a lot of diversity in the percussion
track, for most MIDI files only the first 10 or so percussion
instruments are important in defining the character of the track. The
program Midiexplorer has various tools for exposing the percussion
channel which are described in the documentation. The goal
here is to find the essential characteristics of the percussion
track which distinguishes the MIDI files. This is attempted
in the program midistats. Here is a short description.
.br
A number of experimental tools for analyzing the percussion channel
(track) were introduced into midistats and are accessible through
the runtime arguments. When these tools are used in a script which
runs through a collection of midi files, you can build a database
of percussion descriptors.
.SH OPTIONS
.PP
-corestats
.br
outputs a line with 5 numbers separated by tabs. eg
.br
1 8 384 4057 375
.br
It returns the number of tracks, the number of channels, the
number of divisions per quarter note beat (ppqn),
the number of note onsets in the midi file, and the maximum
number of quarter note beats in midi file.
.PP
-pulseanalysis
.br
counts the number of note onsets as a function of its onset time
relative to a beat, grouping them into 12 intervals and returns
the result as a discrete probability density function. Generally,
the distribution consists of a couple of peaks corresponding
to quarter notes or eigth notes. If the distribution is flat,
it indicates that the times of the note occurrences have not been
quantized into beats and fractions. Here is a sample output.
.br
0.349,0.000,0.000,0.160,0.000,0.000,0.298,0.000,0.000,0.191,0.000,0.000
.PP
-panal
.br
Counts the number of note onsets for each percussion instrument. The first
number is the code (pitch) of the instrument, the second number is the
number of occurrences. eg.
.br
35 337 37 16 38 432 39 208 40 231 42 1088 46 384 49 42 54 1104 57 5 70 1040 85 16
.PP
-ppatfor n
.br
where n is the code number of the percussion instrument. Each beat
is represented by a 4 bit number where the position of the on-bit
indicates the time in the beat when the drum onset occurs. The bits
are ordered from left to right (higher order bits to lower order
bits). This is the order of bits that you would expect in a
time series.
Thus 0 indicates that there was no note onset in that beat, 1 indicates
a note onset at the end of the beat, 4 indicates a note onset
in the middle of the beat, and etc. The function returns a string
of numbers ranging from 0 to 7 indicating the presence of note onsets
for the selected percussion instrument for the sequence of beats
in the midi file. Here is a truncated sample of the output.
.br
0 0 0 0 0 0 0 0 1 0 0 4 1 0 0 4 1 0 0 4 1 0 0 4 1 0 0 4 1 0 0 4 1 4 4 0
1 0 0 0 1 0 5 0 1 0 5 0 1 0 5 0 1 0 5 0 1 0 5 0 1 0 5 0 1 0 5 0 1 0 0 0
1 0 5 0 1 0 5 0 1 etc.
.br
One can see a repeating 4 beat pattern.
.PP
-ppat
.br
midistats attempts to find two percussion instruments in the midi file
which come closest to acting as the bass drum and snare drum.
If it is unsuccessful, it returns a message of its failue. Otherwise,
encodes the position of these drum onsets in a 8 bit byte for each
quarter note beat in the midi file. The lower (right) 4 bits encode the
bass drum and the higher (left) 4 bits encode the snare drum in the
same manner as described above for -ppatfor.
.br
0 0 0 0 0 0 0 0 0 0 33 145 33 145 33 145 33 145 33 145 33 145 33 145
.br
33 145 33 145 33 145 33 145 33 145 33 145 33 145 33 145 33 145 33 145
.br
33 145 33 145 33 145 33 145 33 145 33 and etc.
.PP
-ppathist
.br
computes and displays the histogram of the values that would appear
when running the -ppat. eg.
.br
bass 35 337
.br
snare 38 432
.br
1 (0.1) 64 32 (2.0) 8 33 (2.1) 136 144 (9.0) 8 145 (9.1) 136
.br
The bass percussion code, the number of onsets, and the snare
percussion code and the number of onsets are given in the
first two lines. In the next line the number of occurrences of
each value in the -ppat listing is given. The number in parentheses
splits the two 4-bit values with a period. Thus 33 = (2*16 + 1).
.PP
-pitchclass
.br
Returns the pitch class distribution for the entire midi file.
.PP
-nseqfor n
.br
Note sequence for channel n. This option produces a string of bytes
indicating the presence of a note in a time unit corresponding to
an eigth note. Thus each quarter note beat is represented by two
bytes. The pitch class is represented by the line number on the
staff, where 0 is C. Thus the notes on a scale are represented
by 7 numbers, and sharps and flats are ignored. The line number is
then converted to a bit position in the byte, so that the pitch
classes are represented by the numbers 1,2,4,8, and etc. A chord
of consisting of two note onsets would set two of the corresponding
bits. If we were to represent the full chromatic scale consisting
of 12 pitches, then we would require two-byte integers or
twice of much memory.
.br
Though the pitch resolution is not sufficient to distinguish
major or minor chords, it should be sufficient to be identify some
repeating patterns.
.PP
-nseq
.br
Same as above except it is applied to all channels except the
percussion channel.
.br
.PP
-nseqtokens
Returns the number of distinct sequence elements for each channel.
The channel number and number of distinct elements separated by
a comma is returned in a tab separated list for all active channels
except the percussion channel. Here is an example.
.br
2,3 3,4 4,11 5,6 6,3 7,3 8,6 9,3 11,2 12,1
.br
-ver (version number)
.SH AUTHOR
Seymour Shlien <fy733@ncf.ca>

View File

@@ -1,25 +1,23 @@
abcMIDI : abc <-> MIDI conversion utilities
midi2abc version 3.59 February 08 2023
abc2midi version 4.84 January 06 2023
abc2midi version 4.85 December 23 2023
abc2abc version 2.20 February 07 2023
yaps version 1.92 January 06 2023
abcmatch version 1.82 June 14 2022
midicopy version 1.38 May 06 2022
midistats version 0.59 February 08 2023
midicopy version 1.39 November 08 2022
midistats version 0.87 February 11 2024
24th January 2002
Copyright James Allwright
J.R.Allwright@westminster.ac.uk
jamesallwright@yahoo.co.uk
University of Westminster,
London, UK
October 2021
Seymour Shlien
Ottawa, Canada
August 2023
Copyright Seymour Shlien
fy733@ncf.ca
Ottawa, Canada
This is free software. You may copy and re-distribute it under the terms of
the GNU General Public License version 2 or later, which is available from

View File

@@ -2413,30 +2413,26 @@ int j;
if ((chordnum == -1) && (action == 'c')) {
action = 'f';
};
if (gchords) /* [SS] 2021-06-27 */
if (gchords && g_started) /* [SS] 2021-06-27 2023-12-29*/
switch (action) {
case 'z':
break;
case 'f':
if (g_started && gchords) {
/* do fundamental */
if (inversion == -1)
save_note(g_num*len, g_denom, basepitch+fun.base, 8192, fun.chan, fun.vel);
else
save_note(g_num*len, g_denom, inversion+fun.base, 8192, fun.chan, fun.vel);
};
break;
case 'b':
if (g_started && gchords) {
/* do fundamental */
if (inversion == -1) /* [SS] 2014-11-02 */
save_note(g_num*len, g_denom, basepitch+fun.base, 8192, fun.chan, fun.vel);
else
save_note(g_num*len, g_denom, inversion+fun.base, 8192, fun.chan, fun.vel);
}
/* break; * [SS] 2021-06-27 2021-09-15 */
/* There should not be a break here so the switch statement continues into the next case 'c' */
@@ -2450,28 +2446,28 @@ int j;
break;
case 'g':
if(gchordnotes_size>0 && g_started && gchords)
if(gchordnotes_size>0)
save_note(g_num*len, g_denom, gchordnotes[0], 8192, gchord.chan, gchord.vel);
else /* [SS] 2016-01-03 */
save_note(g_num*len, g_denom, gchordnotes[gchordnotes_size], 8192, gchord.chan, gchord.vel);
break;
case 'h':
if(gchordnotes_size >1 && g_started && gchords)
if(gchordnotes_size >1)
save_note(g_num*len, g_denom, gchordnotes[1], 8192, gchord.chan, gchord.vel);
else /* [SS] 2016-01-03 */
save_note(g_num*len, g_denom, gchordnotes[gchordnotes_size], 8192, gchord.chan, gchord.vel);
break;
case 'i':
if(gchordnotes_size >2 && g_started && gchords)
if(gchordnotes_size >2)
save_note(g_num*len, g_denom, gchordnotes[2], 8192, gchord.chan, gchord.vel);
else /* [SS] 2016-01-03 */
save_note(g_num*len, g_denom, gchordnotes[gchordnotes_size], 8192, gchord.chan, gchord.vel);
break;
case 'j':
if(gchordnotes_size >3 && g_started && gchords)
if(gchordnotes_size >3)
save_note(g_num*len, g_denom, gchordnotes[3], 8192, gchord.chan, gchord.vel);
else /* [SS] 2016-01-03 */
save_note(g_num*len, g_denom, gchordnotes[gchordnotes_size], 8192, gchord.chan, gchord.vel);
@@ -2479,34 +2475,34 @@ int j;
/* [SS] 2021-12-10 */
case 'k':
if(gchordnotes_size >4 && g_started && gchords)
if(gchordnotes_size >4)
save_note(g_num*len, g_denom, gchordnotes[4], 8192, gchord.chan, gchord.vel);
else /* [SS] 2016-01-03 */
save_note(g_num*len, g_denom, gchordnotes[gchordnotes_size], 8192, gchord.chan, gchord.vel);
case 'G':
if(gchordnotes_size>0 && g_started && gchords)
if(gchordnotes_size>0 )
save_note(g_num*len, g_denom, gchordnotes[0]-12, 8192, gchord.chan, gchord.vel);
else /* [SS] 2016-01-03 */
save_note(g_num*len, g_denom, gchordnotes[gchordnotes_size], 8192, gchord.chan, gchord.vel);
break;
case 'H':
if(gchordnotes_size >1 && g_started && gchords)
if(gchordnotes_size >1)
save_note(g_num*len, g_denom, gchordnotes[1]-12, 8192, gchord.chan, gchord.vel);
else /* [SS] 2016-01-03 */
save_note(g_num*len, g_denom, gchordnotes[gchordnotes_size], 8192, gchord.chan, gchord.vel);
break;
case 'I':
if(gchordnotes_size >2 && g_started && gchords)
if(gchordnotes_size >2)
save_note(g_num*len, g_denom, gchordnotes[2]-12, 8192, gchord.chan, gchord.vel);
else /* [SS] 2016-01-03 */
save_note(g_num*len, g_denom, gchordnotes[gchordnotes_size], 8192, gchord.chan, gchord.vel);
break;
case 'J':
if(gchordnotes_size >3 && g_started && gchords)
if(gchordnotes_size >3)
save_note(g_num*len, g_denom, gchordnotes[3]-12, 8192, gchord.chan, gchord.vel);
else /* [SS] 2016-01-03 */
save_note(g_num*len, g_denom, gchordnotes[gchordnotes_size], 8192, gchord.chan, gchord.vel);
@@ -2514,7 +2510,7 @@ int j;
/* [SS] 2021-12-10 */
case 'K':
if(gchordnotes_size >3 && g_started && gchords)
if(gchordnotes_size >3)
save_note(g_num*len, g_denom, gchordnotes[4]-12, 8192, gchord.chan, gchord.vel);
else /* [SS] 2016-01-03 */
save_note(g_num*len, g_denom, gchordnotes[gchordnotes_size], 8192, gchord.chan, gchord.vel);

View File

@@ -52,7 +52,7 @@
#define VERSION "1.38 May 05 2022 midicopy"
#define VERSION "1.39 November 07 2023 midicopy"
#include "midicopy.h"
#define NULLFUNC 0
#define NULL 0
@@ -96,8 +96,9 @@ long max_currtime = 0;
long Mf_currcopytime = 0L; /* time of last copied event */
char *trackdata = NULL;
long trackdata_length, trackdata_size;
char *trackstr[64]; /* [SS] 2017-10-20 2019-07-05*/
int trackstr_length[64]; /* [SS] 2017-10-20 2019-07-05*/
/* char *trackstr[64]; [SS] 2017-10-20 2019-07-05*/
char *trackstr[150]; /* [SS] 2023-11-07 */
int trackstr_length[150]; /* [SS] 2017-10-20 2019-07-05* 2023-11-07*/
int trkid = 0;
int activetrack;
int nochanmsg = 1;
@@ -1290,7 +1291,7 @@ build_new_midi_file (format, ntracks, division, fp)
get_tempo_info_from_track_1 ();
if (ntracks > 63) {printf("too many tracks\n"); exit(1); }
if (ntracks > 149) {printf("too many tracks\n"); exit(1); }
/* The rest of the file is a series of tracks */
for (i = 0; i < ntracks; i++)
@@ -1836,7 +1837,7 @@ main (int argc, char *argv[])
printf ("-ver version information\n");
printf ("-trks n1,n2,..(starting from 1)\n");
printf ("-xtrks n1,n2,.. (tracks to exclude)\n"); /* [SS] 2013-10-27 */
printf ("-xchns n1,n2,.. (tracks to exclude)\n"); /* [SS] 2017-12-06 */
printf ("-xchns n1,n2,.. (channels to exclude)\n"); /* [SS] 2022-11-12 */
printf ("-chns n1,n2,..(starting from 1)\n");
printf ("-from n (in midi ticks)\n");
printf ("-to n (in midi ticks)\n");

File diff suppressed because it is too large Load Diff

View File

@@ -186,7 +186,7 @@ int main()
*/
#define VERSION "4.84 January 20 2023 abc2midi"
#define VERSION "4.85 December 23 2023 abc2midi"
/* enables reading V: indication in header */
#define XTEN1 1