summaryrefslogtreecommitdiff
path: root/attic/muse_qt4_evolution/synti/zynaddsubfx/Seq/Sequencer.h
blob: 82ebe4950c9f6a8553be31268f99d65f0c80c4c3 (plain)
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
/*
  ZynAddSubFX - a software synthesizer
 
  Sequencer.h - The Sequencer
  Copyright (C) 2003-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
*/

#ifndef SEQUENCER_H
#define SEQUENCER_H

#include "../globals.h"
#include "MIDIEvents.h"
#include "MIDIFile.h"

class Sequencer:public MIDIEvents{
    public:
	Sequencer();
	~Sequencer();
	
	//theese functions are called by the master and are ignored if the recorder/player are stopped
	void recordnote(char chan, char note, char vel);
	void recordcontroller(char chan,unsigned int type,int par);
	
	//this is only for player
	//it returns 1 if this must be called at least once more
	//it returns 0 if there are no more notes for the current time
	//or -1 if there is no note
	int getevent(char ntrack, int *midich,int *type,int *par1, int *par2);

	//returns 0 if ok or -1 if there is a error loading file
	int importmidifile(char *filename);	
	
	void startplay();
	void stopplay();
	

	int play;	
	int playspeed;//viteza de rulare (0.1x-10x), 0=1.0x, 128=10x
	void setplayspeed(int speed);
	
    private:
    
	MIDIFile midifile;

    /* Timer */
    struct timestruct{
	double abs;//the time from the begining of the track
	double rel;//the time difference between the last and the current event
	double last;//the time of the last event (absolute, since 1 Jan 1970)
	//theese must be double, because the float's precision is too low
	//and all theese represents the time in seconds
    } playtime[NUM_MIDI_TRACKS];
    
    void resettime(timestruct *t);
    void updatecounter(timestruct *t);//this updates the timer values

    /* Player only*/

    struct {
	event ev;
	double time;
    } nextevent[NUM_MIDI_TRACKS];    
    
    double realplayspeed;
    
};


#endif