| 44 | } |
| 45 | |
| 46 | void NoteStreamDisplay::DrawModule() |
| 47 | { |
| 48 | if (Minimized() || IsVisible() == false) |
| 49 | return; |
| 50 | |
| 51 | int barLines = int(ceil(mDurationMs / TheTransport->MsPerBar())); |
| 52 | ofSetColor(150, 150, 150); |
| 53 | for (int i = 0; i < barLines; ++i) |
| 54 | { |
| 55 | double measureStartTime = gTime - TheTransport->MsPerBar() * (TheTransport->GetMeasurePos(gTime) + i); |
| 56 | float x = ofMap(gTime - measureStartTime, mDurationMs, 0, 0, mWidth); |
| 57 | ofLine(x, 0, x, mHeight); |
| 58 | } |
| 59 | |
| 60 | ofFill(); |
| 61 | if (mPitchMin <= mPitchMax) |
| 62 | { |
| 63 | float noteHeight = mHeight / (mPitchMax - mPitchMin + 1); |
| 64 | |
| 65 | for (int i = 0; i < kNoteStreamCapacity; ++i) |
| 66 | { |
| 67 | if (IsElementActive(i)) |
| 68 | { |
| 69 | float xStart = ofMap(gTime - mNoteStream[i].timeOn, mDurationMs, 0, 0, mWidth); |
| 70 | float xEnd; |
| 71 | if (mNoteStream[i].timeOff == -1) |
| 72 | xEnd = mWidth; |
| 73 | else |
| 74 | xEnd = ofMap(gTime - mNoteStream[i].timeOff, mDurationMs, 0, 0, mWidth); |
| 75 | float yStart = GetYPos(mNoteStream[i].pitch, noteHeight); |
| 76 | |
| 77 | ofSetColor(0, ofMap(mNoteStream[i].velocity, 0, 127.0f, 50, 200), 0); |
| 78 | ofRect(xStart, yStart, xEnd - xStart, noteHeight, L(cornerRadius, 2)); |
| 79 | |
| 80 | ofSetColor(mNoteStream[i].velocity / 127.0f * 255, mNoteStream[i].velocity / 127.0f * 255, mNoteStream[i].velocity / 127.0f * 255); |
| 81 | ofRect(xStart, yStart, 3, noteHeight, L(cornerRadius, 2)); |
| 82 | |
| 83 | ofSetColor(0, 0, 0); |
| 84 | ofRect(xEnd - 3, yStart, 3, noteHeight, L(cornerRadius, 2)); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | ofSetColor(100, 100, 255); |
| 89 | bool* notes = mNoteOutput.GetNotes(); |
| 90 | for (int i = mPitchMin; i <= mPitchMax; ++i) |
| 91 | { |
| 92 | if (notes[i]) |
| 93 | ofRect(mWidth - 3, GetYPos(i, noteHeight), 3, noteHeight, L(cornerRadius, 2)); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | mResetButton->Draw(); |
| 98 | } |
| 99 | |
| 100 | void NoteStreamDisplay::DrawModuleUnclipped() |
| 101 | { |
nothing calls this directly
no test coverage detected