summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2013-05-19 19:28:23 +0200
committerFlorian Jung <flo@windfisch.org>2013-05-19 19:28:23 +0200
commitb720b819008a5450b201f476e6a318e026c2fcb5 (patch)
treee4ec1aea557e5c898216550e13425e0d8830eb61
parent80ebff074a400ad9684755d5396b2578f9c80fd7 (diff)
drum support
-rw-r--r--midirip.c60
1 files changed, 48 insertions, 12 deletions
diff --git a/midirip.c b/midirip.c
index 4e01aab..8fff403 100644
--- a/midirip.c
+++ b/midirip.c
@@ -29,17 +29,14 @@
/* TODO
- * dateiname finden
- * dirliste lesen
* bytes aus datei lesen
- * patchnamen lesen
- * dateien namen geben
- * verzeichnisse anlegen (gruppen)
* --overwrite-option?
+ * zwischen normalem und drum-modus wechseln!
*/
-//LAST STABLE: 07
+//LAST STABLE: 08
+// #define DRUM_MODE
#include <stdio.h>
#include <stdlib.h>
@@ -335,7 +332,7 @@ int process_callback(jack_nframes_t nframes, void *notused) //WICHTIG FINDMICH
if (jack_midi_event_write(midipb, 0, data, 2))
fprintf(stderr,"Note loss when writing\n");
- data[0]=MIDI_NOTE_ON;
+ data[0]=MIDI_NOTE_ON + (recentry->chan & 0x0F);
data[2]=recentry->loud;
for (i=0;recentry->note[i]!=-1;i++)
@@ -365,7 +362,7 @@ int process_callback(jack_nframes_t nframes, void *notused) //WICHTIG FINDMICH
{
// printf("NOTE OFF in %i\n",frame_cnt);
- data[0]=MIDI_NOTE_OFF;
+ data[0]=MIDI_NOTE_OFF + (recentry->chan & 0x0F);
data[2]=recentry->loud;
for (i=0;recentry->note[i]!=-1;i++)
{
@@ -521,6 +518,8 @@ int main(int argc, char *argv[])
int dontignore;
int rangelen;
+ int drumprogram;
+
entry_t *curr_entry;
@@ -542,7 +541,6 @@ int main(int argc, char *argv[])
for (i=0;i<128;i++)
dirs[i]=patchname[i]=dummy;
-
f=fopen("patches.txt","r");
while(!feof(f))
{
@@ -570,7 +568,7 @@ int main(int argc, char *argv[])
}
fclose(f);
-
+#ifndef DRUM_MODE
f=fopen("groups.txt","r");
while(!feof(f))
{
@@ -608,7 +606,7 @@ int main(int argc, char *argv[])
}
fclose(f);
-
+#endif
f=fopen ("config.txt","r");
l=0;
@@ -644,11 +642,32 @@ int main(int argc, char *argv[])
printf ("ERROR: invalid range specified in line %i\n",l);
goto invalid;
}
-
+
while(1)
{
for (i=0;(param[i]!=0) && (param[i]!=',') && (param[i]!='\n');i++); //find ','
+
+#ifdef DRUM_MODE
+ for (j=0;(param[j]!=0) && ((param[j]==' ') || (param[j]=='\t'));j++); //find nonspace
+ drumprogram=getnum(param,&j);
+ loud=120; //TODO anderer default?
+ len=75;
+
+ for (;(param[j]!=0) && ((param[j]==' ') || (param[j]=='\t'));j++); //find next nonspace
+ if (isdigit(param[j]))
+ {
+ printf("loud specified\n");
+ loud=getnum(param,&j);
+ }
+ for (;(param[j]!=0) && ((param[j]==' ') || (param[j]=='\t'));j++); //find next nonspace
+ if (isdigit(param[j]))
+ {
+ len=getnum(param,&j);
+ printf("len\n");
+ }
+
+#else //ifndef DRUM_MODE
state=0;
len=DEFAULT_LEN;
notenum=0;
@@ -730,6 +749,7 @@ int main(int argc, char *argv[])
}
}
+#endif
//in die liste eintragen
for (k=0;k<rangelen;k++)
@@ -747,6 +767,7 @@ int main(int argc, char *argv[])
tmpptr->loud=loud;
tmpptr->notelen=len*samp_rate /1000; //von msec in samples umrechnen
+#ifndef DRUM_MODE
tmpptr->chan=0;
tmpptr->patch=patchlist[k];
tmpptr->dir=dirs[patchlist[k]];
@@ -781,6 +802,21 @@ int main(int argc, char *argv[])
for (j=0;j<notenum;j++)
tmpptr->note[j]=note[j];
tmpptr->note[notenum]=-1;
+#else // ifdef DRUM_MODE
+ tmpptr->chan=9;
+ tmpptr->note[0]=patchlist[k]; tmpptr->note[1]=-1;
+ tmpptr->patch=drumprogram;
+
+ tmpptr->dir="drums";
+ asprintf(&tmpptr->file, "%s/%03i%s %i %i %ims.wav",tmpptr->dir, tmpptr->note[0],
+ patchname[tmpptr->note[0]], tmpptr->patch, tmpptr->loud, len);
+
+
+ printf("chan=%i, note=%i, patch=%i, loud=%i, len=%i,\n\tdir='%s', file='%s'\n",
+ tmpptr->chan, tmpptr->note[0], tmpptr->patch, tmpptr->loud, tmpptr->notelen,
+ tmpptr->dir, tmpptr->file);
+#endif
+
tmpptr->next=NULL;
curr_entry=tmpptr;