2 |
* * |
* * |
3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2008-2009 Anders Dahnielson <anders@dahnielson.com> * |
* Copyright (C) 2008 Anders Dahnielson <anders@dahnielson.com> * |
6 |
* Copyright (C) 2009 Grigor Iliev * |
* Copyright (C) 2009 - 2010 Anders Dahnielson and Grigor Iliev * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
32 |
|
|
33 |
#include "../common/SampleFile.h" |
#include "../common/SampleFile.h" |
34 |
#include "../common/SampleManager.h" |
#include "../common/SampleManager.h" |
35 |
|
#include "../../common/ArrayList.h" |
36 |
|
|
37 |
#define TRIGGER_ATTACK ((unsigned char) (1 << 0)) // 0x01 |
#define TRIGGER_ATTACK ((unsigned char) (1 << 0)) // 0x01 |
38 |
#define TRIGGER_RELEASE ((unsigned char) (1 << 1)) // 0x02 |
#define TRIGGER_RELEASE ((unsigned char) (1 << 1)) // 0x02 |
39 |
#define TRIGGER_FIRST ((unsigned char) (1 << 2)) // 0x04 |
#define TRIGGER_FIRST ((unsigned char) (1 << 2)) // 0x04 |
40 |
#define TRIGGER_LEGATO ((unsigned char) (1 << 3)) // 0x08 |
#define TRIGGER_LEGATO ((unsigned char) (1 << 3)) // 0x08 |
41 |
|
|
42 |
namespace sfz |
namespace sfz |
43 |
{ |
{ |
44 |
// Forward declarations |
// Forward declarations |
45 |
class Articulation; |
class Articulation; |
48 |
class Instrument; |
class Instrument; |
49 |
class File; |
class File; |
50 |
|
|
51 |
|
class Sample : public LinuxSampler::SampleFileBase<Region> { |
52 |
|
public: |
53 |
|
Sample(String File, bool DontClose = false) : LinuxSampler::SampleFileBase<Region>(File, DontClose) { } |
54 |
|
virtual ~Sample() { } |
55 |
|
}; |
56 |
|
|
57 |
// Enumerations |
// Enumerations |
58 |
enum sw_vel_t { VEL_CURRENT, VEL_PREVIOUS }; |
enum sw_vel_t { VEL_CURRENT, VEL_PREVIOUS }; |
59 |
enum off_mode_t { OFF_FAST, OFF_NORMAL }; |
enum off_mode_t { OFF_FAST, OFF_NORMAL }; |
60 |
enum loop_mode_t { NO_LOOP, ONE_SHOT, LOOP_CONTINOUS, LOOP_SUSTAIN }; |
enum loop_mode_t { NO_LOOP, ONE_SHOT, LOOP_CONTINUOUS, LOOP_SUSTAIN }; |
61 |
enum curve_t { GAIN, POWER }; |
enum curve_t { GAIN, POWER }; |
62 |
enum filter_t { LPF_1P, HPF_1P, BPF_1P, BRF_1P, APF_1P, |
enum filter_t { LPF_1P, HPF_1P, BPF_1P, BRF_1P, APF_1P, |
63 |
LPF_2P, HPF_2P, BPF_2P, BRF_2P, PKF_2P, |
LPF_2P, HPF_2P, BPF_2P, BRF_2P, PKF_2P, |
67 |
typedef unsigned char trigger_t; |
typedef unsigned char trigger_t; |
68 |
typedef unsigned char uint8_t; |
typedef unsigned char uint8_t; |
69 |
|
|
70 |
class SampleManager : public LinuxSampler::SampleManager<LinuxSampler::SampleFile, Region> { |
class SampleManager : public LinuxSampler::SampleManager<Sample, Region> { |
71 |
public: |
public: |
72 |
LinuxSampler::SampleFile* FindSample(std::string samplePath); |
Sample* FindSample(std::string samplePath); |
73 |
|
|
74 |
protected: |
protected: |
75 |
virtual void OnSampleInUse(LinuxSampler::SampleFile* pSample) { |
virtual void OnSampleInUse(Sample* pSample) { |
76 |
pSample->Open(); |
pSample->Open(); |
77 |
} |
} |
78 |
|
|
79 |
virtual void OnSampleInNotUse(LinuxSampler::SampleFile* pSample) { |
virtual void OnSampleInNotUse(Sample* pSample) { |
80 |
pSample->Close(); |
pSample->Close(); |
81 |
} |
} |
82 |
}; |
}; |
215 |
virtual ~Articulation(); |
virtual ~Articulation(); |
216 |
}; |
}; |
217 |
|
|
218 |
|
class EGNode |
219 |
|
{ |
220 |
|
public: |
221 |
|
float time; |
222 |
|
float level; |
223 |
|
float shape; |
224 |
|
float curve; |
225 |
|
EGNode(); |
226 |
|
}; |
227 |
|
|
228 |
|
class EG |
229 |
|
{ |
230 |
|
public: |
231 |
|
LinuxSampler::ArrayList<EGNode> node; |
232 |
|
int sustain; |
233 |
|
int loop; |
234 |
|
int loop_count; |
235 |
|
float amplitude; |
236 |
|
float cutoff; |
237 |
|
EG(); |
238 |
|
}; |
239 |
|
|
240 |
///////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////// |
241 |
// class Definition |
// class Definition |
242 |
|
|
278 |
|
|
279 |
trigger_t trigger; |
trigger_t trigger; |
280 |
|
|
281 |
optional<int> group; |
uint group; |
282 |
optional<int> off_by; |
optional<int> off_by; |
283 |
off_mode_t off_mode; |
off_mode_t off_mode; |
284 |
|
|
349 |
float eq1_gain; float eq2_gain; float eq3_gain; |
float eq1_gain; float eq2_gain; float eq3_gain; |
350 |
std::vector<float> eq1_gain_oncc; std::vector<float> eq2_gain_oncc; std::vector<float> eq3_gain_oncc; |
std::vector<float> eq1_gain_oncc; std::vector<float> eq2_gain_oncc; std::vector<float> eq3_gain_oncc; |
351 |
float eq1_vel2gain; float eq2_vel2gain; float eq3_vel2gain; |
float eq1_vel2gain; float eq2_vel2gain; float eq3_vel2gain; |
352 |
|
|
353 |
|
//Deprecated (from version 1) |
354 |
|
float ampeg_delay, ampeg_start, ampeg_attack, ampeg_hold, ampeg_decay, ampeg_sustain, ampeg_release; |
355 |
|
float fileg_delay, fileg_start, fileg_attack, fileg_hold, fileg_decay, fileg_sustain, fileg_release; |
356 |
|
float pitcheg_delay, pitcheg_start, pitcheg_attack, pitcheg_hold, pitcheg_decay, pitcheg_sustain, pitcheg_release; |
357 |
|
|
358 |
|
// envelope generators |
359 |
|
LinuxSampler::ArrayList<EG> eg; |
360 |
}; |
}; |
361 |
|
|
362 |
///////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////// |
370 |
Region(); |
Region(); |
371 |
virtual ~Region(); |
virtual ~Region(); |
372 |
|
|
373 |
LinuxSampler::SampleFile* pSample; |
Sample* pSample; |
374 |
LinuxSampler::SampleFile* GetSample(bool create = true); |
Sample* GetSample(bool create = true); |
375 |
void DestroySampleIfNotUsed(); |
void DestroySampleIfNotUsed(); |
376 |
|
|
377 |
Region* GetParent() { return this; }; // needed by EngineBase |
Region* GetParent() { return this; }; // needed by EngineBase |
378 |
Instrument* GetInstrument() { return pInstrument; } |
Instrument* GetInstrument() { return pInstrument; } |
379 |
void SetInstrument(Instrument* pInstrument) { this->pInstrument = pInstrument; } |
void SetInstrument(Instrument* pInstrument) { this->pInstrument = pInstrument; } |
380 |
|
|
381 |
|
bool HasLoop(); |
382 |
|
uint GetLoopStart(); |
383 |
|
uint GetLoopEnd(); |
384 |
|
uint GetLoopCount(); |
385 |
|
|
386 |
/// Return true if region is triggered by key |
/// Return true if region is triggered by key |
387 |
bool OnKey(uint8_t chan, uint8_t key, uint8_t vel, |
bool OnKey(uint8_t chan, uint8_t key, uint8_t vel, |
388 |
int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft, |
int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft, |
485 |
void push_opcode(std::string token); |
void push_opcode(std::string token); |
486 |
int parseInt(std::string value); |
int parseInt(std::string value); |
487 |
float parseFloat(std::string value); |
float parseFloat(std::string value); |
488 |
|
EG& eg(int x); |
489 |
|
EGNode& egnode(int x, int y); |
490 |
|
|
491 |
std::string currentDir; |
std::string currentDir; |
492 |
/// Pointer to the Instrument belonging to this file |
/// Pointer to the Instrument belonging to this file |