98 double incphase = 440*pow(2.0, (note-69)/12.0 + cents/1200.0)/sr;
99 if (incphase >= 1.0) incphase = fmod(incphase, 1.0);
100 incphase *= 65536.0*65536.0;
101 return (
unsigned int)incphase;
123 virtual void render_to(
float (*buf)[2],
int nsamples)=0;
137 enum {
BlockSize = Base::BlockSize,
MaxSnapshots = (Base::MaxSampleRun + Base::BlockSize - 1) / Base::BlockSize + 1 };
144 while(
sample_ctr + nsamples >= Base::BlockSize)
165 using Base::Channels;
167 using Base::BlockSize;
169 using Base::output_buffer;
171 using Base::render_block;
186 int current_snapshot = 0;
191 render_block(current_snapshot);
195 int ncopy = std::min<int>(BlockSize -
read_ptr, nsamples -
p);
196 for (
int i = 0;
i < ncopy;
i++)
197 for (
int c = 0;
c < Channels;
c++)
205#define for_all_voices(iter) for (dsp::voice **iter = active_voices.begin(); iter != active_voices.end(); iter++)
227 items =
new T[max_count];
254 if (pos !=
count - 1)
299 void kill_note(
int note,
int vel,
bool just_one);
311 virtual void render_to(
float (*output)[2],
int nsamples);
312 virtual void note_on(
int note,
int vel);
315 virtual void note_off(
int note,
int vel);
void fill_snapshots(int nsamples)
Definition synth.h:140
virtual void make_snapshot(int index)=0
unsigned int sample_ctr
Definition synth.h:138
@ MaxSnapshots
Definition synth.h:137
@ BlockSize
Definition synth.h:137
unsigned int read_ptr
Definition synth.h:172
virtual void reset()
Definition synth.h:178
virtual void render_to(float(*buf)[2], int nsamples)
Definition synth.h:183
block_voice()
Definition synth.h:174
int dcount
Definition synth.h:40
keystack()
Definition synth.h:44
bool push(int key)
Definition synth.h:53
bool pop(int key)
Definition synth.h:62
int nth(int n)
Definition synth.h:86
bool empty()
Definition synth.h:83
uint8_t states[128]
Definition synth.h:42
bool has(int key)
Definition synth.h:77
uint8_t active[128]
Definition synth.h:41
void clear()
Definition synth.h:48
int count()
Definition synth.h:80
virtual bool get_active()=0
check if voice can be removed from active voice list
virtual void render_to(float(*buf)[2], int nsamples)=0
render voice data to buffer
virtual void setup(int sr)
reset voice to default state (used when a voice is to be reused)
Definition synth.h:113
voice()
Definition synth.h:110
bool released
Definition synth.h:108
virtual ~voice()
empty virtual destructor
Definition synth.h:130
virtual void reset()=0
reset voice to default state (used when a voice is to be reused)
int sample_rate
Definition synth.h:107
bool stolen
Definition synth.h:108
virtual void note_on(int note, int vel)=0
a note was pressed
bool sostenuto
Definition synth.h:108
virtual float get_priority()
Definition synth.h:128
virtual int get_current_note()=0
return the note used by this voice
virtual void note_off(int vel)=0
a note was released
virtual void steal()=0
very fast note off
unsigned v[N_MAX]
Definition inflate.c:1584
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
int val
Definition jpeglib.h:956
unsigned char uint8_t
Definition mid.cpp:98
unsigned int midi_note_to_phase(int note, double cents, int sr)
Definition synth.h:97
#define false
Definition ordinals.h:83
A basic preallocated var-array with append and.
Definition synth.h:209
size_t size() const
Definition synth.h:236
void init(int max_count)
Definition synth.h:222
~basic_pool()
Definition synth.h:267
int alloc_size
Definition synth.h:214
bool add(T v)
Definition synth.h:238
const T * const_iterator
Definition synth.h:211
T * iterator
Definition synth.h:210
const T * begin() const
Definition synth.h:233
const T * end() const
Definition synth.h:234
T pop()
Definition synth.h:260
void erase(int pos)
Definition synth.h:251
int count
Definition synth.h:213
iterator erase(iterator iter)
Definition synth.h:246
dsp::voice ** items
Definition synth.h:212
T * end()
Definition synth.h:232
T * begin()
Definition synth.h:231
basic_pool()
Definition synth.h:216
bool empty() const
Definition synth.h:235
virtual ~basic_synth()
Definition synth.cpp:218
voice_array active_voices
Voices currently playing.
Definition synth.h:290
virtual dsp::voice * give_voice()
Definition synth.cpp:51
int sample_rate
Current sample rate.
Definition synth.h:282
bool sostenuto
Sostenuto pedal state.
Definition synth.h:286
basic_pool< dsp::voice * > voice_array
Definition synth.h:280
virtual void control_change(int ctl, int val)
Definition synth.cpp:156
virtual void steal_voice()
Definition synth.cpp:64
virtual dsp::voice * alloc_voice()=0
virtual void render_to(float(*output)[2], int nsamples)
Definition synth.cpp:203
virtual void trim_voices()
Definition synth.cpp:85
virtual void setup(int sr)
Definition synth.h:302
virtual void note_off(int note, int vel)
Definition synth.cpp:123
void init_voices(int count)
Definition synth.cpp:26
virtual void percussion_note_on(int note, int vel)
Definition synth.h:313
virtual bool check_percussion()
Definition synth.h:319
void kill_note(int note, int vel, bool just_one)
Definition synth.cpp:39
std::bitset< 128 > gate
Gate values for all 128 MIDI notes.
Definition synth.h:294
bool hold
Hold pedal state.
Definition synth.h:284
virtual void note_on(int note, int vel)
Definition synth.cpp:102
virtual void pitch_bend(int amt)
amt = -8192 to 8191
Definition synth.h:317
virtual void on_pedal_release()
Definition synth.cpp:130
unsigned int polyphony_limit
Maximum allocated number of channels.
Definition synth.h:296
voice_array unused_voices
Voices allocated, but not used.
Definition synth.h:292
voice_array allocated_voices
All voices available.
Definition synth.h:288
int n
Definition crypt.c:458
uch * p
Definition crypt.c:594
return c
Definition crypt.c:175
ZCONST char * key
Definition crypt.c:587
_WDL_CSTRING_PREFIX void INT_PTR count
Definition wdlcstring.h:263