mirror of
https://github.com/sshlien/abcmidi.git
synced 2025-12-06 06:55:06 +00:00
2023.11.01
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
.TH MIDISTATS 1 "25 October 2023"
|
.TH MIDISTATS 1 "1 November 2023"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
\fBmidistats\fP \- program to summarize the statistical properties of a midi file
|
\fBmidistats\fP \- program to summarize the statistical properties of a midi file
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@@ -96,6 +96,14 @@ runs through a collection of midi files, you can build a database
|
|||||||
of percussion descriptors. Some more details are given in the
|
of percussion descriptors. Some more details are given in the
|
||||||
file drums.txt which comes with this documentation.
|
file drums.txt which comes with this documentation.
|
||||||
|
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.B -corestats
|
||||||
|
.TP
|
||||||
|
.B -pulseanalysis
|
||||||
|
.TP
|
||||||
|
.B etc. (See drums.txt in doc folder.)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ 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.77 October 25 2023
|
midistats version 0.78 November 01 2023
|
||||||
|
|
||||||
24th January 2002
|
24th January 2002
|
||||||
Copyright James Allwright
|
Copyright James Allwright
|
||||||
|
|||||||
50
midistats.c
50
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.77 October 25 2023 midistats"
|
#define VERSION "0.78 October 30 2023 midistats"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
/* Microsoft Visual C++ Version 6.0 or higher */
|
/* Microsoft Visual C++ Version 6.0 or higher */
|
||||||
@@ -87,6 +87,7 @@ int divisionsPerBar;
|
|||||||
int unitDivision;
|
int unitDivision;
|
||||||
int maximumPulse;
|
int maximumPulse;
|
||||||
int lastBeat;
|
int lastBeat;
|
||||||
|
int hasLyrics = 0;
|
||||||
|
|
||||||
|
|
||||||
struct eventstruc {int onsetTime;
|
struct eventstruc {int onsetTime;
|
||||||
@@ -150,6 +151,7 @@ struct trkstat {
|
|||||||
int quietTime[17];
|
int quietTime[17];
|
||||||
int rhythmpatterns[17];
|
int rhythmpatterns[17];
|
||||||
int numberOfGaps[17];
|
int numberOfGaps[17];
|
||||||
|
int chanvol[17];
|
||||||
float pitchEntropy[17];
|
float pitchEntropy[17];
|
||||||
} trkdata;
|
} trkdata;
|
||||||
|
|
||||||
@@ -433,6 +435,7 @@ void stats_header (int format, int ntrks, int ldivision)
|
|||||||
trkdata.pressure[i] = 0; /* [SS] 2022-03-04 */
|
trkdata.pressure[i] = 0; /* [SS] 2022-03-04 */
|
||||||
trkdata.quietTime[i] = 0; /* [SS] 2022-08-22 */
|
trkdata.quietTime[i] = 0; /* [SS] 2022-08-22 */
|
||||||
trkdata.numberOfGaps[i] = 0; /* [SS] 2023-09-07 */
|
trkdata.numberOfGaps[i] = 0; /* [SS] 2023-09-07 */
|
||||||
|
trkdata.chanvol[i] = 0; /* [SS] 2023-10-30 */
|
||||||
progcolor[i] = 0;
|
progcolor[i] = 0;
|
||||||
channel2prog[i] = 0; /* [SS] 2023-06-25-8/
|
channel2prog[i] = 0; /* [SS] 2023-06-25-8/
|
||||||
channel2nnotes[i] = 0;
|
channel2nnotes[i] = 0;
|
||||||
@@ -469,6 +472,24 @@ int i;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* [SS] 2023-10-30 */
|
||||||
|
void stats_interpret_pulseCounter () {
|
||||||
|
int i;
|
||||||
|
int maxcount,ncounts;
|
||||||
|
int maxloc;
|
||||||
|
maxcount = 0;
|
||||||
|
ncounts = 0;
|
||||||
|
for (i=0;i<division;i++) {
|
||||||
|
ncounts = ncounts + pulseCounter[i];
|
||||||
|
if (pulseCounter[i] > maxcount) {
|
||||||
|
maxloc = i;
|
||||||
|
maxcount = pulseCounter[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//printf("maxpulse = %f at %d\n",(float) maxcount/(float) ncounts, maxloc);
|
||||||
|
if ((float) maxcount/(float) ncounts < 0.05) printf("unquantized\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void stats_finish()
|
void stats_finish()
|
||||||
{
|
{
|
||||||
@@ -526,6 +547,8 @@ if (npulses > 0)
|
|||||||
for (i=0;i<12;i++) printf("%5.2f ",pitchclass_activity[i]/(double) npulses);
|
for (i=0;i<12;i++) printf("%5.2f ",pitchclass_activity[i]/(double) npulses);
|
||||||
else
|
else
|
||||||
for (i=0;i<12;i++) printf("%5.2f ",(double) pitchclass_activity[i]);
|
for (i=0;i<12;i++) printf("%5.2f ",(double) pitchclass_activity[i]);
|
||||||
|
printf("\nchanvol "); /* [SS] 2023-10-30 */
|
||||||
|
for (i=1;i<17;i++) printf("%4d ",trkdata.chanvol[i]);
|
||||||
printf("\nchnact "); /* [SS] 2018-02-08 */
|
printf("\nchnact "); /* [SS] 2018-02-08 */
|
||||||
if (npulses > 0)
|
if (npulses > 0)
|
||||||
for (i=1;i<17;i++) printf("%5.3f ",chnactivity[i]/(double) trkdata.npulses[0]);
|
for (i=1;i<17;i++) printf("%5.3f ",chnactivity[i]/(double) trkdata.npulses[0]);
|
||||||
@@ -534,10 +557,11 @@ else
|
|||||||
printf("\ntrkact ");
|
printf("\ntrkact ");
|
||||||
lasttrack++;
|
lasttrack++;
|
||||||
for (i=0;i<lasttrack;i++) printf("% 5d",trkactivity[i]);
|
for (i=0;i<lasttrack;i++) printf("% 5d",trkactivity[i]);
|
||||||
|
|
||||||
printf("\npitchentropy %f\n",histogram_entropy(pitchclass_activity,12));
|
printf("\npitchentropy %f\n",histogram_entropy(pitchclass_activity,12));
|
||||||
printf("totalrhythmpatterns =%d\n",nrpatterns);
|
printf("totalrhythmpatterns =%d\n",nrpatterns);
|
||||||
printf("collisions = %d\n",ncollisions);
|
printf("collisions = %d\n",ncollisions);
|
||||||
|
if (hasLyrics) printf("Lyrics\n");
|
||||||
|
stats_interpret_pulseCounter ();
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -667,6 +691,7 @@ int chan, pitch, vol;
|
|||||||
int unit;
|
int unit;
|
||||||
int dithermargin; /* [SS] 2023-08-22 */
|
int dithermargin; /* [SS] 2023-08-22 */
|
||||||
int cpitch; /* [SS] 2023-09-13 */
|
int cpitch; /* [SS] 2023-09-13 */
|
||||||
|
int pulsePosition;
|
||||||
|
|
||||||
cpitch = pitch % 12;
|
cpitch = pitch % 12;
|
||||||
channel_used_in_track[chan+1]++; /* [SS] 2023-09-06 */
|
channel_used_in_track[chan+1]++; /* [SS] 2023-09-06 */
|
||||||
@@ -677,6 +702,11 @@ int chan, pitch, vol;
|
|||||||
trkdata.lastNoteOff[chan+1] = Mf_currtime; /* [SS] 2022.08.22 */
|
trkdata.lastNoteOff[chan+1] = Mf_currtime; /* [SS] 2022.08.22 */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
pulsePosition = Mf_currtime % division;
|
||||||
|
pulseCounter[pulsePosition]++;
|
||||||
|
if (pulsePosition >= 480) {printf("pulsePosition = %d too large\n",pulsePosition);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
trkdata.notemeanpitch[chan+1] += pitch;
|
trkdata.notemeanpitch[chan+1] += pitch;
|
||||||
trkdata.notepitchmax[chan+1] = max(trkdata.notepitchmax[chan+1],pitch);
|
trkdata.notepitchmax[chan+1] = max(trkdata.notepitchmax[chan+1],pitch);
|
||||||
trkdata.notepitchmin[chan+1] = min(trkdata.notepitchmin[chan+1],pitch);
|
trkdata.notepitchmin[chan+1] = min(trkdata.notepitchmin[chan+1],pitch);
|
||||||
@@ -797,11 +827,16 @@ if (trkdata.program[chan+1] != 0) {
|
|||||||
void stats_parameter(chan,control,value)
|
void stats_parameter(chan,control,value)
|
||||||
int chan, control, value;
|
int chan, control, value;
|
||||||
{
|
{
|
||||||
/*if (control == 7) {
|
int chan1;
|
||||||
printf("cntrlvolume %d %d \n",chan+1,value);
|
chan1 = chan+1;
|
||||||
}
|
/* There may be many volume commands for the same channel. Only
|
||||||
|
record the first one.
|
||||||
*/
|
*/
|
||||||
trkdata.cntlparam[chan+1]++;
|
if (control == 7 && trkdata.chanvol[chan1] == 0) {
|
||||||
|
/*printf("cntrlvolume %d %d \n",chan+1,value);*/
|
||||||
|
trkdata.chanvol[chan1] = value; /* [SS] 2023-10-30 */
|
||||||
|
}
|
||||||
|
trkdata.cntlparam[chan1]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -811,6 +846,7 @@ int type, leng;
|
|||||||
char *mess;
|
char *mess;
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
if (type == 5) hasLyrics = 1; /* [SS] 2023-10-30 */
|
||||||
if (type != 3) return;
|
if (type != 3) return;
|
||||||
printf("metatext %d ",type);
|
printf("metatext %d ",type);
|
||||||
for (i=0;i<leng;i++) printf("%c",mess[i]);
|
for (i=0;i<leng;i++) printf("%c",mess[i]);
|
||||||
@@ -903,6 +939,7 @@ void load_header (int format, int ntrks, int ldivision)
|
|||||||
|
|
||||||
void initfunc_for_stats()
|
void initfunc_for_stats()
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
Mf_error = stats_error; /* [SS] 2017-11-19 */
|
Mf_error = stats_error; /* [SS] 2017-11-19 */
|
||||||
Mf_header = stats_header;
|
Mf_header = stats_header;
|
||||||
Mf_trackstart = stats_trackstart;
|
Mf_trackstart = stats_trackstart;
|
||||||
@@ -925,6 +962,7 @@ void initfunc_for_stats()
|
|||||||
Mf_seqspecific = no_op3;
|
Mf_seqspecific = no_op3;
|
||||||
Mf_text = stats_metatext;
|
Mf_text = stats_metatext;
|
||||||
Mf_arbitrary = no_op2;
|
Mf_arbitrary = no_op2;
|
||||||
|
for (i = 0; i< 480; i++) pulseCounter[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user