2023.11.17

This commit is contained in:
sshlien
2023-11-17 13:51:31 -05:00
parent 633e8d8848
commit f470c694ac
4 changed files with 17 additions and 10 deletions

View File

@@ -1,2 +1,2 @@
November 13 2023 November 17 2023

View File

@@ -1,4 +1,4 @@
.TH MIDISTATS 1 "1 November 2023" .TH MIDISTATS 1 "17 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

View File

@@ -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.39 November 08 2022 midicopy version 1.39 November 08 2022
midistats version 0.80 November 13 2023 midistats version 0.80 November 17 2023
24th January 2002 24th January 2002
Copyright James Allwright Copyright James Allwright

View File

@@ -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.80 November 13 2023 midistats" #define VERSION "0.80 November 17 2023 midistats"
#include <limits.h> #include <limits.h>
/* Microsoft Visual C++ Version 6.0 or higher */ /* Microsoft Visual C++ Version 6.0 or higher */
@@ -49,7 +49,7 @@ extern char* strchr();
#include "midifile.h" #include "midifile.h"
void initfuncs(); void initfuncs();
void stats_finish(); void stats_finish();
float histogram_entropy (int *histogram, int size); float histogram_perplexity (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 max(a,b) (( a > b ? a : b))
@@ -481,6 +481,7 @@ float threshold,peak;
int decimate; int decimate;
float tripletsCriterion8,tripletsCriterion4; float tripletsCriterion8,tripletsCriterion4;
int resolution = 12; int resolution = 12;
int nzeros;
threshold = 10.0/(float) division; threshold = 10.0/(float) division;
maxcount = 0; maxcount = 0;
ncounts = 0; ncounts = 0;
@@ -498,8 +499,13 @@ for (i = 0; i < division; i++) {
pulseDistribution[j] += pulseCounter[i]; pulseDistribution[j] += pulseCounter[i];
} }
/* count zeros */
nzeros = 0;
for (i=0;i<resolution;i++) if(pulseDistribution[i] == 0) nzeros++;
if (nzeros > 7 && pulseDistribution[resolution-1] == 0) printf("clean_quantization");
if (pulseDistribution[resolution-1] > 0.05) printf("dithered_quantization\n");
peak = (float) maxcount/ (float) ncounts; peak = (float) maxcount/ (float) ncounts;
/*printf("maxcount = %d ncounts = %d peak = %f threshold = %f\n",maxcount,ncounts,peak,threshold); */
if (peak < threshold) printf("unquantized\n"); if (peak < threshold) printf("unquantized\n");
tripletsCriterion8 = (float) pulseDistribution[8]/ (float) ncounts; tripletsCriterion8 = (float) pulseDistribution[8]/ (float) ncounts;
tripletsCriterion4 = (float) pulseDistribution[4]/ (float) ncounts; tripletsCriterion4 = (float) pulseDistribution[4]/ (float) ncounts;
@@ -574,7 +580,7 @@ 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_perplexity(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"); if (hasLyrics) printf("Lyrics\n");
@@ -584,8 +590,9 @@ printf("\n");
float histogram_entropy (int *histogram, int size) float histogram_perplexity (int *histogram, int size)
{ {
/* The perplexity is 2 to the power of the entropy */
int i; int i;
int total; int total;
float entropy; float entropy;
@@ -604,7 +611,7 @@ float histogram_entropy (int *histogram, int size)
entropy = entropy + e; entropy = entropy + e;
} }
//printf("\n"); //printf("\n");
return -entropy/log(2.0); return pow(2.0,-entropy/log(2.0));
} }
@@ -693,7 +700,7 @@ void stats_trackend()
if (channel_used_in_track[chan] > 0) trkdata.quietTime[chan] += (trkdata.npulses[0] - trkdata.lastNoteOff[chan]); if (channel_used_in_track[chan] > 0) trkdata.quietTime[chan] += (trkdata.npulses[0] - trkdata.lastNoteOff[chan]);
for (chan=0;chan<16;chan++) { /* 2023-09-13 */ for (chan=0;chan<16;chan++) { /* 2023-09-13 */
if (chan == 9 || channel_used_in_track[chan+1] == 0) continue; if (chan == 9 || channel_used_in_track[chan+1] == 0) continue;
trkdata.pitchEntropy[chan+1] = histogram_entropy(chanpitchhistogram +chan*12,11); trkdata.pitchEntropy[chan+1] = histogram_perplexity(chanpitchhistogram +chan*12,11);
} }
output_track_summary(); output_track_summary();
} }