Skip to content

Commit

Permalink
work
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-german committed May 4, 2024
1 parent ce9ad81 commit d40eef6
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Source/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ void MainComponent::hovered(BlocksSlider* blocks_slider, const ModulatorComponen
}

void MainComponent::unhovered(BlocksSlider* blocks_slider, const ModulatorComponent* modulator_component) {
delegate->editorDisconnectedModulation(modulator_component->row, blocks_slider->module_id_.getName(), blocks_slider->parameter_name_);
delegate->editorDisconnectedModulation(modulator_component->model_id_, blocks_slider->module_id_.getName(), blocks_slider->parameter_name_);
blocks_slider->stopModulationSelectionAnimation();
cursor.setSelectionMode(false);
}
2 changes: 1 addition & 1 deletion Source/MainComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ struct MainComponent::Delegate {
virtual void editorChangedModulationMagnitude(int modulationConnectionIndex, float magnitude) = 0;
virtual void editorChangedModulationPolarity(int index, bool bipolar) = 0;
virtual void editorDisconnectedModulation(int index) = 0;
virtual void editorDisconnectedModulation(int modulator_index, std::string target_name, std::string paramter) = 0;
virtual void editorDisconnectedModulation(ID source_id, std::string target_name, std::string paramter) = 0;

virtual void editorStartedAdjustingParameter(ID& id, std::string& parameter_name, bool started) = 0;
virtual void editorAdjustedParameter(ID& id, std::string& parameter_name, float value) = 0;
Expand Down
6 changes: 3 additions & 3 deletions Source/blocks_plugin_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ void PluginProcessor::editorConnectedModulation(int modulatorIndex, std::string
synth_->connectModulation(modulatorIndex, target_name, parameter);
}

void PluginProcessor::editorDisconnectedModulation(int modulator_index, std::string target_name, std::string parameter) { // remove modulator index and add source id
auto connection = synth_->getModuleManager().getConnection(modulator_index, target_name, parameter);
void PluginProcessor::editorDisconnectedModulation(ID source_id, std::string target_name, std::string parameter) { // remove modulator index and add source id
auto connection = synth_->getModuleManager().getConnection(source_id, target_name, parameter);
disconnect(connection);
}

Expand Down Expand Up @@ -565,7 +565,7 @@ void PluginProcessor::disconnect(std::shared_ptr<model::Connection>& connection)
getVoiceHandler()->setDefaultAmpEnvState(connection->target->name, true);
}

printf("disconnecting %s %s %s\n", connection->source->name.c_str(), connection->target->name.c_str(), connection->parameter_name_.c_str());
// printf("disconnecting %s %s %s\n", connection->source->name.c_str(), connection->target->name.c_str(), connection->parameter_name_.c_str());
synth_->disconnectModulation(connection->vital_connection_);
getModuleManager().removeConnection(connection);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/blocks_plugin_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class PluginProcessor: public SynthBase, public juce::AudioProcessor, public Val
void editorParameterGestureChanged(std::string module_name, std::string paramter_name, bool started) override;
void editorChangedModulationPolarity(int index, bool bipolar) override;
void editorDisconnectedModulation(int index) override;
void editorDisconnectedModulation(int modulator_index, std::string target_name, std::string parameter) override;
void editorDisconnectedModulation(ID source_id, std::string target_name, std::string parameter) override;
void editorSavedPreset(std::string name) override;
void editorConnectedModulation(int modulatorIndex, std::string target_name, std::string parameter) override;
void editorChangedBlockLength(Index index, int length) override;
Expand Down
12 changes: 6 additions & 6 deletions Source/gui/ConnectionComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "BinaryData.h"

void ConnectionComponent::paint(juce::Graphics& g) {
// g.fillAll(Colours::transparentBlack);
g.setColour(ThemeManager::shared()->getCurrent().one.withAlpha(0.5f));
float y = getHeight() - 2.0f;
float insets = horizontalInsets * 2.0f;
Expand Down Expand Up @@ -69,23 +68,24 @@ void ConnectionComponent::setupBipolarButton() {
}

void ConnectionComponent::resized() {
int y = 8;
source.setBounds(slider.getX() - 2, y, 100, 20);
int target_width = 100;
int y = 8;
target.setBounds(getWidth() - target_width - 7, y, target_width, 20);
// source.setBounds(slider.getX() - 2, y, 100, 20);
source.setBounds(7, y, 100, 20);

resizeIndicator();
resizeSlider();
resizeIndicator();
resizeBipolarButton();
resizeExitButton();
int value_label_width = 80;
value_label_.setBounds(getWidth() / 2 - value_label_width / 2, slider.getBottom() + 6, value_label_width, 12);
}

void ConnectionComponent::resizeSlider() {
int height = 12;
int y = source.getBounds().getBottom() + 10;
slider.setBounds(horizontalInsets, y, getWidth() - horizontalInsets * 2, height);
int value_label_width = 80;
value_label_.setBounds(getWidth() / 2 - value_label_width / 2, slider.getBottom() + 6, value_label_width, 12);
}

void ConnectionComponent::resizeIndicator() {
Expand Down
1 change: 1 addition & 0 deletions Source/gui/ModulatorComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void ModulatorComponent::drawBottomLine(Graphics& g) const {

void ModulatorComponent::resized() {
bounds = getLocalBounds();
std::cout << "modulator bounds " << bounds.toString() << std::endl;

resizeDragIndicator();
resizeSliderContainer();
Expand Down
5 changes: 4 additions & 1 deletion Source/gui/UILayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ void UILayer::showModulatorsSideMenu() {

void UILayer::setConnections(std::vector<std::shared_ptr<model::Connection>> modulationConnections) {
connections_list_box_model_.setConnections(modulationConnections);
if (connections_.listBox.isVisible()) connections_.listBox.updateContent();
if (connections_.listBox.isVisible()) {
std::cout << "very very" << std::endl;
connections_.listBox.updateContent();
}
}

void UILayer::setModulators(std::vector<std::shared_ptr<model::Module>> newModulators) {
Expand Down
4 changes: 2 additions & 2 deletions Source/model/module_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ std::vector<std::shared_ptr<Connection>> ModuleManager::getConnectionsOfSource(s
return sourceConnections;
}

std::shared_ptr<model::Connection> ModuleManager::getConnection(int modulator_index, std::string target_name, std::string parameter) {
std::shared_ptr<model::Connection> ModuleManager::getConnection(ID source_id, std::string target_name, std::string parameter) {
for (auto connection : connections) {
if (connection->target->name == target_name && connection->target->getParameterName(parameter) == connection->parameter_name_) {
if (connection->target->name == target_name && connection->target->getParameterName(parameter) == connection->parameter_name_ && connection->source->id == source_id) {
return connection;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/model/module_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ModuleManager {

std::shared_ptr<model::Connection> addConnection(std::shared_ptr<Module> source, std::shared_ptr<Module> target, std::string parameter_name, int number = -1);
std::shared_ptr<model::Connection> getConnection(int index) { return connections[index]; }
std::shared_ptr<model::Connection> getConnection(int modulator_index, std::string target_name, std::string parameter);
std::shared_ptr<model::Connection> getConnection(ID source_id, std::string target_name, std::string parameter);
std::vector<std::shared_ptr<model::Connection>> getConnectionsOfSource(std::shared_ptr<Module> source);
std::vector<std::shared_ptr<model::Connection>> getConnectionsOfTarget(std::shared_ptr<Module> target);
std::vector<std::shared_ptr<model::Connection>> getConnections();
Expand Down
2 changes: 1 addition & 1 deletion Source/vital/common/synth_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ std::shared_ptr<model::Connection> SynthBase::createConnectionModel(int modulato
void SynthBase::connectModulation(int modulator_index, std::string target_name, std::string parameter_name) {
auto connection_model = createConnectionModel(modulator_index, target_name, parameter_name);
if (!connection_model) return;
std::cout << "connecting " << connection_model->source->name << " to " << connection_model->target->name << " " << connection_model->parameter_name_ << std::endl;
// std::cout << "connecting " << connection_model->source->name << " to " << connection_model->target->name << " " << connection_model->parameter_name_ << std::endl;

auto parameter = connection_model->target->parameter_map_[parameter_name];
auto destination_scale = parameter->max - parameter->min;
Expand Down
4 changes: 2 additions & 2 deletions Source/vital/synthesis/framework/voice_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ VoiceHandler::VoiceHandler(int num_outputs, int polyphony, bool control_rate):
pitch_wheel_percent_.owner = &voice_router_;
local_pitch_bend_.owner = &voice_router_;

setPolyphony(1);
setPolyphony(8);
// setPolyphony(polyphony);
voice_router_.router(this);
global_router_.router(this);
Expand Down Expand Up @@ -297,7 +297,7 @@ void VoiceHandler::process(int num_samples) {

int polyphony = static_cast<int>(std::roundf(input(kPolyphony)->at(0)[0]));
// setPolyphony(utils::iclamp(polyphony, 1, kMaxActivePolyphony));
setPolyphony(1);
setPolyphony(8);

int priority = utils::roundToInt(input(kVoicePriority)->at(0))[0];
voice_priority_ = static_cast<VoicePriority>(priority);
Expand Down
2 changes: 1 addition & 1 deletion Source/vital/synthesis/synth_engine/sound_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void SoundEngine::init() {

voice_handler_ = new BlocksVoiceHandler(beats_per_second_clamped->output());
addSubmodule(voice_handler_);
voice_handler_->setPolyphony(1);
voice_handler_->setPolyphony(8);
// voice_handler_->setPolyphony(1);
voice_handler_->plug(polyphony, VoiceHandler::kPolyphony);
voice_handler_->plug(voice_priority, VoiceHandler::kVoicePriority);
Expand Down

0 comments on commit d40eef6

Please sign in to comment.