/[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 2935 - (hide annotations) (download) (as text)
Sun Jul 10 14:24:13 2016 UTC (7 years, 9 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 4746 byte(s)
* NKSP: Added & implemented built-in script function "change_cutoff()".
* NKSP: Added & implemented built-in script function "change_reso()".
* NKSP: Added & implemented built-in script function "event_status()".
* NKSP: Added built-in script constants "$EVENT_STATUS_INACTIVE" and
  "$EVENT_STATUS_NOTE_QUEUE" both for being used as flags for
  built-in "event_status()" script function.
* NKSP language: Added support for bitwise operators ".or.", ".and."
  and ".not.".
* NKSP language scanner: Fixed IDs matching to require at least one
  character (i.e. when matching function names or variable names).
* NKSP language scanner: disabled unusued rules.
* Bumped version (2.0.0.svn12).

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 schoenebeck 2935 float Cutoff; ///< between 0.0 and 1.0
38     float Resonance; ///< between 0.0 and 1.0
39 schoenebeck 2931 } Override;
40 schoenebeck 2879 /// Sampler format specific informations and variables.
41     union _Format {
42     /// Gigasampler/GigaStudio format specifics.
43     struct _Gig {
44     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.
45     uint8_t DimBits; ///< Used only in conjunction with DimMask: Dimension bits that shall be selected.
46     } Gig;
47     } Format;
48     protected:
49     NoteBase() : hostKey(0), parentNoteID(0), pChildNotes(NULL) {
50 schoenebeck 2931 Override.Volume = 1.f;
51     Override.Pitch = 1.f;
52     Override.Pan = 0.f;
53     Override.PanSources = 0;
54 schoenebeck 2935 Override.Cutoff = 1.f;
55     Override.Resonance = 1.f;
56 schoenebeck 2880 Format = _Format();
57 schoenebeck 2879 }
58     };
59    
60     /**
61     * Contains the voices caused by one specific note, as well as basic
62     * informations about the note itself.
63     */
64     template<class V>
65     class Note : public NoteBase {
66     public:
67     RTList<V>* pActiveVoices; ///< Contains the active voices associated with this note.
68    
69     Note() : NoteBase(), pActiveVoices(NULL) {}
70    
71     virtual ~Note() {
72     if (pChildNotes) delete pChildNotes;
73     if (pActiveVoices) delete pActiveVoices;
74     }
75    
76     void init(Pool<V>* pVoicePool, Pool<note_id_t>* pNoteIDPool) {
77     if (pActiveVoices) delete pActiveVoices;
78     pActiveVoices = new RTList<V>(pVoicePool);
79     if (pChildNotes) delete pChildNotes;
80     pChildNotes = new RTList<note_id_t>(pNoteIDPool);
81     }
82    
83     void reset() {
84     hostKey = 0;
85     parentNoteID = 0;
86     if (pChildNotes)
87     pChildNotes->clear();
88     cause = Event();
89     eventID = 0;
90 schoenebeck 2931 Override.Volume = 1.f;
91     Override.Pitch = 1.f;
92     Override.Pan = 0.f;
93     Override.PanSources = 0;
94 schoenebeck 2935 Override.Cutoff = 1.f;
95     Override.Resonance = 1.f;
96 schoenebeck 2880 Format = _Format();
97 schoenebeck 2879 if (pActiveVoices) {
98     typename RTList<V>::Iterator itVoice = pActiveVoices->first();
99     typename RTList<V>::Iterator itVoicesEnd = pActiveVoices->end();
100     for (; itVoice != itVoicesEnd; ++itVoice) { // iterate through all voices on this key
101     itVoice->VoiceFreed();
102     }
103     pActiveVoices->clear();
104     }
105     }
106     };
107    
108     } // namespace LinuxSampler
109    
110     #endif // LS_NOTE_H

  ViewVC Help
Powered by ViewVC