Changeset 572 in josm


Ignore:
Timestamp:
2008-03-02T16:10:33+01:00 (16 years ago)
Author:
david
Message:

Reorganise audio interface in light of recent usability comments

Location:
trunk
Files:
4 added
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/OpenAction.java

    r553 r572  
    9191                        GpxLayer gpxLayer = new GpxLayer(r.data, fn);
    9292                        Main.main.addLayer(gpxLayer);
    93             MarkerLayer ml = new MarkerLayer(r.data, tr("Markers from {0}", fn), file, gpxLayer);
    94             if (ml.data.size() > 0) {
    95                 Main.main.addLayer(ml);
    96             }
     93                        if (Main.pref.getBoolean("marker.makeautomarkers", true)) {
     94                                MarkerLayer ml = new MarkerLayer(r.data, tr("Markers from {0}", fn), file, gpxLayer);
     95                                if (ml.data.size() > 0) {
     96                                        Main.main.addLayer(ml);
     97                                }
     98                        }
    9799
    98100                } else {
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioBackAction.java

    r560 r572  
    2626                        amount = 10.0;
    2727                }
     28                this.putValue("help", "Action/Back");
    2829        }
    2930
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r553 r572  
    3636import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3737import org.openstreetmap.josm.gui.layer.OsmDataLayer.ModifiedChangedListener;
     38import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
     39import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker;
    3840
    3941/**
     
    6769        private ArrayList<Layer> layers = new ArrayList<Layer>();
    6870        /**
     71         * The play head marker: there is only one of these so it isn't in any specific layer
     72         */
     73        public PlayHeadMarker playHeadMarker = null;
     74        /**
    6975         * Direct link to the edit layer (if any) in the layers list.
    7076         */
     
    132138                        });
    133139                }
    134 
     140                if (layer instanceof MarkerLayer && playHeadMarker == null)
     141                        playHeadMarker = PlayHeadMarker.create();
     142               
    135143                layers.add(layers.size(), layer);
    136144
     
    211219                if (x1 > 0 || y1 > 0 || x2 < getWidth() || y2 < getHeight())
    212220                        g.drawRect(x1, y1, x2-x1+1, y2-y1+1);
     221               
     222                if (playHeadMarker != null)
     223                        playHeadMarker.paint(g, this);
     224
    213225                super.paint(g);
    214226        }
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r567 r572  
    2424import java.net.URLConnection;
    2525import java.net.UnknownHostException;
     26import java.util.Iterator;
    2627
    2728import javax.swing.AbstractAction;
     
    160161                });
    161162
    162                 JMenuItem applyAudio = new JMenuItem(tr("Make Sampled Audio Layer"), ImageProvider.get("applyaudio"));
    163                 applyAudio.putClientProperty("help", "Action/MakeSampledAudioLayer");
    164                 applyAudio.addActionListener(new ActionListener() {
     163                JMenuItem importAudio = new JMenuItem(tr("Import Audio"), ImageProvider.get("importaudio"));
     164                importAudio.putClientProperty("help", "ImportAudio");
     165                importAudio.addActionListener(new ActionListener() {
    165166                        public void actionPerformed(ActionEvent e) {
    166167                                String dir = Main.pref.get("markers.lastaudiodirectory");
     
    182183                                if (sel == null)
    183184                                        return;
    184                                 applyAudio(sel);
     185                                importAudio(sel);
    185186                                Main.map.repaint();
    186187                        }
     
    245246                                line,
    246247                                tagimage,
    247                                 applyAudio,
     248                                importAudio,
    248249                                markersFromNamedTrackpoints,
    249250                                new JMenuItem(new ConvertToDataLayerAction()),
     
    458459        }
    459460
    460 
    461461        public class ConvertToDataLayerAction extends AbstractAction {
    462462                public ConvertToDataLayerAction() {
     
    485485                }
    486486        }
    487 
     487       
    488488        /**
    489          *
    490          *
     489         * Makes a new marker layer derived from this GpxLayer containing at least one
     490         * audio marker which the given audio file is associated with.
     491         * Markers are derived from the following
     492         * (a) explict waypoints in the GPX layer, or
     493         * (b) named trackpoints in the GPX layer, or
     494         * (c) (in future) voice recognised markers in the sound recording
     495         * (d) a single marker at the beginning of the track
     496         * @param wavFile : the file to be associated with the markers in the new marker layer
    491497         */
    492         private void applyAudio(File wavFile) {
     498        private void importAudio(File wavFile) {
    493499                String uri = "file:".concat(wavFile.getAbsolutePath());
    494             double audioGapSecs = 15.0;
    495                 try {
    496                         audioGapSecs = Double.parseDouble(Main.pref.get("marker.audiosampleminsecs", Double.toString(audioGapSecs)));
    497                 } catch (NumberFormatException e) {
    498                 }
    499             double audioGapMetres = 75.0;
    500                 try {
    501                         audioGapMetres = Double.parseDouble(Main.pref.get("marker.audiosampleminmetres", Double.toString(audioGapMetres)));
    502                 } catch (NumberFormatException e) {
    503                 }
    504                 double audioGapRadians = (audioGapMetres / 40041455.0 /* circumference of Earth in metres */) * 2.0 * Math.PI;
    505                 double audioGapRadiansSquared = audioGapRadians * audioGapRadians;
    506                 double firstTime = -1.0;
    507             double prevOffset = - (audioGapSecs + 1.0); // first point always exceeds time difference
    508             WayPoint prevPoint = null;
    509 
    510             MarkerLayer ml = new MarkerLayer(new GpxData(), tr("Sampled audio markers from {0}", name), associatedFile, me);
     500            MarkerLayer ml = new MarkerLayer(new GpxData(), tr("Audio markers from {0}", name), associatedFile, me);
     501
     502            // (a) try explicit waypoints - unless suppressed
     503            if (Main.pref.getBoolean("marker.audiofromexplicitwaypoints", true) &&
     504                data.waypoints != null &&
     505                ! data.waypoints.isEmpty())
     506            {
     507                double firstTime = -1.0;
     508                for (WayPoint w : data.waypoints) {
     509                        if (firstTime < 0.0) firstTime = w.time;
     510                        double offset = w.time - firstTime;
     511                        String name = w.attr.containsKey("name") ? w.getString("name") :
     512                                w.attr.containsKey("desc") ? w.getString("desc") :
     513                                AudioMarker.inventName(offset);
     514                                AudioMarker am = AudioMarker.create(w.latlon,
     515                                                name, uri, ml, w.time, offset);
     516                                ml.data.add(am);                       
     517                }
     518            }
     519
     520            // (b) use explicitly named track points, again unless suppressed
     521            if (ml.data.isEmpty() &&
     522                Main.pref.getBoolean("marker.namedtrackpoints") &&
     523                data.tracks != null &&
     524                ! data.tracks.isEmpty())
     525            {
     526                double firstTime = -1.0;
     527                for (GpxTrack track : data.tracks) {
     528                        for (Collection<WayPoint> seg : track.trackSegs) {
     529                                for (WayPoint w : seg) {
     530                                        String name;
     531                                        if (w.attr.containsKey("name"))
     532                                                name = w.getString("name");
     533                                        else if (w.attr.containsKey("desc"))
     534                                                name = w.getString("desc");
     535                                        else
     536                                                continue;
     537                                if (firstTime < 0.0) firstTime = w.time;
     538                                double offset = w.time - firstTime;
     539                                        AudioMarker am = AudioMarker.create(w.latlon,
     540                                                        name, uri, ml, w.time, offset);
     541                                        ml.data.add(am);                       
     542                                }
     543                        }
     544                }
     545            }
     546
     547            // (c) analyse audio for spoken markers here, in due course
    511548           
    512                 for (GpxTrack track : data.tracks) {
    513                         for (Collection<WayPoint> seg : track.trackSegs) {
    514                                 for (WayPoint point : seg) {
    515                                         double time = point.time;
    516                                         if (firstTime < 0.0)
    517                                                 firstTime = time;
    518                                         double offset = time - firstTime;
    519                                         if (prevPoint == null ||
    520                                                 (offset - prevOffset > audioGapSecs &&
    521                                                 /* note: distance is misleading: it actually gives distance _squared_ */
    522                                                 point.eastNorth.distance(prevPoint.eastNorth) > audioGapRadiansSquared))
    523                                         {
    524                                                
    525                                                 AudioMarker am = AudioMarker.create(point.latlon,
    526                                                                 AudioMarker.inventName(offset), uri, ml, time, offset);
    527                                                 ml.data.add(am);
    528                                                 prevPoint = point;
    529                                                 prevOffset = offset;
    530                                         }
    531                                 }
    532                         }
    533                 }
    534 
    535         if (ml.data.size() > 0) {
     549            // (d) simply add a single marker at the start of the track
     550            if (ml.data.isEmpty() &&
     551                data.tracks != null &&
     552                    ! data.tracks.isEmpty())
     553                {
     554                for (GpxTrack track : data.tracks) {
     555                        for (Collection<WayPoint> seg : track.trackSegs) {
     556                                for (WayPoint w : seg) {
     557                                AudioMarker am = AudioMarker.create(w.latlon,
     558                                                        tr("start"), uri, ml, w.time, 0.0);
     559                                        ml.data.add(am);                       
     560                                        break;
     561                                }
     562                                break;
     563                        }
     564                        break;
     565                }
     566                }
     567           
     568        if (! ml.data.isEmpty()) {
    536569                Main.main.addLayer(ml);
     570        } else {
     571                        JOptionPane.showMessageDialog(Main.parent, tr("Nothing available to associate audio with."));
    537572        }
    538573        }
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarker.java

    r554 r572  
    6868               
    6969        /**
    70          * Starts playing the audio associated with the marker: used in response to pressing
    71          * the marker as well as indirectly
    72          *
     70         * Starts playing the audio associated with the marker offset by the given amount
     71         * @param after : seconds after marker where playing should start
    7372         */
    74         public void play() {
     73        public void play(double after) {
    7574                try {
    7675                        // first enable tracing the audio along the track
    77                         if (Main.pref.getBoolean("marker.traceaudio", true) && parentLayer != null) {
    78                                 parentLayer.traceAudio();
    79                         }
     76                        Main.map.mapView.playHeadMarker.animate();
    8077
    81                         AudioPlayer.play(audioUrl, offset + syncOffset);
     78                        AudioPlayer.play(audioUrl, offset + syncOffset + after);
    8279                        recentlyPlayedMarker = this;
    8380                } catch (Exception e) {
     
    8582                }
    8683        }
     84
     85        /**
     86         * Starts playing the audio associated with the marker: used in response to pressing
     87         * the marker as well as indirectly
     88         *
     89         */
     90        public void play() { play(0.0); }
    8791
    8892        public void adjustOffset(double adjustment) {
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java

    r562 r572  
    6262public class Marker implements ActionListener {
    6363
    64         public final EastNorth eastNorth;
     64        public EastNorth eastNorth;
    6565        public final String text;
    6666        public final Icon symbol;
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r567 r572  
    4444import org.openstreetmap.josm.gui.layer.GpxLayer;
    4545import org.openstreetmap.josm.gui.layer.markerlayer.AudioMarker;
     46import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker;
    4647import org.openstreetmap.josm.tools.ColorHelper;
    4748import org.openstreetmap.josm.tools.ImageProvider;
     
    6768        private boolean mousePressed = false;
    6869        public GpxLayer fromLayer = null;
    69         private Rectangle audioTracer = null;
     70       
     71        /*
    7072        private Icon audioTracerIcon = null;
    7173        private EastNorth playheadPosition = null;
     
    7375        private static double audioAnimationInterval = 0.0; // seconds
    7476        private static double playheadTime = -1.0;
    75 
     77         */
    7678        public MarkerLayer(GpxData indata, String name, File associatedFile, GpxLayer fromLayer) {
    7779               
     
    161163                        }
    162164                }
    163 
    164                 if (audioTracer != null) {
    165                         Point screen = Main.map.mapView.getPoint(playheadPosition);
    166                         audioTracer.setLocation(screen.x, screen.y);
    167                         audioTracerIcon.paintIcon(Main.map.mapView, g, screen.x, screen.y);
    168                 }
    169         }
    170 
    171         protected void traceAudio() {
    172                 if (timer == null) {
    173                         audioAnimationInterval = Double.parseDouble(Main.pref.get("marker.audioanimationinterval", "1")); //milliseconds
    174                         timer = new Timer((int)(audioAnimationInterval * 1000.0), new ActionListener() {
    175                                 public void actionPerformed(ActionEvent e) {
    176                                         timerAction();
    177                                 }
    178                         });
    179                         timer.start();
    180                 }
    181         }
    182        
    183         /**
    184          * callback for AudioPlayer when position changes
    185          * @param position seconds into the audio stream
    186          */
    187         public void timerAction() {
    188                 AudioMarker recentlyPlayedMarker = AudioMarker.recentlyPlayedMarker();
    189                 if (recentlyPlayedMarker == null)
    190                         return;
    191                 double audioTime = recentlyPlayedMarker.time +
    192                         AudioPlayer.position() -
    193                         recentlyPlayedMarker.offset -
    194                         recentlyPlayedMarker.syncOffset;
    195                 if (Math.abs(audioTime- playheadTime) < audioAnimationInterval)
    196                         return;
    197                 if (fromLayer == null)
    198                         return;
    199                 /* find the pair of track points for this position (adjusted by the syncOffset)
    200                  * and interpolate between them
    201                  */
    202                 WayPoint w1 = null;
    203                 WayPoint w2 = null;
    204 
    205                 for (GpxTrack track : fromLayer.data.tracks) {
    206                         for (Collection<WayPoint> trackseg : track.trackSegs) {
    207                                 for (Iterator<WayPoint> it = trackseg.iterator(); it.hasNext();) {
    208                                         WayPoint w = it.next();
    209                                         if (audioTime < w.time) {
    210                                                 w2 = w;
    211                                                 break;
    212                                         }
    213                                         w1 = w;
    214                                 }
    215                                 if (w2 != null) break;
    216                         }
    217                         if (w2 != null) break;
    218                 }
    219                
    220                 if (w1 == null)
    221                         return;
    222                 playheadPosition = w2 == null ?
    223                         w1.eastNorth :
    224                         w1.eastNorth.interpolate(w2.eastNorth,
    225                                         (audioTime - w1.time)/(w2.time - w1.time));
    226                
    227                 if (audioTracer == null) {
    228                         audioTracerIcon = ImageProvider.getIfAvailable("markers",Main.pref.get("marker.audiotracericon", "audio-tracer"));
    229                         audioTracer = new Rectangle(0, 0, audioTracerIcon.getIconWidth(), audioTracerIcon.getIconHeight());                     
    230                 }
    231                 playheadTime = audioTime;
    232                 Main.map.mapView.repaint();
    233165        }
    234166
     
    249181                for (Marker mkr : data)
    250182                        v.visit(mkr.eastNorth);
    251         }
    252 
    253         public void applyAudio(File wavFile) {
    254                 String uri = "file:".concat(wavFile.getAbsolutePath());
    255                 Collection<Marker> markers = new ArrayList<Marker>();
    256             for (Marker mkr : data) {
    257                 AudioMarker audioMarker = mkr.audioMarkerFromMarker(uri);
    258                 if (audioMarker == null) {
    259                         markers.add(mkr);
    260                 } else {
    261                     markers.add(audioMarker);
    262                 }
    263             }
    264             data.clear();
    265             data.addAll(markers);
    266183        }
    267184
     
    293210                });
    294211
    295                 JMenuItem applyaudio = new JMenuItem(tr("Apply Audio"), ImageProvider.get("applyaudio"));
    296                 applyaudio.putClientProperty("help", "Action/ApplyAudio");
    297                 applyaudio.addActionListener(new ActionListener(){
    298                         public void actionPerformed(ActionEvent e) {
    299                                 String dir = Main.pref.get("markers.lastaudiodirectory");
    300                                 JFileChooser fc = new JFileChooser(dir);
    301                                 fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
    302                                 fc.setAcceptAllFileFilterUsed(false);
    303                                 fc.setFileFilter(new FileFilter(){
    304                                         @Override public boolean accept(File f) {
    305                                                 return f.isDirectory() || f.getName().toLowerCase().endsWith(".wav");
    306                                         }
    307                                         @Override public String getDescription() {
    308                                                 return tr("Wave Audio files (*.wav)");
    309                                         }
    310                                 });
    311                                 fc.showOpenDialog(Main.parent);
    312                                 File sel = fc.getSelectedFile();
    313                                 if (!fc.getCurrentDirectory().getAbsolutePath().equals(dir))
    314                                         Main.pref.put("markers.lastaudiodirectory", fc.getCurrentDirectory().getAbsolutePath());
    315                                 if (sel == null)
    316                                         return;
    317                                 applyAudio(sel);
    318                                 Main.map.repaint();
    319                         }
    320                 });
    321 
    322212                JMenuItem syncaudio = new JMenuItem(tr("Synchronize Audio"), ImageProvider.get("audio-sync"));
    323213                syncaudio.putClientProperty("help", "Action/SynchronizeAudio");
    324214                syncaudio.addActionListener(new ActionListener(){
    325215                        public void actionPerformed(ActionEvent e) {
    326                                 adjustOffsetsOnAudioMarkers();
     216                                if (! AudioPlayer.paused()) {
     217                                        JOptionPane.showMessageDialog(Main.parent,tr("You need to pause audio at the moment when you hear your synchronization cue."));
     218                                        return;
     219                                }
     220                                AudioMarker recent = AudioMarker.recentlyPlayedMarker();
     221                                if (synchronizeAudioMarkers(recent)) {
     222                                        JOptionPane.showMessageDialog(Main.parent, tr("Audio synchronized at point " + recent.text));
     223                                } else {
     224                                        JOptionPane.showMessageDialog(Main.parent,tr("Unable to synchronize in layer being played."));
     225                                }
    327226                        }
    328227                });
     
    332231                moveaudio.addActionListener(new ActionListener(){
    333232                        public void actionPerformed(ActionEvent e) {
    334                                 makeAudioMarkerAtPlayHead();
     233                                if (! AudioPlayer.paused()) {
     234                                        JOptionPane.showMessageDialog(Main.parent,tr("You need to have paused audio at the point on the track where you want the marker."));
     235                                        return;
     236                                }
     237                                PlayHeadMarker playHeadMarker = Main.map.mapView.playHeadMarker;
     238                                if (playHeadMarker == null)
     239                                        return;
     240                                addAudioMarker(playHeadMarker.time, playHeadMarker.eastNorth);
     241                                Main.map.mapView.repaint();
    335242                        }
    336243                });
     
    344251                components.add(new JSeparator());
    345252                components.add(syncaudio);
    346                 components.add(applyaudio);
    347253                if (Main.pref.getBoolean("marker.traceaudio", true)) {
    348254                        components.add (moveaudio);
     
    354260        }
    355261
    356         private void adjustOffsetsOnAudioMarkers() {
    357                 if (! AudioPlayer.paused()) {
    358                         JOptionPane.showMessageDialog(Main.parent,tr("You need to pause audio at the moment when you hear your synchronization cue."));
    359                         return;
    360                 }
    361                 Marker startMarker = AudioMarker.recentlyPlayedMarker();
    362                 boolean explicitMarker = true;
     262        public boolean synchronizeAudioMarkers(AudioMarker startMarker) {
    363263                if (startMarker != null && ! data.contains(startMarker)) {
    364                         explicitMarker = false;
    365264                        startMarker = null;
    366265                }
     
    368267                        // find the first audioMarker in this layer
    369268                        for (Marker m : data) {
    370                                 if (m.getClass() == AudioMarker.class) {
    371                                         startMarker = m;
     269                                if (m instanceof AudioMarker) {
     270                                        startMarker = (AudioMarker) m;
    372271                                        break;
    373272                                }
    374273                        }
    375274                }
    376                 if (startMarker == null) {
    377                         // still no marker to work from - message?
    378                         JOptionPane.showMessageDialog(Main.parent,tr("No audio marker found in the layer to synchronize with."));
    379                         return;
    380                 }
     275                if (startMarker == null)
     276                        return false;
     277                       
    381278                // apply adjustment to all subsequent audio markers in the layer
    382279                double adjustment = AudioPlayer.position() - startMarker.offset; // in seconds
    383280                boolean seenStart = false;
    384                 URL url = ((AudioMarker)startMarker).url();
     281                URL url = startMarker.url();
    385282                for (Marker m : data) {
    386283                        if (m == startMarker)
     
    392289                        }
    393290                }
    394                
    395                 JOptionPane.showMessageDialog(Main.parent, explicitMarker ?
    396                         tr("Audio synchronized with most recently played marker and subsequent ones (that have the same sound track).") :
    397                         tr("Audio synchronized with audio markers in the layer (that have the same sound track as the first one)."));
    398         }
    399        
    400         private void makeAudioMarkerAtPlayHead() {
    401                 if (! AudioPlayer.paused()) {
    402                         JOptionPane.showMessageDialog(Main.parent,tr("You need to pause audio at the point on the track where you want the marker."));
    403                         return;
    404                 }
     291                return true;
     292        }
     293       
     294        public AudioMarker addAudioMarker(double time, EastNorth en) {
    405295                // find first audio marker to get absolute start time
    406296                double offset = 0.0;
     
    409299                        if (m.getClass() == AudioMarker.class) {
    410300                                am = (AudioMarker)m;
    411                                 offset = playheadTime - am.time;
     301                                offset = time - am.time;
    412302                                break;
    413303                        }
     
    415305                if (am == null) {
    416306                        JOptionPane.showMessageDialog(Main.parent,tr("No existing audio markers in this layer to offset from."));
    417                         return;
     307                        return null;
    418308                }
    419309
    420310                // make our new marker
    421                 AudioMarker newAudioMarker = AudioMarker.create(Main.proj.eastNorth2latlon(playheadPosition),
    422                         AudioMarker.inventName(offset), AudioPlayer.url().toString(), this, playheadTime, offset);
     311                AudioMarker newAudioMarker = AudioMarker.create(Main.proj.eastNorth2latlon(en),
     312                        AudioMarker.inventName(offset), AudioPlayer.url().toString(), this, time, offset);
    423313               
    424314                // insert it at the right place in a copy the collection
     
    440330                                newAudioMarker.adjustOffset(am.syncOffset()); // i.e. same as predecessor                               
    441331                        newData.add(newAudioMarker); // insert at end
    442                         newAudioMarker = null;
    443332                }
    444333               
     
    446335                data.clear();
    447336                data.addAll(newData);
    448                 Main.map.mapView.repaint();
     337                return newAudioMarker;
    449338        }
    450339       
  • trunk/src/org/openstreetmap/josm/gui/preferences/AudioPreference.java

    r563 r572  
    2828public class AudioPreference implements PreferenceSetting {
    2929        private JCheckBox audioMenuVisible = new JCheckBox(tr("Display the Audio menu."));
    30         /*
    31         private JCheckBox audioToolbarVisible = new JCheckBox(tr("Display Audio control buttons on toolbar."));
    32         */
    3330        private JCheckBox markerButtonLabels = new JCheckBox(tr("Label audio (and image and web) markers."));
    3431        private JCheckBox markerAudioTraceVisible = new JCheckBox(tr("Display live audio trace."));
    3532        private JCheckBox markersNamedTrackpoints = new JCheckBox(tr("Create audio markers from named trackpoints."));
     33        private JCheckBox makeAutoMarkers = new JCheckBox(tr("Create non-audio markers when reading GPX."));
     34        private JCheckBox audioMarkersFromExplicitWaypoints = new JCheckBox(tr("Import audio uses explicit waypoints."));
    3635
    37         private JTextField audioSampleMinSecs = new JTextField(8);
    38         private JTextField audioSampleMinMetres = new JTextField(8);
    3936        private JTextField audioLeadIn = new JTextField(8);
    4037        private JTextField audioForwardBackAmount = new JTextField(8);
     
    9188                gui.audio.add(markersNamedTrackpoints, GBC.eol().insets(0,0,0,0));
    9289               
    93                 audioSampleMinSecs.setText(Main.pref.get("marker.audiosampleminsecs", "15"));
    94                 audioSampleMinSecs.setToolTipText(tr("Minimum time in seconds between audio samples when creating sampled audio markers from waypoints"));
    95                 gui.audio.add(new JLabel(tr("Min audio marker sample rate (seconds)")), GBC.std());
    96                 gui.audio.add(audioSampleMinSecs, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    97 
    98                 audioSampleMinMetres.setText(Main.pref.get("marker.audiosampleminmetres", "75"));
    99                 audioSampleMinMetres.setToolTipText(tr("Minimum distance in metres between audio samples when creating sampled audio markers from waypoints"));
    100                 gui.audio.add(new JLabel(tr("Min audio marker sample rate (metres)")), GBC.std());
    101                 gui.audio.add(audioSampleMinMetres, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    102 
     90                // makeAutoMarkers
     91                makeAutoMarkers.addActionListener(new ActionListener(){
     92                        public void actionPerformed(ActionEvent e) {
     93                                if (!makeAutoMarkers.isSelected())
     94                                        makeAutoMarkers.setSelected(false);
     95                                makeAutoMarkers.setEnabled(makeAutoMarkers.isSelected());
     96                        }
     97                });
     98                makeAutoMarkers.setSelected(Main.pref.getBoolean("marker.makeautomarkers", true));
     99                makeAutoMarkers.setToolTipText(tr("Automatically make a marker layer from any waypoints when opening a GPX layer."));
     100                gui.audio.add(makeAutoMarkers, GBC.eol().insets(0,0,0,0));
     101               
     102                // audioMarkersFromExplicitWaypoints
     103                audioMarkersFromExplicitWaypoints.addActionListener(new ActionListener(){
     104                        public void actionPerformed(ActionEvent e) {
     105                                if (!audioMarkersFromExplicitWaypoints.isSelected())
     106                                        audioMarkersFromExplicitWaypoints.setSelected(false);
     107                                audioMarkersFromExplicitWaypoints.setEnabled(audioMarkersFromExplicitWaypoints.isSelected());
     108                        }
     109                });
     110                audioMarkersFromExplicitWaypoints.setSelected(Main.pref.getBoolean("marker.audiofromexplicitwaypoints", true));
     111                audioMarkersFromExplicitWaypoints.setToolTipText(tr("When importing audio, apply it to any waypoints in the GPX layer."));
     112                gui.audio.add(audioMarkersFromExplicitWaypoints, GBC.eol().insets(0,0,0,0));
     113               
    103114                audioForwardBackAmount.setText(Main.pref.get("audio.forwardbackamount", "10"));
    104115                audioForwardBackAmount.setToolTipText(tr("The number of seconds to jump forward or back when the relevant button is pressed"));
     
    129140                Main.pref.put("marker.buttonlabels", markerButtonLabels.isSelected());
    130141                Main.pref.put("marker.namedtrackpoints", markersNamedTrackpoints.isSelected());
    131                 Main.pref.put("marker.audiosampleminsecs", audioSampleMinSecs.getText());               
    132                 Main.pref.put("marker.audiosampleminmetres", audioSampleMinMetres.getText());           
     142                Main.pref.put("marker.suppressautomarkers", makeAutoMarkers.isSelected());
     143                Main.pref.put("marker.audiofromexplicitwaypoints", audioMarkersFromExplicitWaypoints.isSelected());
    133144                Main.pref.put("audio.forwardbackamount", audioForwardBackAmount.getText());             
    134145                Main.pref.put("audio.fastfwdmultiplier", audioFastForwardMultiplier.getText());         
  • trunk/src/org/openstreetmap/josm/io/GpxReader.java

    r554 r572  
    241241                                        currentState = states.pop();
    242242                                        currentTrackSeg.add(currentWayPoint);
    243                                         if (Main.pref.getBoolean("marker.namedtrackpoints") &&
    244                                                 (currentWayPoint.attr.containsKey("name") ||
    245                                                         currentWayPoint.attr.containsKey("desc")))
    246                                         {
    247                                                 currentData.waypoints.add(currentWayPoint);
    248                                         }
    249243                                } else if (qName.equals("wpt")) {
    250244                                        currentState = states.pop();
  • trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java

    r563 r572  
    305305                                                                audioOutputLine.close();
    306306                                                        audioFormat = new AudioFormat(audioFormat.getEncoding(),
    307                                                                                 audioFormat.getSampleRate() * (float) speed,
     307                                                                                audioFormat.getSampleRate() * (float) (speed * calibration),
    308308                                                                                audioFormat.getSampleSizeInBits(),
    309309                                                                                audioFormat.getChannels(),
    310310                                                                                audioFormat.getFrameSize(),
    311                                                                                 audioFormat.getFrameRate() * (float) speed,
     311                                                                                audioFormat.getFrameRate() * (float) (speed * calibration),
    312312                                                                                audioFormat.isBigEndian());
    313313                                                        DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
Note: See TracChangeset for help on using the changeset viewer.