Changeset 577 in josm
- Timestamp:
- 2008-03-06T13:50:13+01:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r526 r577 118 118 @Override public void exitMode() { 119 119 super.exitMode(); 120 selectionManager.unregister(Main.map.mapView); 120 121 Main.map.mapView.removeMouseListener(this); 121 122 Main.map.mapView.removeMouseMotionListener(this); … … 210 211 */ 211 212 @Override public void mousePressed(MouseEvent e) { 213 if (! (Boolean)this.getValue("active")) return; 212 214 if (e.getButton() != MouseEvent.BUTTON1) 213 215 return; -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java
r572 r577 57 57 private boolean enabled; 58 58 private boolean wasPlaying = false; 59 private int dropTolerance = 50; /* pixels */ 59 60 60 61 public static PlayHeadMarker create() { … … 75 76 enabled = Main.pref.getBoolean("marker.traceaudio", true); 76 77 if (! enabled) return; 78 try { dropTolerance = Integer.parseInt(Main.pref.get("marker.playHeadDropTolerance", "50")); } 79 catch(NumberFormatException x) { dropTolerance = 50; } 77 80 Main.map.mapView.addMouseListener(new MouseAdapter() { 78 81 @Override public void mousePressed(MouseEvent ev) { … … 117 120 */ 118 121 private void endDrag(boolean reset) { 122 if (! wasPlaying || reset) 123 try { AudioPlayer.pause(); } 124 catch (Exception ex) { AudioPlayer.audioMalfunction(ex);} 119 125 if (reset) 120 126 eastNorth = oldEastNorth; 121 127 Main.map.selectMapMode(oldMode); 122 128 Main.map.mapView.repaint(); 123 if (! wasPlaying)124 try { AudioPlayer.pause(); }125 catch (Exception ex) { AudioPlayer.audioMalfunction(ex);}126 129 timer.start(); 127 130 } … … 177 180 */ 178 181 public void reposition(EastNorth en) { 179 eastNorth = en; 180 WayPoint cw = getClosestTrackPoint(Main.map.mapView.getPoint(en), 25.0); 182 // eastNorth = en; 183 WayPoint cw = null; 184 AudioMarker recent = AudioMarker.recentlyPlayedMarker(); 185 if (recent != null && recent.parentLayer != null && recent.parentLayer.fromLayer != null) { 186 /* work out EastNorth equivalent of 50 (default) pixels tolerance */ 187 Point p = Main.map.mapView.getPoint(en); 188 EastNorth enPlus25px = Main.map.mapView.getEastNorth(p.x+dropTolerance, p.y); 189 cw = recent.parentLayer.fromLayer.nearestPointOnTrack(en, enPlus25px.east() - en.east()); 190 } 191 181 192 AudioMarker ca = null; 182 183 193 /* Find the prior audio marker (there should always be one in the 184 194 * layer, even if it is only one at the start of the track) to 185 195 * offset the audio from */ 186 196 if (cw != null) { 187 AudioMarker recent = AudioMarker.recentlyPlayedMarker();188 197 if (recent != null || recent.parentLayer != null) { 189 198 for (Marker m : recent.parentLayer.data) { … … 239 248 if (ca != null && ! ca.containsPoint(startPoint)) ca = null; 240 249 241 /* If we didn't hit an audio marker, we need to create one at the nearest track point */ 242 if (ca == null) { 243 WayPoint cw = getClosestTrackPoint(startPoint, 10.0); 250 /* If we didn't hit an audio marker, we need to create one at the nearest point on the track */ 251 if (ca == null && recent != null) { 252 /* work out EastNorth equivalent of 50 (default) pixels tolerance */ 253 Point p = Main.map.mapView.getPoint(en); 254 EastNorth enPlus25px = Main.map.mapView.getEastNorth(p.x+dropTolerance, p.y); 255 WayPoint cw = recent.parentLayer.fromLayer.nearestPointOnTrack(en, enPlus25px.east() - en.east()); 244 256 if (cw == null) { 245 257 JOptionPane.showMessageDialog(Main.parent, tr("You need to SHIFT-Drag the play head onto an audio marker or onto the track point where you want to synchronize.")); … … 264 276 if (time < 0.0) return; 265 277 Point screen = mv.getPoint(eastNorth); 266 // buttonRectangle.setLocation(screen.x+4, screen.y+2);267 278 symbol.paintIcon(mv, g, screen.x, screen.y); 268 279 } -
trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java
r572 r577 37 37 private double position; // seconds 38 38 private double bytesPerSecond; 39 private static long chunk = 8000; /* bytes */39 private static long chunk = 4000; /* bytes */ 40 40 private double speed = 1.0; 41 41 … … 238 238 break; 239 239 case PLAYING: 240 command.possiblyInterrupt(); 240 241 for(;;) { 241 242 int nBytesRead = 0; … … 280 281 long nBytesRead = 0; 281 282 position = 0.0; 282 double adjustedOffset = (offset - leadIn) * calibration; 283 offset -= leadIn; 284 double calibratedOffset = offset * calibration; 283 285 bytesPerSecond = audioFormat.getFrameRate() /* frames per second */ 284 286 * audioFormat.getFrameSize() /* bytes per frame */; 285 287 if (speed * bytesPerSecond > 256000.0) 286 288 speed = 256000 / bytesPerSecond; 287 if ( offset != 0.0 && adjustedOffset > 0.0) {289 if (calibratedOffset > 0.0) { 288 290 long bytesToSkip = (long)( 289 adjustedOffset /* seconds (double) */ * bytesPerSecond);291 calibratedOffset /* seconds (double) */ * bytesPerSecond); 290 292 /* skip doesn't seem to want to skip big chunks, so 291 293 * reduce it to smaller ones … … 300 302 if (bytesToSkip > 0) 301 303 audioInputStream.skip(bytesToSkip); 302 position = adjustedOffset;304 position = offset; 303 305 } 304 306 if (audioOutputLine != null)
Note:
See TracChangeset
for help on using the changeset viewer.