mirror of https://github.com/dcoredump/dexed.git
parent
1087ad7c24
commit
fe88998c12
@ -0,0 +1,333 @@ |
||||
#ifndef dexed_ttl_h |
||||
#define dexed_ttl_h |
||||
|
||||
|
||||
#ifndef PEG_STRUCT |
||||
#define PEG_STRUCT |
||||
typedef struct { |
||||
float min; |
||||
float max; |
||||
float default_value; |
||||
char toggled; |
||||
char integer; |
||||
char logarithmic; |
||||
} peg_data_t; |
||||
#endif |
||||
|
||||
/* <https://github.com/dcoredump/dexed> */ |
||||
|
||||
static const char p_uri[] = "https://github.com/dcoredump/dexed"; |
||||
|
||||
enum p_port_enum { |
||||
p_lv2_events_in, |
||||
p_lv2_freewheel, |
||||
p_lv2_latency, |
||||
p_lv2_audio_out_1, |
||||
p_cutoff, |
||||
p_resonance, |
||||
p_output, |
||||
p_algorithm, |
||||
p_feedback, |
||||
p_osc_key_sync, |
||||
p_lfo_speed, |
||||
p_lfo_delay, |
||||
p_lfo_pm_depth, |
||||
p_lfo_am_depth, |
||||
p_lfo_key_sync, |
||||
p_lfo_wave, |
||||
p_middle_c, |
||||
p_p_mode_sens_, |
||||
p_pitch_eg_rate_1, |
||||
p_pitch_eg_rate_2, |
||||
p_pitch_eg_rate_3, |
||||
p_pitch_eg_rate_4, |
||||
p_pitch_eg_level_1, |
||||
p_pitch_eg_level_2, |
||||
p_pitch_eg_level_3, |
||||
p_pitch_eg_level_4, |
||||
p_op1_eg_rate_1, |
||||
p_op1_eg_rate_2, |
||||
p_op1_eg_rate_3, |
||||
p_op1_eg_rate_4, |
||||
p_op1_eg_level_1, |
||||
p_op1_eg_level_2, |
||||
p_op1_eg_level_3, |
||||
p_op1_eg_level_4, |
||||
p_op1_output_level, |
||||
p_op1_mode, |
||||
p_op1_f_coarse, |
||||
p_op1_f_fine, |
||||
p_op1_osc_detune, |
||||
p_op1_break_point, |
||||
p_op1_l_scale_depth, |
||||
p_op1_r_scale_depth, |
||||
p_op1_l_key_scale, |
||||
p_op1_r_key_scale, |
||||
p_op1_rate_scaling, |
||||
p_op1_a_mod_sens_, |
||||
p_op1_key_velocity, |
||||
p_op2_eg_rate_1, |
||||
p_op2_eg_rate_2, |
||||
p_op2_eg_rate_3, |
||||
p_op2_eg_rate_4, |
||||
p_op2_eg_level_1, |
||||
p_op2_eg_level_2, |
||||
p_op2_eg_level_3, |
||||
p_op2_eg_level_4, |
||||
p_op2_output_level, |
||||
p_op2_mode, |
||||
p_op2_f_coarse, |
||||
p_op2_f_fine, |
||||
p_op2_osc_detune, |
||||
p_op2_break_point, |
||||
p_op2_l_scale_depth, |
||||
p_op2_r_scale_depth, |
||||
p_op2_l_key_scale, |
||||
p_op2_r_key_scale, |
||||
p_op2_rate_scaling, |
||||
p_op2_a_mod_sens_, |
||||
p_op2_key_velocity, |
||||
p_op3_eg_rate_1, |
||||
p_op3_eg_rate_2, |
||||
p_op3_eg_rate_3, |
||||
p_op3_eg_rate_4, |
||||
p_op3_eg_level_1, |
||||
p_op3_eg_level_2, |
||||
p_op3_eg_level_3, |
||||
p_op3_eg_level_4, |
||||
p_op3_output_level, |
||||
p_op3_mode, |
||||
p_op3_f_coarse, |
||||
p_op3_f_fine, |
||||
p_op3_osc_detune, |
||||
p_op3_break_point, |
||||
p_op3_l_scale_depth, |
||||
p_op3_r_scale_depth, |
||||
p_op3_l_key_scale, |
||||
p_op3_r_key_scale, |
||||
p_op3_rate_scaling, |
||||
p_op3_a_mod_sens_, |
||||
p_op3_key_velocity, |
||||
p_op4_eg_rate_1, |
||||
p_op4_eg_rate_2, |
||||
p_op4_eg_rate_3, |
||||
p_op4_eg_rate_4, |
||||
p_op4_eg_level_1, |
||||
p_op4_eg_level_2, |
||||
p_op4_eg_level_3, |
||||
p_op4_eg_level_4, |
||||
p_op4_output_level, |
||||
p_op4_mode, |
||||
p_op4_f_coarse, |
||||
p_op4_f_fine, |
||||
p_op4_osc_detune, |
||||
p_op4_break_point, |
||||
p_op4_l_scale_depth, |
||||
p_op4_r_scale_depth, |
||||
p_op4_l_key_scale, |
||||
p_op4_r_key_scale, |
||||
p_op4_rate_scaling, |
||||
p_op4_a_mod_sens_, |
||||
p_op4_key_velocity, |
||||
p_op5_eg_rate_1, |
||||
p_op5_eg_rate_2, |
||||
p_op5_eg_rate_3, |
||||
p_op5_eg_rate_4, |
||||
p_op5_eg_level_1, |
||||
p_op5_eg_level_2, |
||||
p_op5_eg_level_3, |
||||
p_op5_eg_level_4, |
||||
p_op5_output_level, |
||||
p_op5_mode, |
||||
p_op5_f_coarse, |
||||
p_op5_f_fine, |
||||
p_op5_osc_detune, |
||||
p_op5_break_point, |
||||
p_op5_l_scale_depth, |
||||
p_op5_r_scale_depth, |
||||
p_op5_l_key_scale, |
||||
p_op5_r_key_scale, |
||||
p_op5_rate_scaling, |
||||
p_op5_a_mod_sens_, |
||||
p_op5_key_velocity, |
||||
p_op6_eg_rate_1, |
||||
p_op6_eg_rate_2, |
||||
p_op6_eg_rate_3, |
||||
p_op6_eg_rate_4, |
||||
p_op6_eg_level_1, |
||||
p_op6_eg_level_2, |
||||
p_op6_eg_level_3, |
||||
p_op6_eg_level_4, |
||||
p_op6_output_level, |
||||
p_op6_mode, |
||||
p_op6_f_coarse, |
||||
p_op6_f_fine, |
||||
p_op6_osc_detune, |
||||
p_op6_break_point, |
||||
p_op6_l_scale_depth, |
||||
p_op6_r_scale_depth, |
||||
p_op6_l_key_scale, |
||||
p_op6_r_key_scale, |
||||
p_op6_rate_scaling, |
||||
p_op6_a_mod_sens_, |
||||
p_op6_key_velocity, |
||||
p_n_ports |
||||
}; |
||||
|
||||
static const peg_data_t p_ports[] = { |
||||
{ -3.40282e+38, 3.40282e+38, -3.40282e+38, 0, 0, 0 },
|
||||
{ 0, 1, 0, 1, 0, 0 },
|
||||
{ -3.40282e+38, 3.40282e+38, -3.40282e+38, 0, 1, 0 },
|
||||
{ -3.40282e+38, 3.40282e+38, -3.40282e+38, 0, 0, 0 },
|
||||
{ 0, 1, 1, 0, 0, 0 },
|
||||
{ 0, 1, 0, 0, 0, 0 },
|
||||
{ 0, 2, 1, 0, 0, 0 },
|
||||
{ 1, 32, 1, 0, 1, 0 },
|
||||
{ 1, 8, 1, 0, 1, 0 },
|
||||
{ 1, 1, 0, 1, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 1, 0, 1, 1, 0 },
|
||||
{ 1, 6, 1, 0, 1, 0 },
|
||||
{ 0, 48, 24, 0, 1, 0 },
|
||||
{ 1, 8, 1, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 1, 0, 1, 1, 0 },
|
||||
{ 0, 31, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ -7, 7, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 1, 0, 1, 1, 0 },
|
||||
{ 0, 31, 0, 0, 1, 0 },
|
||||
{ 0, 100, 0, 0, 1, 0 },
|
||||
{ -7, 7, 0, 0, 1, 0 },
|
||||
{ 0, 100, 0, 0, 1, 0 },
|
||||
{ 0, 100, 0, 0, 1, 0 },
|
||||
{ 0, 100, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 1, 0, 1, 1, 0 },
|
||||
{ 0, 31, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ -7, 7, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 1, 0 },
|
||||
{ 0, 99, 1, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 7, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 1, 0, 1, 1, 0 },
|
||||
{ 0, 31, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ -7, 7, 0, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 39, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 1, 0, 1, 1, 0 },
|
||||
{ 0, 31, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ -7, 7, 0, 0, 1, 0 },
|
||||
{ 0, 99, 39, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 99, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 1, 0, 1, 1, 0 },
|
||||
{ 0, 31, 1, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ -7, 7, 7, 0, 1, 0 },
|
||||
{ 0, 99, 39, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 99, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 1, 0 },
|
||||
{ 0, 3, 0, 0, 1, 0 },
|
||||
{ 0, 7, 0, 0, 1, 0 },
|
||||
}; |
||||
|
||||
|
||||
#endif /* dexed_ttl_h */ |
@ -0,0 +1,76 @@ |
||||
/*
|
||||
* Copyright 2012 Google Inc. |
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
#include <time.h> |
||||
#include <string.h> |
||||
|
||||
#include "synth.h" |
||||
#include "ringbuffer.h" |
||||
|
||||
RingBuffer::RingBuffer() { |
||||
rd_ix_ = 0; |
||||
wr_ix_ = 0; |
||||
} |
||||
|
||||
int RingBuffer::BytesAvailable() { |
||||
return (wr_ix_ - rd_ix_) & (kBufSize - 1); |
||||
} |
||||
|
||||
int RingBuffer::WriteBytesAvailable() { |
||||
return (rd_ix_ - wr_ix_ - 1) & (kBufSize - 1); |
||||
} |
||||
|
||||
int RingBuffer::Read(int size, uint8_t *bytes) { |
||||
int rd_ix = rd_ix_; |
||||
SynthMemoryBarrier(); // read barrier, make sure data is committed before ix
|
||||
int fragment_size = min(size, kBufSize - rd_ix); |
||||
memcpy(bytes, buf_ + rd_ix, fragment_size); |
||||
if (size > fragment_size) { |
||||
memcpy(bytes + fragment_size, buf_, size - fragment_size); |
||||
} |
||||
SynthMemoryBarrier(); // full barrier, make sure read commits before updating
|
||||
rd_ix_ = (rd_ix + size) & (kBufSize - 1); |
||||
return size; |
||||
} |
||||
|
||||
int RingBuffer::Write(const uint8_t *bytes, int size) { |
||||
int remaining = size; |
||||
while (remaining > 0) { |
||||
int rd_ix = rd_ix_; |
||||
int wr_ix = wr_ix_; |
||||
int space_available = (rd_ix - wr_ix - 1) & (kBufSize - 1); |
||||
if (space_available == 0) { |
||||
struct timespec sleepTime; |
||||
sleepTime.tv_sec = 0; |
||||
sleepTime.tv_nsec = 1000000; |
||||
nanosleep(&sleepTime, NULL); |
||||
} else { |
||||
int wr_size = min(remaining, space_available); |
||||
int fragment_size = min(wr_size, kBufSize - wr_ix); |
||||
memcpy(buf_ + wr_ix, bytes, fragment_size); |
||||
if (wr_size > fragment_size) { |
||||
memcpy(buf_, bytes + fragment_size, wr_size - fragment_size); |
||||
} |
||||
SynthMemoryBarrier(); // write barrier, make sure data commits
|
||||
wr_ix_ = (wr_ix + wr_size) & (kBufSize - 1); |
||||
remaining -= wr_size; |
||||
bytes += wr_size; |
||||
} |
||||
} |
||||
// JJK : defined as returning int
|
||||
return 0; |
||||
} |
||||
|
@ -0,0 +1,44 @@ |
||||
/*
|
||||
* Copyright 2012 Google Inc. |
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
#ifndef SYNTH_RINGBUFFER_H_ |
||||
#define SYNTH_RINGBUFFER_H_ |
||||
|
||||
class RingBuffer { |
||||
public: |
||||
RingBuffer(); |
||||
|
||||
// Returns number of bytes available for reading.
|
||||
int BytesAvailable(); |
||||
|
||||
// Returns number of bytes that can be written without blocking.
|
||||
int WriteBytesAvailable(); |
||||
|
||||
// Reads bytes. It is the caller's responsibility to make sure that
|
||||
// size <= a previous value of BytesAvailable().
|
||||
int Read(int size, uint8_t *bytes); |
||||
|
||||
// Writes bytes into the buffer. If the buffer is full, the method will
|
||||
// block until space is available.
|
||||
int Write(const uint8_t *bytes, int size); |
||||
private: |
||||
static const int kBufSize = 8192; |
||||
uint8_t buf_[kBufSize]; |
||||
volatile unsigned int rd_ix_; |
||||
volatile unsigned int wr_ix_; |
||||
}; |
||||
|
||||
#endif // SYNTH_RINGBUFFER_H_
|
Loading…
Reference in new issue