1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/*
ZynAddSubFX - a software synthesizer
Dump.C - It dumps the notes to a text file
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License (version 2) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdlib.h>
#include <time.h>
#include "Util.h"
#include "Dump.h"
Dump dump;
Dump::Dump(){
file=NULL;
tick=0;
k=0;
keyspressed=0;
};
Dump::~Dump(){
if (file!=NULL) {
double duration=(double)tick*(double) SOUND_BUFFER_SIZE/(double) SAMPLE_RATE;
fprintf(file,"\n# statistics: duration = %d seconds; keyspressed = %d\n\n\n\n",(int) duration,keyspressed);
fclose(file);
};
};
void Dump::startnow(){
if (file!=NULL) return;//the file is already open
if (config.cfg.DumpNotesToFile!=0){
if (config.cfg.DumpAppend!=0) file=fopen(config.cfg.DumpFile,"a");
else file=fopen(config.cfg.DumpFile,"w");
if (file==NULL) return;
if (config.cfg.DumpAppend!=0) fprintf(file,"%s","#************************************\n");
time_t tm=time(NULL);
fprintf(file,"#date/time = %s\n",ctime(&tm));
fprintf(file,"#1 tick = %g milliseconds\n",SOUND_BUFFER_SIZE*1000.0/SAMPLE_RATE);
fprintf(file,"SAMPLERATE = %d\n",SAMPLE_RATE);
fprintf(file,"TICKSIZE = %d #samples\n",SOUND_BUFFER_SIZE);
fprintf(file,"\n\nSTART\n");
};
};
void Dump::inctick(){
tick++;
};
void Dump::dumpnote(char chan,char note, char vel){
if (file==NULL) return;
if (note==0) return;
if (vel==0) fprintf(file,"n %d -> %d %d \n",tick,chan,note);//note off
else fprintf(file,"N %d -> %d %d %d \n",tick,chan,note,vel);//note on
if (vel!=0) keyspressed++;
#ifndef JACKAUDIOOUT
if (k++>25) {
fflush(file);
k=0;
};
#endif
};
void Dump::dumpcontroller(char chan,unsigned int type,int par){
if (file==NULL) return;
switch(type){
case C_pitchwheel:fprintf(file,"P %d -> %d %d\n",tick,chan,par);
break;
default:fprintf(file,"C %d -> %d %d %d\n",tick,chan,type,par);
break;
};
#ifndef JACKAUDIOOUT
if (k++>25) {
fflush(file);
k=0;
};
#endif
};
|