[WIP]Updates mixer manager and mixer source to use 8 kHz audio for

sound card inputs.

Updated DecoderFactory to only include an AM/FM demodulator when we're
using a tuner input.
This commit is contained in:
Denny
2018-06-23 09:49:40 -04:00
parent 7a830077bd
commit 19fa256c60
3 changed files with 341 additions and 355 deletions

View File

@@ -89,6 +89,7 @@ import io.github.dsheirer.module.decode.tait.Tait1200DecoderState;
import io.github.dsheirer.module.demodulate.am.AMDemodulatorModule; import io.github.dsheirer.module.demodulate.am.AMDemodulatorModule;
import io.github.dsheirer.module.demodulate.audio.DemodulatedAudioFilterModule; import io.github.dsheirer.module.demodulate.audio.DemodulatedAudioFilterModule;
import io.github.dsheirer.module.demodulate.fm.FMDemodulatorModule; import io.github.dsheirer.module.demodulate.fm.FMDemodulatorModule;
import io.github.dsheirer.source.SourceType;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -147,31 +148,44 @@ public class DecoderFactory
switch(decodeConfig.getDecoderType()) switch(decodeConfig.getDecoderType())
{ {
case AM: case AM:
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
{
modules.add(new AMDemodulatorModule());
//TODO: update AM demodulator to produce demodulated 8 kHz audio and delete the following filter module
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
}
modules.add(new AMDecoder(decodeConfig)); modules.add(new AMDecoder(decodeConfig));
modules.add(new AlwaysUnsquelchedDecoderState(DecoderType.AM, channel.getName())); modules.add(new AlwaysUnsquelchedDecoderState(DecoderType.AM, channel.getName()));
modules.add(new AMDemodulatorModule());
//TODO: update AM demodulator to produce demodulated 8 kHz audio and delete the following filter module
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
modules.add(new AudioModule(metadata)); modules.add(new AudioModule(metadata));
break; break;
case NBFM: case NBFM:
modules.add(new NBFMDecoder(decodeConfig)); modules.add(new NBFMDecoder(decodeConfig));
modules.add(new AlwaysUnsquelchedDecoderState(DecoderType.NBFM, channel.getName())); modules.add(new AlwaysUnsquelchedDecoderState(DecoderType.NBFM, channel.getName()));
modules.add(new FMDemodulatorModule(CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
modules.add(new AudioModule(metadata)); modules.add(new AudioModule(metadata));
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
{
modules.add(new FMDemodulatorModule(CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
}
break; break;
case LTR_STANDARD: case LTR_STANDARD:
MessageDirection direction = ((DecodeConfigLTRStandard) decodeConfig).getMessageDirection(); MessageDirection direction = ((DecodeConfigLTRStandard) decodeConfig).getMessageDirection();
modules.add(new LTRStandardDecoder(aliasList, direction)); modules.add(new LTRStandardDecoder(aliasList, direction));
modules.add(new LTRStandardDecoderState(aliasList)); modules.add(new LTRStandardDecoderState(aliasList));
modules.add(new FMDemodulatorModule(CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
modules.add(new AudioModule(metadata)); modules.add(new AudioModule(metadata));
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
{
modules.add(new FMDemodulatorModule(CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
}
break; break;
case LTR_NET: case LTR_NET:
modules.add(new LTRNetDecoder((DecodeConfigLTRNet) decodeConfig, aliasList)); modules.add(new LTRNetDecoder((DecodeConfigLTRNet) decodeConfig, aliasList));
modules.add(new LTRNetDecoderState(aliasList)); modules.add(new LTRNetDecoderState(aliasList));
modules.add(new FMDemodulatorModule(CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
modules.add(new AudioModule(metadata)); modules.add(new AudioModule(metadata));
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
{
modules.add(new FMDemodulatorModule(CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
}
break; break;
case MPT1327: case MPT1327:
DecodeConfigMPT1327 mptConfig = (DecodeConfigMPT1327) decodeConfig; DecodeConfigMPT1327 mptConfig = (DecodeConfigMPT1327) decodeConfig;
@@ -179,8 +193,11 @@ public class DecoderFactory
Sync sync = mptConfig.getSync(); Sync sync = mptConfig.getSync();
modules.add(new MPT1327Decoder(aliasList, sync)); modules.add(new MPT1327Decoder(aliasList, sync));
modules.add(new MPT1327DecoderState(aliasList, channelMap, channelType, mptConfig.getCallTimeout() * 1000)); modules.add(new MPT1327DecoderState(aliasList, channelMap, channelType, mptConfig.getCallTimeout() * 1000));
modules.add(new FMDemodulatorModule(CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
modules.add(new AudioModule(metadata)); modules.add(new AudioModule(metadata));
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
{
modules.add(new FMDemodulatorModule(CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
}
if(channelType == ChannelType.STANDARD) if(channelType == ChannelType.STANDARD)
{ {
@@ -192,15 +209,17 @@ public class DecoderFactory
case PASSPORT: case PASSPORT:
modules.add(new PassportDecoder(decodeConfig, aliasList)); modules.add(new PassportDecoder(decodeConfig, aliasList));
modules.add(new PassportDecoderState(aliasList)); modules.add(new PassportDecoderState(aliasList));
modules.add(new FMDemodulatorModule(CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
modules.add(new AudioModule(metadata)); modules.add(new AudioModule(metadata));
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
{
modules.add(new FMDemodulatorModule(CHANNEL_BANDWIDTH, DEMODULATED_AUDIO_SAMPLE_RATE));
}
break; break;
case P25_PHASE1: case P25_PHASE1:
DecodeConfigP25Phase1 p25Config = (DecodeConfigP25Phase1) decodeConfig; DecodeConfigP25Phase1 p25Config = (DecodeConfigP25Phase1) decodeConfig;
Modulation modulation = p25Config.getModulation(); Modulation modulation = p25Config.getModulation();
switch(modulation) switch(modulation)
{ {
case C4FM: case C4FM:
@@ -288,8 +307,7 @@ public class DecoderFactory
{ {
if(module instanceof Decoder) if(module instanceof Decoder)
{ {
filterSet.addFilters(getMessageFilter( filterSet.addFilters(getMessageFilter(((Decoder)module).getDecoderType()));
((Decoder) module).getDecoderType()));
} }
} }

View File

@@ -1,19 +1,17 @@
/******************************************************************************* /*******************************************************************************
* SDR Trunk * sdr-trunk
* Copyright (C) 2014 Dennis Sheirer * Copyright (C) 2014-2018 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* it under the terms of the GNU General Public License as published by * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* the Free Software Foundation, either version 3 of the License, or * later version.
* (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* but WITHOUT ANY WARRANTY; without even the implied warranty of * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* 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/>
* *
* 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; package io.github.dsheirer.source.mixer;
@@ -42,395 +40,369 @@ import java.util.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public class MixerManager public class MixerManager
{ {
private final static Logger mLog = private final static Logger mLog = LoggerFactory.getLogger(MixerManager.class);
LoggerFactory.getLogger( MixerManager.class );
private List<InputMixerConfiguration> mInputMixers = new ArrayList<>(); private List<InputMixerConfiguration> mInputMixers = new ArrayList<>();
private List<MixerChannelConfiguration> mOutputMixers = new ArrayList<>(); private List<MixerChannelConfiguration> mOutputMixers = new ArrayList<>();
private HashMap<String,MixerTunerDataLine> mMixerTuners = new HashMap<>(); private Map<String,MixerTunerDataLine> mMixerTuners = new HashMap<>();
public MixerManager() public MixerManager()
{
loadMixers();
}
public RealMixerSource getSource( SourceConfiguration config )
{ {
RealMixerSource retVal = null; loadMixers();
}
if( config instanceof SourceConfigMixer) public RealMixerSource getSource(SourceConfiguration config)
{ {
SourceConfigMixer mixerConfig = (SourceConfigMixer)config; RealMixerSource retVal = null;
String mixerName = mixerConfig.getMixer(); if(config instanceof SourceConfigMixer)
{
SourceConfigMixer mixerConfig = (SourceConfigMixer)config;
if( mixerName != null ) String mixerName = mixerConfig.getMixer();
{
InputMixerConfiguration mixer = getInputMixer( mixerName );
if( mixer != null ) if(mixerName != null)
{ {
MixerChannel channel = mixerConfig.getChannel(); InputMixerConfiguration mixer = getInputMixer(mixerName);
if( mixer.supportsChannel( channel ) ) if(mixer != null)
{ {
MixerChannel channel = mixerConfig.getChannel();
if( channel == MixerChannel.MONO ) if(mixer.supportsChannel(channel))
{ {
DataLine.Info info =
new DataLine.Info(TargetDataLine.class,
AudioFormats.PCM_SIGNED_48KHZ_16BITS_MONO );
TargetDataLine dataLine; if(channel == MixerChannel.MONO)
{
DataLine.Info info = new DataLine.Info(TargetDataLine.class,
AudioFormats.PCM_SIGNED_8KHZ_16BITS_MONO);
TargetDataLine dataLine;
try try
{ {
dataLine = (TargetDataLine)mixer dataLine = (TargetDataLine)mixer.getMixer().getLine(info);
.getMixer().getLine( info );
if( dataLine != null ) if(dataLine != null)
{ {
return new RealMixerSource( dataLine, return new RealMixerSource(dataLine, AudioFormats.PCM_SIGNED_8KHZ_16BITS_MONO,
AudioFormats.PCM_SIGNED_48KHZ_16BITS_MONO, new ShortAdapter());
new ShortAdapter() ); }
}
} }
catch ( LineUnavailableException e ) catch(LineUnavailableException e)
{ {
mLog.error( "couldn't get mixer data line " + mLog.error("couldn't get mixer data line for [" + mixerName + "] for channel [" +
"for [" + mixerName + "] for channel [" + channel.name() + "]", e);
channel.name() + "]", e );
} }
} }
else else
{ {
DataLine.Info info = DataLine.Info info = new DataLine.Info(TargetDataLine.class,
new DataLine.Info(TargetDataLine.class, AudioFormats.PCM_SIGNED_8KHZ_16BITS_STEREO);
AudioFormats.PCM_SIGNED_48KHZ_16BITS_STEREO );
TargetDataLine dataLine; TargetDataLine dataLine;
try try
{ {
dataLine = (TargetDataLine)mixer dataLine = (TargetDataLine)mixer.getMixer().getLine(info);
.getMixer().getLine( info );
if( dataLine != null ) if(dataLine != null)
{ {
return new RealMixerSource( dataLine, return new RealMixerSource(dataLine, AudioFormats.PCM_SIGNED_8KHZ_16BITS_STEREO,
AudioFormats.PCM_SIGNED_48KHZ_16BITS_STEREO, new ChannelShortAdapter(mixerConfig.getChannel()));
new ChannelShortAdapter( }
mixerConfig.getChannel() ) );
}
} }
catch ( LineUnavailableException e ) catch(LineUnavailableException e)
{ {
mLog.error( "couldn't get mixer data line " + mLog.error("couldn't get mixer data line for [" + mixerName + "] for channel [" +
"for [" + mixerName + "] for channel [" + channel.name() + "]", e);
channel.name() + "]", e );
} }
} }
} }
} }
} }
} }
return null; return null;
} }
public InputMixerConfiguration[] getInputMixers() public InputMixerConfiguration[] getInputMixers()
{ {
return mInputMixers.toArray( new InputMixerConfiguration[ mInputMixers.size() ] ); return mInputMixers.toArray(new InputMixerConfiguration[mInputMixers.size()]);
} }
public InputMixerConfiguration getInputMixer( String name ) public InputMixerConfiguration getInputMixer(String name)
{ {
for( InputMixerConfiguration mixer: mInputMixers ) for(InputMixerConfiguration mixer : mInputMixers)
{ {
if( mixer.getMixerName().contentEquals( name ) ) if(mixer.getMixerName().contentEquals(name))
{ {
return mixer; return mixer;
} }
} }
return null; return null;
} }
public MixerChannelConfiguration[] getOutputMixers() public MixerChannelConfiguration[] getOutputMixers()
{ {
return mOutputMixers.toArray( new MixerChannelConfiguration[ mOutputMixers.size() ] ); return mOutputMixers.toArray(new MixerChannelConfiguration[mOutputMixers.size()]);
} }
public Collection<MixerTunerDataLine> getMixerTunerDataLines() public Collection<MixerTunerDataLine> getMixerTunerDataLines()
{ {
if( mMixerTuners.isEmpty() ) if(mMixerTuners.isEmpty())
{ {
return Collections.emptyList(); return Collections.emptyList();
} }
else else
{ {
return mMixerTuners.values(); return mMixerTuners.values();
} }
} }
private void loadMixers() private void loadMixers()
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append( "loading system mixer devices\n" ); sb.append("loading system mixer devices\n");
for( Mixer.Info mixerInfo: AudioSystem.getMixerInfo() ) for(Mixer.Info mixerInfo : AudioSystem.getMixerInfo())
{ {
//Sort between the mixers and the tuner mixers, and load each //Sort between the mixers and the tuner mixers, and load each
MixerTunerType mixerTunerType = MixerTunerType.getMixerTunerType( mixerInfo ); MixerTunerType mixerTunerType = MixerTunerType.getMixerTunerType(mixerInfo);
if( mixerTunerType == MixerTunerType.UNKNOWN ) if(mixerTunerType == MixerTunerType.UNKNOWN)
{ {
Mixer mixer = AudioSystem.getMixer( mixerInfo ); Mixer mixer = AudioSystem.getMixer(mixerInfo);
if( mixer != null ) if(mixer != null)
{ {
EnumSet<MixerChannel> inputChannels = getSupportedTargetChannels( mixer ); EnumSet<MixerChannel> inputChannels = getSupportedTargetChannels(mixer);
if( inputChannels != null ) if(inputChannels != null)
{ {
mInputMixers.add( mInputMixers.add(new InputMixerConfiguration(mixer, inputChannels));
new InputMixerConfiguration( mixer, inputChannels ) );
sb.append( "\t[LOADED] Input: " + mixerInfo.getName() + sb.append("\t[LOADED] Input: " + mixerInfo.getName() + " CHANNELS: " + inputChannels + "\n");
" CHANNELS: " + inputChannels + "\n" ); }
}
EnumSet<MixerChannel> outputChannels = getSupportedSourceChannels( mixer ); EnumSet<MixerChannel> outputChannels = getSupportedSourceChannels(mixer);
if( outputChannels != null ) if(outputChannels != null)
{ {
for( MixerChannel channel: outputChannels ) for(MixerChannel channel : outputChannels)
{ {
mOutputMixers.add( new MixerChannelConfiguration( mixer, channel ) ); mOutputMixers.add(new MixerChannelConfiguration(mixer, channel));
} }
sb.append( "\t[LOADED] Output: " + mixerInfo.getName() + sb.append("\t[LOADED] Output: " + mixerInfo.getName() + " CHANNELS: " + outputChannels + "\n");
" CHANNELS: " + outputChannels + "\n" ); }
}
} }
else else
{ {
sb.append( "\t[NOT LOADED] Mixer:" + mixerInfo.getName() + sb.append("\t[NOT LOADED] Mixer:" + mixerInfo.getName() + " - couldn't get mixer\n");
" - couldn't get mixer\n" );
} }
} }
else //Process as a Mixer-based tuner data line else
{ {
TargetDataLine tdl = TargetDataLine tdl = getTargetDataLine(mixerInfo, mixerTunerType.getAudioFormat());
getTargetDataLine( mixerInfo,
mixerTunerType.getAudioFormat() );
if( tdl != null ) if(tdl != null)
{ {
switch( mixerTunerType ) switch(mixerTunerType)
{ {
case FUNCUBE_DONGLE_PRO: case FUNCUBE_DONGLE_PRO:
case FUNCUBE_DONGLE_PRO_PLUS: case FUNCUBE_DONGLE_PRO_PLUS:
mMixerTuners.put( mixerInfo.getName(), mMixerTuners.put(mixerInfo.getName(),
new MixerTunerDataLine( tdl, mixerTunerType ) ); new MixerTunerDataLine(tdl, mixerTunerType));
sb.append( "\t[LOADED] FunCube Dongle Mixer Tuner:" + mixerInfo.getName() + "[" + mixerTunerType.getDisplayString() + "]\n" ); sb.append("\t[LOADED] FunCube Dongle Mixer Tuner:" + mixerInfo.getName() + "[" + mixerTunerType.getDisplayString() + "]\n");
break; break;
case UNKNOWN: case UNKNOWN:
default: default:
sb.append( "\t[NOT LOADED] Tuner:" + mixerInfo.getName() + " - unrecognized tuner type\n" ); sb.append("\t[NOT LOADED] Tuner:" + mixerInfo.getName() + " - unrecognized tuner type\n");
break; break;
} }
} }
} }
} }
mLog.info( sb.toString() ); mLog.info(sb.toString());
} }
public HashMap<String,MixerTunerDataLine> getMixerTuners() public Map<String,MixerTunerDataLine> getMixerTuners()
{ {
return mMixerTuners; return mMixerTuners;
} }
private TargetDataLine getTargetDataLine( Mixer.Info mixerInfo, AudioFormat format ) private TargetDataLine getTargetDataLine(Mixer.Info mixerInfo, AudioFormat format)
{ {
TargetDataLine retVal = null; TargetDataLine retVal = null;
Mixer mixer = AudioSystem.getMixer( mixerInfo ); Mixer mixer = AudioSystem.getMixer(mixerInfo);
if( mixer != null ) if(mixer != null)
{ {
try try
{ {
DataLine.Info datalineInfo= DataLine.Info datalineInfo = new DataLine.Info(TargetDataLine.class, format);
new DataLine.Info(TargetDataLine.class, format );
retVal = (TargetDataLine) mixer.getLine( datalineInfo ); retVal = (TargetDataLine)mixer.getLine(datalineInfo);
} }
catch( Exception e ) catch(Exception e)
{ {
//Do nothing ... we couldn't get the TDL //Do nothing ... we couldn't get the TDL
} }
} }
return retVal; return retVal;
} }
private EnumSet<MixerChannel> getSupportedTargetChannels( Mixer mixer ) private EnumSet<MixerChannel> getSupportedTargetChannels(Mixer mixer)
{ {
DataLine.Info stereoInfo= DataLine.Info stereoInfo = new DataLine.Info(TargetDataLine.class,
new DataLine.Info(TargetDataLine.class, AudioFormats.PCM_SIGNED_8KHZ_16BITS_STEREO);
AudioFormats.PCM_SIGNED_48KHZ_16BITS_STEREO );
boolean stereoSupported = mixer.isLineSupported( stereoInfo ); boolean stereoSupported = mixer.isLineSupported(stereoInfo);
DataLine.Info monoInfo= DataLine.Info monoInfo = new DataLine.Info(TargetDataLine.class,
new DataLine.Info(TargetDataLine.class, AudioFormats.PCM_SIGNED_8KHZ_16BITS_MONO);
AudioFormats.PCM_SIGNED_48KHZ_16BITS_MONO );
boolean monoSupported = mixer.isLineSupported( monoInfo ); boolean monoSupported = mixer.isLineSupported(monoInfo);
if( stereoSupported && monoSupported ) if(stereoSupported && monoSupported)
{ {
return EnumSet.of( MixerChannel.LEFT, return EnumSet.of(MixerChannel.LEFT, MixerChannel.RIGHT, MixerChannel.MONO);
MixerChannel.RIGHT,
MixerChannel.MONO );
} }
else if( stereoSupported ) else if(stereoSupported)
{ {
return EnumSet.of( MixerChannel.LEFT, return EnumSet.of(MixerChannel.LEFT, MixerChannel.RIGHT, MixerChannel.MONO);
MixerChannel.RIGHT,
MixerChannel.MONO );
} }
else if( monoSupported ) else if(monoSupported)
{ {
return EnumSet.of( MixerChannel.MONO ); return EnumSet.of(MixerChannel.MONO);
} }
return null; return null;
} }
/** /**
* Returns enumset of SourceDataLine (audio output) channels * Returns enumset of SourceDataLine (audio output) channels
* (MONO and/or STEREO) supported by the mixer, or null if the mixer doesn't * (MONO and/or STEREO) supported by the mixer, or null if the mixer doesn't
* have any source data lines. * have any source data lines.
*/ */
private EnumSet<MixerChannel> getSupportedSourceChannels( Mixer mixer ) private EnumSet<MixerChannel> getSupportedSourceChannels(Mixer mixer)
{ {
DataLine.Info stereoInfo= DataLine.Info stereoInfo = new DataLine.Info(SourceDataLine.class,
new DataLine.Info(SourceDataLine.class, AudioFormats.PCM_SIGNED_8KHZ_16BITS_STEREO);
AudioFormats.PCM_SIGNED_48KHZ_16BITS_STEREO );
boolean stereoSupported = mixer.isLineSupported( stereoInfo ); boolean stereoSupported = mixer.isLineSupported(stereoInfo);
DataLine.Info monoInfo= DataLine.Info monoInfo = new DataLine.Info(SourceDataLine.class, AudioFormats.PCM_SIGNED_8KHZ_16BITS_MONO);
new DataLine.Info(SourceDataLine.class,
AudioFormats.PCM_SIGNED_48KHZ_16BITS_MONO );
boolean monoSupported = mixer.isLineSupported( monoInfo ); boolean monoSupported = mixer.isLineSupported(monoInfo);
if( stereoSupported && monoSupported ) if(stereoSupported && monoSupported)
{ {
return EnumSet.of( MixerChannel.MONO, return EnumSet.of(MixerChannel.MONO, MixerChannel.STEREO);
MixerChannel.STEREO );
} }
else if( stereoSupported ) else if(stereoSupported)
{ {
return EnumSet.of( MixerChannel.STEREO ); return EnumSet.of(MixerChannel.STEREO);
} }
else if( monoSupported ) else if(monoSupported)
{ {
return EnumSet.of( MixerChannel.MONO ); return EnumSet.of(MixerChannel.MONO);
} }
return null; return null;
} }
public static String getMixerDevices() public static String getMixerDevices()
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for( Mixer.Info mixerInfo: AudioSystem.getMixerInfo() ) for(Mixer.Info mixerInfo : AudioSystem.getMixerInfo())
{ {
sb.append( "\n--------------------------------------------------" ); sb.append("\n--------------------------------------------------");
sb.append( "\nMIXER name:" + mixerInfo.getName() + sb.append("\nMIXER name:" + mixerInfo.getName() +
"\n desc:" + mixerInfo.getDescription() + "\n desc:" + mixerInfo.getDescription() +
"\n vendor:" + mixerInfo.getVendor() + "\n vendor:" + mixerInfo.getVendor() +
"\n version:" + mixerInfo.getVersion() + "\n version:" + mixerInfo.getVersion() +
"\n" ); "\n");
Mixer mixer = AudioSystem.getMixer( mixerInfo ); Mixer mixer = AudioSystem.getMixer(mixerInfo);
Line.Info[] sourceLines = mixer.getSourceLineInfo(); Line.Info[] sourceLines = mixer.getSourceLineInfo();
for( Line.Info lineInfo: sourceLines ) for(Line.Info lineInfo : sourceLines)
{ {
sb.append( " SOURCE LINE desc:" + lineInfo.toString() + sb.append(" SOURCE LINE desc:" + lineInfo.toString() +
"\n class:" + lineInfo.getClass() + "\n class:" + lineInfo.getClass() +
"\n lineclass:" + lineInfo.getLineClass() + "\n lineclass:" + lineInfo.getLineClass() +
"\n" ); "\n");
} }
Line.Info[] targetLines = mixer.getTargetLineInfo(); Line.Info[] targetLines = mixer.getTargetLineInfo();
for( Line.Info lineInfo: targetLines ) for(Line.Info lineInfo : targetLines)
{ {
sb.append( " TARGET LINE desc:" + lineInfo.toString() + sb.append(" TARGET LINE desc:" + lineInfo.toString() +
"\n class:" + lineInfo.getClass() + "\n class:" + lineInfo.getClass() +
"\n lineclass:" + lineInfo.getLineClass() + "\n lineclass:" + lineInfo.getLineClass() +
"\n" ); "\n");
} }
Line.Info portInfo = new Line.Info( Port.class ); Line.Info portInfo = new Line.Info(Port.class);
if( mixer.isLineSupported( portInfo ) ) if(mixer.isLineSupported(portInfo))
{ {
sb.append( "**PORT LINE IS SUPPORTED BY THIS MIXER***\n" ); sb.append("**PORT LINE IS SUPPORTED BY THIS MIXER***\n");
} }
} }
return sb.toString(); return sb.toString();
} }
public class InputMixerConfiguration public class InputMixerConfiguration
{ {
private Mixer mMixer; private Mixer mMixer;
private EnumSet<MixerChannel> mChannels; private EnumSet<MixerChannel> mChannels;
public InputMixerConfiguration( Mixer mixer, EnumSet<MixerChannel> channels ) public InputMixerConfiguration(Mixer mixer, EnumSet<MixerChannel> channels)
{ {
mMixer = mixer; mMixer = mixer;
mChannels = channels; mChannels = channels;
} }
public Mixer getMixer() public Mixer getMixer()
{ {
return mMixer; return mMixer;
} }
public String getMixerName() public String getMixerName()
{ {
return mMixer.getMixerInfo().getName(); return mMixer.getMixerInfo().getName();
} }
public EnumSet<MixerChannel> getChannels() public EnumSet<MixerChannel> getChannels()
{ {
return mChannels; return mChannels;
} }
public boolean supportsChannel( MixerChannel channel ) public boolean supportsChannel(MixerChannel channel)
{ {
return mChannels.contains( channel ); return mChannels.contains(channel);
} }
public String toString() public String toString()
{ {
return mMixer.getMixerInfo().getName(); return mMixer.getMixerInfo().getName();
} }
} }
} }

View File

@@ -1,19 +1,17 @@
/******************************************************************************* /*******************************************************************************
* SDR Trunk * sdr-trunk
* Copyright (C) 2014 Dennis Sheirer * Copyright (C) 2014-2018 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* it under the terms of the GNU General Public License as published by * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* the Free Software Foundation, either version 3 of the License, or * later version.
* (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* but WITHOUT ANY WARRANTY; without even the implied warranty of * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* 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/>
* *
* 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; package io.github.dsheirer.source.mixer;
@@ -63,9 +61,7 @@ public class RealMixerSource extends RealSource
* mixer into float array data. Can optionally invert the channel data if * mixer into float array data. Can optionally invert the channel data if
* the left/right stereo channels are inverted. * the left/right stereo channels are inverted.
*/ */
public RealMixerSource(TargetDataLine targetDataLine, public RealMixerSource(TargetDataLine targetDataLine, AudioFormat format, ISampleAdapter sampleAdapter)
AudioFormat format,
ISampleAdapter sampleAdapter)
{ {
mTargetDataLine = targetDataLine; mTargetDataLine = targetDataLine;
mAudioFormat = format; mAudioFormat = format;