1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:37:35 +00:00

Piano+LibDSP: Move Track to LibDSP

This is a tangly commit and it fixes all the bugs that a plain move
would have caused (i.e. we need to touch other logic which had wrong
assumptions).
This commit is contained in:
kleines Filmröllchen 2022-07-13 12:44:19 +02:00 committed by Linus Groh
parent 125122a9ab
commit 4941cffdd0
29 changed files with 322 additions and 413 deletions

View file

@ -33,36 +33,8 @@ void WaveEditor::paint_event(GUI::PaintEvent& event)
GUI::Painter painter(*this);
painter.fill_rect(frame_inner_rect(), Color::Black);
auto recorded_sample = m_track_manager.current_track().recorded_sample();
if (recorded_sample.is_empty())
return;
double width_scale = static_cast<double>(frame_inner_rect().width()) / recorded_sample.size();
painter.translate(frame_thickness(), frame_thickness());
int prev_x = 0;
int left_prev_y = sample_to_y(recorded_sample[0].left);
int right_prev_y = sample_to_y(recorded_sample[0].right);
painter.set_pixel({ prev_x, left_prev_y }, left_wave_colors[RecordedSample]);
painter.set_pixel({ prev_x, right_prev_y }, right_wave_colors[RecordedSample]);
for (size_t x = 1; x < recorded_sample.size(); ++x) {
int left_y = sample_to_y(recorded_sample[x].left);
int right_y = sample_to_y(recorded_sample[x].right);
Gfx::IntPoint left_point1(prev_x * width_scale, left_prev_y);
Gfx::IntPoint left_point2(x * width_scale, left_y);
painter.draw_line(left_point1, left_point2, left_wave_colors[RecordedSample]);
Gfx::IntPoint right_point1(prev_x * width_scale, right_prev_y);
Gfx::IntPoint right_point2(x * width_scale, right_y);
painter.draw_line(right_point1, right_point2, right_wave_colors[RecordedSample]);
prev_x = x;
left_prev_y = left_y;
right_prev_y = right_y;
}
// FIXME: This widget currently can't display anything.
return;
}
SamplerWidget::SamplerWidget(TrackManager& track_manager)