mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
#660 Updates audio processing subsystem to use audio segments. Updates audio playback, recording and streaming to use audio segments. Adds support to UserPreferences for sound card selection and audio tone insertion during playback. Adds record preference for WAVE or MP3. Resolves issues with metadata in recordings. (#675)
This commit is contained in:
@@ -35,7 +35,6 @@ import io.github.dsheirer.source.tuner.channel.TunerChannelSource;
|
||||
|
||||
public class SourceManager
|
||||
{
|
||||
private MixerManager mMixerManager;
|
||||
private RecordingSourceManager mRecordingSourceManager;
|
||||
private TunerManager mTunerManager;
|
||||
private TunerModel mTunerModel;
|
||||
@@ -43,9 +42,8 @@ public class SourceManager
|
||||
public SourceManager(TunerModel tunerModel, SettingsManager settingsManager, UserPreferences userPreferences)
|
||||
{
|
||||
mTunerModel = tunerModel;
|
||||
mMixerManager = new MixerManager();
|
||||
mRecordingSourceManager = new RecordingSourceManager(settingsManager);
|
||||
mTunerManager = new TunerManager(mMixerManager, tunerModel, userPreferences);
|
||||
mTunerManager = new TunerManager(tunerModel, userPreferences);
|
||||
|
||||
//TODO: change mixer & recording managers to be models and hand them
|
||||
//in via the constructor. Perform loading outside of this class.
|
||||
@@ -60,11 +58,6 @@ public class SourceManager
|
||||
mTunerManager.dispose();
|
||||
}
|
||||
|
||||
public MixerManager getMixerManager()
|
||||
{
|
||||
return mMixerManager;
|
||||
}
|
||||
|
||||
public RecordingSourceManager getRecordingSourceManager()
|
||||
{
|
||||
return mRecordingSourceManager;
|
||||
@@ -87,7 +80,7 @@ public class SourceManager
|
||||
switch(config.getSourceType())
|
||||
{
|
||||
case MIXER:
|
||||
retVal = mMixerManager.getSource(config);
|
||||
retVal = MixerManager.getSource(config);
|
||||
break;
|
||||
case TUNER:
|
||||
if(config instanceof SourceConfigTuner)
|
||||
|
||||
@@ -1,76 +1,108 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2020 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.source.mixer;
|
||||
|
||||
import javax.sound.sampled.Mixer;
|
||||
|
||||
public class MixerChannelConfiguration
|
||||
{
|
||||
private Mixer mMixer;
|
||||
private MixerChannel mMixerChannel;
|
||||
|
||||
public MixerChannelConfiguration( Mixer mixer, MixerChannel channel )
|
||||
{
|
||||
mMixer = mixer;
|
||||
mMixerChannel = channel;
|
||||
}
|
||||
|
||||
public Mixer getMixer()
|
||||
{
|
||||
return mMixer;
|
||||
}
|
||||
|
||||
public MixerChannel getMixerChannel()
|
||||
{
|
||||
return mMixerChannel;
|
||||
}
|
||||
|
||||
public boolean matches( String mixer, String channels )
|
||||
{
|
||||
return mixer != null &&
|
||||
channels != null &&
|
||||
mMixer.getMixerInfo().getName().contentEquals( mixer ) &&
|
||||
mMixerChannel.name().contentEquals( channels );
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( mMixer.getMixerInfo().getName() );
|
||||
sb.append( " - " );
|
||||
sb.append( mMixerChannel.name() );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
private Mixer mMixer;
|
||||
private MixerChannel mMixerChannel;
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ( ( mMixer == null ) ? 0 : mMixer.hashCode() );
|
||||
result = prime * result
|
||||
+ ( ( mMixerChannel == null ) ? 0 : mMixerChannel.hashCode() );
|
||||
return result;
|
||||
}
|
||||
public MixerChannelConfiguration(Mixer mixer, MixerChannel channel)
|
||||
{
|
||||
mMixer = mixer;
|
||||
mMixerChannel = channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if ( this == obj )
|
||||
return true;
|
||||
if ( obj == null )
|
||||
return false;
|
||||
if ( getClass() != obj.getClass() )
|
||||
return false;
|
||||
MixerChannelConfiguration other = (MixerChannelConfiguration) obj;
|
||||
if ( mMixer == null )
|
||||
public Mixer getMixer()
|
||||
{
|
||||
return mMixer;
|
||||
}
|
||||
|
||||
public MixerChannel getMixerChannel()
|
||||
{
|
||||
return mMixerChannel;
|
||||
}
|
||||
|
||||
public boolean matches(String mixer, String channels)
|
||||
{
|
||||
return mixer != null &&
|
||||
channels != null &&
|
||||
mMixer.getMixerInfo().getName().contentEquals(mixer) &&
|
||||
mMixerChannel.name().contentEquals(channels);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append(mMixer.getMixerInfo().getName());
|
||||
sb.append(" - ");
|
||||
sb.append(mMixerChannel.name());
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((mMixer == null) ? 0 : mMixer.hashCode());
|
||||
result = prime * result
|
||||
+ ((mMixerChannel == null) ? 0 : mMixerChannel.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(this == obj)
|
||||
{
|
||||
if ( other.mMixer != null )
|
||||
return true;
|
||||
}
|
||||
if(obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(getClass() != obj.getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
MixerChannelConfiguration other = (MixerChannelConfiguration)obj;
|
||||
if(mMixer == null)
|
||||
{
|
||||
if(other.mMixer != null)
|
||||
{
|
||||
return false;
|
||||
} else if ( !mMixer.equals( other.mMixer ) )
|
||||
}
|
||||
}
|
||||
else if(!mMixer.equals(other.mMixer))
|
||||
{
|
||||
return false;
|
||||
if ( mMixerChannel != other.mMixerChannel )
|
||||
}
|
||||
if(mMixerChannel != other.mMixerChannel)
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,26 +36,19 @@ import javax.sound.sampled.SourceDataLine;
|
||||
import javax.sound.sampled.TargetDataLine;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Utility class for accessing input, output and tuner mixers
|
||||
*/
|
||||
public class MixerManager
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(MixerManager.class);
|
||||
|
||||
private List<InputMixerConfiguration> mInputMixers = new ArrayList<>();
|
||||
private List<MixerChannelConfiguration> mOutputMixers = new ArrayList<>();
|
||||
private Map<String,MixerTunerDataLine> mMixerTuners = new HashMap<>();
|
||||
public MixerManager() {}
|
||||
|
||||
public MixerManager()
|
||||
{
|
||||
loadMixers();
|
||||
}
|
||||
|
||||
public RealMixerSource getSource(SourceConfiguration config)
|
||||
public static RealMixerSource getSource(SourceConfiguration config)
|
||||
{
|
||||
RealMixerSource retVal = null;
|
||||
|
||||
@@ -131,14 +124,31 @@ public class MixerManager
|
||||
return null;
|
||||
}
|
||||
|
||||
public InputMixerConfiguration[] getInputMixers()
|
||||
public static List<InputMixerConfiguration> getInputMixers()
|
||||
{
|
||||
return mInputMixers.toArray(new InputMixerConfiguration[mInputMixers.size()]);
|
||||
List<InputMixerConfiguration> inputMixers = new ArrayList<>();
|
||||
|
||||
for(Mixer.Info mixerInfo : AudioSystem.getMixerInfo())
|
||||
{
|
||||
Mixer mixer = AudioSystem.getMixer(mixerInfo);
|
||||
|
||||
if(mixer != null)
|
||||
{
|
||||
EnumSet<MixerChannel> inputChannels = getSupportedTargetChannels(mixer);
|
||||
|
||||
if(inputChannels != null)
|
||||
{
|
||||
inputMixers.add(new InputMixerConfiguration(mixer, inputChannels));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return inputMixers;
|
||||
}
|
||||
|
||||
public InputMixerConfiguration getInputMixer(String name)
|
||||
public static InputMixerConfiguration getInputMixer(String name)
|
||||
{
|
||||
for(InputMixerConfiguration mixer : mInputMixers)
|
||||
for(InputMixerConfiguration mixer : getInputMixers())
|
||||
{
|
||||
if(mixer.getMixerName().contentEquals(name))
|
||||
{
|
||||
@@ -149,67 +159,50 @@ public class MixerManager
|
||||
return null;
|
||||
}
|
||||
|
||||
public MixerChannelConfiguration[] getOutputMixers()
|
||||
public static MixerChannelConfiguration getDefaultOutputMixer()
|
||||
{
|
||||
return mOutputMixers.toArray(new MixerChannelConfiguration[mOutputMixers.size()]);
|
||||
List<MixerChannelConfiguration> outputMixers = getOutputMixers();
|
||||
|
||||
if(outputMixers.size() >= 1)
|
||||
{
|
||||
return outputMixers.get(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Collection<MixerTunerDataLine> getMixerTunerDataLines()
|
||||
public static List<MixerChannelConfiguration> getOutputMixers()
|
||||
{
|
||||
if(mMixerTuners.isEmpty())
|
||||
List<MixerChannelConfiguration> outputMixers = new ArrayList<>();
|
||||
|
||||
for(Mixer.Info mixerInfo : AudioSystem.getMixerInfo())
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return mMixerTuners.values();
|
||||
Mixer mixer = AudioSystem.getMixer(mixerInfo);
|
||||
|
||||
if(mixer != null)
|
||||
{
|
||||
List<MixerChannel> outputChannels = getSupportedSourceChannels(mixer);
|
||||
|
||||
for(MixerChannel channel : outputChannels)
|
||||
{
|
||||
outputMixers.add(new MixerChannelConfiguration(mixer, channel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return outputMixers;
|
||||
}
|
||||
|
||||
private void loadMixers()
|
||||
public static Collection<MixerTunerDataLine> getMixerTunerDataLines()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("loading system mixer devices\n");
|
||||
List<MixerTunerDataLine> tuners = new ArrayList<>();
|
||||
|
||||
for(Mixer.Info mixerInfo : AudioSystem.getMixerInfo())
|
||||
{
|
||||
//Sort between the mixers and the tuner mixers, and load each
|
||||
MixerTunerType mixerTunerType = MixerTunerType.getMixerTunerType(mixerInfo);
|
||||
|
||||
if(mixerTunerType == MixerTunerType.UNKNOWN)
|
||||
{
|
||||
Mixer mixer = AudioSystem.getMixer(mixerInfo);
|
||||
|
||||
if(mixer != null)
|
||||
{
|
||||
EnumSet<MixerChannel> inputChannels = getSupportedTargetChannels(mixer);
|
||||
|
||||
if(inputChannels != null)
|
||||
{
|
||||
mInputMixers.add(new InputMixerConfiguration(mixer, inputChannels));
|
||||
|
||||
sb.append("\t[LOADED] Input: " + mixerInfo.getName() + " CHANNELS: " + inputChannels + "\n");
|
||||
}
|
||||
|
||||
EnumSet<MixerChannel> outputChannels = getSupportedSourceChannels(mixer);
|
||||
|
||||
if(outputChannels != null)
|
||||
{
|
||||
for(MixerChannel channel : outputChannels)
|
||||
{
|
||||
mOutputMixers.add(new MixerChannelConfiguration(mixer, channel));
|
||||
}
|
||||
|
||||
sb.append("\t[LOADED] Output: " + mixerInfo.getName() + " CHANNELS: " + outputChannels + "\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("\t[NOT LOADED] Mixer:" + mixerInfo.getName() + " - couldn't get mixer\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
if(mixerTunerType != MixerTunerType.UNKNOWN)
|
||||
{
|
||||
TargetDataLine tdl = getTargetDataLine(mixerInfo, mixerTunerType.getAudioFormat());
|
||||
|
||||
@@ -219,28 +212,17 @@ public class MixerManager
|
||||
{
|
||||
case FUNCUBE_DONGLE_PRO:
|
||||
case FUNCUBE_DONGLE_PRO_PLUS:
|
||||
mMixerTuners.put(mixerInfo.getName(),
|
||||
new MixerTunerDataLine(tdl, mixerTunerType));
|
||||
sb.append("\t[LOADED] FunCube Dongle Mixer Tuner:" + mixerInfo.getName() + "[" + mixerTunerType.getDisplayString() + "]\n");
|
||||
break;
|
||||
case UNKNOWN:
|
||||
default:
|
||||
sb.append("\t[NOT LOADED] Tuner:" + mixerInfo.getName() + " - unrecognized tuner type\n");
|
||||
tuners.add(new MixerTunerDataLine(tdl, mixerTunerType));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mLog.info(sb.toString());
|
||||
return tuners;
|
||||
}
|
||||
|
||||
public Map<String,MixerTunerDataLine> getMixerTuners()
|
||||
{
|
||||
return mMixerTuners;
|
||||
}
|
||||
|
||||
private TargetDataLine getTargetDataLine(Mixer.Info mixerInfo, AudioFormat format)
|
||||
private static TargetDataLine getTargetDataLine(Mixer.Info mixerInfo, AudioFormat format)
|
||||
{
|
||||
TargetDataLine retVal = null;
|
||||
|
||||
@@ -263,7 +245,7 @@ public class MixerManager
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private EnumSet<MixerChannel> getSupportedTargetChannels(Mixer mixer)
|
||||
private static EnumSet<MixerChannel> getSupportedTargetChannels(Mixer mixer)
|
||||
{
|
||||
DataLine.Info stereoInfo = new DataLine.Info(TargetDataLine.class,
|
||||
AudioFormats.PCM_SIGNED_8KHZ_16BITS_STEREO);
|
||||
@@ -296,8 +278,10 @@ public class MixerManager
|
||||
* (MONO and/or STEREO) supported by the mixer, or null if the mixer doesn't
|
||||
* have any source data lines.
|
||||
*/
|
||||
private EnumSet<MixerChannel> getSupportedSourceChannels(Mixer mixer)
|
||||
private static List<MixerChannel> getSupportedSourceChannels(Mixer mixer)
|
||||
{
|
||||
List<MixerChannel> channels = new ArrayList<>();
|
||||
|
||||
DataLine.Info stereoInfo = new DataLine.Info(SourceDataLine.class,
|
||||
AudioFormats.PCM_SIGNED_8KHZ_16BITS_STEREO);
|
||||
|
||||
@@ -307,20 +291,17 @@ public class MixerManager
|
||||
|
||||
boolean monoSupported = mixer.isLineSupported(monoInfo);
|
||||
|
||||
if(stereoSupported && monoSupported)
|
||||
if(stereoSupported)
|
||||
{
|
||||
return EnumSet.of(MixerChannel.MONO, MixerChannel.STEREO);
|
||||
}
|
||||
else if(stereoSupported)
|
||||
{
|
||||
return EnumSet.of(MixerChannel.STEREO);
|
||||
}
|
||||
else if(monoSupported)
|
||||
{
|
||||
return EnumSet.of(MixerChannel.MONO);
|
||||
channels.add(MixerChannel.STEREO);
|
||||
}
|
||||
|
||||
return null;
|
||||
if(monoSupported)
|
||||
{
|
||||
channels.add(MixerChannel.MONO);
|
||||
}
|
||||
|
||||
return channels;
|
||||
}
|
||||
|
||||
public static String getMixerDevices()
|
||||
@@ -369,7 +350,7 @@ public class MixerManager
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public class InputMixerConfiguration
|
||||
public static class InputMixerConfiguration
|
||||
{
|
||||
private Mixer mMixer;
|
||||
private EnumSet<MixerChannel> mChannels;
|
||||
@@ -405,4 +386,12 @@ public class MixerManager
|
||||
return mMixer.getMixerInfo().getName();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
for(MixerChannelConfiguration config : getOutputMixers())
|
||||
{
|
||||
mLog.debug(config.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
@@ -24,7 +24,9 @@ import io.github.dsheirer.source.config.SourceConfigMixer;
|
||||
import io.github.dsheirer.source.config.SourceConfiguration;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.EnumSet;
|
||||
@@ -33,140 +35,141 @@ public class MixerSourceEditor extends Editor<Channel>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JComboBox<MixerManager.InputMixerConfiguration> mComboMixers;
|
||||
private JComboBox<MixerChannel>mComboChannels;
|
||||
|
||||
private JComboBox<MixerChannel> mComboChannels;
|
||||
|
||||
private SourceManager mSourceManager;
|
||||
|
||||
public MixerSourceEditor( SourceManager sourceManager )
|
||||
{
|
||||
mSourceManager = sourceManager;
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "insets 0 0 0 0,wrap 4", "[right][grow,fill][right][grow,fill]", "" ) );
|
||||
public MixerSourceEditor(SourceManager sourceManager)
|
||||
{
|
||||
mSourceManager = sourceManager;
|
||||
init();
|
||||
}
|
||||
|
||||
mComboMixers = new JComboBox<MixerManager.InputMixerConfiguration>();
|
||||
MixerManager.InputMixerConfiguration[] inputMixers = mSourceManager.getMixerManager().getInputMixers();
|
||||
mComboMixers.setModel( new DefaultComboBoxModel<MixerManager.InputMixerConfiguration>( inputMixers ) );
|
||||
mComboMixers.setEnabled( false );
|
||||
mComboMixers.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
MixerManager.InputMixerConfiguration selected = (MixerManager.InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||
|
||||
EnumSet<MixerChannel> channels = selected.getChannels();
|
||||
|
||||
mComboChannels.setModel( new DefaultComboBoxModel<MixerChannel>(
|
||||
channels.toArray( new MixerChannel[ channels.size() ] ) ) );
|
||||
|
||||
repaint();
|
||||
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
private void init()
|
||||
{
|
||||
setLayout(new MigLayout("insets 0 0 0 0,wrap 4", "[right][grow,fill][right][grow,fill]", ""));
|
||||
|
||||
add( new JLabel( "Mixer:" ) );
|
||||
add( mComboMixers );
|
||||
mComboMixers = new JComboBox<MixerManager.InputMixerConfiguration>();
|
||||
DefaultComboBoxModel<MixerManager.InputMixerConfiguration> model = new DefaultComboBoxModel<>();
|
||||
model.addAll(MixerManager.getInputMixers());
|
||||
mComboMixers.setModel(model);
|
||||
mComboMixers.setEnabled(false);
|
||||
mComboMixers.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
MixerManager.InputMixerConfiguration selected = (MixerManager.InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||
|
||||
mComboChannels = new JComboBox<MixerChannel>();
|
||||
EnumSet<MixerChannel> channels = selected.getChannels();
|
||||
|
||||
MixerManager.InputMixerConfiguration selected = (MixerManager.InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||
mComboChannels.setModel(new DefaultComboBoxModel<MixerChannel>(
|
||||
channels.toArray(new MixerChannel[channels.size()])));
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
EnumSet<MixerChannel> channels = selected.getChannels();
|
||||
|
||||
mComboChannels.setModel( new DefaultComboBoxModel<MixerChannel>(
|
||||
channels.toArray( new MixerChannel[ channels.size() ] ) ) );
|
||||
}
|
||||
|
||||
mComboChannels.setEnabled( false );
|
||||
mComboChannels.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
repaint();
|
||||
|
||||
add( new JLabel( "Channel:" ) );
|
||||
add( mComboChannels );
|
||||
}
|
||||
setModified(true);
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void setItem( Channel item )
|
||||
{
|
||||
super.setItem( item );
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
mComboMixers.setEnabled( true );
|
||||
mComboChannels.setEnabled( true );
|
||||
|
||||
SourceConfiguration config = item.getSourceConfiguration();
|
||||
|
||||
if( config instanceof SourceConfigMixer)
|
||||
{
|
||||
SourceConfigMixer mixer = (SourceConfigMixer)config;
|
||||
add(new JLabel("Mixer:"));
|
||||
add(mComboMixers);
|
||||
|
||||
for( MixerManager.InputMixerConfiguration inputMixer: mSourceManager.getMixerManager().getInputMixers() )
|
||||
{
|
||||
if( inputMixer.getMixerName().equalsIgnoreCase( mixer.getMixer() ) )
|
||||
{
|
||||
mComboMixers.setSelectedItem( inputMixer );
|
||||
|
||||
for( MixerChannel channel: inputMixer.getChannels() )
|
||||
{
|
||||
if( channel.getLabel() != null && mixer.getChannel() != null )
|
||||
{
|
||||
if( channel.getLabel().equalsIgnoreCase( mixer.getChannel().getLabel() ) )
|
||||
{
|
||||
mComboChannels.setSelectedItem( channel );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mComboMixers.setEnabled( false );
|
||||
mComboChannels.setEnabled( false );
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
mComboChannels = new JComboBox<MixerChannel>();
|
||||
|
||||
public void save()
|
||||
{
|
||||
if( hasItem() && isModified() )
|
||||
{
|
||||
SourceConfigMixer config = new SourceConfigMixer();
|
||||
|
||||
MixerManager.InputMixerConfiguration selected =
|
||||
(MixerManager.InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||
config.setMixer( selected.getMixerName() );
|
||||
|
||||
MixerChannel channel = (MixerChannel)mComboChannels.getSelectedItem();
|
||||
config.setChannel( channel );
|
||||
|
||||
getItem().setSourceConfiguration( config );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
MixerManager.InputMixerConfiguration selected = (MixerManager.InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||
|
||||
if(selected != null)
|
||||
{
|
||||
EnumSet<MixerChannel> channels = selected.getChannels();
|
||||
|
||||
mComboChannels.setModel(new DefaultComboBoxModel<MixerChannel>(
|
||||
channels.toArray(new MixerChannel[channels.size()])));
|
||||
}
|
||||
|
||||
mComboChannels.setEnabled(false);
|
||||
mComboChannels.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
setModified(true);
|
||||
}
|
||||
});
|
||||
|
||||
add(new JLabel("Channel:"));
|
||||
add(mComboChannels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(Channel item)
|
||||
{
|
||||
super.setItem(item);
|
||||
|
||||
if(hasItem())
|
||||
{
|
||||
mComboMixers.setEnabled(true);
|
||||
mComboChannels.setEnabled(true);
|
||||
|
||||
SourceConfiguration config = item.getSourceConfiguration();
|
||||
|
||||
if(config instanceof SourceConfigMixer)
|
||||
{
|
||||
SourceConfigMixer mixer = (SourceConfigMixer)config;
|
||||
|
||||
for(MixerManager.InputMixerConfiguration inputMixer : MixerManager.getInputMixers())
|
||||
{
|
||||
if(inputMixer.getMixerName().equalsIgnoreCase(mixer.getMixer()))
|
||||
{
|
||||
mComboMixers.setSelectedItem(inputMixer);
|
||||
|
||||
for(MixerChannel channel : inputMixer.getChannels())
|
||||
{
|
||||
if(channel.getLabel() != null && mixer.getChannel() != null)
|
||||
{
|
||||
if(channel.getLabel().equalsIgnoreCase(mixer.getChannel().getLabel()))
|
||||
{
|
||||
mComboChannels.setSelectedItem(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
setModified(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
setModified(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mComboMixers.setEnabled(false);
|
||||
mComboChannels.setEnabled(false);
|
||||
|
||||
setModified(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
if(hasItem() && isModified())
|
||||
{
|
||||
SourceConfigMixer config = new SourceConfigMixer();
|
||||
|
||||
MixerManager.InputMixerConfiguration selected =
|
||||
(MixerManager.InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||
config.setMixer(selected.getMixerName());
|
||||
|
||||
MixerChannel channel = (MixerChannel)mComboChannels.getSelectedItem();
|
||||
config.setChannel(channel);
|
||||
|
||||
getItem().setSourceConfiguration(config);
|
||||
}
|
||||
|
||||
setModified(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2020 Dennis Sheirer
|
||||
*
|
||||
* * ******************************************************************************
|
||||
* * Copyright (C) 2014-2020 Dennis Sheirer
|
||||
* *
|
||||
* * This program is free software: you can redistribute it and/or modify
|
||||
* * it under the terms of the GNU General Public License as published by
|
||||
* * the Free Software Foundation, either version 3 of the License, or
|
||||
* * (at your option) any later version.
|
||||
* *
|
||||
* * This program is distributed in the hope that it will be useful,
|
||||
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* * GNU General Public License for more details.
|
||||
* *
|
||||
* * You should have received a copy of the GNU General Public License
|
||||
* * along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* * *****************************************************************************
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.source.tuner;
|
||||
|
||||
import io.github.dsheirer.record.RecorderManager;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.record.RecorderFactory;
|
||||
import io.github.dsheirer.record.wave.ComplexBufferWaveRecorder;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.sample.buffer.IReusableComplexBufferProvider;
|
||||
@@ -476,11 +474,11 @@ public abstract class TunerController implements Tunable, ISourceEventProcessor,
|
||||
* Records the complex I/Q buffers produced by the tuner
|
||||
* @param recorderManager to obtain a baseband recorder
|
||||
*/
|
||||
public void startRecorder(RecorderManager recorderManager)
|
||||
public void startRecorder(UserPreferences userPreferences)
|
||||
{
|
||||
if(!isRecording())
|
||||
{
|
||||
mRecorder = recorderManager.getBasebandRecorder("TUNER_" + getFrequency());
|
||||
mRecorder = RecorderFactory.getBasebandRecorder("TUNER_" + getFrequency(), userPreferences);
|
||||
mRecorder.setSampleRate((float)getSampleRate());
|
||||
mRecorder.start();
|
||||
addBufferListener(mRecorder);
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2020 Dennis Sheirer
|
||||
*
|
||||
* * ******************************************************************************
|
||||
* * Copyright (C) 2014-2019 Dennis Sheirer
|
||||
* *
|
||||
* * This program is free software: you can redistribute it and/or modify
|
||||
* * it under the terms of the GNU General Public License as published by
|
||||
* * the Free Software Foundation, either version 3 of the License, or
|
||||
* * (at your option) any later version.
|
||||
* *
|
||||
* * This program is distributed in the hope that it will be useful,
|
||||
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* * GNU General Public License for more details.
|
||||
* *
|
||||
* * You should have received a copy of the GNU General Public License
|
||||
* * along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* * *****************************************************************************
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.source.tuner;
|
||||
@@ -26,7 +23,7 @@ import com.jidesoft.swing.JideSplitPane;
|
||||
import io.github.dsheirer.gui.control.JFrequencyControl;
|
||||
import io.github.dsheirer.gui.editor.Editor;
|
||||
import io.github.dsheirer.gui.editor.EmptyEditor;
|
||||
import io.github.dsheirer.record.RecorderManager;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
|
||||
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationEditor;
|
||||
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationFactory;
|
||||
@@ -69,12 +66,12 @@ public class TunerEditor extends Editor<Tuner>
|
||||
private JScrollPane mEditorScroller;
|
||||
private Editor<TunerConfiguration> mEditor = new EmptyEditor<>("a tuner");
|
||||
private JideSplitPane mEditorSplitPane = new JideSplitPane();
|
||||
private RecorderManager mRecorderManager;
|
||||
private UserPreferences mRecorderManager;
|
||||
|
||||
public TunerEditor(TunerConfigurationModel tunerConfigurationModel, RecorderManager recorderManager)
|
||||
public TunerEditor(TunerConfigurationModel tunerConfigurationModel, UserPreferences userPreferences)
|
||||
{
|
||||
mTunerConfigurationModel = tunerConfigurationModel;
|
||||
mRecorderManager = recorderManager;
|
||||
mRecorderManager = userPreferences;
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ public class TunerManager
|
||||
private final static Logger mLog = LoggerFactory.getLogger(TunerManager.class);
|
||||
private static final int MAXIMUM_USB_2_DATA_RATE = 480000000;
|
||||
|
||||
private MixerManager mMixerManager;
|
||||
private TunerModel mTunerModel;
|
||||
private UserPreferences mUserPreferences;
|
||||
private Map<Integer,List<Tuner>> mUSBBusTunerMap = new TreeMap<>();
|
||||
@@ -72,9 +71,8 @@ public class TunerManager
|
||||
LIBUSB_TRANSFER_PROCESSOR = new USBMasterProcessor();
|
||||
}
|
||||
|
||||
public TunerManager(MixerManager mixerManager, TunerModel tunerModel, UserPreferences userPreferences)
|
||||
public TunerManager(TunerModel tunerModel, UserPreferences userPreferences)
|
||||
{
|
||||
mMixerManager = mixerManager;
|
||||
mTunerModel = tunerModel;
|
||||
mUserPreferences = userPreferences;
|
||||
|
||||
@@ -563,8 +561,7 @@ public class TunerManager
|
||||
*/
|
||||
private MixerTunerDataLine getMixerTunerDataLine(TunerType tunerClass)
|
||||
{
|
||||
Collection<MixerTunerDataLine> datalines =
|
||||
mMixerManager.getMixerTunerDataLines();
|
||||
Collection<MixerTunerDataLine> datalines = MixerManager.getMixerTunerDataLines();
|
||||
|
||||
for(MixerTunerDataLine mixerTDL : datalines)
|
||||
{
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2020 Dennis Sheirer
|
||||
*
|
||||
* * ******************************************************************************
|
||||
* * Copyright (C) 2014-2020 Dennis Sheirer
|
||||
* *
|
||||
* * This program is free software: you can redistribute it and/or modify
|
||||
* * it under the terms of the GNU General Public License as published by
|
||||
* * the Free Software Foundation, either version 3 of the License, or
|
||||
* * (at your option) any later version.
|
||||
* *
|
||||
* * This program is distributed in the hope that it will be useful,
|
||||
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* * GNU General Public License for more details.
|
||||
* *
|
||||
* * You should have received a copy of the GNU General Public License
|
||||
* * along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* * *****************************************************************************
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.source.tuner;
|
||||
@@ -25,7 +22,6 @@ package io.github.dsheirer.source.tuner;
|
||||
import com.jidesoft.swing.JideSplitPane;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.preference.swing.JTableColumnWidthMonitor;
|
||||
import io.github.dsheirer.record.RecorderManager;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.source.tuner.TunerEvent.Event;
|
||||
import io.github.dsheirer.source.tuner.recording.AddRecordingTunerDialog;
|
||||
@@ -74,10 +70,10 @@ public class TunerViewPanel extends JPanel
|
||||
private TunerEditor mTunerEditor;
|
||||
private UserPreferences mUserPreferences;
|
||||
|
||||
public TunerViewPanel(TunerModel tunerModel, UserPreferences userPreferences, RecorderManager recorderManager)
|
||||
public TunerViewPanel(TunerModel tunerModel, UserPreferences userPreferences)
|
||||
{
|
||||
mTunerModel = tunerModel;
|
||||
mTunerEditor = new TunerEditor(mTunerModel.getTunerConfigurationModel(), recorderManager);
|
||||
mTunerEditor = new TunerEditor(mTunerModel.getTunerConfigurationModel(), userPreferences);
|
||||
mUserPreferences = userPreferences;
|
||||
|
||||
init();
|
||||
|
||||
Reference in New Issue
Block a user