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

Annotation of /linuxsampler/trunk/src/engines/common/Note.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2931 - (hide annotations) (download) (as text)
Sat Jul 9 14:38:33 2016 UTC (7 years, 9 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 4476 byte(s)
* Implemented built-in instrument script function "change_vol()".
* Implemented built-in instrument script function "change_tune()".
* Implemented built-in instrument script function "change_pan()".
* Bumped version (2.0.0.svn11).

1 schoenebeck 2879 /*
2     * Copyright (c) 2016 Christian Schoenebeck
3     *
4     * http://www.linuxsampler.org
5     *
6     * This file is part of LinuxSampler and released under the same terms.
7     * See README file for details.
8     */
9    
10     #ifndef LS_NOTE_H
11     #define LS_NOTE_H
12    
13     #include "../../common/Pool.h"
14     #include "Event.h"
15    
16     namespace LinuxSampler {
17    
18     /**
19     * Abstract base class of its deriving @c Note class, this class (NoteBase)
20     * is not intended to be instantiated directly. It just provides access to
21     * the parts of a Note object which do not depend on any C++ template
22     * parameter.
23     */
24     class NoteBase {
25     public:
26     int hostKey; ///< Key on which this is @c Note is allocated on. This is usually the note-on event's note number, however in case of a child note this will rather be the parent note's key instead!
27     note_id_t parentNoteID; ///< If not null: unique ID of the parent note of this note (see comments of field @c pChildNotes).
28     RTList<note_id_t>* pChildNotes; ///< Note ID list of "child" notes of this note. These are special notes that must be released once this note gets released.
29     Event cause; ///< Copy of the original event (usually a note-on event) which caused this note.
30     event_id_t eventID; ///< Unique ID of the actual original @c Event which caused this note.
31 schoenebeck 2931 /// Optional synthesis parameters that might be overridden (by calling real-time instrument script functions like change_vol(), change_pitch(), etc.).
32     struct _Override {
33     float Volume; ///< as linear amplification ratio (1.0 being neutral)
34     float Pitch; ///< as linear frequency ratio (1.0 being neutral)
35     float Pan; ///< between -1.0 (most left) and +1.0 (most right) and 0.0 being neutral.
36     int64_t PanSources; ///< Might be used for calculating an average pan value in differential way: amount of times the Pan value had been changed and shall be calculated relatively upon.
37     } Override;
38 schoenebeck 2879 /// Sampler format specific informations and variables.
39     union _Format {
40     /// Gigasampler/GigaStudio format specifics.
41     struct _Gig {
42     uint8_t DimMask; ///< May be used to override the Dimension zone to be selected for a new voice: each 1 bit means that respective bit shall be overridden by taking the respective bit from DimBits instead.
43     uint8_t DimBits; ///< Used only in conjunction with DimMask: Dimension bits that shall be selected.
44     } Gig;
45     } Format;
46     protected:
47     NoteBase() : hostKey(0), parentNoteID(0), pChildNotes(NULL) {
48 schoenebeck 2931 Override.Volume = 1.f;
49     Override.Pitch = 1.f;
50     Override.Pan = 0.f;
51     Override.PanSources = 0;
52 schoenebeck 2880 Format = _Format();
53 schoenebeck 2879 }
54     };
55    
56     /**
57     * Contains the voices caused by one specific note, as well as basic
58     * informations about the note itself.
59     */
60     template<class V>
61     class Note : public NoteBase {
62     public:
63     RTList<V>* pActiveVoices; ///< Contains the active voices associated with this note.
64    
65     Note() : NoteBase(), pActiveVoices(NULL) {}
66    
67     virtual ~Note() {
68     if (pChildNotes) delete pChildNotes;
69     if (pActiveVoices) delete pActiveVoices;
70     }
71    
72     void init(Pool<V>* pVoicePool, Pool<note_id_t>* pNoteIDPool) {
73     if (pActiveVoices) delete pActiveVoices;
74     pActiveVoices = new RTList<V>(pVoicePool);
75     if (pChildNotes) delete pChildNotes;
76     pChildNotes = new RTList<note_id_t>(pNoteIDPool);
77     }
78    
79     void reset() {
80     hostKey = 0;
81     parentNoteID = 0;
82     if (pChildNotes)
83     pChildNotes->clear();
84     cause = Event();
85     eventID = 0;
86 schoenebeck 2931 Override.Volume = 1.f;
87     Override.Pitch = 1.f;
88     Override.Pan = 0.f;
89     Override.PanSources = 0;
90 schoenebeck 2880 Format = _Format();
91 schoenebeck 2879 if (pActiveVoices) {
92     typename RTList<V>::Iterator itVoice = pActiveVoices->first();
93     typename RTList<V>::Iterator itVoicesEnd = pActiveVoices->end();
94     for (; itVoice != itVoicesEnd; ++itVoice) { // iterate through all voices on this key
95     itVoice->VoiceFreed();
96     }
97     pActiveVoices->clear();
98     }
99     }
100     };
101    
102     } // namespace LinuxSampler
103    
104     #endif // LS_NOTE_H

  ViewVC Help
Powered by ViewVC