Skip to content
This repository was archived by the owner on Feb 8, 2025. It is now read-only.

Commit

Permalink
Merge branch 'master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
mtytel committed Feb 24, 2018
2 parents cb54f5d + 1dd743f commit 559f5f1
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 24 deletions.
2 changes: 1 addition & 1 deletion JUCE/modules/juce_audio_devices/native/juce_linux_Midi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ static AlsaClient::Port* iterateMidiClient (const AlsaClient::Ptr& client,
{
if (snd_seq_query_next_port (seqHandle, portInfo) == 0
&& (snd_seq_port_info_get_capability (portInfo)
& (forInput ? SND_SEQ_PORT_CAP_SUBS_WRITE : SND_SEQ_PORT_CAP_SUBS_READ)) != 0)
& (forInput ? SND_SEQ_PORT_CAP_SUBS_READ : SND_SEQ_PORT_CAP_SUBS_WRITE)) != 0)
{
const String portName = snd_seq_port_info_get_name(portInfo);

Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ ifndef LIBDIR
endif

DPKG := $(shell dpkg-buildflags --version 2> /dev/null)
PAID := 1

ifdef DPKG
DEB_BUILD_MAINT_OPTIONS = hardening=+all
Expand Down
3 changes: 1 addition & 2 deletions mopo/src/circular_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ namespace mopo {
CircularQueue() : data_(nullptr), capacity_(0), start_(0), end_(0) { }

void reserve(int capcity) {
if (data_)
delete data_;
delete data_;

capacity_ = capcity + 1;
data_ = new T[capacity_];
Expand Down
5 changes: 4 additions & 1 deletion mopo/src/reverb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ namespace mopo {

Bypass* audio_input = new Bypass();
LinearSmoothBuffer* feedback_input = new LinearSmoothBuffer();
cr::Clamp* damping_clamp = new cr::Clamp(0.0f, 1.0f);
LinearSmoothBuffer* damping_input = new LinearSmoothBuffer();

registerInput(audio_input->input(), kAudio);
registerInput(feedback_input->input(), kFeedback);
registerInput(damping_input->input(), kDamping);
registerInput(damping_clamp->input(0), kDamping);
damping_input->plug(damping_clamp);

Multiply* gained_input = new Multiply();
gained_input->plug(audio_input, 0);
Expand All @@ -41,6 +43,7 @@ namespace mopo {
addProcessor(audio_input);
addProcessor(gained_input);
addProcessor(feedback_input);
addProcessor(damping_clamp);
addProcessor(damping_input);

VariableAdd* left_comb_total = new VariableAdd(NUM_COMB);
Expand Down
35 changes: 32 additions & 3 deletions mopo/src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
#include <cmath>
#include <cstdlib>

#ifdef __SSE2__
#include <emmintrin.h>
#else
#if defined(_MSC_VER)
#include <intrin.h>
#elif defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__))
#include <x86intrin.h>
#elif defined(__GNUC__) && defined(__ARM_NEON__)
#include <algorithm>
#endif

Expand Down Expand Up @@ -90,6 +92,17 @@ namespace mopo {
return value;
}

inline void enableDenormalFlushing(bool enable) {
if (enable) {
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
}
else {
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_OFF);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_OFF);
}
}

#else
inline mopo_float min(mopo_float one, mopo_float two) {
return fmin(one, two);
Expand All @@ -102,6 +115,10 @@ namespace mopo {
inline mopo_float clamp(mopo_float value, mopo_float min, mopo_float max) {
return fmin(max, fmax(value, min));
}

inline void enableDenormalFlushing(bool enable) {
}

#endif

inline int imax(int one, int two) {
Expand Down Expand Up @@ -136,6 +153,10 @@ namespace mopo {
return value <= EPSILON && value >= -EPSILON;
}

inline bool closeToZerof(float value) {
return value <= EPSILON && value >= -EPSILON;
}

inline mopo_float gainToDb(mopo_float gain) {
return DB_GAIN_CONVERSION_MULT * log10(gain);
}
Expand Down Expand Up @@ -221,6 +242,14 @@ namespace mopo {
return true;
}

inline bool isSilentf(const float* buffer, int length) {
for (int i = 0; i < length; ++i) {
if (!closeToZerof(buffer[i]))
return false;
}
return true;
}

inline mopo_float rms(const mopo_float* buffer, int num) {
mopo_float square_total = 0.0;
VECTORIZE_LOOP
Expand Down
2 changes: 1 addition & 1 deletion src/common/helm_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ namespace mopo {
ValueDetails::kLinear, false, "cents", "Osc Feedback Tune" },
{ "osc_mix", 0.0, 1.0, 0, 0.5, 0.0, 1.0, // DEPRECATED
ValueDetails::kLinear, false, "", "Osc Mix" },
{ "pitch_bend_range", 0.0, 24.0, 25, 2.0, 0.0, 1.0,
{ "pitch_bend_range", 0.0, 48.0, 49, 2.0, 0.0, 1.0,
ValueDetails::kLinear, false, "semitones", "Pitch Bend Range" },
{ "poly_lfo_amplitude", -1.0, 1.0, 0, 1.0, 0.0, 1.0,
ValueDetails::kLinear, false, "", "Poly LFO Amp" },
Expand Down
2 changes: 2 additions & 0 deletions src/common/synth_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ bool SynthBase::saveToActiveFile() {
}

void SynthBase::processAudio(AudioSampleBuffer* buffer, int channels, int samples, int offset) {
mopo::utils::enableDenormalFlushing(true);

if (engine_.getBufferSize() != samples)
engine_.setBufferSize(samples);

Expand Down
8 changes: 4 additions & 4 deletions src/editor_components/open_gl_background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void OpenGLBackground::init(OpenGLContext& open_gl_context) {
image_shader_->use();
position_ = new OpenGLShaderProgram::Attribute(*image_shader_, "position");
texture_coordinates_ = new OpenGLShaderProgram::Attribute(*image_shader_, "tex_coord_in");
texture_uniform_ = new OpenGLShaderProgram::Uniform(*image_shader_, "texture");
texture_uniform_ = new OpenGLShaderProgram::Uniform(*image_shader_, "image");
}
}

Expand Down Expand Up @@ -111,6 +111,8 @@ void OpenGLBackground::disableAttributes(OpenGLContext& open_gl_context) {
}

void OpenGLBackground::render(OpenGLContext& open_gl_context) {
MOPO_ASSERT(glGetError() == GL_NO_ERROR);

if ((new_background_ || background_.getWidth() == 0) && background_image_.getWidth() > 0) {
new_background_ = false;
background_.loadImage(background_image_);
Expand All @@ -129,7 +131,6 @@ void OpenGLBackground::render(OpenGLContext& open_gl_context) {
vertices_, GL_STATIC_DRAW);
}

glEnable(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

Expand All @@ -145,10 +146,9 @@ void OpenGLBackground::render(OpenGLContext& open_gl_context) {
disableAttributes(open_gl_context);
background_.unbind();

glDisable(GL_TEXTURE_2D);

open_gl_context.extensions.glBindBuffer(GL_ARRAY_BUFFER, 0);
open_gl_context.extensions.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
MOPO_ASSERT(glGetError() == GL_NO_ERROR);
}

void OpenGLBackground::updateBackgroundImage(Image background) {
Expand Down
7 changes: 4 additions & 3 deletions src/editor_components/open_gl_envelope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ void OpenGLEnvelope::drawPosition(OpenGLContext& open_gl_context) {
position_texture_.bind();

open_gl_context.extensions.glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);

if (background_.texture_uniform() != nullptr)
background_.texture_uniform()->set(0);
Expand All @@ -450,19 +449,21 @@ void OpenGLEnvelope::drawPosition(OpenGLContext& open_gl_context) {

position_texture_.unbind();

glDisable(GL_TEXTURE_2D);

open_gl_context.extensions.glBindBuffer(GL_ARRAY_BUFFER, 0);
open_gl_context.extensions.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}

void OpenGLEnvelope::render(OpenGLContext& open_gl_context, bool animate) {
MOPO_ASSERT(glGetError() == GL_NO_ERROR);

setViewPort(open_gl_context);

background_.render(open_gl_context);

if (animate)
drawPosition(open_gl_context);

MOPO_ASSERT(glGetError() == GL_NO_ERROR);
}

void OpenGLEnvelope::destroy(OpenGLContext& open_gl_context) {
Expand Down
7 changes: 4 additions & 3 deletions src/editor_components/open_gl_oscilloscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ void OpenGLOscilloscope::drawLines(OpenGLContext& open_gl_context) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
int desktop_scale = roundToInt(open_gl_context.getRenderingScale());
float ratio = getHeight() / 64.0f;
glLineWidth(2.0f * ratio * desktop_scale);
glLineWidth(1.0f);

setViewPort(open_gl_context);

if (output_memory_) {
Expand Down Expand Up @@ -121,11 +120,13 @@ void OpenGLOscilloscope::drawLines(OpenGLContext& open_gl_context) {
GL_FALSE, 2 * sizeof(float), 0);
open_gl_context.extensions.glEnableVertexAttribArray(position_->attributeID);
glDrawElements(GL_LINES, 2 * RESOLUTION, GL_UNSIGNED_INT, 0);

open_gl_context.extensions.glDisableVertexAttribArray(position_->attributeID);

open_gl_context.extensions.glBindBuffer(GL_ARRAY_BUFFER, 0);
open_gl_context.extensions.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glDisable(GL_LINE_SMOOTH);
MOPO_ASSERT(glGetError() == GL_NO_ERROR);
}

void OpenGLOscilloscope::render(OpenGLContext& open_gl_context, bool animate) {
Expand Down
4 changes: 4 additions & 0 deletions src/editor_components/open_gl_peak_meter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ void OpenGLPeakMeter::updateVertices() {
}

void OpenGLPeakMeter::render(OpenGLContext& open_gl_context, bool animate) {
MOPO_ASSERT(glGetError() == GL_NO_ERROR);

if (!animate || peak_output_ == nullptr)
return;

Expand All @@ -117,6 +119,8 @@ void OpenGLPeakMeter::render(OpenGLContext& open_gl_context, bool animate) {

open_gl_context.extensions.glBindBuffer(GL_ARRAY_BUFFER, 0);
open_gl_context.extensions.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

MOPO_ASSERT(glGetError() == GL_NO_ERROR);
}

void OpenGLPeakMeter::destroy(OpenGLContext& open_gl_context) {
Expand Down
7 changes: 4 additions & 3 deletions src/editor_components/open_gl_wave_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ void OpenGLWaveViewer::drawPosition(OpenGLContext& open_gl_context) {
position_texture_.bind();

open_gl_context.extensions.glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);

if (background_.texture_uniform() != nullptr)
background_.texture_uniform()->set(0);
Expand All @@ -305,19 +304,21 @@ void OpenGLWaveViewer::drawPosition(OpenGLContext& open_gl_context) {

position_texture_.unbind();

glDisable(GL_TEXTURE_2D);

open_gl_context.extensions.glBindBuffer(GL_ARRAY_BUFFER, 0);
open_gl_context.extensions.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}

void OpenGLWaveViewer::render(OpenGLContext& open_gl_context, bool animate) {
MOPO_ASSERT(glGetError() == GL_NO_ERROR);

setViewPort(open_gl_context);

background_.render(open_gl_context);

if (animate)
drawPosition(open_gl_context);

MOPO_ASSERT(glGetError() == GL_NO_ERROR);
}

void OpenGLWaveViewer::destroy(OpenGLContext& open_gl_context) {
Expand Down
1 change: 1 addition & 0 deletions src/editor_sections/full_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ FullInterface::FullInterface(mopo::control_map controls, mopo::output_map modula
open_gl_context.setContinuousRepainting(true);
open_gl_context.setRenderer(this);
open_gl_context.attachTo(*getTopLevelComponent());
open_gl_context.setOpenGLVersionRequired(OpenGLContext::openGL3_2);

addSubSection(synthesis_interface_ = new SynthesisInterface(controls, keyboard_state));
addSubSection(arp_section_ = new ArpSection(TRANS("ARP")));
Expand Down
4 changes: 2 additions & 2 deletions src/look_and_feel/shaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const char* Shaders::shaders_[] = {

"varying " JUCE_MEDIUMP " vec2 tex_coord_out;\n"
"\n"
"uniform sampler2D texture;\n"
"uniform sampler2D image;\n"
"\n"
"void main()\n"
"{\n"
" gl_FragColor = texture2D(texture, tex_coord_out);\n"
" gl_FragColor = texture2D(image, tex_coord_out);\n"
"}\n",

"attribute " JUCE_MEDIUMP " vec4 position;\n"
Expand Down
5 changes: 5 additions & 0 deletions src/synthesis/helm_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ namespace mopo {
arpeggiator_->setBufferSize(buffer_size);
}

void HelmEngine::setSampleRate(int sample_rate) {
ProcessorRouter::setSampleRate(sample_rate);
arpeggiator_->setSampleRate(sample_rate);
}

void HelmEngine::allNotesOff(int sample) {
arpeggiator_->allNotesOff(sample);
}
Expand Down
1 change: 1 addition & 0 deletions src/synthesis/helm_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace mopo {

void process() override;
void setBufferSize(int buffer_size) override;
void setSampleRate(int sample_rate) override;

std::set<ModulationConnection*> getModulationConnections() { return mod_connections_; }
bool isModulationActive(ModulationConnection* connection);
Expand Down

0 comments on commit 559f5f1

Please sign in to comment.