mirror of
https://github.com/sshlien/abcmidi.git
synced 2025-12-06 06:55:06 +00:00
2023.05.30
This commit is contained in:
@@ -15079,3 +15079,10 @@ 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.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -40,9 +40,12 @@ number of occurrences. eg.
|
||||
-ppatfor n
|
||||
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. Thus
|
||||
0 indicates that there was no note onset in that beat, 1 indicates
|
||||
a note onset in the beginning of the beat, 4 indicates a note onset
|
||||
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
|
||||
|
||||
44
midistats.c
44
midistats.c
@@ -18,7 +18,7 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#define VERSION "0.67 March 14 2023 midistats"
|
||||
#define VERSION "0.69 May 27 2023 midistats"
|
||||
|
||||
#include <limits.h>
|
||||
/* Microsoft Visual C++ Version 6.0 or higher */
|
||||
@@ -77,6 +77,7 @@ int percanalysis;
|
||||
int percpattern;
|
||||
int percpatternfor;
|
||||
int percpatternhist;
|
||||
int pitchclassanalysis;
|
||||
int corestats;
|
||||
int chordthreshold; /* number of maximum number of pulses separating note */
|
||||
int beatsPerBar = 4; /* 4/4 time */
|
||||
@@ -104,6 +105,7 @@ int percanalysis = 0;
|
||||
int percpattern = 0;
|
||||
int percpatternfor = 0;
|
||||
int percpatternhist = 0;
|
||||
int pitchclassanalysis = 0;
|
||||
int corestats = 0;
|
||||
|
||||
|
||||
@@ -982,6 +984,7 @@ for (i = 0; i <lastEvent; i++) {
|
||||
if (index >= 8000) {printf("index too large in drumpattern\n");
|
||||
break;
|
||||
}
|
||||
part = 3 - part; /* order the bits going left to right */
|
||||
drumpat[index] = drumpat[index] |= 1 << part;
|
||||
}
|
||||
}
|
||||
@@ -1009,11 +1012,25 @@ for (i = 0; i <lastEvent; i++) {
|
||||
}
|
||||
remainder = onset % division;
|
||||
part = remainder/quarter;
|
||||
part = 3 - part; /* order the bits from left to right */
|
||||
if (pitch == perc1) drumpat[index] = drumpat[index] |= 1 << part;
|
||||
else drumpat[index] = drumpat[index] |= 16 * (1 << part);
|
||||
}
|
||||
}
|
||||
|
||||
void pitchClassAnalysis () {
|
||||
int i;
|
||||
int channel;
|
||||
int pitch;
|
||||
for (i=0;i<12;i++) pitchclass_activity[i] = 0;
|
||||
for (i = 0; i < lastEvent; i++) {
|
||||
channel = midievents[i].channel;
|
||||
if (channel == 9) continue;
|
||||
pitch = midievents[i].pitch;
|
||||
pitchclass_activity[pitch % 12]++;
|
||||
}
|
||||
}
|
||||
|
||||
void output_perc_pattern (int i) {
|
||||
int left,right;
|
||||
left = i/16;
|
||||
@@ -1078,6 +1095,17 @@ if (bassmax && snaremax) {
|
||||
dualDrumPattern(bassindex,snareindex);
|
||||
}
|
||||
|
||||
void outputPitchClassHistogram() {
|
||||
int i;
|
||||
float activity;
|
||||
activity = 0;
|
||||
for (i=0;i<12;i++) activity += (float) pitchclass_activity[i];
|
||||
for (i=0;i<11;i++) printf("%5.3f,",pitchclass_activity[i]/activity);
|
||||
printf("%5.3f",pitchclass_activity[11]/activity);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void corestatsOutput() {
|
||||
printf("%d\t%d\t%d\n", division,lastEvent,lastBeat);
|
||||
@@ -1229,6 +1257,12 @@ int argc;
|
||||
stats = 0;
|
||||
}
|
||||
|
||||
arg = getarg("-pitchclass",argc,argv);
|
||||
if (arg != -1) {
|
||||
pitchclassanalysis = 1;
|
||||
stats = 0;
|
||||
}
|
||||
|
||||
|
||||
arg = getarg("-o",argc,argv);
|
||||
if ((arg != -1) && (arg < argc)) {
|
||||
@@ -1256,6 +1290,7 @@ int argc;
|
||||
printf(" -ppat\n");
|
||||
printf(" -ppatfor\n");
|
||||
printf(" -ppathist\n");
|
||||
printf(" -pitchclass\n");
|
||||
printf(" -ver version number\n");
|
||||
printf(" -d <number> debug parameter\n");
|
||||
printf(" The input filename is assumed to be any string not\n");
|
||||
@@ -1308,6 +1343,10 @@ if (percpatternhist) {
|
||||
drumPatternHistogram();
|
||||
}
|
||||
if (corestats) corestatsOutput();
|
||||
if (pitchclassanalysis) {
|
||||
pitchClassAnalysis();
|
||||
outputPitchClassHistogram();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1322,6 +1361,7 @@ int argc;
|
||||
arg = process_command_line_arguments(argc,argv);
|
||||
if(stats == 1) midistats(argc,argv);
|
||||
if(pulseanalysis || corestats || percanalysis ||\
|
||||
percpatternfor || percpattern || percpatternhist) loadEvents();
|
||||
percpatternfor || percpattern || percpatternhist ||\
|
||||
pitchclassanalysis) loadEvents();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user