MCPcopy Create free account
hub / github.com/DamRsn/NeuralNote / paint

Method paint

NeuralNote/Source/Components/PianoRoll.cpp:41–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41void PianoRoll::paint(Graphics& g)
42{
43 Rectangle<float> local_bounds = {0, 0, static_cast<float>(getWidth()), static_cast<float>(getHeight())};
44
45 auto rect_width = static_cast<float>(getWidth());
46
47 g.setColour(WAVEFORM_BG_COLOR);
48 g.fillRoundedRectangle(getLocalBounds().toFloat(), 4);
49
50 if (mProcessor->getState() == PopulatedAudioAndMidiRegions) {
51 // Draw horizontal note lines
52 for (int i = MIN_MIDI_NOTE; i <= MAX_MIDI_NOTE; i++) {
53 if (mKeyboard.getRectangleForKey(i).intersects(local_bounds)) {
54 Colour fill_colour = _isWhiteKey(i) ? Colours::white : Colours::black;
55
56 fill_colour = fill_colour.withAlpha(0.2f);
57
58 g.setColour(fill_colour);
59
60 auto [note_y_start, note_height] = _getNoteHeightAndWidthPianoRoll(i);
61 g.fillRect(0.0f, note_y_start, rect_width, note_height);
62 }
63 }
64
65 // Draw vertical lines if we have info on bpm, time signature ...
66 if (mProcessor->getParameterValue(ParameterHelpers::EnableTimeQuantizationId) > 0.5f) {
67 _drawBeatVerticalLines(g);
68 }
69
70 // Draw notes
71 for (auto& note_event: mProcessor->getTranscriptionManager()->getNoteEventVector()) {
72 auto [note_y_start, note_height] = _getNoteHeightAndWidthPianoRoll(note_event.pitch);
73 auto start = static_cast<float>(note_event.startTime);
74 auto end = static_cast<float>(note_event.endTime);
75
76 if (note_y_start < 0 || note_height >= static_cast<float>(getHeight()))
77 continue;
78
79 g.setColour(mNoteGradient.getColourAtPosition(note_event.amplitude));
80 g.fillRect(_timeToPixel(start), note_y_start, _timeToPixel(end) - _timeToPixel(start), note_height);
81
82 g.setColour(Colours::black);
83 g.drawRect(_timeToPixel(start), note_y_start, _timeToPixel(end) - _timeToPixel(start), note_height, 0.5);
84
85 // Draw pitch bend
86 if (static_cast<PitchBendModes>(
87 static_cast<int>(std::round(mProcessor->getParameterValue(ParameterHelpers::PitchBendModeId))))
88 == SinglePitchBend) {
89 const auto& bends = note_event.bends;
90
91 if (!note_event.bends.empty()) {
92 auto path_stroke_type = PathStrokeType(1, PathStrokeType::mitered, PathStrokeType::butt);
93 Path p;
94 float y_ref_pb = note_y_start + note_height / 2.0f;
95
96 p.startNewSubPath(_timeToPixel(start), y_ref_pb);
97
98 for (size_t i = 0; i < bends.size(); i++) {

Callers

nothing calls this directly

Calls 3

getStateMethod · 0.80
getParameterValueMethod · 0.80

Tested by

no test coverage detected