mirror of
https://github.com/sshlien/abcmidi.git
synced 2025-12-06 06:55:06 +00:00
2024.03.21
This commit is contained in:
@@ -6,7 +6,7 @@ abc2abc version 2.21 February 19 2024
|
|||||||
yaps version 1.93 February 19 2024
|
yaps version 1.93 February 19 2024
|
||||||
abcmatch version 1.83 February 19 2024
|
abcmatch version 1.83 February 19 2024
|
||||||
midicopy version 1.39 November 08 2022
|
midicopy version 1.39 November 08 2022
|
||||||
midistats version 0.90 March 18 2024
|
midistats version 0.91 March 21 2024
|
||||||
|
|
||||||
24th January 2002
|
24th January 2002
|
||||||
Copyright James Allwright
|
Copyright James Allwright
|
||||||
|
|||||||
28
midistats.c
28
midistats.c
@@ -17,7 +17,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.90 March 18 2024 midistats"
|
#define VERSION "0.91 March 21 2024 midistats"
|
||||||
|
|
||||||
/* midistrats.c is a descendent of midi2abc.c which was becoming to
|
/* midistrats.c is a descendent of midi2abc.c which was becoming to
|
||||||
large. The object of the program is to extract statistical characterisitic
|
large. The object of the program is to extract statistical characterisitic
|
||||||
@@ -65,6 +65,7 @@ extern char* strchr();
|
|||||||
void initfuncs();
|
void initfuncs();
|
||||||
void stats_finish();
|
void stats_finish();
|
||||||
float histogram_perplexity (int *histogram, int size);
|
float histogram_perplexity (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 ();
|
||||||
void keymatch();
|
void keymatch();
|
||||||
@@ -637,6 +638,7 @@ 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("\npitchperplexity %f\n",histogram_perplexity(pitchclass_activity,12));
|
printf("\npitchperplexity %f\n",histogram_perplexity(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");
|
if (hasLyrics) printf("Lyrics\n");
|
||||||
@@ -670,6 +672,30 @@ float histogram_perplexity (int *histogram, int size)
|
|||||||
return pow(2.0,-entropy/log(2.0));
|
return pow(2.0,-entropy/log(2.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float histogram_entropy (int *histogram, int size)
|
||||||
|
{
|
||||||
|
/* The perplexity is 2 to the power of the entropy */
|
||||||
|
int i;
|
||||||
|
int total;
|
||||||
|
float entropy;
|
||||||
|
float e,p;
|
||||||
|
total = 0;
|
||||||
|
entropy = 0.0;
|
||||||
|
//printf("\nhistogram_entropy of:");
|
||||||
|
for (i=0;i<size;i++) {
|
||||||
|
total += histogram[i];
|
||||||
|
//printf(" %d",histogram[i]);
|
||||||
|
}
|
||||||
|
for (i=0;i<size;i++) {
|
||||||
|
if (histogram[i] < 1) continue;
|
||||||
|
p = (float) histogram[i]/total;
|
||||||
|
e = p*log(p);
|
||||||
|
entropy = entropy + e;
|
||||||
|
}
|
||||||
|
//printf("\n");
|
||||||
|
return -entropy/log(2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user