Skip to content

Commit

Permalink
Rename SiEffectorModule and SiOPMModule for clarity
Browse files Browse the repository at this point in the history
SiEffectorModule is now SiEffector, all methods
accepting or returning effects were renamed as
well to avoid the word "effector".

SiOPMModule is now SiOPMSoundChip, which
is more appropriate. The entire /processor folder
is now /chip too.

These renames are necessary to better convey
meaning of each part of the system, and it's
important to do them before those classes
become public.
  • Loading branch information
YuriSizov committed May 13, 2024
1 parent dd2ab97 commit 18013c9
Show file tree
Hide file tree
Showing 69 changed files with 428 additions and 428 deletions.
2 changes: 1 addition & 1 deletion src/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Import("env")

env.add_source_files(env.library_sources, "*.cpp")

SConscript("chip/SCsub")
SConscript("effector/SCsub")
SConscript("events/SCsub")
SConscript("processor/SCsub")
SConscript("sequencer/SCsub")
SConscript("templates/SCsub")
SConscript("utils/SCsub")
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "siopm_channel_base.h"

#include <godot_cpp/core/class_db.hpp>
#include "processor/siopm_module.h"
#include "processor/siopm_stream.h"
#include "chip/siopm_sound_chip.h"
#include "chip/siopm_stream.h"
#include "utils/godot_util.h"

