/[svn]/linuxsampler/trunk/src/engines/common/Event.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/engines/common/Event.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 53 - (show annotations) (download) (as text)
Mon Apr 26 17:15:51 2004 UTC (19 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5439 byte(s)
* completely restructured source tree
* implemented multi channel support
* implemented instrument manager, which controls sharing of instruments
  between multiple sampler engines / sampler channels
* created abstract classes 'AudioOutputDevice' and 'MidiInputDevice' for
  convenient implementation of further audio output driver and MIDI input
  driver for LinuxSampler
* implemented following LSCP commands: 'SET CHANNEL MIDI INPUT TYPE',
  'LOAD ENGINE', 'GET CHANNELS', 'ADD CHANNEL', 'REMOVE CHANNEL',
  'SET CHANNEL AUDIO OUTPUT TYPE'
* temporarily removed all command line options
* LSCP server is now launched by default

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003 by Benno Senoner and Christian Schoenebeck *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
20 * MA 02111-1307 USA *
21 ***************************************************************************/
22
23 #ifndef __LS_EVENT_H__
24 #define __LS_EVENT_H__
25
26 #include "../../common/global.h"
27
28 namespace LinuxSampler {
29
30 // just symbol prototyping
31 class Event;
32
33 /**
34 * Generates Event objects and is responsible for resolving the position
35 * in the current audio fragment each Event actually belongs to.
36 */
37 class EventGenerator {
38 public:
39 EventGenerator(uint SampleRate);
40 void UpdateFragmentTime(uint SamplesToProcess);
41 Event CreateEvent();
42 protected:
43 typedef uint32_t time_stamp_t; ///< We read the processor's cycle count register as a reference for the real time. These are of course only abstract values with arbitrary time entity, but that's not a problem as we calculate relatively.
44 inline uint ToFragmentPos(time_stamp_t TimeStamp) {
45 return uint ((TimeStamp - FragmentTime.begin) * FragmentTime.sample_ratio);
46 }
47 friend class Event;
48 private:
49 uint uiSampleRate;
50 uint uiSamplesProcessed;
51 struct __FragmentTime__ {
52 time_stamp_t begin; ///< Real time stamp of the beginning of this audio fragment cycle.
53 time_stamp_t end; ///< Real time stamp of the end of this audio fragment cycle.
54 float sample_ratio; ///< (Samples per cycle) / (Real time duration of cycle)
55 } FragmentTime;
56 time_stamp_t CreateTimeStamp();
57 };
58
59 /**
60 * Events are usually caused by a MIDI source or an internal modulation
61 * controller like LFO or EG. An event can only be created by an
62 * EventGenerator.
63 *
64 * @see EventGenerator
65 */
66 class Event {
67 public:
68 Event(){}
69 enum type_t {
70 type_note_on,
71 type_note_off,
72 type_pitchbend,
73 type_control_change,
74 type_cancel_release, ///< transformed either from a note-on or sustain-pedal-down event
75 type_release ///< transformed either from a note-off or sustain-pedal-up event
76 } Type;
77 enum destination_t {
78 destination_vca, ///< Volume level
79 destination_vco, ///< Pitch depth
80 destination_vcfc, ///< Filter curoff frequency
81 destination_vcfr, ///< Filter resonance
82 destination_count ///< Total number of modulation destinations (this has to stay the last element in the enum)
83 };
84 union {
85 uint8_t Key; ///< MIDI key number for note-on and note-off events.
86 uint8_t Controller; ///< MIDI controller number for control change events.
87 };
88 union {
89 uint8_t Velocity; ///< Trigger or release velocity for note-on or note-off events.
90 uint8_t Value; ///< Value for control change events.
91 };
92 int16_t Pitch; ///< Pitch value for pitchbend events.
93
94 inline uint FragmentPos() {
95 if (iFragmentPos >= 0) return (uint) iFragmentPos;
96 return (uint) (iFragmentPos = pEventGenerator->ToFragmentPos(TimeStamp));
97 }
98 protected:
99 typedef EventGenerator::time_stamp_t time_stamp_t;
100 Event(EventGenerator* pGenerator, EventGenerator::time_stamp_t Time);
101 friend class EventGenerator;
102 private:
103 EventGenerator* pEventGenerator; ///< Creator of the event.
104 time_stamp_t TimeStamp; ///< Time stamp of the event's occurence.
105 int iFragmentPos; ///< Position in the current fragment this event refers to.
106 };
107
108 } // namespace LinuxSampler
109
110 #endif // __LS_EVENT_H__

  ViewVC Help
Powered by ViewVC