/[svn]/linuxsampler/tags/v0_1_0/src/modulationsystem.h
ViewVC logotype

Annotation of /linuxsampler/tags/v0_1_0/src/modulationsystem.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 37 - (hide annotations) (download) (as text)
Wed Mar 10 22:01:36 2004 UTC (20 years, 3 months ago) by schoenebeck
Original Path: linuxsampler/trunk/src/modulationsystem.h
File MIME type: text/x-c++hdr
File size: 5466 byte(s)
* src/eg_vca.cpp: added following transitions to the envelope generator:
  'Attack_Hold' -> 'Release', 'Decay_1' -> 'Release' in case of a release
  event
* EG1 parameters 'Attack Time', 'Release Time' and 'Sustain Time' are now
  controllable by a MIDI controller defined in the .gig file
* src/voice.cpp: fixed bug in pitch calculation which caused new triggered
  voices to be played back without honoring the current pitch bend value

1 schoenebeck 30 /***************************************************************************
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 __MODULATION_SYSTEM_H__
24     #define __MODULATION_SYSTEM_H__
25    
26     #include "global.h"
27    
28 schoenebeck 32 /**
29     * Handles modulation parameters and events for the current audio fragment.
30     *
31     * TODO: class should better be renamed to 'EventSystem' or even better: most of the attributes here could be moved into the engine and everything left would just be class Event (thus -> event.h and event.cpp), but that can wait until we restructe the source tree for multi engine support
32     */
33 schoenebeck 30 class ModulationSystem {
34     public:
35     enum destination_t {
36     destination_vca, ///< Volume level
37 schoenebeck 32 destination_vco, ///< Pitch depth
38 schoenebeck 37 destination_count ///< Total number of modulation destinations (this has to stay the last element in the enum)
39 schoenebeck 30 };
40 schoenebeck 37 typedef uint32_t real_time_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.
41 schoenebeck 32 enum event_type_t {
42     event_type_note_on,
43     event_type_note_off,
44     event_type_pitchbend,
45 schoenebeck 33 event_type_control_change,
46     event_type_cancel_release, ///< transformed either from a note-on or sustain-pedal-down event
47     event_type_release ///< transformed either from a note-off or sustain-pedal-up event
48 schoenebeck 30 };
49 schoenebeck 32 class Event {
50     public:
51     event_type_t Type;
52     union {
53     uint8_t Key; ///< MIDI key number for note-on and note-off events.
54     uint8_t Controller; ///< MIDI controller number for control change events.
55     };
56     union {
57     uint8_t Velocity; ///< Trigger or release velocity for note-on or note-off events.
58     uint8_t Value; ///< Value for control change events.
59     };
60     int16_t Pitch; ///< Pitch value for pitchbend events.
61 schoenebeck 30
62 schoenebeck 32 Event() {
63     TimeStamp = ModulationSystem::CreateTimeStamp();
64     iFragmentPos = -1;
65 schoenebeck 33 }
66     inline uint FragmentPos() {
67 schoenebeck 32 if (iFragmentPos >= 0) return (uint) iFragmentPos;
68     return (uint) (iFragmentPos = ModulationSystem::ToFragmentPos(TimeStamp));
69 schoenebeck 33 }
70 schoenebeck 32 private:
71     real_time_t TimeStamp; ///< Time stamp of the event's occurence.
72     int iFragmentPos; ///< Position in the current fragment this event refers to.
73     };
74    
75 schoenebeck 30 static float** pDestinationParameter;
76    
77 schoenebeck 32 static void Initialize(uint SampleRate, uint MaxSamplesPerCycle);
78     static void Close();
79     static void ResetDestinationParameter(ModulationSystem::destination_t dst, float val);
80     static void UpdateFragmentTime();
81     static real_time_t CreateTimeStamp();
82 schoenebeck 33 static inline uint MaxSamplesPerCycle() { return uiMaxSamplesPerCycle; }
83     static inline uint SampleRate() { return uiSampleRate; }
84 schoenebeck 32 static inline uint ToFragmentPos(real_time_t time_stamp) {
85     return uint ((time_stamp - FragmentTime.begin) * FragmentTime.sample_ratio);
86 schoenebeck 33 }
87 schoenebeck 30 protected:
88 schoenebeck 31 static uint uiMaxSamplesPerCycle;
89     static uint uiSampleRate;
90 schoenebeck 32 static struct __FragmentTime__ {
91     real_time_t begin; ///< Real time stamp of the beginning of this audio fragment cycle.
92     real_time_t end; ///< Real time stamp of the end of this audio fragment cycle.
93     float sample_ratio; ///< (Samples per cycle) / (Real time duration of cycle)
94     } FragmentTime;
95 schoenebeck 30 };
96    
97     #endif // __MODULATION_SYSTEM_H__

  ViewVC Help
Powered by ViewVC