diff --git a/Applications/Piano/Music.h b/Applications/Piano/Music.h index ddcc2fb2aee8fd..c6a2c4fd7ade3c 100644 --- a/Applications/Piano/Music.h +++ b/Applications/Piano/Music.h @@ -112,7 +112,7 @@ constexpr KeyColor key_pattern[] = { const Color note_pressed_color(64, 64, 255); const Color column_playing_color(128, 128, 255); -const Color wave_colors[] = { +const Color left_wave_colors[] = { // Sine { 255, @@ -151,6 +151,45 @@ const Color wave_colors[] = { }, }; +const Color right_wave_colors[] = { + // Sine + { + 255, + 223, + 0, + }, + // Triangle + { + 35, + 171, + 90, + }, + // Square + { + 139, + 128, + 255, + }, + // Saw + { + 240, + 100, + 220, + }, + // Noise + { + 197, + 223, + 225, + }, + // RecordedSample + { + 227, + 105, + 39, + }, +}; + constexpr int notes_per_octave = 12; constexpr int white_keys_per_octave = 7; constexpr int black_keys_per_octave = 5; diff --git a/Applications/Piano/SamplerWidget.cpp b/Applications/Piano/SamplerWidget.cpp index 78eb08eee998c6..6b7f34f8ddead5 100644 --- a/Applications/Piano/SamplerWidget.cpp +++ b/Applications/Piano/SamplerWidget.cpp @@ -69,18 +69,26 @@ void WaveEditor::paint_event(GUI::PaintEvent& event) painter.translate(frame_thickness(), frame_thickness()); int prev_x = 0; - int prev_y = sample_to_y(recorded_sample[0].left); - painter.set_pixel({ prev_x, prev_y }, wave_colors[RecordedSample]); + 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 (int x = 1; x < recorded_sample.size(); ++x) { - int y = sample_to_y(recorded_sample[x].left); + int left_y = sample_to_y(recorded_sample[x].left); + int right_y = sample_to_y(recorded_sample[x].right); - Gfx::Point point1(prev_x * width_scale, prev_y); - Gfx::Point point2(x * width_scale, y); - painter.draw_line(point1, point2, wave_colors[RecordedSample]); + Gfx::Point left_point1(prev_x * width_scale, left_prev_y); + Gfx::Point left_point2(x * width_scale, left_y); + painter.draw_line(left_point1, left_point2, left_wave_colors[RecordedSample]); + + Gfx::Point right_point1(prev_x * width_scale, right_prev_y); + Gfx::Point right_point2(x * width_scale, right_y); + painter.draw_line(right_point1, right_point2, right_wave_colors[RecordedSample]); prev_x = x; - prev_y = y; + left_prev_y = left_y; + right_prev_y = right_y; } } diff --git a/Applications/Piano/WaveWidget.cpp b/Applications/Piano/WaveWidget.cpp index ffdc728d19314c..1d592b60d20061 100644 --- a/Applications/Piano/WaveWidget.cpp +++ b/Applications/Piano/WaveWidget.cpp @@ -60,23 +60,32 @@ void WaveWidget::paint_event(GUI::PaintEvent& event) painter.fill_rect(frame_inner_rect(), Color::Black); painter.translate(frame_thickness(), frame_thickness()); - Color wave_color = wave_colors[m_audio_engine.wave()]; + Color left_wave_color = left_wave_colors[m_audio_engine.wave()]; + Color right_wave_color = right_wave_colors[m_audio_engine.wave()]; auto buffer = m_audio_engine.buffer(); double width_scale = static_cast(frame_inner_rect().width()) / buffer.size(); int prev_x = 0; - int prev_y = sample_to_y(buffer[0].left); - painter.set_pixel({ prev_x, prev_y }, wave_color); + int prev_y_left = sample_to_y(buffer[0].left); + int prev_y_right = sample_to_y(buffer[0].right); + painter.set_pixel({ prev_x, prev_y_left }, left_wave_color); + painter.set_pixel({ prev_x, prev_y_right }, right_wave_color); for (size_t x = 1; x < buffer.size(); ++x) { - int y = sample_to_y(buffer[x].left); + int y_left = sample_to_y(buffer[x].left); + int y_right = sample_to_y(buffer[x].right); - Gfx::Point point1(prev_x * width_scale, prev_y); - Gfx::Point point2(x * width_scale, y); - painter.draw_line(point1, point2, wave_color); + Gfx::Point point1_left(prev_x * width_scale, prev_y_left); + Gfx::Point point2_left(x * width_scale, y_left); + painter.draw_line(point1_left, point2_left, left_wave_color); + + Gfx::Point point1_right(prev_x * width_scale, prev_y_right); + Gfx::Point point2_right(x * width_scale, y_right); + painter.draw_line(point1_right, point2_right, right_wave_color); prev_x = x; - prev_y = y; + prev_y_left = y_left; + prev_y_right = y_right; } GUI::Frame::paint_event(event);