LibDSP: Rename library namespace to DSP

That's the standard naming convention, but I didn't follow it when
originally creating LibDSP and nobody corrected me, so here I am one
year later :^)
This commit is contained in:
kleines Filmröllchen 2022-07-17 11:35:31 +02:00 committed by Linus Groh
parent 3f59356c79
commit 00e13b5b27
Notes: sideshowbarker 2024-07-17 08:46:34 +09:00
36 changed files with 92 additions and 92 deletions

View file

@ -7,13 +7,13 @@
*/ */
#include "KeysWidget.h" #include "KeysWidget.h"
#include "LibDSP/Keyboard.h"
#include "TrackManager.h" #include "TrackManager.h"
#include <AK/Array.h> #include <AK/Array.h>
#include <AK/StringView.h> #include <AK/StringView.h>
#include <LibDSP/Keyboard.h>
#include <LibGUI/Painter.h> #include <LibGUI/Painter.h>
KeysWidget::KeysWidget(NonnullRefPtr<LibDSP::Keyboard> keyboard) KeysWidget::KeysWidget(NonnullRefPtr<DSP::Keyboard> keyboard)
: m_keyboard(move(keyboard)) : m_keyboard(move(keyboard))
{ {
set_fill_with_background_color(true); set_fill_with_background_color(true);
@ -27,7 +27,7 @@ int KeysWidget::mouse_note() const
return -1; return -1;
} }
void KeysWidget::set_key(i8 key, LibDSP::Keyboard::Switch switch_note) void KeysWidget::set_key(i8 key, DSP::Keyboard::Switch switch_note)
{ {
m_keyboard->set_keyboard_note_in_active_octave(key, switch_note); m_keyboard->set_keyboard_note_in_active_octave(key, switch_note);
} }
@ -253,7 +253,7 @@ void KeysWidget::mousedown_event(GUI::MouseEvent& event)
m_mouse_note = note_for_event_position(event.position()); m_mouse_note = note_for_event_position(event.position());
set_key(m_mouse_note, LibDSP::Keyboard::Switch::On); set_key(m_mouse_note, DSP::Keyboard::Switch::On);
update(); update();
} }
@ -264,7 +264,7 @@ void KeysWidget::mouseup_event(GUI::MouseEvent& event)
m_mouse_down = false; m_mouse_down = false;
set_key(m_mouse_note, LibDSP::Keyboard::Switch::Off); set_key(m_mouse_note, DSP::Keyboard::Switch::Off);
update(); update();
} }
@ -278,8 +278,8 @@ void KeysWidget::mousemove_event(GUI::MouseEvent& event)
if (m_mouse_note == new_mouse_note) if (m_mouse_note == new_mouse_note)
return; return;
set_key(m_mouse_note, LibDSP::Keyboard::Switch::Off); set_key(m_mouse_note, DSP::Keyboard::Switch::Off);
set_key(new_mouse_note, LibDSP::Keyboard::Switch::On); set_key(new_mouse_note, DSP::Keyboard::Switch::On);
update(); update();
m_mouse_note = new_mouse_note; m_mouse_note = new_mouse_note;

View file

@ -24,7 +24,7 @@ public:
int mouse_note() const; int mouse_note() const;
private: private:
KeysWidget(NonnullRefPtr<LibDSP::Keyboard>); KeysWidget(NonnullRefPtr<DSP::Keyboard>);
virtual void paint_event(GUI::PaintEvent&) override; virtual void paint_event(GUI::PaintEvent&) override;
virtual void mousedown_event(GUI::MouseEvent&) override; virtual void mousedown_event(GUI::MouseEvent&) override;
@ -33,9 +33,9 @@ private:
int note_for_event_position(Gfx::IntPoint const&) const; int note_for_event_position(Gfx::IntPoint const&) const;
void set_key(i8 key, LibDSP::Keyboard::Switch); void set_key(i8 key, DSP::Keyboard::Switch);
NonnullRefPtr<LibDSP::Keyboard> m_keyboard; NonnullRefPtr<DSP::Keyboard> m_keyboard;
bool m_mouse_down { false }; bool m_mouse_down { false };
int m_mouse_note { -1 }; int m_mouse_note { -1 };

View file

