Changeset 342
- Timestamp:
- 10/04/08 16:20:57 (16 years ago)
- Location:
- trunk/src_apollo/org/apollo
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src_apollo/org/apollo/audio/structure/AudioStructureModel.java
r318 r342 1093 1093 if (odframe != null) { 1094 1094 tinf = odframe.removeTrack(localFilename); 1095 assert(tinf != null);1095 //assert(tinf != null); 1096 1096 cancelFetch = doNotify = true; 1097 1097 } -
trunk/src_apollo/org/apollo/audio/util/FrameLayoutDaemon.java
r340 r342 553 553 * 554 554 * @return 555 * The best timeline for the given frame - null if could not infer (if had to). 555 556 */ 556 557 public Timeline getTimeline(Frame targetFrame) { -
trunk/src_apollo/org/apollo/gui/EditableSampledTrackGraphView.java
r338 r342 279 279 0, 280 280 0, 281 -1,282 281 TrackNameCreator.getDefaultName(), 283 282 getMix()); -
trunk/src_apollo/org/apollo/util/AudioMath.java
r315 r342 27 27 */ 28 28 public static int millisecondsToFrames(long ms, AudioFormat format) { 29 double portion = ms;30 portion/= 1000.0;31 return (int) (format.getFrameRate() * portion);29 double tmp = ms * format.getFrameRate(); 30 tmp /= 1000.0; 31 return (int)tmp; 32 32 } 33 33 34 34 public static long framesToMilliseconds(long frames, AudioFormat format) { 35 double portion = frames;36 portion/= (double)format.getFrameRate();37 return (long) (portion * 1000.0);35 double tmp = frames * 1000.0; 36 tmp /= (double)format.getFrameRate(); 37 return (long)tmp; 38 38 } 39 39 -
trunk/src_apollo/org/apollo/widgets/SampleRecorder.java
r335 r342 386 386 getX(), 387 387 getY(), 388 initiationTime,389 388 TrackNameCreator.getNameCopy(targetFrame.getTitle() + "_"), 390 389 null); … … 393 392 394 393 targetFrame.addAllItems(trackWidget.getItems()); 395 394 395 // Must be exact 396 trackWidget.setInitiationTime(initiationTime); 397 396 398 } else { 397 399 -
trunk/src_apollo/org/apollo/widgets/SampledTrack.java
r340 r342 405 405 } 406 406 407 // Toggle indexing407 // Toggle pitch-track indexing 408 408 if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_I) { 409 409 setShouldOmitIndexAudio(!shouldOmitIndexAudio()); … … 453 453 initTime += AudioMath.framesToMilliseconds(rightSideStartFrame, trackModel.getFormat()); 454 454 455 System.out.println("initTime = " + getInitiationTimeFromMeta() + " + " + AudioMath.framesToMilliseconds(rightSideStartFrame, trackModel.getFormat()) 456 + " = " + initTime); 457 455 458 SampledTrack rightSideTrack = SampledTrack.createFromMemory( 456 459 rightsideAudio, … … 459 462 0, // X Coord overridden 460 463 getY(), 461 initTime,462 464 getName() + " part", 463 465 trackMix); … … 465 467 // Anchor it 466 468 target.addAllItems(rightSideTrack.getItems()); 469 470 // Adjust initiation time to be exact 471 rightSideTrack.setInitiationTime(initTime); 472 473 // TODO: FrameLayoutDaemon.getInstance().resumeLayout(this); ? 467 474 } 468 475 … … 511 518 /** 512 519 * Creates a {@link SampledTrack} instantly from audio bytes in memory and adds it to a given frame. 520 * 513 521 * @param audioBytes 514 522 * The audio samples. … … 523 531 * 524 532 * @param y 525 *526 * @param specificInitTime527 * Negative to determine init time from x position. Positive to override528 * and determine x position from given init time529 533 * 530 534 * @param name … … 543 547 Frame targetFrame, 544 548 int x, int y, 545 long specificInitTime,546 549 String name, 547 550 TrackMixSubject mixTemplate) { … … 554 557 source.setParent(targetFrame); 555 558 556 557 559 558 560 long runningtime = AudioMath.framesToMilliseconds( 559 561 audioBytes.length / format.getFrameSize(), format); 560 561 562 562 563 Timeline tl = FrameLayoutDaemon.getInstance().getTimeline(targetFrame); … … 570 571 if (width > 0 && width < FrameLayoutDaemon.MIN_TRACK_WIDGET_WIDTH) width = FrameLayoutDaemon.MIN_TRACK_WIDGET_WIDTH; 571 572 572 if (specificInitTime < 0) { 573 574 if (tl == null) specificInitTime = 0; 575 else specificInitTime = tl.getMSTimeAtX(x); 576 577 } else if (tl != null) { // if defined a specific ms time and a timeline is avialable 578 579 x = tl.getXAtMSTime(specificInitTime); 580 } 581 573 long initTime = (tl == null) ? 0 : tl.getMSTimeAtX(x); 574 582 575 source.setPosition(x, y); 583 576 … … 585 578 LinkedList<String> data = new LinkedList<String>(); 586 579 587 data.add(TrackWidgetCommons.META_INITIATIONTIME_TAG + specificInitTime);580 data.add(TrackWidgetCommons.META_INITIATIONTIME_TAG + initTime); 588 581 data.add(TrackWidgetCommons.META_LAST_WIDTH_TAG + width); // although layout manager will handle, just to quick set 589 582 if (name != null) data.add(TrackWidgetCommons.META_NAME_TAG + name); … … 703 696 getX(), 704 697 getY(), 705 -1,706 698 TrackNameCreator.getNameCopy(trackModel.getName()), 707 699 trackMix); … … 1571 1563 public Long getInitiationTimeFromMeta() { 1572 1564 return getStrippedDataLong(TrackWidgetCommons.META_INITIATIONTIME_TAG, null); 1565 } 1566 1567 /** 1568 * Adjusts the initiation time for this track - to the exact millisecond. 1569 * 1570 * The x-position is updated (which will be eventually done with possibly better 1571 * accuracy if the layout daemon is on) 1572 * 1573 * @param specificInitTime 1574 * The new initiation time for this track in milliseconds 1575 */ 1576 public void setInitiationTime(long specificInitTime) { 1577 1578 Frame parent = getParentFrame(); 1579 1580 // Update x position if it can 1581 if (parent != null) { 1582 Timeline tl = FrameLayoutDaemon.getInstance().getTimeline(parent); 1583 if (tl != null) { 1584 this.setPosition(tl.getXAtMSTime(specificInitTime), getY()); 1585 } 1586 } 1587 1588 updateData(TrackWidgetCommons.META_INITIATIONTIME_TAG, TrackWidgetCommons.META_INITIATIONTIME_TAG + specificInitTime); 1589 1590 // If this track is in the audio model ... 1591 if (AudioStructureModel.getInstance().getTrackGraphInfo(localFileName, (parent != null) ? parent.getName() : null) != null) { 1592 1593 // Add and remove it 1594 AudioStructureModel.getInstance().onTrackWidgetRemoved( 1595 localFileName, (parent != null) ? parent.getName() : null); 1596 1597 AudioStructureModel.getInstance().onTrackWidgetAnchored( 1598 localFileName, (parent != null) ? parent.getName() : null, 1599 specificInitTime, getRunningMSTimeFromRawAudio(), getName()); 1600 } 1573 1601 } 1574 1602
Note:
See TracChangeset
for help on using the changeset viewer.