Changeset 318 for trunk/src_apollo/org/apollo/widgets/SampleRecorder.java
- Timestamp:
- 09/23/08 16:00:42 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src_apollo/org/apollo/widgets/SampleRecorder.java
r315 r318 17 17 import java.io.IOException; 18 18 import java.io.PipedInputStream; 19 import java.util.LinkedList; 20 import java.util.List; 19 21 20 22 import javax.sound.sampled.AudioFormat; … … 49 51 import org.expeditee.gui.Frame; 50 52 import org.expeditee.gui.FrameGraphics; 53 import org.expeditee.gui.FrameMouseActions; 51 54 import org.expeditee.items.ItemParentStateChangedEvent; 52 55 import org.expeditee.items.Text; 53 56 import org.expeditee.items.widgets.InteractiveWidget; 54 57 58 /** 59 * Records sampled audio ... the cornerstone widget to Apollo. 60 * 61 * @author Brook Novak 62 * 63 */ 55 64 public class SampleRecorder extends InteractiveWidget 56 65 implements ActionListener, Observer, MultitrackLoadListener { … … 85 94 private boolean hasExplicityStopped = false; 86 95 96 private boolean isSelfDestructable = false; 97 87 98 private final static int BUTTON_HEIGHT = 50; 88 99 private final static int LABEL_HEIGHT = 30; … … 97 108 98 109 private final static int RENDER_POINTS_PER_SECOND = 20; // how many points to render each second 110 111 private final static String SELF_DESTRUCT_OFF_META = "permanent"; 112 private final static String COUNTDOWN_META = "countdown="; 113 99 114 100 115 public SampleRecorder(Text source, String[] args) { … … 105 120 COUNTDOWN_SETTINGS_HEIGHT + BUTTON_HEIGHT + LABEL_HEIGHT + AnimatedSampleGraph.GRAPH_HEIGHT + (4 * VERT_SPACING)); 106 121 122 isSelfDestructable = !containsDataTrimmedIgnoreCase(SELF_DESTRUCT_OFF_META); 123 int countdown = getStrippedDataInt(COUNTDOWN_META, 0); 124 if (countdown < 0) countdown = 0; 125 else if (countdown > MAX_COUNTDOWN_TIME) 126 countdown = MAX_COUNTDOWN_TIME; 127 107 128 // Create gui layout 108 129 recordButton = new JButton(); … … 133 154 countDownSpinner = new JSpinner(model); 134 155 countDownSpinner.setPreferredSize(new Dimension(50, COUNTDOWN_SETTINGS_HEIGHT)); 135 156 countDownSpinner.setValue(countdown); 157 136 158 countDownSpinnerLabel = new JLabel("Count down:"); 137 159 countDownSpinnerLabel.setPreferredSize(new Dimension(AnimatedSampleGraph.GRAPH_WIDTH - 50, COUNTDOWN_SETTINGS_HEIGHT)); … … 307 329 308 330 } else { 309 310 // Remove this temporary widget 311 removeSelf(); 331 332 if (isSelfDestructable) { 333 // Remove this temporary widget 334 removeSelf(); 335 } 312 336 313 337 // Spawn an audio track using the actual bytes and audio format buffered from … … 326 350 if (!shouldPlayback) initiationTime = -1; 327 351 328 SampledTrack Evo4 trackWidget = SampledTrackEvo4.createFromMemory(352 SampledTrack trackWidget = SampledTrack.createFromMemory( 329 353 audioByteReader.bufferedAudioBytes.toByteArray(), 330 354 audioByteReader.audioFormat, … … 336 360 null); 337 361 338 targetFrame.addAllItems(trackWidget.getItems()); 362 if (isSelfDestructable) { 363 364 targetFrame.addAllItems(trackWidget.getItems()); 365 366 } else { 367 368 FrameMouseActions.pickup(trackWidget.getItems()); 369 370 // Reset the state 371 setState(WidgetState.Ready, "Ready"); 372 373 } 339 374 340 375 … … 379 414 return null; 380 415 } 381 416 417 @Override 418 protected List<String> getData() { 419 420 List<String> data = new LinkedList<String>(); 421 422 if (isSelfDestructable) 423 data.add(SELF_DESTRUCT_OFF_META); 424 425 data.add(COUNTDOWN_META + countDownSpinner.getValue()); 426 427 return data; 428 } 429 382 430 @Override 383 431 protected void onParentStateChanged(int eventType) {
Note:
See TracChangeset
for help on using the changeset viewer.