Merges #34 Major redesign of Tuner, Channel and Alias management.

Changes to model, view and controller components and updates all gui
editors.  Removes the configuration panel and tree and replaces with 3
new panels.  Updates playlist.xml to a new playlist_v2.xml format.
This commit is contained in:
denny
2016-04-01 08:23:49 -04:00
450 changed files with 19560 additions and 22805 deletions

View File

@@ -6,13 +6,8 @@ import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sample.Listener;
import settings.ColorSetting;
import settings.ColorSetting.ColorSettingName;
@@ -30,8 +25,6 @@ public class AudioChannelPanel extends JPanel
{
private static final long serialVersionUID = 1L;
private static final Logger mLog = LoggerFactory.getLogger( AudioChannelPanel.class );
private Font mFont = new Font( Font.MONOSPACED, Font.PLAIN, 12 );
private Color mLabelColor;
private Color mDetailsColor;
@@ -48,11 +41,8 @@ public class AudioChannelPanel extends JPanel
private JLabel mFromLabel = new JLabel( "FROM:" );
private JLabel mFrom = new JLabel( "" );
private JLabel mFromAlias = new JLabel( "" );
private enum AudioStatus { STARTED,STOPPED };
private AudioStatus mAudioStatus = AudioStatus.STOPPED;
private AudioMetadata mAudioMetadata;
private boolean mConfigured = false;
public AudioChannelPanel( SettingsManager settingsManager, AudioOutput audioOutput )
{
@@ -127,9 +117,6 @@ public class AudioChannelPanel extends JPanel
mFromAlias.setForeground( mLabelColor );
add( mFromAlias,"wrap" );
JSeparator separator = new JSeparator( JSeparator.HORIZONTAL );
separator.setBackground( Color.DARK_GRAY );
add( separator, "span,growx" );
}
@Override
@@ -137,19 +124,15 @@ public class AudioChannelPanel extends JPanel
{
switch( audioEvent.getType() )
{
case AUDIO_STARTED:
synchronized( mAudioStatus )
{
mAudioStatus = AudioStatus.STARTED;
updateLabels();
}
break;
case AUDIO_STOPPED:
synchronized( mAudioStatus )
EventQueue.invokeLater( new Runnable()
{
mAudioStatus = AudioStatus.STOPPED;
resetLabels();
}
@Override
public void run()
{
resetLabels();
}
} );
break;
case AUDIO_MUTED:
case AUDIO_UNMUTED:
@@ -173,55 +156,13 @@ public class AudioChannelPanel extends JPanel
*/
private void resetLabels()
{
EventQueue.invokeLater( new Runnable()
{
@Override
public void run()
{
mFrom.setText( "" );
updateAlias( mFromAlias, null );
mTo.setText( "" );
updateAlias( mToAlias, null );
}
} );
}
private void updateLabels()
{
if( mAudioMetadata != null )
{
final Metadata from = mAudioMetadata.getMetadata( MetadataType.FROM );
final Metadata to = mAudioMetadata.getMetadata( MetadataType.TO );
EventQueue.invokeLater( new Runnable()
{
@Override
public void run()
{
if( from != null )
{
mFrom.setText( from.getValue() );
updateAlias( mFromAlias, from.getAlias() );
}
else
{
mFrom.setText( "-----" );
}
if( to != null )
{
mTo.setText( to.getValue() );
updateAlias( mToAlias, to.getAlias() );
}
else
{
mTo.setText( "-----" );
}
}
} );
}
mFrom.setText( "" );
updateAlias( mFromAlias, null );
mTo.setText( "" );
updateAlias( mToAlias, null );
mConfigured = false;
}
/**
@@ -263,17 +204,40 @@ public class AudioChannelPanel extends JPanel
@Override
public void receive( AudioMetadata audioMetadata )
{
mAudioMetadata = audioMetadata;
if( audioMetadata.isUpdated() )
if( !mConfigured || audioMetadata.isUpdated() )
{
synchronized( mAudioStatus )
final Metadata from = audioMetadata.getMetadata( MetadataType.FROM );
final Metadata to = audioMetadata.getMetadata( MetadataType.TO );
EventQueue.invokeLater( new Runnable()
{
if( mAudioStatus == AudioStatus.STARTED )
@Override
public void run()
{
updateLabels();
if( from != null )
{
mFrom.setText( from.getValue() );
updateAlias( mFromAlias, from.getAlias() );
}
else
{
mFrom.setText( "-----" );
}
if( to != null )
{
mTo.setText( to.getValue() );
updateAlias( mToAlias, to.getAlias() );
}
else
{
mTo.setText( "-----" );
}
}
}
} );
mConfigured = true;
}
}
}

View File

@@ -4,6 +4,7 @@ import java.awt.Color;
import java.util.List;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import net.miginfocom.swing.MigLayout;
import settings.SettingsManager;
@@ -21,17 +22,30 @@ public class AudioChannelsPanel extends JPanel
setBackground( Color.BLACK );
List<AudioOutput> outputs = controller.getAudioOutputs();
for( AudioOutput audioOutput: controller.getAudioOutputs() )
for( int x = 0; x < outputs.size(); x++ )
{
add( new AudioChannelPanel( settingsManager, audioOutput ), "wrap" );
add( new AudioChannelPanel( settingsManager, outputs.get( x ) ), "wrap" );
if( x < outputs.size() - 1 )
{
addSeparator();
}
}
/* Add an empty channel panel so that the panel is sized appropriately
* for either a single channel or two channels */
if( outputs.size() == 1 )
{
addSeparator();
add( new AudioChannelPanel( settingsManager, null ), "wrap" );
}
}
private void addSeparator()
{
JSeparator separator = new JSeparator( JSeparator.HORIZONTAL );
separator.setBackground( Color.DARK_GRAY );
add( separator, "span,growx" );
}
}

