mirror of
https://github.com/sshlien/abcmidi.git
synced 2025-12-06 15:05:07 +00:00
Compare commits
2 Commits
2023.06.25
...
2023.08.31
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48c443fabd | ||
|
|
3f405a1aba |
11
doc/CHANGES
11
doc/CHANGES
@@ -15093,3 +15093,14 @@ be the acoutic piano (0) by default.
|
|||||||
If more than one channel with the same program color, they should be
|
If more than one channel with the same program color, they should be
|
||||||
added together.
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ the sum of the note durations in MIDI pulse units,
|
|||||||
the number of control parameter messages,
|
the number of control parameter messages,
|
||||||
the number of pressure messages.
|
the number of pressure messages.
|
||||||
and the number of distinct rhythm patterns for each channel
|
and the number of distinct rhythm patterns for each channel
|
||||||
|
the minimum pitch value
|
||||||
|
the maximum pitch value
|
||||||
|
the minimum note length in pulses
|
||||||
|
the maximum note length in pulses
|
||||||
.PP
|
.PP
|
||||||
After processing all the individual tracks, the following information
|
After processing all the individual tracks, the following information
|
||||||
applies to the entire midi file.
|
applies to the entire midi file.
|
||||||
|
|||||||
@@ -6,20 +6,18 @@ abc2abc version 2.20 February 07 2023
|
|||||||
yaps version 1.92 January 06 2023
|
yaps version 1.92 January 06 2023
|
||||||
abcmatch version 1.82 June 14 2022
|
abcmatch version 1.82 June 14 2022
|
||||||
midicopy version 1.38 May 06 2022
|
midicopy version 1.38 May 06 2022
|
||||||
midistats version 0.59 February 08 2023
|
midistats version 0.72 August 31 2023
|
||||||
|
|
||||||
24th January 2002
|
24th January 2002
|
||||||
|
|
||||||
Copyright James Allwright
|
Copyright James Allwright
|
||||||
J.R.Allwright@westminster.ac.uk
|
jamesallwright@yahoo.co.uk
|
||||||
University of Westminster,
|
University of Westminster,
|
||||||
London, UK
|
London, UK
|
||||||
|
|
||||||
October 2021
|
August 2023
|
||||||
|
Copyright Seymour Shlien
|
||||||
Seymour Shlien
|
|
||||||
Ottawa, Canada
|
|
||||||
fy733@ncf.ca
|
fy733@ncf.ca
|
||||||
|
Ottawa, Canada
|
||||||
|
|
||||||
This is free software. You may copy and re-distribute it under the terms of
|
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
|
the GNU General Public License version 2 or later, which is available from
|
||||||
|
|||||||
54
midistats.c
54
midistats.c
@@ -18,7 +18,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define VERSION "0.70 June 25 2023 midistats"
|
#define VERSION "0.72 August 31 2023 midistats"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
/* Microsoft Visual C++ Version 6.0 or higher */
|
/* Microsoft Visual C++ Version 6.0 or higher */
|
||||||
@@ -52,7 +52,8 @@ void stats_finish();
|
|||||||
float histogram_entropy (int *histogram, int size);
|
float histogram_entropy (int *histogram, int size);
|
||||||
void stats_noteoff(int chan,int pitch,int vol);
|
void stats_noteoff(int chan,int pitch,int vol);
|
||||||
void stats_eot ();
|
void stats_eot ();
|
||||||
|
#define max(a,b) (( a > b ? a : b))
|
||||||
|
#define min(a,b) (( a < b ? a : b))
|
||||||
|
|
||||||
/* Global variables and structures */
|
/* Global variables and structures */
|
||||||
|
|
||||||
@@ -114,8 +115,9 @@ int trackcount = 0;
|
|||||||
|
|
||||||
int notechan[2048],notechanvol[2048]; /*for linking on and off midi
|
int notechan[2048],notechanvol[2048]; /*for linking on and off midi
|
||||||
channel commands */
|
channel commands */
|
||||||
int last_tick[17]; /* for getting last pulse number in MIDI file */
|
int lastTick[2048]; /* for getting last pulse number for chan (0-15) and pitch (0-127) in MIDI file */
|
||||||
int last_on_tick[17]; /* for detecting chords [SS] 2019-08-02 */
|
int last_on_tick[17]; /* for detecting chords [SS] 2019-08-02 */
|
||||||
|
int channel_active[17]; /* for dealing with chords [SS] 2023-08-30 */
|
||||||
|
|
||||||
int histogram[256];
|
int histogram[256];
|
||||||
unsigned char drumpat[8000];
|
unsigned char drumpat[8000];
|
||||||
@@ -131,7 +133,11 @@ struct trkstat {
|
|||||||
int notecount[17];
|
int notecount[17];
|
||||||
int chordcount[17];
|
int chordcount[17];
|
||||||
int notemeanpitch[17];
|
int notemeanpitch[17];
|
||||||
|
int notepitchmin[17];
|
||||||
|
int notepitchmax[17];
|
||||||
int notelength[17];
|
int notelength[17];
|
||||||
|
int notelengthmin[17];
|
||||||
|
int notelengthmax[17];
|
||||||
int pitchbend[17];
|
int pitchbend[17];
|
||||||
int pressure[17];
|
int pressure[17];
|
||||||
int cntlparam[17];
|
int cntlparam[17];
|
||||||
@@ -584,9 +590,15 @@ for (i=1;i<17;i++) {
|
|||||||
printf("trkinfo ");
|
printf("trkinfo ");
|
||||||
printf("%d %d ",i,trkdata.program[i]); /* channel number and program*/
|
printf("%d %d ",i,trkdata.program[i]); /* channel number and program*/
|
||||||
printf("%d %d ",trkdata.notecount[i],trkdata.chordcount[i]);
|
printf("%d %d ",trkdata.notecount[i],trkdata.chordcount[i]);
|
||||||
printf("%d %d ",trkdata.notemeanpitch[i], trkdata.notelength[i]);
|
/* [SS] 2023-08-22 */
|
||||||
|
if (i != 10) printf("%d %d ",trkdata.notemeanpitch[i], trkdata.notelength[i]);
|
||||||
|
else
|
||||||
|
printf("-1 0 ");
|
||||||
printf("%d %d ",trkdata.cntlparam[i],trkdata.pressure[i]); /* [SS] 2022-03-04 */
|
printf("%d %d ",trkdata.cntlparam[i],trkdata.pressure[i]); /* [SS] 2022-03-04 */
|
||||||
printf("%d %d ",trkdata.quietTime[i],trkdata.rhythmpatterns[i]);
|
printf("%d %d ",trkdata.quietTime[i],trkdata.rhythmpatterns[i]);
|
||||||
|
if (i != 10) printf("%d %d %d %d",trkdata.notepitchmin[i], trkdata.notepitchmax[i] ,trkdata.notelengthmin[i], trkdata.notelengthmax[i]);
|
||||||
|
else
|
||||||
|
printf("-1 0");
|
||||||
trkdata.quietTime[i] = 0;
|
trkdata.quietTime[i] = 0;
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
@@ -604,13 +616,19 @@ void stats_trackstart()
|
|||||||
for (i=0;i<17;i++) {
|
for (i=0;i<17;i++) {
|
||||||
trkdata.notecount[i] = 0;
|
trkdata.notecount[i] = 0;
|
||||||
trkdata.notemeanpitch[i] = 0;
|
trkdata.notemeanpitch[i] = 0;
|
||||||
|
trkdata.notepitchmin[i] = 128;
|
||||||
|
trkdata.notepitchmax[i] = 0;
|
||||||
trkdata.notelength[i] = 0;
|
trkdata.notelength[i] = 0;
|
||||||
|
trkdata.notelengthmin[i] = 10000;
|
||||||
|
trkdata.notelengthmax[i] = 0;
|
||||||
trkdata.chordcount[i] = 0;
|
trkdata.chordcount[i] = 0;
|
||||||
trkdata.cntlparam[i] = 0;
|
trkdata.cntlparam[i] = 0;
|
||||||
last_tick[i] = -1;
|
|
||||||
last_on_tick[i] = -1;
|
last_on_tick[i] = -1;
|
||||||
|
channel_active[i] = 0;
|
||||||
}
|
}
|
||||||
printf("trk %d \n",tracknum);
|
printf("trk %d \n",tracknum);
|
||||||
|
|
||||||
|
for (i=0;i<2048;i++) lastTick[i] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void stats_trackend()
|
void stats_trackend()
|
||||||
@@ -628,7 +646,9 @@ int chan, pitch, vol;
|
|||||||
int delta;
|
int delta;
|
||||||
int barnum;
|
int barnum;
|
||||||
int unit;
|
int unit;
|
||||||
|
int dithermargin; /* [SS] 2023-08-22 */
|
||||||
|
|
||||||
|
dithermargin = unitDivision/2 - 1;
|
||||||
if (vol == 0) {
|
if (vol == 0) {
|
||||||
/* treat as noteoff */
|
/* treat as noteoff */
|
||||||
stats_noteoff(chan,pitch,vol);
|
stats_noteoff(chan,pitch,vol);
|
||||||
@@ -636,6 +656,8 @@ int chan, pitch, vol;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
trkdata.notemeanpitch[chan+1] += pitch;
|
trkdata.notemeanpitch[chan+1] += pitch;
|
||||||
|
trkdata.notepitchmax[chan+1] = max(trkdata.notepitchmax[chan+1],pitch);
|
||||||
|
trkdata.notepitchmin[chan+1] = min(trkdata.notepitchmin[chan+1],pitch);
|
||||||
if (trkdata.lastNoteOff[chan+1] >= 0) {
|
if (trkdata.lastNoteOff[chan+1] >= 0) {
|
||||||
delta = Mf_currtime - trkdata.lastNoteOff[chan+1];
|
delta = Mf_currtime - trkdata.lastNoteOff[chan+1];
|
||||||
trkdata.lastNoteOff[chan+1] = -1; /* in case of chord */
|
trkdata.lastNoteOff[chan+1] = -1; /* in case of chord */
|
||||||
@@ -646,7 +668,7 @@ int chan, pitch, vol;
|
|||||||
|
|
||||||
if (abs(Mf_currtime - last_on_tick[chan+1]) < chordthreshold) trkdata.chordcount[chan+1]++;
|
if (abs(Mf_currtime - last_on_tick[chan+1]) < chordthreshold) trkdata.chordcount[chan+1]++;
|
||||||
else trkdata.notecount[chan+1]++; /* [SS] 2019-08-02 */
|
else trkdata.notecount[chan+1]++; /* [SS] 2019-08-02 */
|
||||||
last_tick[chan+1] = Mf_currtime;
|
lastTick[chan*128 + pitch] = Mf_currtime;
|
||||||
last_on_tick[chan+1] = Mf_currtime; /* [SS] 2019-08-02 */
|
last_on_tick[chan+1] = Mf_currtime; /* [SS] 2019-08-02 */
|
||||||
/* last_on_tick not updated by stats_noteoff */
|
/* last_on_tick not updated by stats_noteoff */
|
||||||
|
|
||||||
@@ -661,7 +683,7 @@ int chan, pitch, vol;
|
|||||||
barChn[chan].rhythmPattern = 0;
|
barChn[chan].rhythmPattern = 0;
|
||||||
barChn[chan].activeBarNumber = barnum;
|
barChn[chan].activeBarNumber = barnum;
|
||||||
}
|
}
|
||||||
unit = (Mf_currtime % divisionsPerBar)/unitDivision;
|
unit = ((Mf_currtime+dithermargin) % divisionsPerBar)/unitDivision;
|
||||||
//printf("unit = %d pattern = %d \n",unit,barChn[chan].rhythmPattern);
|
//printf("unit = %d pattern = %d \n",unit,barChn[chan].rhythmPattern);
|
||||||
barChn[chan].rhythmPattern = barChn[chan].rhythmPattern |= (1UL << unit);
|
barChn[chan].rhythmPattern = barChn[chan].rhythmPattern |= (1UL << unit);
|
||||||
}
|
}
|
||||||
@@ -674,6 +696,8 @@ int chan, pitch, vol;
|
|||||||
else drumhistogram[pitch]++;
|
else drumhistogram[pitch]++;
|
||||||
}
|
}
|
||||||
else pitchhistogram[pitch % 12]++; /* [SS] 2017-11-01 */
|
else pitchhistogram[pitch % 12]++; /* [SS] 2017-11-01 */
|
||||||
|
|
||||||
|
channel_active[chan+1]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -686,17 +710,27 @@ void stats_noteoff(int chan,int pitch,int vol)
|
|||||||
int length;
|
int length;
|
||||||
int program;
|
int program;
|
||||||
/* ignore if there was no noteon */
|
/* ignore if there was no noteon */
|
||||||
if (last_tick[chan+1] == -1) return;
|
if (lastTick[chan*128+pitch] == -1) return;
|
||||||
length = Mf_currtime - last_tick[chan+1];
|
length = Mf_currtime - lastTick[chan*128+pitch];
|
||||||
trkdata.notelength[chan+1] += length;
|
trkdata.notelength[chan+1] += length;
|
||||||
|
trkdata.notelengthmax[chan+1] = max(trkdata.notelengthmax[chan+1],length);
|
||||||
|
trkdata.notelengthmin[chan+1] = min(trkdata.notelengthmin[chan+1],length);
|
||||||
|
if (length < 3) printf("chan = %d lasttick = %d currtime = %ld\n",chan,lastTick[chan*128+pitch],Mf_currtime);
|
||||||
trkdata.lastNoteOff[chan+1] = Mf_currtime; /* [SS] 2022.08.22 */
|
trkdata.lastNoteOff[chan+1] = Mf_currtime; /* [SS] 2022.08.22 */
|
||||||
chnactivity[chan+1] += length;
|
chnactivity[chan+1] += length;
|
||||||
if (chan == 9) return; /* drum channel */
|
if (chan == 9) return; /* drum channel */
|
||||||
pitchclass_activity[pitch % 12] += length;
|
pitchclass_activity[pitch % 12] += length;
|
||||||
program = trkdata.program[chan+1];
|
program = trkdata.program[chan+1];
|
||||||
progactivity[program] += length;
|
progactivity[program] += length;
|
||||||
|
channel_active[chan+1]--;
|
||||||
/* [SS] 2018-04-18 */
|
/* [SS] 2018-04-18 */
|
||||||
if(Mf_currtime > last_tick[chan+1]) last_tick[chan+1] = Mf_currtime;
|
if(Mf_currtime > lastTick[chan*128+pitch] && channel_active[chan+1] == 0)
|
||||||
|
lastTick[chan*128+pitch] = Mf_currtime; /* [SS] 2023.08.30 handle chords */
|
||||||
|
|
||||||
|
if (length > 4800) {
|
||||||
|
lastTick[chan*128+pitch] = Mf_currtime; /* handle stuck note [SS] 2023.08.30 */
|
||||||
|
channel_active[chan+1] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user