LMMS
Loading...
Searching...
No Matches
Part.h
Go to the documentation of this file.
1/*
2 ZynAddSubFX - a software synthesizer
3
4 Part.h - Part implementation
5 Copyright (C) 2002-2005 Nasca Octavian Paul
6 Author: Nasca Octavian Paul
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of version 2 of the GNU General Public License
10 as published by the Free Software Foundation.
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 (version 2 or later) for more details.
16
17 You should have received a copy of the GNU General Public License (version 2)
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21*/
22
23#ifndef PART_H
24#define PART_H
25
26#define MAX_INFO_TEXT_SIZE 1000
27
28#include "../globals.h"
30#include "../Misc/Microtonal.h"
31
32#include "ThreadShims.h"
33#include <list> // For the monomemnotes list.
34
35class EffectMgr;
39class SynthNote;
40class XMLWrapper;
41class FFTwrapper;
42
44class Part
45{
46 public:
51 Part(Microtonal *microtonal_, FFTwrapper *fft_, std::mutex *mutex_);
53 ~Part();
54
55 // Midi commands implemented
56 void NoteOn(unsigned char note,
57 unsigned char velocity,
58 int masterkeyshift);
59 void NoteOff(unsigned char note);
60 void PolyphonicAftertouch(unsigned char note,
61 unsigned char velocity,
62 int masterkeyshift);
63 void AllNotesOff(); //panic
64 void SetController(unsigned int type, int par);
65 void RelaseSustainedKeys(); //this is called when the sustain pedal is relased
66 void RelaseAllKeys(); //this is called on AllNotesOff controller
67
68 /* The synthesizer part output */
69 void ComputePartSmps(); //Part output
70
71 //instrumentonly: 0 - save all, 1 - save only instrumnet, 2 - save only instrument without the name(used in bank)
72
73
74 //saves the instrument settings to a XML file
75 //returns 0 for ok or <0 if there is an error
76 int saveXML(const char *filename);
77 int loadXMLinstrument(const char *filename);
78
79 void add2XML(XMLwrapper *xml);
80 void add2XMLinstrument(XMLwrapper *xml);
81
82 void defaults();
83 void defaultsinstrument();
84
85 void applyparameters(bool lockmutex = true);
86
87 void getfromXML(XMLwrapper *xml);
88 void getfromXMLinstrument(XMLwrapper *xml);
89
90 void cleanup(bool final = false);
91
92 //the part's kit
93 struct {
94 unsigned char Penabled, Pmuted, Pminkey, Pmaxkey;
95 unsigned char *Pname;
97 unsigned char Psendtoparteffect;
102
103
104 //Part parameters
105 void setkeylimit(unsigned char Pkeylimit);
106 void setkititemstatus(int kititem, int Penabled_);
107
108 unsigned char Penabled;
109 unsigned char Pvolume;
110 unsigned char Pminkey;
111 unsigned char Pmaxkey; //the maximum key that the part receives noteon messages
112 void setPvolume(char Pvolume);
113 unsigned char Pkeyshift; //Part keyshift
114 unsigned char Prcvchn; //from what midi channel it receive commnads
115 unsigned char Ppanning; //part panning
116 void setPpanning(char Ppanning);
117 unsigned char Pvelsns; //velocity sensing (amplitude velocity scale)
118 unsigned char Pveloffs; //velocity offset
119 unsigned char Pnoteon; //if the part receives NoteOn messages
120 unsigned char Pkitmode; //if the kitmode is enabled
121 unsigned char Pdrummode; //if all keys are mapped and the system is 12tET (used for drums)
122
123 unsigned char Ppolymode; //Part mode - 0=monophonic , 1=polyphonic
124 unsigned char Plegatomode; // 0=normal, 1=legato
125 unsigned char Pkeylimit; //how many keys are alowed to be played same time (0=off), the older will be relased
126
127 unsigned char *Pname; //name of the instrument
128 struct { //instrument additional information
129 unsigned char Ptype;
130 unsigned char Pauthor[MAX_INFO_TEXT_SIZE + 1];
131 unsigned char Pcomments[MAX_INFO_TEXT_SIZE + 1];
133
134
135 float *partoutl; //Left channel output of the part
136 float *partoutr; //Right channel output of the part
137
138 float *partfxinputl[NUM_PART_EFX + 1], //Left and right signal that pass thru part effects;
139 *partfxinputr[NUM_PART_EFX + 1]; //partfxinput l/r [NUM_PART_EFX] is for "no effect" buffer
140
144
145 float volume, oldvolumel, oldvolumer; //this is applied by Master
146 float panning; //this is applied by Master, too
147
148 Controller ctl; //Part controllers
149
150 EffectMgr *partefx[NUM_PART_EFX]; //insertion part effects (they are part of the instrument)
151 unsigned char Pefxroute[NUM_PART_EFX]; //how the effect's output is routed(to next effect/to out)
152 bool Pefxbypass[NUM_PART_EFX]; //if the effects are bypassed
153
154
155 std::mutex *mutex;
156 std::mutex load_mutex;
157
159
160 private:
161 void RunNote(unsigned k);
162 void KillNotePos(int pos);
163 void RelaseNotePos(int pos);
164 void MonoMemRenote(); // MonoMem stuff.
165
166 int killallnotes; //is set to 1 if I want to kill all notes
167
168 struct PartNotes {
170 int note; //if there is no note playing, the "note"=-1
172 struct {
178 int time;
179 };
180
181 int lastpos, lastposb; // To keep track of previously used pos and posb.
182 bool lastlegatomodevalid; // To keep track of previous legatomodevalid.
183
184 // MonoMem stuff
185 std::list<unsigned char> monomemnotes; // A list to remember held notes.
186 struct {
187 unsigned char velocity;
188 int mkeyshift; // I'm not sure masterkeyshift should be remembered.
189 } monomem[256];
190 /* 256 is to cover all possible note values.
191 monomem[] is used in conjunction with the list to
192 store the velocity and masterkeyshift values of a given note (the list only store note values).
193 For example 'monomem[note].velocity' would be the velocity value of the note 'note'.*/
194
196
197 float oldfreq; //this is used for portamento
200};
201
202#endif
#define NUM_KIT_ITEMS
Definition globals.h:135
#define NUM_PART_EFX
Definition globals.h:130
#define MAX_INFO_TEXT_SIZE
Definition Part.h:26
#define POLIPHONY
Definition globals.h:67
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
Definition ADnoteParameters.h:292
Definition Controller.h:9
Definition EffectMgr.h:44
Definition FFTwrapper.h:32
Definition Microtonal.h:37
Definition PADnoteParameters.h:41
unsigned char Padenabled
Definition Part.h:96
std::mutex load_mutex
Definition Part.h:156
int loadXMLinstrument(const char *filename)
Definition Part.cpp:1203
unsigned char Pkeyshift
Definition Part.h:113
unsigned char Plegatomode
Definition Part.h:124
~Part()
Definition Part.cpp:173
unsigned char Ppadenabled
Definition Part.h:96
void getfromXML(XMLwrapper *xml)
Definition Part.cpp:1311
bool Pefxbypass[NUM_PART_EFX]
Definition Part.h:152
unsigned char Pdrummode
Definition Part.h:121
float * partfxinputl[NUM_PART_EFX+1]
Definition Part.h:138
void defaultsinstrument()
Definition Part.cpp:114
bool lastlegatomodevalid
Definition Part.h:182
void AllNotesOff()
Definition Part.cpp:923
void SetController(unsigned int type, int par)
Definition Part.cpp:703
int lastpos
Definition Part.h:181
unsigned char Pkitmode
Definition Part.h:120
Part(Microtonal *microtonal_, FFTwrapper *fft_, std::mutex *mutex_)
Definition Part.cpp:39
unsigned char Pefxroute[NUM_PART_EFX]
Definition Part.h:151
void RelaseSustainedKeys()
Definition Part.cpp:795
void RelaseAllKeys()
Definition Part.cpp:811
void getfromXMLinstrument(XMLwrapper *xml)
Definition Part.cpp:1227
void add2XMLinstrument(XMLwrapper *xml)
Definition Part.cpp:1091
SUBnoteParameters * subpars
Definition Part.h:99
unsigned char Ptype
Definition Part.h:129
float panning
Definition Part.h:146
PartNotes partnote[POLIPHONY]
Definition Part.h:195
void RelaseNotePos(int pos)
Definition Part.cpp:835
unsigned char Pvelsns
Definition Part.h:117
void defaults()
Definition Part.cpp:95
int killallnotes
Definition Part.h:166
unsigned char Pveloffs
Definition Part.h:118
float * partoutl
Definition Part.h:135
PADnoteParameters * padpars
Definition Part.h:100
unsigned char Pvolume
Definition Part.h:109
void PolyphonicAftertouch(unsigned char note, unsigned char velocity, int masterkeyshift)
Definition Part.cpp:648
NoteStatus
Definition Part.h:141
@ KEY_PLAYING
Definition Part.h:142
@ KEY_RELASED
Definition Part.h:142
@ KEY_RELASED_AND_SUSTAINED
Definition Part.h:142
@ KEY_OFF
Definition Part.h:142
float * partfxinputr[NUM_PART_EFX+1]
Definition Part.h:139
unsigned char Psendtoparteffect
Definition Part.h:97
int lastnote
Definition Part.h:158
unsigned char Pminkey
Definition Part.h:94
struct Part::@243141143316370164336047262077137337050107356130 monomem[256]
unsigned char Ppolymode
Definition Part.h:123
float oldfreq
Definition Part.h:197
unsigned char Prcvchn
Definition Part.h:114
void ComputePartSmps()
Definition Part.cpp:977
float oldvolumer
Definition Part.h:145
void MonoMemRenote()
Definition Part.cpp:821
unsigned char Psubenabled
Definition Part.h:96
void applyparameters(bool lockmutex=true)
Definition Part.cpp:1220
unsigned char Penabled
Definition Part.h:94
std::mutex * mutex
Definition Part.h:155
void NoteOn(unsigned char note, unsigned char velocity, int masterkeyshift)
Definition Part.cpp:203
std::list< unsigned char > monomemnotes
Definition Part.h:185
FFTwrapper * fft
Definition Part.h:199
void KillNotePos(int pos)
Definition Part.cpp:857
Microtonal * microtonal
Definition Part.h:198
unsigned char Pkeylimit
Definition Part.h:125
float oldvolumel
Definition Part.h:145
unsigned char * Pname
Definition Part.h:95
int mkeyshift
Definition Part.h:188
void NoteOff(unsigned char note)
Definition Part.cpp:626
unsigned char Pmuted
Definition Part.h:94
int lastposb
Definition Part.h:181
struct Part::@006256356256137173273147022164271224103033145322 kit[NUM_KIT_ITEMS]
void setkeylimit(unsigned char Pkeylimit)
Definition Part.cpp:888
Controller ctl
Definition Part.h:148
unsigned char Pnoteon
Definition Part.h:119
unsigned char Ppanning
Definition Part.h:115
void add2XML(XMLwrapper *xml)
Definition Part.cpp:1157
int saveXML(const char *filename)
Definition Part.cpp:1189
unsigned char velocity
Definition Part.h:187
void setkititemstatus(int kititem, int Penabled_)
Definition Part.cpp:1056
unsigned char Pcomments[MAX_INFO_TEXT_SIZE+1]
Definition Part.h:131
float * partoutr
Definition Part.h:136
ADnoteParameters * adpars
Definition Part.h:98
void setPpanning(char Ppanning)
Definition Part.cpp:1042
float volume
Definition Part.h:145
void RunNote(unsigned k)
Definition Part.cpp:928
void setPvolume(char Pvolume)
Definition Part.cpp:1035
unsigned char Pmaxkey
Definition Part.h:94
EffectMgr * partefx[NUM_PART_EFX]
Definition Part.h:150
unsigned char Pauthor[MAX_INFO_TEXT_SIZE+1]
Definition Part.h:130
Definition SUBnoteParameters.h:33
Definition SynthNote.h:28
register unsigned k
Definition inflate.c:946
static char filename[]
Definition features.c:5
struct backing_store_struct * info
Definition jmemsys.h:183
static void cleanup(void)
Definition lilv_test.c:152
Definition Part.h:168
int itemsplaying
Definition Part.h:171
NoteStatus status
Definition Part.h:169
struct Part::PartNotes::@206043346056251215376271021025252027352032065324 kititem[NUM_KIT_ITEMS]
int sendtoparteffect
Definition Part.h:176
int time
Definition Part.h:178
SynthNote * subnote
Definition Part.h:174
SynthNote * padnote
Definition Part.h:175
SynthNote * adnote
Definition Part.h:173
int note
Definition Part.h:170