@ -70,23 +70,23 @@ KnobsWidget::KnobsWidget(TrackManager& track_manager, MainWidget& main_widget)
for (auto& raw_parameter : m_track_manager.current_track().synth()->parameters()) { for (auto& raw_parameter : m_track_manager.current_track().synth()->parameters()) {
// The synth has range and enum parameters // The synth has range and enum parameters
switch (raw_parameter.type()) { switch (raw_parameter.type()) {
case LibDSP::ParameterType::Range: { case DSP::ParameterType::Range: {
auto& parameter = static_cast<LibDSP::ProcessorRangeParameter&>(raw_parameter); auto& parameter = static_cast<DSP::ProcessorRangeParameter&>(raw_parameter);
m_synth_values.append(m_values_container->add<GUI::Label>(String::number(static_cast<double>(parameter.value())))); m_synth_values.append(m_values_container->add<GUI::Label>(String::number(static_cast<double>(parameter.value()))));
auto& parameter_knob_value = m_synth_values.last(); auto& parameter_knob_value = m_synth_values.last();
m_synth_labels.append(m_labels_container->add<GUI::Label>(String::formatted("Synth: {}", parameter.name()))); m_synth_labels.append(m_labels_container->add<GUI::Label>(String::formatted("Synth: {}", parameter.name())));
m_synth_knobs.append(m_knobs_container->add<ProcessorParameterSlider>(Orientation::Vertical, parameter, parameter_knob_value)); m_synth_knobs.append(m_knobs_container->add<ProcessorParameterSlider>(Orientation::Vertical, parameter, parameter_knob_value));
break; break;
} }
case LibDSP::ParameterType::Enum: { case DSP::ParameterType::Enum: {
// FIXME: We shouldn't do that, but we know the synth and it is nice // FIXME: We shouldn't do that, but we know the synth and it is nice
auto& parameter = static_cast<LibDSP::ProcessorEnumParameter<LibDSP::Synthesizers::Waveform>&>(raw_parameter); auto& parameter = static_cast<DSP::ProcessorEnumParameter<DSP::Synthesizers::Waveform>&>(raw_parameter);
// The value is empty for enum parameters // The value is empty for enum parameters
m_synth_values.append(m_values_container->add<GUI::Label>(String::empty())); m_synth_values.append(m_values_container->add<GUI::Label>(String::empty()));
m_synth_labels.append(m_labels_container->add<GUI::Label>(String::formatted("Synth: {}", parameter.name()))); m_synth_labels.append(m_labels_container->add<GUI::Label>(String::formatted("Synth: {}", parameter.name())));
auto enum_strings = Vector<String> { "Sine", "Triangle", "Square", "Saw", "Noise" }; auto enum_strings = Vector<String> { "Sine", "Triangle", "Square", "Saw", "Noise" };
m_synth_knobs.append(m_knobs_container->add<ProcessorParameterDropdown<LibDSP::Synthesizers::Waveform>>(parameter, move(enum_strings))); m_synth_knobs.append(m_knobs_container->add<ProcessorParameterDropdown<DSP::Synthesizers::Waveform>>(parameter, move(enum_strings)));
m_synth_waveform = static_cast<ProcessorParameterDropdown<LibDSP::Synthesizers::Waveform>&>(m_synth_knobs.last()); m_synth_waveform = static_cast<ProcessorParameterDropdown<DSP::Synthesizers::Waveform>&>(m_synth_knobs.last());
break; break;
} }
default: default:
@ -96,7 +96,7 @@ KnobsWidget::KnobsWidget(TrackManager& track_manager, MainWidget& main_widget)
for (auto& raw_parameter : m_track_manager.current_track().delay()->parameters()) { for (auto& raw_parameter : m_track_manager.current_track().delay()->parameters()) {
// FIXME: We shouldn't do that, but we know the effect and it's nice. // FIXME: We shouldn't do that, but we know the effect and it's nice.
auto& parameter = static_cast<LibDSP::ProcessorRangeParameter&>(raw_parameter); auto& parameter = static_cast<DSP::ProcessorRangeParameter&>(raw_parameter);
m_delay_values.append(m_values_container->add<GUI::Label>(String::number(static_cast<double>(parameter.value())))); m_delay_values.append(m_values_container->add<GUI::Label>(String::number(static_cast<double>(parameter.value()))));
auto& parameter_knob_value = m_delay_values.last(); auto& parameter_knob_value = m_delay_values.last();
m_delay_labels.append(m_labels_container->add<GUI::Label>(String::formatted("Delay: {}", parameter.name()))); m_delay_labels.append(m_labels_container->add<GUI::Label>(String::formatted("Delay: {}", parameter.name())));

View file

@ -49,7 +49,7 @@ private:
RefPtr<GUI::Widget> m_knobs_container; RefPtr<GUI::Widget> m_knobs_container;
RefPtr<GUI::Slider> m_volume_knob; RefPtr<GUI::Slider> m_volume_knob;
RefPtr<GUI::Slider> m_octave_knob; RefPtr<GUI::Slider> m_octave_knob;
RefPtr<ProcessorParameterDropdown<LibDSP::Synthesizers::Waveform>> m_synth_waveform; RefPtr<ProcessorParameterDropdown<DSP::Synthesizers::Waveform>> m_synth_waveform;
NonnullRefPtrVector<GUI::Widget> m_synth_knobs; NonnullRefPtrVector<GUI::Widget> m_synth_knobs;
NonnullRefPtrVector<ProcessorParameterSlider> m_delay_knobs; NonnullRefPtrVector<ProcessorParameterSlider> m_delay_knobs;

View file

@ -85,7 +85,7 @@ void MainWidget::keydown_event(GUI::KeyEvent& event)
else else
m_keys_pressed[event.key()] = true; m_keys_pressed[event.key()] = true;
note_key_action(event.key(), LibDSP::Keyboard::Switch::On); note_key_action(event.key(), DSP::Keyboard::Switch::On);
special_key_action(event.key()); special_key_action(event.key());
m_keys_widget->update(); m_keys_widget->update();
} }
@ -94,11 +94,11 @@ void MainWidget::keyup_event(GUI::KeyEvent& event)
{ {
m_keys_pressed[event.key()] = false; m_keys_pressed[event.key()] = false;
note_key_action(event.key(), LibDSP::Keyboard::Switch::Off); note_key_action(event.key(), DSP::Keyboard::Switch::Off);
m_keys_widget->update(); m_keys_widget->update();
} }
void MainWidget::note_key_action(int key_code, LibDSP::Keyboard::Switch switch_note) void MainWidget::note_key_action(int key_code, DSP::Keyboard::Switch switch_note)
{ {
auto key = m_keys_widget->key_code_to_key(key_code); auto key = m_keys_widget->key_code_to_key(key_code);
if (key == -1) if (key == -1)
@ -110,10 +110,10 @@ void MainWidget::special_key_action(int key_code)
{ {
switch (key_code) { switch (key_code) {
case Key_Z: case Key_Z:
set_octave_and_ensure_note_change(LibDSP::Keyboard::Direction::Down); set_octave_and_ensure_note_change(DSP::Keyboard::Direction::Down);
break; break;
case Key_X: case Key_X:
set_octave_and_ensure_note_change(LibDSP::Keyboard::Direction::Up); set_octave_and_ensure_note_change(DSP::Keyboard::Direction::Up);
break; break;
case Key_C: case Key_C:
m_knobs_widget->cycle_waveform(); m_knobs_widget->cycle_waveform();
@ -127,20 +127,20 @@ void MainWidget::special_key_action(int key_code)
void MainWidget::turn_off_pressed_keys() void MainWidget::turn_off_pressed_keys()
{ {
if (m_keys_widget->mouse_note() != -1) if (m_keys_widget->mouse_note() != -1)
m_track_manager.keyboard()->set_keyboard_note_in_active_octave(m_keys_widget->mouse_note(), LibDSP::Keyboard::Switch::Off); m_track_manager.keyboard()->set_keyboard_note_in_active_octave(m_keys_widget->mouse_note(), DSP::Keyboard::Switch::Off);
for (int i = 0; i < key_code_count; ++i) { for (int i = 0; i < key_code_count; ++i) {
if (m_keys_pressed[i]) if (m_keys_pressed[i])
note_key_action(i, LibDSP::Keyboard::Switch::Off); note_key_action(i, DSP::Keyboard::Switch::Off);
} }
} }
void MainWidget::turn_on_pressed_keys() void MainWidget::turn_on_pressed_keys()
{ {
if (m_keys_widget->mouse_note() != -1) if (m_keys_widget->mouse_note() != -1)
m_track_manager.keyboard()->set_keyboard_note_in_active_octave(m_keys_widget->mouse_note(), LibDSP::Keyboard::Switch::On); m_track_manager.keyboard()->set_keyboard_note_in_active_octave(m_keys_widget->mouse_note(), DSP::Keyboard::Switch::On);
for (int i = 0; i < key_code_count; ++i) { for (int i = 0; i < key_code_count; ++i) {
if (m_keys_pressed[i]) if (m_keys_pressed[i])
note_key_action(i, LibDSP::Keyboard::Switch::On); note_key_action(i, DSP::Keyboard::Switch::On);
} }
} }
@ -154,7 +154,7 @@ void MainWidget::set_octave_and_ensure_note_change(int octave)
m_keys_widget->update(); m_keys_widget->update();
} }
void MainWidget::set_octave_and_ensure_note_change(LibDSP::Keyboard::Direction direction) void MainWidget::set_octave_and_ensure_note_change(DSP::Keyboard::Direction direction)
{ {
turn_off_pressed_keys(); turn_off_pressed_keys();
m_track_manager.keyboard()->change_virtual_keyboard_octave(direction); m_track_manager.keyboard()->change_virtual_keyboard_octave(direction);

View file

@ -29,7 +29,7 @@ public:
void add_track_actions(GUI::Menu&); void add_track_actions(GUI::Menu&);
void set_octave_and_ensure_note_change(LibDSP::Keyboard::Direction); void set_octave_and_ensure_note_change(DSP::Keyboard::Direction);
void set_octave_and_ensure_note_change(int); void set_octave_and_ensure_note_change(int);
private: private:
@ -39,7 +39,7 @@ private:
virtual void keyup_event(GUI::KeyEvent&) override; virtual void keyup_event(GUI::KeyEvent&) override;
virtual void custom_event(Core::CustomEvent&) override; virtual void custom_event(Core::CustomEvent&) override;
void note_key_action(int key_code, LibDSP::Keyboard::Switch); void note_key_action(int key_code, DSP::Keyboard::Switch);
void special_key_action(int key_code); void special_key_action(int key_code);
void turn_off_pressed_keys(); void turn_off_pressed_keys();

View file

@ -19,7 +19,7 @@ requires(IsEnum<EnumT>) class ProcessorParameterDropdown : public GUI::ComboBox
C_OBJECT(ProcessorParameterDropdown); C_OBJECT(ProcessorParameterDropdown);
public: public:
ProcessorParameterDropdown(LibDSP::ProcessorEnumParameter<EnumT>& parameter, Vector<String> modes) ProcessorParameterDropdown(DSP::ProcessorEnumParameter<EnumT>& parameter, Vector<String> modes)
: ComboBox() : ComboBox()
, m_parameter(parameter) , m_parameter(parameter)
, m_modes(move(modes)) , m_modes(move(modes))
@ -33,7 +33,7 @@ public:
on_change = [this]([[maybe_unused]] auto name, GUI::ModelIndex model_index) { on_change = [this]([[maybe_unused]] auto name, GUI::ModelIndex model_index) {
auto value = static_cast<EnumT>(model_index.row()); auto value = static_cast<EnumT>(model_index.row());
m_parameter.set_value_sneaky(value, LibDSP::Detail::ProcessorParameterSetValueTag {}); m_parameter.set_value_sneaky(value, DSP::Detail::ProcessorParameterSetValueTag {});
}; };
m_parameter.did_change_value = [this](auto new_value) { m_parameter.did_change_value = [this](auto new_value) {
set_selected_index(static_cast<int>(new_value)); set_selected_index(static_cast<int>(new_value));
@ -53,6 +53,6 @@ public:
} }
private: private:
LibDSP::ProcessorEnumParameter<EnumT>& m_parameter; DSP::ProcessorEnumParameter<EnumT>& m_parameter;
Vector<String> m_modes; Vector<String> m_modes;
}; };

View file

@ -9,7 +9,7 @@
#include <AK/FixedPoint.h> #include <AK/FixedPoint.h>
#include <AK/Math.h> #include <AK/Math.h>
ProcessorParameterSlider::ProcessorParameterSlider(Orientation orientation, LibDSP::ProcessorRangeParameter& parameter, RefPtr<GUI::Label> value_label) ProcessorParameterSlider::ProcessorParameterSlider(Orientation orientation, DSP::ProcessorRangeParameter& parameter, RefPtr<GUI::Label> value_label)
: Slider(orientation) : Slider(orientation)
, WidgetWithLabel(move(value_label)) , WidgetWithLabel(move(value_label))
, m_parameter(parameter) , m_parameter(parameter)
@ -30,13 +30,13 @@ ProcessorParameterSlider::ProcessorParameterSlider(Orientation orientation, LibD
m_value_label->set_text(String::formatted("{:.2f}", static_cast<double>(m_parameter))); m_value_label->set_text(String::formatted("{:.2f}", static_cast<double>(m_parameter)));
on_change = [this](auto value) { on_change = [this](auto value) {
LibDSP::ParameterFixedPoint real_value; DSP::ParameterFixedPoint real_value;
real_value.raw() = value; real_value.raw() = value;
if (is_logarithmic()) if (is_logarithmic())
// FIXME: Implement exponential for fixed point // FIXME: Implement exponential for fixed point
real_value = exp(static_cast<double>(real_value)); real_value = exp(static_cast<double>(real_value));
m_parameter.set_value_sneaky(real_value, LibDSP::Detail::ProcessorParameterSetValueTag {}); m_parameter.set_value_sneaky(real_value, DSP::Detail::ProcessorParameterSetValueTag {});
if (m_value_label) { if (m_value_label) {
double value = static_cast<double>(m_parameter); double value = static_cast<double>(m_parameter);
String label_text = String::formatted("{:.2f}", value); String label_text = String::formatted("{:.2f}", value);

View file

@ -20,11 +20,11 @@ class ProcessorParameterSlider
C_OBJECT(ProcessorParameterSlider); C_OBJECT(ProcessorParameterSlider);
public: public:
ProcessorParameterSlider(Orientation, LibDSP::ProcessorRangeParameter&, RefPtr<GUI::Label>); ProcessorParameterSlider(Orientation, DSP::ProcessorRangeParameter&, RefPtr<GUI::Label>);
constexpr bool is_logarithmic() const { return m_parameter.is_logarithmic() == LibDSP::Logarithmic::Yes; } constexpr bool is_logarithmic() const { return m_parameter.is_logarithmic() == DSP::Logarithmic::Yes; }
protected: protected:
LibDSP::ProcessorRangeParameter& m_parameter; DSP::ProcessorRangeParameter& m_parameter;
private: private:
// Converts based on processor parameter boundaries. // Converts based on processor parameter boundaries.

View file

@ -15,7 +15,7 @@
#include <LibGUI/AbstractScrollableWidget.h> #include <LibGUI/AbstractScrollableWidget.h>
class TrackManager; class TrackManager;
using LibDSP::RollNote; using DSP::RollNote;
class RollWidget final : public GUI::AbstractScrollableWidget { class RollWidget final : public GUI::AbstractScrollableWidget {
C_OBJECT(RollWidget) C_OBJECT(RollWidget)

View file

@ -16,10 +16,10 @@
#include <LibDSP/Music.h> #include <LibDSP/Music.h>
#include <math.h> #include <math.h>
Track::Track(NonnullRefPtr<LibDSP::Transport> transport, NonnullRefPtr<LibDSP::Keyboard> keyboard) Track::Track(NonnullRefPtr<DSP::Transport> transport, NonnullRefPtr<DSP::Keyboard> keyboard)
: m_transport(move(transport)) : m_transport(move(transport))
, m_delay(make_ref_counted<LibDSP::Effects::Delay>(m_transport)) , m_delay(make_ref_counted<DSP::Effects::Delay>(m_transport))
, m_synth(make_ref_counted<LibDSP::Synthesizers::Classic>(m_transport)) , m_synth(make_ref_counted<DSP::Synthesizers::Classic>(m_transport))
, m_keyboard(move(keyboard)) , m_keyboard(move(keyboard))
{ {
set_volume(volume_max); set_volume(volume_max);
@ -27,7 +27,7 @@ Track::Track(NonnullRefPtr<LibDSP::Transport> transport, NonnullRefPtr<LibDSP::K
void Track::fill_sample(Sample& sample) void Track::fill_sample(Sample& sample)
{ {
auto playing_notes = LibDSP::RollNotes {}; auto playing_notes = DSP::RollNotes {};
for (size_t i = 0; i < note_count; ++i) { for (size_t i = 0; i < note_count; ++i) {
bool has_roll_notes = false; bool has_roll_notes = false;
@ -48,9 +48,9 @@ void Track::fill_sample(Sample& sample)
} }
} }
auto synthesized_sample = LibDSP::Signal { FixedArray<Audio::Sample>::must_create_but_fixme_should_propagate_errors(1) }; auto synthesized_sample = DSP::Signal { FixedArray<Audio::Sample>::must_create_but_fixme_should_propagate_errors(1) };
m_synth->process(playing_notes, synthesized_sample); m_synth->process(playing_notes, synthesized_sample);
auto delayed_signal = LibDSP::Signal { FixedArray<Audio::Sample>::must_create_but_fixme_should_propagate_errors(1) }; auto delayed_signal = DSP::Signal { FixedArray<Audio::Sample>::must_create_but_fixme_should_propagate_errors(1) };
m_delay->process(synthesized_sample, delayed_signal); m_delay->process(synthesized_sample, delayed_signal);
auto delayed_sample = delayed_signal.get<FixedArray<Audio::Sample>>()[0]; auto delayed_sample = delayed_signal.get<FixedArray<Audio::Sample>>()[0];

View file

@ -19,7 +19,7 @@
#include <LibDSP/Synthesizers.h> #include <LibDSP/Synthesizers.h>
#include <LibDSP/Transport.h> #include <LibDSP/Transport.h>
using LibDSP::RollNote; using DSP::RollNote;
using RollIter = AK::SinglyLinkedListIterator<SinglyLinkedList<RollNote>, RollNote>; using RollIter = AK::SinglyLinkedListIterator<SinglyLinkedList<RollNote>, RollNote>;
class Track { class Track {
@ -27,14 +27,14 @@ class Track {
AK_MAKE_NONMOVABLE(Track); AK_MAKE_NONMOVABLE(Track);
public: public:
Track(NonnullRefPtr<LibDSP::Transport>, NonnullRefPtr<LibDSP::Keyboard>); Track(NonnullRefPtr<DSP::Transport>, NonnullRefPtr<DSP::Keyboard>);
~Track() = default; ~Track() = default;
Vector<Audio::Sample> const& recorded_sample() const { return m_recorded_sample; } Vector<Audio::Sample> const& recorded_sample() const { return m_recorded_sample; }
SinglyLinkedList<RollNote> const& roll_notes(int note) const { return m_roll_notes[note]; } SinglyLinkedList<RollNote> const& roll_notes(int note) const { return m_roll_notes[note]; }
int volume() const { return m_volume; } int volume() const { return m_volume; }
NonnullRefPtr<LibDSP::Synthesizers::Classic> synth() { return m_synth; } NonnullRefPtr<DSP::Synthesizers::Classic> synth() { return m_synth; }
NonnullRefPtr<LibDSP::Effects::Delay> delay() { return m_delay; } NonnullRefPtr<DSP::Effects::Delay> delay() { return m_delay; }
void fill_sample(Sample& sample); void fill_sample(Sample& sample);
void reset(); void reset();
@ -52,12 +52,12 @@ private:
int m_volume; int m_volume;
NonnullRefPtr<LibDSP::Transport> m_transport; NonnullRefPtr<DSP::Transport> m_transport;
NonnullRefPtr<LibDSP::Effects::Delay> m_delay; NonnullRefPtr<DSP::Effects::Delay> m_delay;
NonnullRefPtr<LibDSP::Synthesizers::Classic> m_synth; NonnullRefPtr<DSP::Synthesizers::Classic> m_synth;
SinglyLinkedList<RollNote> m_roll_notes[note_count]; SinglyLinkedList<RollNote> m_roll_notes[note_count];
RollIter m_roll_iterators[note_count]; RollIter m_roll_iterators[note_count];
NonnullRefPtr<LibDSP::Keyboard> m_keyboard; NonnullRefPtr<DSP::Keyboard> m_keyboard;
bool m_is_active_track { false }; bool m_is_active_track { false };
}; };

View file

@ -12,8 +12,8 @@
#include <AK/NonnullRefPtr.h> #include <AK/NonnullRefPtr.h>
TrackManager::TrackManager() TrackManager::TrackManager()
: m_transport(make_ref_counted<LibDSP::Transport>(120, 4)) : m_transport(make_ref_counted<DSP::Transport>(120, 4))
, m_keyboard(make_ref_counted<LibDSP::Keyboard>(m_transport)) , m_keyboard(make_ref_counted<DSP::Keyboard>(m_transport))
{ {
add_track(); add_track();
m_tracks[m_current_track]->set_active(true); m_tracks[m_current_track]->set_active(true);

View file

@ -9,14 +9,14 @@
#pragma once #pragma once
#include "AK/NonnullRefPtr.h"
#include "LibDSP/Keyboard.h"
#include "Music.h" #include "Music.h"
#include "Track.h" #include "Track.h"
#include <AK/Array.h> #include <AK/Array.h>
#include <AK/Noncopyable.h> #include <AK/Noncopyable.h>
#include <AK/NonnullOwnPtr.h> #include <AK/NonnullOwnPtr.h>
#include <AK/NonnullRefPtr.h>
#include <AK/Vector.h> #include <AK/Vector.h>
#include <LibDSP/Keyboard.h>
class TrackManager { class TrackManager {
AK_MAKE_NONCOPYABLE(TrackManager); AK_MAKE_NONCOPYABLE(TrackManager);
@ -38,22 +38,22 @@ public:
m_tracks[m_current_track]->set_active(true); m_tracks[m_current_track]->set_active(true);
} }
NonnullRefPtr<LibDSP::Transport> transport() const { return m_transport; } NonnullRefPtr<DSP::Transport> transport() const { return m_transport; }
NonnullRefPtr<LibDSP::Keyboard> keyboard() const { return m_keyboard; } NonnullRefPtr<DSP::Keyboard> keyboard() const { return m_keyboard; }
// Legacy API, do not add new users. // Legacy API, do not add new users.
void time_forward(int amount); void time_forward(int amount);
void fill_buffer(Span<Sample>); void fill_buffer(Span<Sample>);
void reset(); void reset();
void set_keyboard_note(int note, LibDSP::Keyboard::Switch note_switch); void set_keyboard_note(int note, DSP::Keyboard::Switch note_switch);
void set_should_loop(bool b) { m_should_loop = b; } void set_should_loop(bool b) { m_should_loop = b; }
void add_track(); void add_track();
int next_track_index() const; int next_track_index() const;
private: private:
Vector<NonnullOwnPtr<Track>> m_tracks; Vector<NonnullOwnPtr<Track>> m_tracks;
NonnullRefPtr<LibDSP::Transport> m_transport; NonnullRefPtr<DSP::Transport> m_transport;
NonnullRefPtr<LibDSP::Keyboard> m_keyboard; NonnullRefPtr<DSP::Keyboard> m_keyboard;
size_t m_current_track { 0 }; size_t m_current_track { 0 };
Array<Sample, sample_count> m_front_buffer; Array<Sample, sample_count> m_front_buffer;

View file

@ -32,7 +32,7 @@ void BarsVisualizationWidget::render(GUI::PaintEvent& event, FixedArray<float> c
AK::TypedTransfer<float>::copy(m_previous_samples.data(), samples.data(), samples.size()); AK::TypedTransfer<float>::copy(m_previous_samples.data(), samples.data(), samples.size());
LibDSP::fft(m_fft_samples.span(), false); DSP::fft(m_fft_samples.span(), false);
Array<float, bar_count> groups {}; Array<float, bar_count> groups {};
@ -102,7 +102,7 @@ BarsVisualizationWidget::BarsVisualizationWidget()
logarithmic_spectrum_action->set_checked(true); logarithmic_spectrum_action->set_checked(true);
m_context_menu->add_action(logarithmic_spectrum_action); m_context_menu->add_action(logarithmic_spectrum_action);
m_fft_window = LibDSP::Window<float>::hann<fft_size>(); m_fft_window = DSP::Window<float>::hann<fft_size>();
// As we use full-overlapping windows, the passed-in data is only half the size of one FFT operation. // As we use full-overlapping windows, the passed-in data is only half the size of one FFT operation.
MUST(set_render_sample_count(fft_size / 2)); MUST(set_render_sample_count(fft_size / 2));

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include <LibAudio/ConnectionFromClient.h> #include <LibAudio/ConnectionToServer.h>
#include <LibGUI/Application.h> #include <LibGUI/Application.h>
#include <LibGUI/BoxLayout.h> #include <LibGUI/BoxLayout.h>
#include <LibGUI/ImageWidget.h> #include <LibGUI/ImageWidget.h>

View file

@ -13,8 +13,8 @@
namespace Audio { namespace Audio {
LibDSP::MDCT<12> MP3LoaderPlugin::s_mdct_12; DSP::MDCT<12> MP3LoaderPlugin::s_mdct_12;
LibDSP::MDCT<36> MP3LoaderPlugin::s_mdct_36; DSP::MDCT<36> MP3LoaderPlugin::s_mdct_36;
MP3LoaderPlugin::MP3LoaderPlugin(StringView path) MP3LoaderPlugin::MP3LoaderPlugin(StringView path)
: m_file(Core::File::construct(path)) : m_file(Core::File::construct(path))

View file

@ -58,8 +58,8 @@ private:
AK::Vector<AK::Tuple<size_t, int>> m_seek_table; AK::Vector<AK::Tuple<size_t, int>> m_seek_table;
AK::Array<AK::Array<AK::Array<float, 18>, 32>, 2> m_last_values {}; AK::Array<AK::Array<AK::Array<float, 18>, 32>, 2> m_last_values {};
AK::Array<AK::Array<float, 1024>, 2> m_synthesis_buffer {}; AK::Array<AK::Array<float, 1024>, 2> m_synthesis_buffer {};
static LibDSP::MDCT<36> s_mdct_36; static DSP::MDCT<36> s_mdct_36;
static LibDSP::MDCT<12> s_mdct_12; static DSP::MDCT<12> s_mdct_12;
u32 m_sample_rate { 0 }; u32 m_sample_rate { 0 };
u8 m_num_channels { 0 }; u8 m_num_channels { 0 };

View file

@ -6,7 +6,7 @@
#include "Clip.h" #include "Clip.h"
namespace LibDSP { namespace DSP {
Sample AudioClip::sample_at(u32 time) Sample AudioClip::sample_at(u32 time)
{ {

View file

@ -11,7 +11,7 @@
#include <AK/Types.h> #include <AK/Types.h>
#include <LibDSP/Music.h> #include <LibDSP/Music.h>
namespace LibDSP { namespace DSP {
// A clip is a self-contained snippet of notes or audio that can freely move inside and in between tracks. // A clip is a self-contained snippet of notes or audio that can freely move inside and in between tracks.
class Clip : public RefCounted<Clip> { class Clip : public RefCounted<Clip> {

View file

@ -8,7 +8,7 @@
#include <AK/FixedArray.h> #include <AK/FixedArray.h>
#include <math.h> #include <math.h>
namespace LibDSP::Effects { namespace DSP::Effects {
Delay::Delay(NonnullRefPtr<Transport> transport) Delay::Delay(NonnullRefPtr<Transport> transport)
: EffectProcessor(move(transport)) : EffectProcessor(move(transport))

View file

@ -11,7 +11,7 @@
#include <LibDSP/ProcessorParameter.h> #include <LibDSP/ProcessorParameter.h>
#include <LibDSP/Transport.h> #include <LibDSP/Transport.h>
namespace LibDSP::Effects { namespace DSP::Effects {
// A simple digital delay effect using a delay buffer. // A simple digital delay effect using a delay buffer.
// This is based on Piano's old built-in delay. // This is based on Piano's old built-in delay.

View file

@ -8,7 +8,7 @@
#include <AK/StdLibExtras.h> #include <AK/StdLibExtras.h>
namespace LibDSP { namespace DSP {
// For now, this cannot be optimal as clang doesn't know underlying type specifications. // For now, this cannot be optimal as clang doesn't know underlying type specifications.
enum EnvelopeState { enum EnvelopeState {

View file

@ -10,7 +10,7 @@
#include <AK/Math.h> #include <AK/Math.h>
#include <AK/Span.h> #include <AK/Span.h>
namespace LibDSP { namespace DSP {
constexpr void fft(Span<Complex<float>> sample_data, bool invert = false) constexpr void fft(Span<Complex<float>> sample_data, bool invert = false)
{ {

View file

@ -9,7 +9,7 @@
#include <AK/Error.h> #include <AK/Error.h>
#include <AK/NumericLimits.h> #include <AK/NumericLimits.h>
namespace LibDSP { namespace DSP {
void Keyboard::set_keyboard_note(u8 pitch, Keyboard::Switch note_switch) void Keyboard::set_keyboard_note(u8 pitch, Keyboard::Switch note_switch)
{ {

View file

@ -11,7 +11,7 @@
#include <LibDSP/Music.h> #include <LibDSP/Music.h>
#include <LibDSP/Transport.h> #include <LibDSP/Transport.h>
namespace LibDSP { namespace DSP {
class Keyboard : public RefCounted<Keyboard> { class Keyboard : public RefCounted<Keyboard> {

View file

@ -10,7 +10,7 @@
#include <AK/Math.h> #include <AK/Math.h>
#include <AK/Span.h> #include <AK/Span.h>
namespace LibDSP { namespace DSP {
template<size_t N> template<size_t N>
requires(N % 2 == 0) class MDCT { requires(N % 2 == 0) class MDCT {

View file

@ -15,7 +15,7 @@
#include <LibAudio/Sample.h> #include <LibAudio/Sample.h>
#include <LibDSP/Envelope.h> #include <LibDSP/Envelope.h>
namespace LibDSP { namespace DSP {
using Sample = Audio::Sample; using Sample = Audio::Sample;

View file

@ -17,7 +17,7 @@
#include <LibDSP/ProcessorParameter.h> #include <LibDSP/ProcessorParameter.h>
#include <LibDSP/Transport.h> #include <LibDSP/Transport.h>
namespace LibDSP { namespace DSP {
// A processor processes notes or audio into notes or audio. Processors are e.g. samplers, synthesizers, effects, arpeggiators etc. // A processor processes notes or audio into notes or audio. Processors are e.g. samplers, synthesizers, effects, arpeggiators etc.
class Processor : public RefCounted<Processor> { class Processor : public RefCounted<Processor> {

View file

@ -14,7 +14,7 @@
#include <AK/Types.h> #include <AK/Types.h>
#include <LibDSP/Music.h> #include <LibDSP/Music.h>
namespace LibDSP { namespace DSP {
using ParameterFixedPoint = FixedPoint<8, i64>; using ParameterFixedPoint = FixedPoint<8, i64>;
@ -78,7 +78,7 @@ public:
ParameterT value() const { return m_value; }; ParameterT value() const { return m_value; };
void set_value(ParameterT value) void set_value(ParameterT value)
{ {
set_value_sneaky(value, LibDSP::Detail::ProcessorParameterSetValueTag {}); set_value_sneaky(value, DSP::Detail::ProcessorParameterSetValueTag {});
if (did_change_value) if (did_change_value)
did_change_value(value); did_change_value(value);
} }
@ -151,14 +151,14 @@ public:
} }
template<> template<>
struct AK::Formatter<LibDSP::ProcessorRangeParameter> : AK::StandardFormatter { struct AK::Formatter<DSP::ProcessorRangeParameter> : AK::StandardFormatter {
Formatter() = default; Formatter() = default;
explicit Formatter(StandardFormatter formatter) explicit Formatter(StandardFormatter formatter)
: StandardFormatter(formatter) : StandardFormatter(formatter)
{ {
} }
ErrorOr<void> format(FormatBuilder& builder, LibDSP::ProcessorRangeParameter value) ErrorOr<void> format(FormatBuilder& builder, DSP::ProcessorRangeParameter value)
{ {
if (m_mode == Mode::Pointer) { if (m_mode == Mode::Pointer) {
Formatter<FlatPtr> formatter { *this }; Formatter<FlatPtr> formatter { *this };

View file

@ -14,10 +14,10 @@
#include <LibDSP/Processor.h> #include <LibDSP/Processor.h>
#include <LibDSP/Synthesizers.h> #include <LibDSP/Synthesizers.h>
namespace LibDSP::Synthesizers { namespace DSP::Synthesizers {
Classic::Classic(NonnullRefPtr<Transport> transport) Classic::Classic(NonnullRefPtr<Transport> transport)
: LibDSP::SynthesizerProcessor(transport) : DSP::SynthesizerProcessor(transport)
, m_waveform("Waveform"sv, Waveform::Saw) , m_waveform("Waveform"sv, Waveform::Saw)
, m_attack("Attack"sv, 0.01, 2000, 5, Logarithmic::Yes) , m_attack("Attack"sv, 0.01, 2000, 5, Logarithmic::Yes)
, m_decay("Decay"sv, 0.01, 20'000, 80, Logarithmic::Yes) , m_decay("Decay"sv, 0.01, 20'000, 80, Logarithmic::Yes)

View file

@ -12,7 +12,7 @@
#include <LibDSP/ProcessorParameter.h> #include <LibDSP/ProcessorParameter.h>
#include <LibDSP/Transport.h> #include <LibDSP/Transport.h>
namespace LibDSP::Synthesizers { namespace DSP::Synthesizers {
enum Waveform : u8 { enum Waveform : u8 {
Sine, Sine,

View file

@ -14,7 +14,7 @@
#include <LibDSP/Processor.h> #include <LibDSP/Processor.h>
#include <LibDSP/Track.h> #include <LibDSP/Track.h>
namespace LibDSP { namespace DSP {
bool Track::add_processor(NonnullRefPtr<Processor> new_processor) bool Track::add_processor(NonnullRefPtr<Processor> new_processor)
{ {

View file

@ -13,7 +13,7 @@
#include <LibDSP/Music.h> #include <LibDSP/Music.h>
#include <LibDSP/Processor.h> #include <LibDSP/Processor.h>
namespace LibDSP { namespace DSP {
// A track is also known as a channel and serves as a container for the audio pipeline: clips -> processors -> mixing & output // A track is also known as a channel and serves as a container for the audio pipeline: clips -> processors -> mixing & output
class Track : public RefCounted<Track> { class Track : public RefCounted<Track> {

View file

@ -10,7 +10,7 @@
#include <AK/Types.h> #include <AK/Types.h>
#include <LibDSP/Music.h> #include <LibDSP/Music.h>
namespace LibDSP { namespace DSP {
// The DAW-wide timekeeper and synchronizer // The DAW-wide timekeeper and synchronizer
class Transport final : public RefCounted<Transport> { class Transport final : public RefCounted<Transport> {

View file

@ -9,7 +9,7 @@
#include <AK/FixedArray.h> #include <AK/FixedArray.h>
#include <AK/Math.h> #include <AK/Math.h>
namespace LibDSP { namespace DSP {
template<typename T> template<typename T>
class Window final { class Window final {