1
0
mirror of https://github.com/JvanKatwijk/javaDab synced 2018-12-22 06:18:52 +01:00

added reset handling

This commit is contained in:
JvanKatwijk
2018-04-08 18:15:33 +02:00
parent 9373942260
commit eb15064e24
49 changed files with 314 additions and 122 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -31,13 +31,20 @@ public class JavaRadio {
} catch (IOException ex) {
}
String dabMode = savedValues. getProperty ("dabMode", "1");
int test = 1;
try {
test = Integer.parseInt (dabMode);
} catch (Exception e) {}
final int mode = test;
/* Create and display the form */
java.awt.EventQueue.invokeLater (new Runnable() {
final Device tuner = theDevice;
@Override
public void run () {
RadioModel model = new RadioModel (1, tuner);
RadioView view = new RadioView (model);
RadioModel model = new RadioModel (mode, tuner);
RadioView view = new RadioView ();
RadioController controller =
new RadioController (model,
view,

136
README.md
View File

@@ -19,35 +19,18 @@ The javaRadio software is modelled after, and derived from the C++ software
in Qt-DAB and dab-cmdline. While it is work in progress, the implementation
does work.
----------------------------------------------------------------------------
Installation
----------------------------------------------------------------------------
One needs to have installed
* a. jdk-8* for running (compiling) the program
* b. libfaad, the faad library as well as the include files;
* c. portaudio, the library for handling the soundcard;
* d. fftw3, the library for the fft operation.
* e. libmirsdrapi-rsp, the library for the SDRplay, and/or librtlsdr, the
library for the dabsticks, and/or libairspy, the library for the
airspy.
-----------------------------------------------------------------------------
Features
-----------------------------------------------------------------------------
The GUI in the current implementation is a complete rewrite,
to gain some experience with a
- more or less - proper MVC design approach. Therefore, the implementation
is built around three classes,
package_Model, package_View and package_Controller.
The implementation currently supports DAB and DAB+ audio services, including
some PAD (Program Associated Data) handling (i.e. dynamic labels and images that are transmitted using PAD).
It does not support data services, labels of data services are not even shown on the GUI.
Devices that are supported are
* SDRplay,
* rtlsdr based DABsticks,
* AIRspy
Some simplifications are introduced:
* Device selection is automated: if a device is connected, the software
will detect it and open it;
* There is no possibility yet to set the Band or the Mode. Default settings are Band III and Mode 1.
* There is no possibility yet to save output or the raw input.
* There is no possibility of selecting a soundcard.
The gainsettings for the external devices are predefined. In a next version
a gain slider will be added.
-----------------------------------------------------------------------------
The use of native code
@@ -66,42 +49,83 @@ wrappers around the existing libraries mainly.
* f. a wrapper around the portaudio library.
------------------------------------------------------------------------------
Installing the libraries and running javaRadio
------------------------------------------------------------------------------
The C(++) code for the wrappers is in the different subdirectories in the
directory "libraries".
These (sub)directories contain - obviously - the code, as well as a script
to generate the wrapper under Ubuntu and Stretch. However, one might have
to adapt the wrapper to point to the right include directories of the
installed jdk.
The distribution contains file "JavaRadio.class"
containing the (compiled) java code.
One needs jdk8 to run the code.
However, prior to running one has to install libraries and wrappers.
Installation of the wrappers is in "/usr/local/lib".
The wrappers for the libraries are encoded in C/C++ and are part
of the sourcetree, in the subdirectory "libraries".
The individual directories where the wrappers are, contain a simple
script to generate the wrapper. Obviously, the paths in these scripts
have to be adapted for java in the local environment.
-----------------------------------------------------------------------
Install libraries
* a. libfaad, the faad library as well as the include files;
* b. libsndfile, the library for handling ".sdr" files;
* c. portaudio, the library for handling the soundcard;
* d. fftw3, the library for the fft operation.
* e. libmirsdrapi-rsp, the library for the SDRplay, and/or librtlsdr, the
library for the dabsticks, and/or libairspy, the library for the
airspy.
Handling devices
------------------------------------------------------------------------
The main program will check the availability of the various devices.
Three devices are supported, one might want to exclude devices that
are not available from these checks. This is done by commenting out
the try {....}catch sections in the function "bindDevices" in the file
Javaradio.java.
-------------------------------------------------------------------------
------------------------------------------------------------------------
Compiling and running the program
-------------------------------------------------------------------------
If/when everything is in place, "cd" to the directory where the java sources
are stored.
Compilation is simply by "javac JavaRadio.java"
Running is simply by "java JavaRadio"
Running DAB then is simply by "java JavaRadio".
Note that the current implementation will scan the channels in Band III,
and will show the collected services. It does not have a channel selector.
Selecting a service then may take
a few moments since the tuner has to be set to the channel the service
is on. If a next service is chosen that is transmitted in the same channel,
switching is fast.
(A later version will store the list of services and - on command - retrieve
it to save start up time).
-----------------------------------------------------------------------------
Features
-----------------------------------------------------------------------------
The - pretty simple - GUI doen not provide for a channel selector. In the
first run of the program, the program will scan all channels in the selected
band (default Band III). It will keep a list of channels where DAB signals
were found, so the subsequent times the program is run it will ONLY scan
the channels on this list.
Depending on the conditions, the interrogation of some channels may not detect
a DAB signal, where - at another time or location - the DAB channel could
have been detected. The "reset" button will cause a scan to be done
over all channels and build a new list of channels carrying detectable data.
The GUI is pretty self explanatory, basically the only things that can be
selected are the gain setting for the attached device (a slider),
and a selective. The GUI will show when scanning is complete and services
are ready to be selected.
The implementation currently supports DAB and DAB+ audio services, including
some PAD (Program Associated Data) handling (i.e. dynamic labels and images that are transmitted using PAD).
It does not support data services, labels of data services are not even shown on the GUI.
Devices that are supported are
* SDRplay,
* rtlsdr based DABsticks,
* AIRspy
------------------------------------------------------------------------------
Selecting a band
-------------------------------------------------------------------------------
While most transmissions are in Band III, in some countries the Band (and
the Mode) differ. This can be set in an "ini" file. Such an ini file
is stored in the home directory, and is named ".javaDab.ini"
Adding a line "dabBand=LBand" will cause the tuner to
be set to the L-Band, and setting "dabMode=2" will set the software to
recognize Mode 2.
-----------------------------------------------------------------------------
Todo
-------------------------------------------------------------------------------

Binary file not shown.

View File

@@ -28,6 +28,7 @@ public interface Device {
public void resetBuffer ();
public int bitDepth ();
public void setGain (int v);
public void autoGain (boolean b);
public int samples ();
public int getSamples (float [] v, int amount);
public boolean is_nullDevice ();

Binary file not shown.

View File

@@ -60,6 +60,10 @@ public class airspyDevice implements Device {
airspy_setGain (handle, g);
}
@Override
public void autoGain (boolean b) {
}
public airspyDevice (int frequency,
int gain,
boolean autogain) throws Exception {

Binary file not shown.

View File

@@ -43,5 +43,7 @@ public class nullDevice implements Device {
@Override
public void setGain (int g) {}
@Override
public void autoGain (boolean b) {}
@Override
public boolean is_nullDevice () { return true; }
}

Binary file not shown.

View File

@@ -60,6 +60,11 @@ public class rtlsdrDevice implements Device {
rtlsdr_setGain (handle, g);
}
@Override
public void autoGain (boolean b) {
rtlsdr_autogain (handle, b);
}
@Override
public boolean is_nullDevice () { return false; }
public rtlsdrDevice (int frequency,
@@ -84,4 +89,5 @@ public class rtlsdrDevice implements Device {
private native void rtlsdr_setVFOFrequency (long handle, int freq);
private native int rtlsdr_getVFOFrequency (long handle);
private native void rtlsdr_setGain (long handle, int g);
private native void rtlsdr_autogain (long handle, boolean b);
}

Binary file not shown.

View File

@@ -62,6 +62,11 @@ public class sdrplayDevice implements Device {
sdr_setGain (handle, g);
}
@Override
public void autoGain (boolean b) {
sdr_autogain (handle, b);
}
@Override
public boolean is_nullDevice () { return false; }
@@ -89,4 +94,6 @@ public class sdrplayDevice implements Device {
private native int sdr_getVFOFrequency (long handle);
private native void sdr_setGain (long handle,
int g);
private native void sdr_autogain (long handle,
boolean b);
}

View File

@@ -135,3 +135,11 @@ JNIEXPORT void JNICALL Java_devices_rtlsdrDevice_rtlsdr_1setGain
h -> setGain (gain);
}
JNIEXPORT void JNICALL Java_devices_rtlsdrDevice_rtlsdr_1autoGain
(JNIEnv *env , jobject obj , jlong handle , jboolean gain) {
if (handle == 0)
return;
rtlsdrHandler *h = reinterpret_cast <rtlsdrHandler *> (handle);
h -> set_autogain (gain);
}

View File

@@ -153,7 +153,7 @@ bool sdrplayHandler::has_autogain (void) {
return true;
}
void sdrplayHandler::set_agcControl (bool b) {
void sdrplayHandler::set_autogain (bool b) {
}
static

View File

@@ -64,7 +64,7 @@ public:
int16_t bitDepth (void);
void setGain (int32_t);
bool has_autogain (void);
void set_agcControl (bool);
void set_autogain (bool);
RingBuffer<std::complex<float>> *_I_Buffer;
int16_t nrBits;
private:

View File

@@ -170,4 +170,13 @@ JNIEXPORT void
h -> setGain (gain);
}
JNIEXPORT void
JNICALL Java_devices_sdrplayDevice_sdr_1autoGain
(JNIEnv *env, jobject obj, jlong handle, jboolean gain){
if (handle == 0)
return;
sdrplayHandler *h = reinterpret_cast <sdrplayHandler *> (handle);
h -> set_autogain (gain);
}

View File

@@ -50,7 +50,7 @@ public class RadioController implements modelSignals, viewSignals {
serviceCount = 0;
timer = new Timer ();
}
//
public void startRadio () {
m_model. addServiceListener (this);
m_view. addServiceListener (this);
@@ -59,6 +59,40 @@ public class RadioController implements modelSignals, viewSignals {
theGain = Integer.parseInt (gv);
m_view. setDeviceGain (theGain);
m_model. setDeviceGain (theGain);
startScanning ();
}
//
// startScanning can be called from the reset function to
// generate a new list of channels with services
@Override
public void reset () {
if (scanning)
return;
m_model. stopChannel ();
m_view. clearScreen ();
for (int i = 0; i < my_bandHandler. numberofItems (); i ++)
savedValues. setProperty (my_bandHandler. channel (i), "true");
startScanning ();
}
private void startScanning () {
scanning = true;
channelNumber = 0;
serviceCount = 0;
while (true) {
if (channelNumber >= my_bandHandler. numberofItems ()) {
readytoGo ();
return;
}
String h = savedValues.
getProperty (my_bandHandler. channel (channelNumber),
"true");
if (h. equals ("true"))
break;
channelNumber ++;
}
timerTask = new TimerTask () {
@Override
public void run () {
@@ -73,17 +107,28 @@ public class RadioController implements modelSignals, viewSignals {
@Override
public void no_signal_found () {
System. out. println ("channel number " + channelNumber);
savedValues.
setProperty (my_bandHandler. channel (channelNumber),
"false");
handle_scannerTimeout ();
}
public void handle_scannerTimeout () {
timerTask. cancel ();
m_model. stopChannel ();
while (true) {
channelNumber ++;
if (channelNumber >= my_bandHandler. numberofItems ()) {
readytoGo ();
return;
}
String h = savedValues. getProperty (my_bandHandler.
channel (channelNumber), "true");
if (h. equals ("true"))
break;
}
timerTask = new TimerTask () {
@Override
public void run () {
@@ -115,6 +160,9 @@ public class RadioController implements modelSignals, viewSignals {
public void readytoGo () {
scanning = false;
if (serviceCount == 0)
m_view. show_noServices ();
else
m_view. showServiceEnabled (serviceCount);
}
@@ -147,6 +195,11 @@ public class RadioController implements modelSignals, viewSignals {
Integer. toString (val));
}
@Override
public void autogainButton () {
m_model. set_autoGain ();
}
private void show_serviceData (int index) {
String serviceName = services. get (index). serviceName;
String channel = services. get (index). channel;

Binary file not shown.

View File

@@ -34,8 +34,8 @@ public class DabAudio extends DabVirtual {
private final int fragmentSize;
private final Protection protectionHandler;
private final AudioProcessor audioProcessor;
private final PCMwrapper soundHandler;
// private final SoundCard soundHandler;
// private final PCMwrapper soundHandler;
private final SoundCard soundHandler;
private int countforInterleaver = 0;
private int interleaverIndex = 0;
private final byte [] shiftRegister = new byte [9];
@@ -77,8 +77,8 @@ public class DabAudio extends DabVirtual {
protectionHandler = new EEP_protection (pd. bitRate,
pd. protLevel);
//
soundHandler = new PCMwrapper ();
// soundHandler = new SoundCard ();
// soundHandler = new PCMwrapper ();
soundHandler = new SoundCard ();
if (dabModus == DAB_PLUS)
audioProcessor = new MP4_Processor (pd. bitRate,
theScreen,

Binary file not shown.

View File

@@ -36,8 +36,8 @@ import utils.*;
private int baudRate;
private final int bitRate;
private final RadioModel theGUI;
private final PCMwrapper soundHandler;
// private final SoundCard soundHandler;
// private final PCMwrapper soundHandler;
private final SoundCard soundHandler;
private final Padhandler my_padHandler;
private final short [] sampleBuf;
private boolean mp2Loaded;
@@ -52,8 +52,8 @@ import utils.*;
public MP2_Processor (int bitRate,
RadioModel theScreen,
// SoundCard soundHandler) {
PCMwrapper soundHandler) {
SoundCard soundHandler) {
// PCMwrapper soundHandler) {
this. bitRate = bitRate;
theGUI = theScreen;

Binary file not shown.

View File

@@ -31,8 +31,8 @@ import utils.*;
private final byte [] outVector;
private final byte [] rsIn;
private final byte [] rsOut;
private final PCMwrapper soundHandler;
// private final SoundCard soundHandler;
// private final PCMwrapper soundHandler;
private final SoundCard soundHandler;
private final Padhandler my_padHandler;
private final firecodeChecker fc;
@@ -50,8 +50,8 @@ import utils.*;
public MP4_Processor (int bitRate,
RadioModel theScreen,
PCMwrapper rb) {
// SoundCard rb) {
// PCMwrapper rb) {
SoundCard rb) {
this. bitRate = bitRate;
this. theGUI = theScreen;
soundHandler = rb;

Binary file not shown.

View File

@@ -37,6 +37,7 @@ public class RadioModel {
}
private boolean channel_active = false;
public void selectChannel (int frequency, boolean scanning) {
my_device. stopReader ();
my_device. setVFOFrequency (frequency * 1000);
@@ -52,9 +53,12 @@ public class RadioModel {
// restart the dabprocessor
dabProcessor. start ();
my_device. restartReader ();
channel_active = true;
}
public void stopChannel () {
if (!channel_active)
return;
dabProcessor. stopProcessor ();
my_device. stopReader ();
}
@@ -63,6 +67,13 @@ public class RadioModel {
my_device. setGain (gainValue);
}
private boolean autoGain = false;
public void set_autoGain () {
autoGain = !autoGain;
my_device. autoGain (autoGain);
}
// This one is called from within the dabProcessor
// in case no DAB signal is found
public void no_signal_found () {

Binary file not shown.

Binary file not shown.

BIN
package_View/RadioView$3.class Executable file

Binary file not shown.

BIN
package_View/RadioView$4.class Executable file

Binary file not shown.

Binary file not shown.

View File

@@ -1,8 +1,9 @@
package package_View;
import java.awt.*;
import javax.swing.*;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import java.awt.event.*;
import package_Model.*;
import java.io.ByteArrayInputStream;
import java.util.*;
import javax.imageio.ImageIO;
@@ -16,12 +17,13 @@ import java. awt. Dimension;
public class RadioView extends JFrame {
//... Components
private final JLabel m_copyright = new JLabel ("Jan's Radio");
private final JLabel m_timesync = new JLabel ("sync ");
private final JLabel m_stereo = new JLabel ("st");
private final JLabel m_motLabel = new JLabel (" ");
private final JLabel m_dynamicLabel = new JLabel (" ");
private final JSlider m_gainSlider = new JSlider ();
private final JButton m_resetButton = new JButton ("reset");
private final JButton m_autogainButton = new JButton ("auto");
private final JLabel m_gainLabel = new JLabel ("50");
private final JLabel m_ficLevel_1 = new JLabel (" ");
@@ -30,7 +32,7 @@ public class RadioView extends JFrame {
private final JLabel m_ficLevel_4 = new JLabel (" ");
private final JLabel m_ficLevel_5 = new JLabel (" ");
private final JLabel m_ensembleName = new JLabel ("ensemble");
private final JLabel m_ensembleLabel = new JLabel ("ensemble");
private final JLabel m_selectedService= new JLabel ("wait for services");
private final JLabel m_channelLabel = new JLabel (" ");
private final JLabel m_serviceCount = new JLabel (" ");
@@ -41,15 +43,17 @@ public class RadioView extends JFrame {
}
//======================================================= constructor
/** Constructor
* @param model */
public RadioView (RadioModel model) {
/** Constructor */
public RadioView () {
//... Set up the logic
m_copyright. setToolTipText ("Copyright(s) 2018 Jan van Katwijk, \nLazy Chair Computing.");
m_selectedService. setToolTipText ("the name of the selected service");
m_timesync. setToolTipText ("Green indicates time sync OK");
m_stereo. setToolTipText ("Green indicates transmission is stereo");
m_resetButton. setBackground (Color. red);
m_resetButton. setOpaque (true);
m_autogainButton. setBackground (Color. green);
m_autogainButton. setOpaque (true);
m_timesync. setBackground (Color. red);
m_timesync. setOpaque (true);
m_stereo. setBackground (Color. red);
@@ -60,18 +64,18 @@ public class RadioView extends JFrame {
m_selectedService. setOpaque (true);
m_gainSlider. setPreferredSize(new Dimension(30, 60));
m_serviceCount. setToolTipText ("number of services detected");
//... Layout the components.
JPanel row1 = new JPanel();
row1. setLayout (new FlowLayout ());
row1. add (m_copyright);
row1. add (Box. createRigidArea (new Dimension (10, 0)));
row1. add (m_timesync);
row1. add (m_stereo);
row1. add (Box. createRigidArea (new Dimension (10, 0)));
row1. add (m_motLabel);
row1. add (Box. createRigidArea (new Dimension (10, 0)));
row1. add (m_serviceCount);
row1. add (Box. createRigidArea (new Dimension (10, 0)));
row1. add (m_resetButton);
m_ficLevel_1. setBackground (Color. red);
m_ficLevel_1. setOpaque (true);
m_ficLevel_2. setBackground (Color. red);
@@ -84,28 +88,32 @@ public class RadioView extends JFrame {
m_ficLevel_5. setOpaque (true);
JPanel row2 = new JPanel ();
row2.setLayout(new FlowLayout());
row2.setLayout(new BoxLayout (row2, BoxLayout. X_AXIS));
row2. add (m_channelLabel);
row2. add (Box. createRigidArea (new Dimension (25, 0)));
row2. add (Box. createRigidArea (new Dimension (50, 0)));
row2. add (m_ficLevel_1);
row2. add (Box. createRigidArea (new Dimension (5, 0)));
row2. add (m_ficLevel_2);
row2. add (Box. createRigidArea (new Dimension (5, 0)));
row2. add (m_ficLevel_3);
row2. add (Box. createRigidArea (new Dimension (5, 0)));
row2. add (m_ficLevel_4);
row2. add (Box. createRigidArea (new Dimension (5, 0)));
row2. add (m_ficLevel_5);
JPanel row3 = new JPanel ();
row3. setLayout (new FlowLayout ());
row3. add (m_ensembleName);
row3. add (m_ensembleLabel);
JPanel row4 = new JPanel ();
row4. setLayout (new FlowLayout ());
row4. add (m_selectedService);
row4. add (Box. createRigidArea (new Dimension (30, 0)));
row4. add (Box. createRigidArea (new Dimension (100, 0)));
JPanel row5 = new JPanel ();
row5. setLayout (new FlowLayout ());
row5. add (m_dynamicLabel);
row5. add (Box. createRigidArea (new Dimension (220, 0)));
row5. add (Box. createRigidArea (new Dimension (100, 0)));
JPanel leftpart = new JPanel ();
leftpart. setLayout (new BoxLayout (leftpart, BoxLayout. Y_AXIS));
@@ -121,10 +129,11 @@ public class RadioView extends JFrame {
rightpart. setLayout (new BoxLayout (rightpart, BoxLayout. Y_AXIS));
m_gainSlider. setOrientation (JSlider. VERTICAL);
m_gainSlider. setToolTipText ("The gain for the device, range 1 .. 100");
rightpart. add (m_autogainButton);
rightpart. add (m_gainSlider);
rightpart. add (m_gainLabel);
frame. add (rightpart);
frame. add (Box. createRigidArea (new Dimension (30, 0)));
frame. add (Box. createRigidArea (new Dimension (40, 0)));
JPanel gui = new JPanel ();
gui. setLayout (new BoxLayout (gui, BoxLayout. Y_AXIS));
gui. add (frame);
@@ -133,7 +142,7 @@ public class RadioView extends JFrame {
this. setContentPane (gui);
this. pack ();
this. setTitle("JavaRadio - MVC");
this. setTitle("Jan's JavaRadio - MVC");
// The window closing event should probably be passed to the
// Controller in a real program, but this is a short example.
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@@ -164,6 +173,26 @@ public class RadioView extends JFrame {
});
}
});
m_resetButton.
addActionListener (new ActionListener () {
@Override
public void actionPerformed (ActionEvent evt) {
listeners. forEach ((hl) -> {
hl. reset ();
});
}
});
m_autogainButton.
addActionListener (new ActionListener () {
@Override
public void actionPerformed (ActionEvent evt) {
listeners. forEach ((hl) -> {
hl. autogainButton ();
});
}
});
}
private void tableSelect_withLeft (String name) {
@@ -206,7 +235,7 @@ public class RadioView extends JFrame {
}
public void setEnsembleName (String s) {
m_ensembleName. setText (s);
m_ensembleLabel. setText (s);
}
public void show_isStereo (boolean b) {
@@ -284,13 +313,27 @@ public class RadioView extends JFrame {
m_selectedService. setOpaque (true);
}
JFrame warningFrame = new JFrame ();
public void show_noServices () {
JPanel panel = new JPanel ();
JOptionPane. showMessageDialog (panel,
"No services detected",
"Warning",
JOptionPane. WARNING_MESSAGE);
m_resetButton. setBackground (Color. green);
m_resetButton. setOpaque (true);
}
public void showServiceEnabled (int numofServices) {
m_selectedService. setText ("please choose a service");
m_selectedService. setBackground (Color. green);
m_selectedService. setOpaque (true);
showServiceCount (numofServices);
m_resetButton. setBackground (Color. green);
m_resetButton. setOpaque (true);
}
public void showServiceCount (int numofServices) {
m_serviceCount. setBackground (Color. green);
m_serviceCount. setOpaque (true);
@@ -397,4 +440,15 @@ public class RadioView extends JFrame {
m_gainSlider. setValue (v);
m_gainLabel. setText (Integer. toString (v));
}
public void clearScreen () {
m_dynamicLabel. setText (" ");
m_ensembleLabel. setText (" ");
m_serviceTable. clearTable ();
m_selectedService. setText ("wait for services");
m_selectedService. setBackground (Color. red);
m_selectedService. setOpaque (true);
m_resetButton. setBackground (Color.red);
m_resetButton. setOpaque (true);
}
}

Binary file not shown.

View File

@@ -29,6 +29,12 @@ public class serviceTable extends JFrame {
this. setVisible (true);
}
public void clearTable () {
DefaultTableModel dm = (DefaultTableModel)table. getModel ();
while (dm. getRowCount () > 0)
dm. removeRow (0);
}
public void newService (String name) {
((DefaultTableModel)table. getModel ()).
addRow (new Object [] {name});

Binary file not shown.

View File

@@ -5,5 +5,7 @@ public interface viewSignals {
public void tableSelect_withLeft (String s);
public void tableSelect_withRight (String s);
public void gainValue (int gainValue);
public void reset ();
public void autogainButton ();
}

Binary file not shown.

View File

@@ -28,11 +28,12 @@ public class AACDecoder {
private final LFfilter f_32000_r;
private final LFfilter f_32000_i;
private final PCMwrapper soundHandler;
// private final SoundCard soundHandler;
// private final PCMwrapper soundHandler;
private final SoundCard soundHandler;
// public AACDecoder (PCMwrapper b) {
public AACDecoder (SoundCard b) {
public AACDecoder (PCMwrapper b) {
// public AACDecoder (SoundCard b) {
soundHandler = b;
info = new int [10];
localBuffer = new short [1024];
@@ -75,15 +76,8 @@ public class AACDecoder {
if ((amount <= 0) || (error != 0)) // may be an error
return 0;
// aacFetchData returns the amount of "short" values,
// where 2 short values together are one - two channel - sound sample
// while (amount > 0) {
// int samplesRead = aacFetchData (localBuffer);
// if (samplesRead > 0) {
// convert_and_store (localBuffer, samplesRead, rate);
// }
// amount -= samplesRead;
// }
// the aacwrapper/decoder puts the values in a ringbuffer
// the fetch function fetches at most localbuffersize values
int samplesRead = aacFetchData (localBuffer);
while (samplesRead > 0) {
convert_and_store (localBuffer, samplesRead, rate);
@@ -120,7 +114,7 @@ public class AACDecoder {
default:
case 48000:
try {
soundHandler. addData (buffer, size);
addData (buffer, size);
} catch (Exception e) {
System. out. println (e. getMessage ());
}
@@ -138,7 +132,7 @@ public class AACDecoder {
lbuffer [4 * i + 3] = 0;
}
try {
soundHandler. addData (lbuffer, 2 * size);
addData (lbuffer, 2 * size);
} catch (Exception e) {}
}
@@ -158,11 +152,15 @@ public class AACDecoder {
}
try {
soundHandler. addData (lbuffer, (int)(1.5 * size));
addData (lbuffer, (int)(1.5 * size));
} catch (Exception e) {
System. out. println (e. getMessage ());
}
}
public void addData (short [] buffer, int size) {
soundHandler. addData (buffer, size);
}
}

Binary file not shown.

BIN
utils/RingBuffer.class Executable file

Binary file not shown.

BIN
utils/SoundCard.class Executable file

Binary file not shown.