MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / DrawModule

Method DrawModule

Source/Rewriter.cpp:111–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111void Rewriter::DrawModule()
112{
113 if (Minimized() || IsVisible() == false)
114 return;
115
116 mRewriteButton->Draw();
117 mStartRecordTimeButton->Draw();
118
119 if (mStartRecordTime != -1)
120 {
121 ofSetColor(255, 100, 0, 100 + 50 * (cosf(TheTransport->GetMeasurePos(gTime) * 4 * FTWO_PI)));
122 ofRect(mStartRecordTimeButton->GetRect(true));
123 }
124
125 if (mConnectedLooper)
126 {
127 int loopSamples = abs(int(TheTransport->MsPerBar() / 1000 * gSampleRate)) * mConnectedLooper->GetNumBars();
128 ofRectangle rect(3, mHeight - kBufferHeight - 3, mWidth - 6, kBufferHeight);
129 float playhead = fmod(TheTransport->GetMeasureTime(gTime), mConnectedLooper->GetNumBars()) / mConnectedLooper->GetNumBars();
130 //mRecordBuffer.Draw(rect.x, rect.y, rect.width, rect.height, loopSamples, L(channel,0), loopSamples * playhead);
131 //mRecordBuffer.Draw(rect.x, rect.y, rect.width * playhead, rect.height, loopSamples * playhead, L(channel, 0));
132
133 ofPushMatrix();
134 ofTranslate(rect.x, rect.y);
135 int nowOffset = mRecordBuffer.GetRawBufferOffset(0);
136 int startSample = nowOffset - loopSamples * playhead;
137 if (startSample < 0)
138 startSample += mRecordBuffer.Size();
139 int endSample = startSample - 1;
140 if (endSample < 0)
141 endSample += loopSamples;
142 int loopBeginSample = startSample - loopSamples * (1 - playhead);
143 if (loopBeginSample < 0)
144 loopBeginSample += mRecordBuffer.Size();
145
146 DrawAudioBuffer(rect.width, rect.height, mRecordBuffer.GetRawBuffer()->GetChannel(0), startSample, endSample, -1, 1, ofColor::black, nowOffset, loopBeginSample, mRecordBuffer.Size());
147 ofPopMatrix();
148
149 ofSetColor(0, 255, 0);
150 ofLine(rect.x + rect.width * playhead, rect.y, rect.x + rect.width * playhead, rect.y + rect.height);
151 }
152 else
153 {
154 DrawTextNormal("connect a looper", 5, mHeight - 3 - kBufferHeight / 2);
155 }
156}
157
158void Rewriter::ButtonClicked(ClickButton* button, double time)
159{

Callers

nothing calls this directly

Calls 15

ofSetColorFunction · 0.85
ofRectFunction · 0.85
ofPushMatrixFunction · 0.85
ofTranslateFunction · 0.85
DrawAudioBufferFunction · 0.85
ofPopMatrixFunction · 0.85
ofLineFunction · 0.85
DrawTextNormalFunction · 0.85
MsPerBarMethod · 0.80
GetMeasureTimeMethod · 0.80
GetRawBufferOffsetMethod · 0.80
SizeMethod · 0.80

Tested by

no test coverage detected