- Timestamp:
- 05/19/21 09:01:33 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/apollo/gui/WaveFormRenderProccessingUnit.java
r1146 r1561 3 3 import java.awt.Graphics2D; 4 4 import java.util.LinkedList; 5 import java.util.List; 5 6 6 7 import javax.sound.sampled.AudioFormat; … … 269 270 for (int i = 0; i < amps.length; i+=2) { 270 271 272 g.setColor(SwingConversions.toSwingColor(ApolloColorIndexedModels.WAVEFORM_COLOR)); 273 271 274 float peak = amps[i]; 272 275 float trough = amps[i + 1]; … … 293 296 } 294 297 298 int frameSize = 4; 299 int bi_start = (currentTask.startFrame + renderStart); 300 int bi_end = bi_start + (renderLength); 301 302 for (int bi = bi_start; bi<bi_end; bi++) { 303 if (currentTask.frameIsBeat[bi]) { 304 g.setColor(SwingConversions.toSwingColor(ApolloColorIndexedModels.WAVEFORM_SELECTION_COLOR)); 305 g.drawLine(x, halfMaxHeight, x, -halfMaxHeight); 306 break; 307 } 308 } 309 295 310 currentAmplitude ++; 296 311 } … … 303 318 } // next pass 304 319 305 // Less ion learnt: do not request lots of requests to repaint306 // later on the AWT Event queu otherwise it will get congested320 // Lesson learnt: do not request lots of requests to repaint 321 // later on the AWT Event queue otherwise it will get congested 307 322 // and will freeze up the interact for annoying periods of time. 308 323 currentTask.setState(WaveFormRenderTask.STATE_STOPPED); … … 348 363 private Image imageBuffer; // nullified when stopped. 349 364 private byte[] audioBytes; // nullified when stopped. - Arrays (not contents) are immutable so no need to worry about threading issues with indexes 365 private boolean[] frameIsBeat; 366 350 367 private final int startFrame; 351 368 private final int frameLength; // in frames … … 357 374 byte[] audioBytes, 358 375 AudioFormat format, 376 List<Double> detectedBeats, 359 377 int startFrame, 360 378 int frameLength, … … 371 389 this.frameLength = frameLength; 372 390 this.recommendInvalidations = recommendInvalidations; 391 392 this.frameIsBeat = new boolean[frameLength]; 393 if (detectedBeats != null) { 394 for (double beat_in_secs: detectedBeats){ 395 int frame_pos = (int)Math.round(beat_in_secs * format.getSampleRate()); 396 frameIsBeat[frame_pos] = true; 397 } 398 } 399 373 400 renderer = new DualPeakTroughWaveFormRenderer(format); 374 401 } … … 384 411 if (state == STATE_STOPPED) { 385 412 audioBytes = null; 413 frameIsBeat = null; 386 414 imageBuffer = null; 387 415 }
Note:
See TracChangeset
for help on using the changeset viewer.