commit 0319dc6ef8a96d3ae47179632a348031f1ad832a
parent 4a8867f55c09da6a33dcafa92d5f42d7c585cd69
Author: paulnasca <paulnasca>
Date: Mon, 15 Mar 2004 19:52:06 +0000
*** empty log message ***
Diffstat:
7 files changed, 143 insertions(+), 93 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -559,5 +559,7 @@
12 Mar 2004 - Adaugata modulatie la OscilGen (functia de baza)
13 Mar 2004 - Adaugat HarmonicShift la oscilgen
15 Mar 2004 - Inceput sa scriu partea de incarcare MIDI
+ - Inlaturata partea de recording din Sequencer
+
diff --git a/src/Misc/Master.C b/src/Misc/Master.C
@@ -107,7 +107,6 @@ void Master::defaults(){
*/
void Master::NoteOn(unsigned char chan,unsigned char note,unsigned char velocity){
dump.dumpnote(chan,note,velocity);
- seq.recordnote(chan,note,velocity);
noteon(chan,note,velocity);
};
@@ -135,7 +134,6 @@ void Master::noteon(unsigned char chan,unsigned char note,unsigned char velocity
*/
void Master::NoteOff(unsigned char chan,unsigned char note){
dump.dumpnote(chan,note,0);
- seq.recordnote(chan,note,0);
noteoff(chan,note);
};
@@ -156,7 +154,6 @@ void Master::noteoff(unsigned char chan,unsigned char note){
*/
void Master::SetController(unsigned char chan,unsigned int type,int par){
dump.dumpcontroller(chan,type,par);
- seq.recordcontroller(chan,type,par);
setcontroller(chan,type,par);
};
diff --git a/src/Seq/MIDIFile.C b/src/Seq/MIDIFile.C
@@ -0,0 +1,82 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ MIDIFile.C - MIDI file loader
+ Copyright (C) 2003-2004 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 <stdio.h>
+#include <string.h>
+#include "MIDIFile.h"
+
+
+MIDIFile::MIDIFile(){
+ midifile=NULL;
+ midifilesize=0;
+};
+
+MIDIFile::~MIDIFile(){
+ clearmidifile();
+};
+
+int MIDIFile::loadfile(char *filename){
+ clearmidifile();
+
+ FILE *file=fopen(filename,"r");
+ if (file==NULL) return(-1);
+
+ char header[4];
+ memset(header,0,4);
+ fread(header,4,1,file);
+
+ //test to see if this a midi file
+ if ((header[0]!='M')||(header[1]!='T')||(header[2]!='h')||(header[3]!='d')){
+ fclose(file);
+ return(-1);
+ };
+
+ //get the filesize
+ fseek(file,0,SEEK_END);
+ midifilesize=ftell(file);
+ rewind(file);
+
+ midifile=new unsigned char[midifilesize];
+ memset(midifile,0,midifilesize);
+ fread(midifile,midifilesize,1,file);
+ fclose(file);
+
+ for (int i=0;i<midifilesize;i++) printf("%2x ",midifile[i]);
+ printf("\n");
+
+
+ return(0);
+};
+
+int MIDIFile::parsemidifile(){
+ return(0);
+};
+
+//private members
+
+void MIDIFile::clearmidifile(){
+ if (midifile!=NULL) delete(midifile);
+ midifile=NULL;
+ midifilesize=0;
+
+};
+
diff --git a/src/Seq/MIDIFile.h b/src/Seq/MIDIFile.h
@@ -0,0 +1,45 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ MIDIFile.h - MIDI file loader
+ Copyright (C) 2003-2004 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
+
+*/
+
+#ifndef MIDIFILE_H
+#define MIDIFILE_H
+
+class MIDIFile{
+ public:
+ MIDIFile();
+ ~MIDIFile();
+
+ //returns -1 if there is an error, otherwise 0
+ int loadfile(char *filename);
+
+ //returns -1 if there is an error, otherwise 0
+ int parsemidifile();
+
+ private:
+ unsigned char *midifile;
+ int midifilesize;
+
+ void clearmidifile();
+
+};
+
+#endif
diff --git a/src/Seq/Sequencer.C b/src/Seq/Sequencer.C
@@ -32,7 +32,6 @@
Sequencer::Sequencer(){
- rec=0;
play=0;
for (int i=0;i<NUM_MIDI_CHANNELS;i++){
midichan[i].track.first=NULL;
@@ -59,66 +58,13 @@ Sequencer::~Sequencer(){
int Sequencer::importmidifile(char *filename){
+ if (midifile.loadfile(filename)<0) return(-1);
+ if (midifile.parsemidifile()<0) return(-1);
return(0);
};
-void Sequencer::recordnote(char chan, char note, char vel){
- if (rec==0) return;
- if (chan>=NUM_MIDI_CHANNELS) return;
-
- updatecounter(&rectime);
- int dt=(int) (rectime.rel*1000.0);
- tmpevent.deltatime=dt;
-
- tmpevent.type=1;
- tmpevent.par1=note;
- tmpevent.par2=vel;
-
- writeevent(&midichan[chan].record,&tmpevent);
- midichan[chan].record.length=rectime.abs;
-
- printf("Note %d %d %d \n",chan,note,vel);
-};
-
-void Sequencer::recordcontroller(char chan,unsigned int type,int par){
- if (rec==0) return;
- if (chan>=NUM_MIDI_CHANNELS) return;
-
- updatecounter(&rectime);
- int dt=(int) (rectime.rel*1000.0);
- tmpevent.deltatime=dt;
-
- tmpevent.type=2;
- tmpevent.par1=type;
- tmpevent.par2=par;
-
- writeevent(&midichan[chan].record,&tmpevent);
- midichan[chan].record.length=rectime.abs;
-
- printf("Ctl %d %d %d \n",chan,type,par);
-};
-
-
-
-void Sequencer::startrec(){
- if (rec!=0) return;
- resettime(&rectime);
- rec=1;
-};
-
-void Sequencer::stoprec(){
- if (rec==0) return;
- //for now, only record over track (erase the track)
- for (int i=0;i<NUM_MIDI_CHANNELS;i++){
- deletelist(&midichan[i].track);
- midichan[i].track=midichan[i].record;
- deletelistreference(&midichan[i].record);
- };
- rec=0;
-};
-
void Sequencer::startplay(){
if (play!=0) return;
play=1;
diff --git a/src/Seq/Sequencer.h b/src/Seq/Sequencer.h
@@ -17,7 +17,6 @@
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
-
*/
#ifndef SEQUENCER_H
@@ -44,15 +43,11 @@ class Sequencer{
//returns 0 if ok or -1 if there is a error loading file
int importmidifile(char *filename);
- //UI controlling functions
- void startrec();
- void stoprec();
-
void startplay();
void stopplay();
- int rec,play;
+ int play;
private:
diff --git a/src/UI/SeqUI.fl b/src/UI/SeqUI.fl
@@ -1,5 +1,5 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0104
+version 1.0200
header_name {.h}
code_name {.cc}
decl {//Copyright (c) 2002-2004 Nasca Octavian Paul} {}
@@ -15,35 +15,13 @@ decl {\#include "../Misc/Master.h"} {public
decl {\#include "WidgetPDial.h"} {public
}
-class SeqUI {open
-} {
- Function {make_window()} {open
- } {
+class SeqUI {} {
+ Function {make_window()} {} {
Fl_Window seqwin {
- label {Sequencer - ZynAddSubFX} open
- xywh {104 235 239 100} visible
+ label {Sequencer - ZynAddSubFX}
+ xywh {104 235 235 100} type Double hide
} {
Fl_Group {} {
- label Recorder
- xywh {10 20 100 65} box ENGRAVED_BOX labelfont 1
- } {
- Fl_Button recordbutton {
- label {Rec.}
- callback {o->deactivate();
-stopbutton_rec->activate();
-master->seq.startrec();}
- tooltip {Start Recording} xywh {20 30 30 30} box ROUND_UP_BOX color 88 labelfont 1 labelsize 16 align 2
- }
- Fl_Button stopbutton_rec {
- label Stop
- callback {o->deactivate();
-recordbutton->activate();
-
-master->seq.stoprec();}
- tooltip {Stop Recording} xywh {65 29 30 31} box THIN_UP_BOX color 4 labelfont 1 labelsize 16 align 2 deactivate
- }
- }
- Fl_Group {} {
label Player
xywh {120 20 100 65} box ENGRAVED_BOX labelfont 1
} {
@@ -60,10 +38,15 @@ master->seq.startplay();}
callback {o->deactivate();
playbutton->activate();
-master->seq.stopplay();} selected
+master->seq.stopplay();}
tooltip {Stop Playing} xywh {175 29 30 31} box THIN_UP_BOX color 4 labelfont 1 labelsize 16 align 2 deactivate
}
}
+ Fl_Button {} {
+ label {Open test.mid}
+ callback {master->seq.importmidifile("test.mid");} selected
+ xywh {20 25 75 55} align 128
+ }
}
}
Function {SeqUI(Master *master_)} {open