View File

@@ -73,17 +73,19 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
private ThreadPoolManager mThreadPoolManager;
private ScheduledFuture<?> mProcessingTask;
private MixerManager mMixerManager;
private MixerChannelConfiguration mMixerChannelConfiguration;
/**
* Processes all audio produced by the decoding channels and routes audio
* packets to any combination of outputs based on any alias audio routing
* options specified by the user.
*/
public AudioManager( ThreadPoolManager manager )
public AudioManager( ThreadPoolManager manager, MixerManager mixerManager )
{
mThreadPoolManager = manager;
mMixerManager = mixerManager;
loadSettings();
}
@@ -100,8 +102,7 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
String channels = properties.get( AUDIO_CHANNELS_PROPERTY, MixerChannel.MONO.name() );
MixerChannelConfiguration[] mixerConfigurations =
MixerManager.getInstance().getOutputMixers();
MixerChannelConfiguration[] mixerConfigurations = mMixerManager.getOutputMixers();
for( MixerChannelConfiguration mixerConfig: mixerConfigurations )
{

View File

@@ -1,6 +1,7 @@
package audio;
import java.util.Arrays;
import java.util.concurrent.ScheduledExecutorService;
import module.Module;
@@ -8,7 +9,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sample.Listener;
import sample.real.IRealBufferListener;
import sample.real.IFilteredRealBufferListener;
import sample.real.RealBuffer;
import audio.metadata.AudioMetadata;
import audio.metadata.IMetadataListener;
@@ -18,7 +19,6 @@ import audio.squelch.SquelchState;
import controller.channel.ChannelEvent;
import controller.channel.IChannelEventListener;
import dsp.filter.Filters;
import dsp.filter.dc.DCRemovalFilter_RB;
import dsp.filter.fir.real.RealFIRFilter_R_R;
/**
@@ -32,49 +32,31 @@ import dsp.filter.fir.real.RealFIRFilter_R_R;
public class AudioModule extends Module implements IAudioPacketProvider,
IChannelEventListener,
IMetadataListener,
IRealBufferListener,
IFilteredRealBufferListener,
ISquelchStateListener,
Listener<RealBuffer>
{
protected static final Logger mLog = LoggerFactory.getLogger( AudioModule.class );
/* Determines responsiveness of DC filter to frequency changes */
private static final float DC_REMOVAL_RATIO = 0.000003f;
/* Provides a unique identifier for this audio module instance to use as a
* source identifier for all audio packets */
private static int UNIQUE_ID = 0;
private int mSourceID;
private AudioMetadata mAudioMetadata;
private ChannelEventListener mChannelEventListener = new ChannelEventListener();
private SquelchStateListener mSquelchStateListener = new SquelchStateListener();
private SquelchState mSquelchState = SquelchState.SQUELCH;
private RealFIRFilter_R_R mAudioFilter = new RealFIRFilter_R_R(
Filters.FIR_BANDPASS_AUDIO_48KHZ.getCoefficients(), 2.0f );
private DCRemovalFilter_RB mDCRemovalFilter;
private Listener<AudioPacket> mAudioPacketListener;
//TODO: remove this -- is being replaced by the DemodulatedAudioFilterModule
private RealFIRFilter_R_R mAudioFilter = new RealFIRFilter_R_R(
Filters.FIR_BANDPASS_AUDIO_48KHZ.getCoefficients(), 2.0f );
private boolean mRemoveDC = false;
public AudioModule( boolean record, boolean removeDC )
public AudioModule( boolean record )
{
mSourceID = ++UNIQUE_ID;
mAudioMetadata = new AudioMetadata( mSourceID, record );
mRemoveDC = removeDC;
if( mRemoveDC )
{
mDCRemovalFilter = new DCRemovalFilter_RB( DC_REMOVAL_RATIO );
mDCRemovalFilter.setListener( this );
}
}
@Override
@@ -91,7 +73,7 @@ public class AudioModule extends Module implements IAudioPacketProvider,
}
@Override
public void start()
public void start( ScheduledExecutorService executor )
{
/* No start operations provided */
}
@@ -132,13 +114,8 @@ public class AudioModule extends Module implements IAudioPacketProvider,
}
@Override
public Listener<RealBuffer> getRealBufferListener()
public Listener<RealBuffer> getFilteredRealBufferListener()
{
if( mRemoveDC )
{
return mDCRemovalFilter;
}
return this;
}
@@ -183,10 +160,10 @@ public class AudioModule extends Module implements IAudioPacketProvider,
{
switch( event.getEvent() )
{
case CHANNEL_STATE_RESET:
case NOTIFICATION_STATE_RESET:
mAudioMetadata.reset();
break;
case CHANGE_SELECTED:
case NOTIFICATION_SELECTION_CHANGE:
mAudioMetadata.setSelected( event.getChannel().isSelected() );
break;
default:

View File

@@ -27,8 +27,8 @@ import org.slf4j.LoggerFactory;
import sample.Listener;
import settings.SettingsManager;
import source.SourceManager;
import source.mixer.MixerChannelConfiguration;
import source.mixer.MixerManager;
import audio.output.AudioOutput;
public class AudioPanel extends JPanel implements Listener<AudioEvent>
@@ -43,14 +43,18 @@ public class AudioPanel extends JPanel implements Listener<AudioEvent>
new ImageIcon( "images/audio_unmuted.png" ), 38 );
private SettingsManager mSettingsManager;
private SourceManager mSourceManager;
private IAudioController mController;
private JButton mMuteButton;
private AudioChannelsPanel mAudioChannelsPanel;
public AudioPanel( SettingsManager settingsManager, IAudioController controller )
public AudioPanel( SettingsManager settingsManager,
SourceManager sourceManager,
IAudioController controller )
{
mSettingsManager = settingsManager;
mSourceManager = sourceManager;
mController = controller;
mController.addControllerListener( this );
@@ -148,7 +152,7 @@ public class AudioPanel extends JPanel implements Listener<AudioEvent>
JMenu outputMenu = new JMenu( "Audio Output" );
MixerChannelConfiguration[] mixerConfigurations =
MixerManager.getInstance().getOutputMixers();
mSourceManager.getMixerManager().getOutputMixers();
for( MixerChannelConfiguration mixerConfig: mixerConfigurations )
{

View File

@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
import sample.Listener;
import alias.Alias;
import alias.priority.Priority;
import alias.id.priority.Priority;
public class AudioMetadata implements Listener<Metadata>
{
@@ -305,6 +305,7 @@ public class AudioMetadata implements Listener<Metadata>
sb.append( getPriority() );
sb.append( " updated:" + isUpdated() );
sb.append( " " );
for( Entry<MetadataType,Metadata> entry: getMetadata().entrySet() )
{
sb.append( entry.getValue().getKey() );

View File

@@ -1,3 +1,20 @@
/*******************************************************************************
* 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/>
******************************************************************************/
package audio.metadata;
import alias.Alias;
@@ -142,5 +159,4 @@ public class Metadata
return true;
}
}

View File

@@ -1,3 +1,20 @@
/*******************************************************************************
* 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/>
******************************************************************************/
package audio.output;
import java.nio.ByteBuffer;
@@ -147,8 +164,7 @@ public abstract class AudioOutput implements Listener<AudioPacket>, LineListener
public void reset()
{
broadcast( new AudioEvent( AudioEvent.Type.AUDIO_STOPPED,
getChannelName() ) );
broadcast( new AudioEvent( AudioEvent.Type.AUDIO_STOPPED, getChannelName() ) );
}
public void dispose()

View File

@@ -1,3 +1,20 @@
/*******************************************************************************
* 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/>
******************************************************************************/
package audio.output;
import java.nio.ByteBuffer;

View File

@@ -1,3 +1,20 @@
/*******************************************************************************
* 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/>
******************************************************************************/
package audio.output;
import java.nio.ByteBuffer;