#define COPY_TL_TABLE(m_target, m_source) \
Expand Down Expand Up @@ -47,13 +47,13 @@ void SiOPMChannelBase::set_filter_type(int p_type) {
// Volume control.

void SiOPMChannelBase::set_all_stream_send_levels(Vector<int> p_levels) {
for (int i = 0; i < SiOPMModule::STREAM_SEND_SIZE; i++) {
for (int i = 0; i < SiOPMSoundChip::STREAM_SEND_SIZE; i++) {
int value = p_levels[i];
_volumes.write[i] = value != INT32_MIN ? value * 0.0078125 : 0;
}

_has_effect_send = false;
for (int i = 1; i < SiOPMModule::STREAM_SEND_SIZE; i++) {
for (int i = 1; i < SiOPMSoundChip::STREAM_SEND_SIZE; i++) {
if (_volumes[i] > 0) {
_has_effect_send = true;
}
Expand All @@ -74,7 +74,7 @@ void SiOPMChannelBase::set_stream_send(int p_stream_num, double p_volume) {
_has_effect_send = true;
} else {
_has_effect_send = false;
for (int i = 1; i < SiOPMModule::STREAM_SEND_SIZE; i++) {
for (int i = 1; i < SiOPMSoundChip::STREAM_SEND_SIZE; i++) {
if (_volumes[i] > 0) {
_has_effect_send = true;
}
Expand Down Expand Up @@ -139,19 +139,19 @@ void SiOPMChannelBase::offset_filter(int p_offset) {

void SiOPMChannelBase::set_input(int p_level, int p_pipe_index) {
if (p_level > 0) {
_in_pipe = _chip->get_pipe(p_pipe_index & 3, _buffer_index);
_in_pipe = _sound_chip->get_pipe(p_pipe_index & 3, _buffer_index);
_input_mode = InputMode::INPUT_PIPE;
_input_level = p_level + 10;
} else {
_in_pipe = _chip->get_zero_buffer();
_in_pipe = _sound_chip->get_zero_buffer();
_input_mode = InputMode::INPUT_ZERO;
_input_level = 0;
}
}

void SiOPMChannelBase::set_ring_modulation(int p_level, int p_pipe_index) {
_ringmod_level = p_level * 4.0 / (1 << SiOPMRefTable::LOG_VOLUME_BITS);
_ring_pipe = p_level > 0 ? _chip->get_pipe(p_pipe_index & 3, _buffer_index) : nullptr;
_ring_pipe = p_level > 0 ? _sound_chip->get_pipe(p_pipe_index & 3, _buffer_index) : nullptr;
}

void SiOPMChannelBase::set_output(OutputMode p_output_mode, int p_pipe_index) {
Expand All @@ -166,8 +166,8 @@ void SiOPMChannelBase::set_output(OutputMode p_output_mode, int p_pipe_index) {
}

_output_mode = p_output_mode;
_out_pipe = _chip->get_pipe(pipe_index, _buffer_index);
_base_pipe = flag_add ? _out_pipe : _chip->get_zero_buffer();
_out_pipe = _sound_chip->get_pipe(pipe_index, _buffer_index);
_base_pipe = flag_add ? _out_pipe : _sound_chip->get_zero_buffer();
}

void SiOPMChannelBase::set_volume_tables(int (&p_velocity_table)[SiOPMRefTable::TL_TABLE_SIZE], int (&p_expression_table)[SiOPMRefTable::TL_TABLE_SIZE]) {
Expand Down Expand Up @@ -274,11 +274,11 @@ void SiOPMChannelBase::_no_process(int p_length) {

// Rotate the output buffer.
if (_output_mode == OutputMode::OUTPUT_STANDARD) {
int pipe_index = (_buffer_index + p_length) & (_chip->get_buffer_length() - 1);
_out_pipe = _chip->get_pipe(4, pipe_index);
int pipe_index = (_buffer_index + p_length) & (_sound_chip->get_buffer_length() - 1);
_out_pipe = _sound_chip->get_pipe(4, pipe_index);
} else {
_out_pipe = _rotate_pipe(_out_pipe, p_length);
_base_pipe = _output_mode == OutputMode::OUTPUT_ADD ? pipe : _chip->get_zero_buffer();
_base_pipe = _output_mode == OutputMode::OUTPUT_ADD ? pipe : _sound_chip->get_zero_buffer();
}

// Rotate the input buffer when connected by @i.
Expand Down Expand Up @@ -381,16 +381,16 @@ void SiOPMChannelBase::buffer(int p_length) {

if (_output_mode == OutputMode::OUTPUT_STANDARD && !_mute) {
if (_has_effect_send) {
for (int i = 0; i < SiOPMModule::STREAM_SEND_SIZE; i++) {
for (int i = 0; i < SiOPMSoundChip::STREAM_SEND_SIZE; i++) {
if (_volumes[i] > 0) {
SiOPMStream *stream = _streams[i] ? _streams[i] : _chip->get_stream_slot(i);
SiOPMStream *stream = _streams[i] ? _streams[i] : _sound_chip->get_stream_slot(i);
if (stream) {
stream->write(mono_out, _buffer_index, p_length, _volumes[i], _pan);
}
}
}
} else {
SiOPMStream *stream = _streams[0] ? _streams[0] : _chip->get_output_stream();
SiOPMStream *stream = _streams[0] ? _streams[0] : _sound_chip->get_output_stream();
stream->write(mono_out, _buffer_index, p_length, _volumes[0], _pan);
}
}
Expand All @@ -409,7 +409,7 @@ void SiOPMChannelBase::initialize(SiOPMChannelBase *p_prev, int p_buffer_index)
// Volume.

if (p_prev) {
for (int i = 0; i < SiOPMModule::STREAM_SEND_SIZE; i++) {
for (int i = 0; i < SiOPMSoundChip::STREAM_SEND_SIZE; i++) {
_volumes.write[i] = p_prev->_volumes[i];
_streams.write[i] = p_prev->_streams[i];
}
Expand All @@ -422,7 +422,7 @@ void SiOPMChannelBase::initialize(SiOPMChannelBase *p_prev, int p_buffer_index)
} else {
_volumes.write[0] = 0.5;
_streams.write[0] = nullptr;
for (int i = 1; i < SiOPMModule::STREAM_SEND_SIZE; i++) {
for (int i = 1; i < SiOPMSoundChip::STREAM_SEND_SIZE; i++) {
_volumes.write[i] = 0;
_streams.write[i] = nullptr;
}
Expand Down Expand Up @@ -469,15 +469,15 @@ void SiOPMChannelBase::_bind_methods() {
ClassDB::bind_method(D_METHOD("_no_process", "length"), &SiOPMChannelBase::_no_process);
}

SiOPMChannelBase::SiOPMChannelBase(SiOPMModule *p_chip) {
SiOPMChannelBase::SiOPMChannelBase(SiOPMSoundChip *p_chip) {
_table = SiOPMRefTable::get_instance();
_chip = p_chip;
_sound_chip = p_chip;
_process_function = Callable(this, "_no_process");

_streams.clear();
_streams.resize_zeroed(SiOPMModule::STREAM_SEND_SIZE);
_streams.resize_zeroed(SiOPMSoundChip::STREAM_SEND_SIZE);
_volumes.clear();
_volumes.resize_zeroed(SiOPMModule::STREAM_SEND_SIZE);
_volumes.resize_zeroed(SiOPMSoundChip::STREAM_SEND_SIZE);
}

#undef COPY_TL_TABLE
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
#include <godot_cpp/templates/vector.hpp>
#include <godot_cpp/variant/callable.hpp>
#include "sion_enums.h"
#include "processor/channels/siopm_channel_manager.h"
#include "processor/siopm_ref_table.h"
#include "chip/channels/siopm_channel_manager.h"
#include "chip/siopm_ref_table.h"
#include "templates/singly_linked_list.h"

using namespace godot;

class SiOPMChannelParams;
class SiOPMModule;
class SiOPMSoundChip;
class SiOPMStream;
class SiOPMWaveBase;

Expand Down Expand Up @@ -70,7 +70,7 @@ class SiOPMChannelBase : public Object {
//

SiOPMRefTable *_table = nullptr;
SiOPMModule *_chip = nullptr;
SiOPMSoundChip *_sound_chip = nullptr;

Callable _process_function;

Expand Down Expand Up @@ -228,7 +228,7 @@ class SiOPMChannelBase : public Object {
virtual void initialize(SiOPMChannelBase *p_prev, int p_buffer_index);
virtual void reset();

SiOPMChannelBase(SiOPMModule *p_chip = nullptr);
SiOPMChannelBase(SiOPMSoundChip *p_chip = nullptr);
~SiOPMChannelBase() {}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#include "siopm_channel_fm.h"

#include <godot_cpp/core/class_db.hpp>
#include "processor/channels/siopm_operator.h"
#include "processor/siopm_channel_params.h"
#include "processor/siopm_module.h"
#include "processor/wave/siopm_wave_pcm_data.h"
#include "processor/wave/siopm_wave_pcm_table.h"
#include "processor/wave/siopm_wave_table.h"
#include "chip/channels/siopm_operator.h"
#include "chip/siopm_channel_params.h"
#include "chip/siopm_sound_chip.h"
#include "chip/wave/siopm_wave_pcm_data.h"
#include "chip/wave/siopm_wave_pcm_table.h"
#include "chip/wave/siopm_wave_table.h"

List<SiOPMOperator *> SiOPMChannelFM::_free_operators;

Expand All @@ -23,7 +23,7 @@ SiOPMOperator *SiOPMChannelFM::_alloc_fm_operator() {

return op;
} else {
return memnew(SiOPMOperator(_chip));
return memnew(SiOPMOperator(_sound_chip));
}
}

Expand Down Expand Up @@ -85,7 +85,7 @@ void SiOPMChannelFM::get_channel_params(SiOPMChannelParams *r_params) const {
r_params->set_amplitude_modulation_depth(_amplitude_modulation_depth);
r_params->set_pitch_modulation_depth(_pitch_modulation_depth);

for (int i = 0; i < SiOPMModule::STREAM_SEND_SIZE; i++) {
for (int i = 0; i < SiOPMSoundChip::STREAM_SEND_SIZE; i++) {
r_params->set_master_volume(i, _volumes[i]);
}
r_params->set_pan(_pan);
Expand Down Expand Up @@ -113,12 +113,12 @@ void SiOPMChannelFM::set_channel_params(SiOPMChannelParams *p_params, bool p_wit
}

if (p_with_volume) {
for (int i = 0; i < SiOPMModule::STREAM_SEND_SIZE; i++) {
for (int i = 0; i < SiOPMSoundChip::STREAM_SEND_SIZE; i++) {
_volumes.write[i] = p_params->get_master_volume(i);
}

_has_effect_send = false;
for (int i = 1; i < SiOPMModule::STREAM_SEND_SIZE; i++) {
for (int i = 1; i < SiOPMSoundChip::STREAM_SEND_SIZE; i++) {
if (_volumes[i] > 0) {
_has_effect_send = true;
break;
Expand Down Expand Up @@ -567,7 +567,7 @@ void SiOPMChannelFM::set_feedback(int p_level, int p_connection) {
_input_mode = INPUT_FEEDBACK;
} else {
// Disable feedback.
_in_pipe = _chip->get_zero_buffer();
_in_pipe = _sound_chip->get_zero_buffer();
_input_level = 0;
_input_mode = INPUT_ZERO;
}
Expand Down Expand Up @@ -1515,7 +1515,7 @@ void SiOPMChannelFM::_bind_methods() {
ClassDB::bind_method(D_METHOD("_process_sync", "length"), &SiOPMChannelFM::_process_sync);
}

SiOPMChannelFM::SiOPMChannelFM(SiOPMModule *p_chip) : SiOPMChannelBase(p_chip) {
SiOPMChannelFM::SiOPMChannelFM(SiOPMSoundChip *p_chip) : SiOPMChannelBase(p_chip) {
_process_function_list = {
{
Callable(this, "_process_operator1_lfo_off"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <godot_cpp/templates/list.hpp>
#include <godot_cpp/templates/vector.hpp>
#include "processor/channels/siopm_channel_base.h"
#include "chip/channels/siopm_channel_base.h"
#include "templates/singly_linked_list.h"

using namespace godot;
Expand Down Expand Up @@ -171,7 +171,7 @@ class SiOPMChannelFM : public SiOPMChannelBase {
virtual void initialize(SiOPMChannelBase *p_prev, int p_buffer_index) override;
virtual void reset() override;

SiOPMChannelFM(SiOPMModule *p_chip = nullptr);
SiOPMChannelFM(SiOPMSoundChip *p_chip = nullptr);
};

#endif // SIOPM_CHANNEL_FM_H
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#include "siopm_channel_ks.h"

#include "sion_enums.h"
#include "processor/channels/siopm_operator.h"
#include "processor/siopm_module.h"
#include "processor/siopm_stream.h"
#include "processor/wave/siopm_wave_pcm_table.h"
#include "processor/wave/siopm_wave_table.h"
#include "chip/channels/siopm_operator.h"
#include "chip/siopm_sound_chip.h"
#include "chip/siopm_stream.h"
#include "chip/wave/siopm_wave_pcm_table.h"
#include "chip/wave/siopm_wave_table.h"
#include "sequencer/simml_ref_table.h"
#include "sequencer/simml_voice.h"

Expand Down Expand Up @@ -198,16 +198,16 @@ void SiOPMChannelKS::buffer(int p_length) {

if (_output_mode == OutputMode::OUTPUT_STANDARD && !_mute) {
if (_has_effect_send) {
for (int i = 0; i < SiOPMModule::STREAM_SEND_SIZE; i++) {
for (int i = 0; i < SiOPMSoundChip::STREAM_SEND_SIZE; i++) {
if (_volumes[i] > 0) {
SiOPMStream *stream = _streams[i] ? _streams[i] : _chip->get_stream_slot(i);
SiOPMStream *stream = _streams[i] ? _streams[i] : _sound_chip->get_stream_slot(i);
if (stream) {
stream->write(mono_out, _buffer_index, p_length, _volumes[i] * _expression, _pan);
}
}
}
} else {
SiOPMStream *stream = _streams[0] ? _streams[0] : _chip->get_output_stream();
SiOPMStream *stream = _streams[0] ? _streams[0] : _sound_chip->get_output_stream();
stream->write(mono_out, _buffer_index, p_length, _volumes[0] * _expression, _pan);
}
}
Expand Down Expand Up @@ -270,6 +270,6 @@ void SiOPMChannelKS::reset() {
SiOPMChannelFM::reset();
}

SiOPMChannelKS::SiOPMChannelKS(SiOPMModule *p_chip) : SiOPMChannelFM(p_chip) {
SiOPMChannelKS::SiOPMChannelKS(SiOPMSoundChip *p_chip) : SiOPMChannelFM(p_chip) {
_ks_delay_buffer.resize_zeroed(KS_BUFFER_SIZE);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
#define SIOPM_CHANNEL_KS_H

#include <godot_cpp/templates/vector.hpp>
#include "processor/channels/siopm_channel_fm.h"
#include "chip/channels/siopm_channel_fm.h"
#include "templates/singly_linked_list.h"

using namespace godot;

enum SiONPitchTableType : unsigned int;
class SiOPMModule;
class SiOPMSoundChip;

// Karplus-Strong algorithm with FM synth.
class SiOPMChannelKS : public SiOPMChannelFM {
Expand Down Expand Up @@ -89,7 +89,7 @@ class SiOPMChannelKS : public SiOPMChannelFM {
virtual void initialize(SiOPMChannelBase *p_prev, int p_buffer_index) override;
virtual void reset() override;

SiOPMChannelKS(SiOPMModule *p_chip = nullptr);
SiOPMChannelKS(SiOPMSoundChip *p_chip = nullptr);
};

#endif // SIOPM_CHANNEL_KS_H
Loading

0 comments on commit 18013c9

Please sign in to comment.