CurrentFilePath :=\r
CurrentFileFullPath :=\r
User :=OFA-Staff\r
-Date :=8/20/2012\r
+Date :=8/22/2012\r
CodeLitePath :="C:\bin\CodeLite"\r
LinkerName :=g++\r
ArchiveTool :=ar rcus\r
PATH:=$(WXWIN)\lib\gcc_dll;$(PATH)\r
WXCFG:=gcc_dll\mswu\r
UNIT_TEST_PP_SRC_DIR:=C:\bin\UnitTest++-1.3\r
-Objects=$(IntermediateDirectory)/src_dlg_about$(ObjectSuffix) $(IntermediateDirectory)/src_dlg_audio$(ObjectSuffix) $(IntermediateDirectory)/src_dlg_comports$(ObjectSuffix) $(IntermediateDirectory)/src_dlg_options$(ObjectSuffix) $(IntermediateDirectory)/src_fdmdv2_main$(ObjectSuffix) $(IntermediateDirectory)/src_fdmdv2_plot$(ObjectSuffix) $(IntermediateDirectory)/src_paclass$(ObjectSuffix) $(IntermediateDirectory)/src_topFrame$(ObjectSuffix) \r
+Objects=$(IntermediateDirectory)/src_dlg_about$(ObjectSuffix) $(IntermediateDirectory)/src_dlg_audio$(ObjectSuffix) $(IntermediateDirectory)/src_dlg_comports$(ObjectSuffix) $(IntermediateDirectory)/src_dlg_options$(ObjectSuffix) $(IntermediateDirectory)/src_fdmdv2_main$(ObjectSuffix) $(IntermediateDirectory)/src_fdmdv2_plot$(ObjectSuffix) $(IntermediateDirectory)/src_topFrame$(ObjectSuffix) $(IntermediateDirectory)/src_fdmdv2_plot_scatter$(ObjectSuffix) $(IntermediateDirectory)/src_fdmdv2_plot_waterfall$(ObjectSuffix) $(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(ObjectSuffix) \\r
+ $(IntermediateDirectory)/src_fdmdv2_scalar$(ObjectSuffix) $(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(ObjectSuffix) \r
\r
##\r
## Main Build Targets \r
$(IntermediateDirectory)/src_fdmdv2_plot$(PreprocessSuffix): ../src/fdmdv2_plot.cpp\r
@$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_fdmdv2_plot$(PreprocessSuffix) "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_plot.cpp"\r
\r
-$(IntermediateDirectory)/src_paclass$(ObjectSuffix): ../src/paclass.cpp $(IntermediateDirectory)/src_paclass$(DependSuffix)\r
- $(CompilerName) $(IncludePCH) $(SourceSwitch) "C:/bin/Projects/Radio/fdmdv2/src/paclass.cpp" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/src_paclass$(ObjectSuffix) $(IncludePath)\r
-$(IntermediateDirectory)/src_paclass$(DependSuffix): ../src/paclass.cpp\r
- @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_paclass$(ObjectSuffix) -MF$(IntermediateDirectory)/src_paclass$(DependSuffix) -MM "C:/bin/Projects/Radio/fdmdv2/src/paclass.cpp"\r
-\r
-$(IntermediateDirectory)/src_paclass$(PreprocessSuffix): ../src/paclass.cpp\r
- @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_paclass$(PreprocessSuffix) "C:/bin/Projects/Radio/fdmdv2/src/paclass.cpp"\r
-\r
$(IntermediateDirectory)/src_topFrame$(ObjectSuffix): ../src/topFrame.cpp $(IntermediateDirectory)/src_topFrame$(DependSuffix)\r
$(CompilerName) $(IncludePCH) $(SourceSwitch) "C:/bin/Projects/Radio/fdmdv2/src/topFrame.cpp" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/src_topFrame$(ObjectSuffix) $(IncludePath)\r
$(IntermediateDirectory)/src_topFrame$(DependSuffix): ../src/topFrame.cpp\r
$(IntermediateDirectory)/src_topFrame$(PreprocessSuffix): ../src/topFrame.cpp\r
@$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_topFrame$(PreprocessSuffix) "C:/bin/Projects/Radio/fdmdv2/src/topFrame.cpp"\r
\r
+$(IntermediateDirectory)/src_fdmdv2_plot_scatter$(ObjectSuffix): ../src/fdmdv2_plot_scatter.cpp $(IntermediateDirectory)/src_fdmdv2_plot_scatter$(DependSuffix)\r
+ $(CompilerName) $(IncludePCH) $(SourceSwitch) "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_plot_scatter.cpp" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/src_fdmdv2_plot_scatter$(ObjectSuffix) $(IncludePath)\r
+$(IntermediateDirectory)/src_fdmdv2_plot_scatter$(DependSuffix): ../src/fdmdv2_plot_scatter.cpp\r
+ @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_fdmdv2_plot_scatter$(ObjectSuffix) -MF$(IntermediateDirectory)/src_fdmdv2_plot_scatter$(DependSuffix) -MM "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_plot_scatter.cpp"\r
+\r
+$(IntermediateDirectory)/src_fdmdv2_plot_scatter$(PreprocessSuffix): ../src/fdmdv2_plot_scatter.cpp\r
+ @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_fdmdv2_plot_scatter$(PreprocessSuffix) "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_plot_scatter.cpp"\r
+\r
+$(IntermediateDirectory)/src_fdmdv2_plot_waterfall$(ObjectSuffix): ../src/fdmdv2_plot_waterfall.cpp $(IntermediateDirectory)/src_fdmdv2_plot_waterfall$(DependSuffix)\r
+ $(CompilerName) $(IncludePCH) $(SourceSwitch) "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_plot_waterfall.cpp" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/src_fdmdv2_plot_waterfall$(ObjectSuffix) $(IncludePath)\r
+$(IntermediateDirectory)/src_fdmdv2_plot_waterfall$(DependSuffix): ../src/fdmdv2_plot_waterfall.cpp\r
+ @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_fdmdv2_plot_waterfall$(ObjectSuffix) -MF$(IntermediateDirectory)/src_fdmdv2_plot_waterfall$(DependSuffix) -MM "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_plot_waterfall.cpp"\r
+\r
+$(IntermediateDirectory)/src_fdmdv2_plot_waterfall$(PreprocessSuffix): ../src/fdmdv2_plot_waterfall.cpp\r
+ @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_fdmdv2_plot_waterfall$(PreprocessSuffix) "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_plot_waterfall.cpp"\r
+\r
+$(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(ObjectSuffix): ../src/fdmdv2_plot_spectrum.cpp $(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(DependSuffix)\r
+ $(CompilerName) $(IncludePCH) $(SourceSwitch) "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_plot_spectrum.cpp" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(ObjectSuffix) $(IncludePath)\r
+$(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(DependSuffix): ../src/fdmdv2_plot_spectrum.cpp\r
+ @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(ObjectSuffix) -MF$(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(DependSuffix) -MM "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_plot_spectrum.cpp"\r
+\r
+$(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(PreprocessSuffix): ../src/fdmdv2_plot_spectrum.cpp\r
+ @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(PreprocessSuffix) "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_plot_spectrum.cpp"\r
+\r
+$(IntermediateDirectory)/src_fdmdv2_scalar$(ObjectSuffix): ../src/fdmdv2_scalar.cpp $(IntermediateDirectory)/src_fdmdv2_scalar$(DependSuffix)\r
+ $(CompilerName) $(IncludePCH) $(SourceSwitch) "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_scalar.cpp" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/src_fdmdv2_scalar$(ObjectSuffix) $(IncludePath)\r
+$(IntermediateDirectory)/src_fdmdv2_scalar$(DependSuffix): ../src/fdmdv2_scalar.cpp\r
+ @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_fdmdv2_scalar$(ObjectSuffix) -MF$(IntermediateDirectory)/src_fdmdv2_scalar$(DependSuffix) -MM "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_scalar.cpp"\r
+\r
+$(IntermediateDirectory)/src_fdmdv2_scalar$(PreprocessSuffix): ../src/fdmdv2_scalar.cpp\r
+ @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_fdmdv2_scalar$(PreprocessSuffix) "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_scalar.cpp"\r
+\r
+$(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(ObjectSuffix): ../src/fdmdv2_pa_wrapper.cpp $(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(DependSuffix)\r
+ $(CompilerName) $(IncludePCH) $(SourceSwitch) "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_pa_wrapper.cpp" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(ObjectSuffix) $(IncludePath)\r
+$(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(DependSuffix): ../src/fdmdv2_pa_wrapper.cpp\r
+ @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(ObjectSuffix) -MF$(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(DependSuffix) -MM "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_pa_wrapper.cpp"\r
+\r
+$(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(PreprocessSuffix): ../src/fdmdv2_pa_wrapper.cpp\r
+ @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(PreprocessSuffix) "C:/bin/Projects/Radio/fdmdv2/src/fdmdv2_pa_wrapper.cpp"\r
+\r
\r
-include $(IntermediateDirectory)/*$(DependSuffix)\r
##\r
$(RM) $(IntermediateDirectory)/src_fdmdv2_plot$(ObjectSuffix)\r
$(RM) $(IntermediateDirectory)/src_fdmdv2_plot$(DependSuffix)\r
$(RM) $(IntermediateDirectory)/src_fdmdv2_plot$(PreprocessSuffix)\r
- $(RM) $(IntermediateDirectory)/src_paclass$(ObjectSuffix)\r
- $(RM) $(IntermediateDirectory)/src_paclass$(DependSuffix)\r
- $(RM) $(IntermediateDirectory)/src_paclass$(PreprocessSuffix)\r
$(RM) $(IntermediateDirectory)/src_topFrame$(ObjectSuffix)\r
$(RM) $(IntermediateDirectory)/src_topFrame$(DependSuffix)\r
$(RM) $(IntermediateDirectory)/src_topFrame$(PreprocessSuffix)\r
+ $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_scatter$(ObjectSuffix)\r
+ $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_scatter$(DependSuffix)\r
+ $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_scatter$(PreprocessSuffix)\r
+ $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_waterfall$(ObjectSuffix)\r
+ $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_waterfall$(DependSuffix)\r
+ $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_waterfall$(PreprocessSuffix)\r
+ $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(ObjectSuffix)\r
+ $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(DependSuffix)\r
+ $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(PreprocessSuffix)\r
+ $(RM) $(IntermediateDirectory)/src_fdmdv2_scalar$(ObjectSuffix)\r
+ $(RM) $(IntermediateDirectory)/src_fdmdv2_scalar$(DependSuffix)\r
+ $(RM) $(IntermediateDirectory)/src_fdmdv2_scalar$(PreprocessSuffix)\r
+ $(RM) $(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(ObjectSuffix)\r
+ $(RM) $(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(DependSuffix)\r
+ $(RM) $(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(PreprocessSuffix)\r
$(RM) $(OutputFile)\r
$(RM) $(OutputFile).exe\r
$(RM) "C:\bin\Projects\Radio\fdmdv2\build\.build-release\fdmdv2"\r
<File Name="../src/dlg_options.cpp"/>
<File Name="../src/fdmdv2_main.cpp"/>
<File Name="../src/fdmdv2_plot.cpp"/>
- <File Name="../src/paclass.cpp"/>
<File Name="../src/topFrame.cpp"/>
+ <File Name="../src/fdmdv2_plot_scatter.cpp"/>
+ <File Name="../src/fdmdv2_plot_waterfall.cpp"/>
+ <File Name="../src/fdmdv2_plot_spectrum.cpp"/>
+ <File Name="../src/fdmdv2_scalar.cpp"/>
+ <File Name="../src/fdmdv2_pa_wrapper.cpp"/>
</VirtualDirectory>
<VirtualDirectory Name="include">
<File Name="../src/dlg_about.h"/>
<File Name="../src/dlg_options.h"/>
<File Name="../src/fdmdv2_main.h"/>
<File Name="../src/fdmdv2_plot.h"/>
- <File Name="../src/paclass.h"/>
<File Name="../src/topFrame.h"/>
<File Name="../extern/include/rig.h"/>
<File Name="../extern/include/rig_dll.h"/>
<File Name="../extern/include/portaudiocpp/SystemDeviceIterator.hxx"/>
<File Name="../extern/include/portaudiocpp/SystemHostApiIterator.hxx"/>
</VirtualDirectory>
+ <File Name="../src/fdmdv2_plot_scatter.h"/>
+ <File Name="../src/fdmdv2_plot_waterfall.h"/>
+ <File Name="../src/fdmdv2_plot_spectrum.h"/>
+ <File Name="../src/fdmdv2_scalar.h"/>
+ <File Name="../src/fdmdv2_pa_wrapper.h"/>
</VirtualDirectory>
<VirtualDirectory Name="resources">
<File Name="../src/FDMDV2.fbp"/>
-./Release/src_dlg_about.o ./Release/src_dlg_audio.o ./Release/src_dlg_comports.o ./Release/src_dlg_options.o ./Release/src_fdmdv2_main.o ./Release/src_fdmdv2_plot.o ./Release/src_paclass.o ./Release/src_topFrame.o \r
+./Release/src_dlg_about.o ./Release/src_dlg_audio.o ./Release/src_dlg_comports.o ./Release/src_dlg_options.o ./Release/src_fdmdv2_main.o ./Release/src_fdmdv2_plot.o ./Release/src_topFrame.o ./Release/src_fdmdv2_plot_scatter.o ./Release/src_fdmdv2_plot_waterfall.o ./Release/src_fdmdv2_plot_spectrum.o ./Release/src_fdmdv2_scalar.o ./Release/src_fdmdv2_pa_wrapper.o \r
\r
#include "sndfile.h"\r
#include "portaudio.h"
-#include "paclass.h"
+#include "fdmdv2_pa_wrapper.h"
\r
#include "codec2.h"
#include "fdmdv.h"
\r
+#define MIN_DB -40.0\r
+#define MAX_DB 0.0\r
+#define BETA 0.1 // constant for time averageing spectrum data\r
+#define MIN_HZ 0\r
+#define MAX_HZ 4000\r
+#define WATERFALL_SECS_Y 5 // number of seconds respresented by y axis of waterfall\r
+#define DT 0.02 // time between samples\r
+#define FS 8000 // FDMDV modem sample rate\r
+\r
#include "topFrame.h"
#include "dlg_about.h"\r
#include "dlg_audio.h"\r
#include "dlg_options.h"\r
#include "dlg_comports.h"\r
#include "fdmdv2_plot.h"
+#include "fdmdv2_scalar.h"
+#include "fdmdv2_plot_scatter.h"
+#include "fdmdv2_plot_waterfall.h"
+#include "fdmdv2_plot_spectrum.h"
\r
enum
{
--- /dev/null
+#include "fdmdv2_pa_wrapper.h"
+
+PortAudioWrap::PortAudioWrap()
+{
+ stream = NULL;\r
+ userData = NULL;\r
+ samplerate = 0;\r
+ framesPerBuffer = 0;
+ statusFlags = 0;\r
+ streamCallback = NULL;\r
+ streamFinishedCallback = NULL;\r
+ timeInfo = 0;
+}
+
+PortAudioWrap::~PortAudioWrap()
+{
+}
+
+//PaError PortAudioWrap::init()
+//{
+// return Pa_Initialize();
+//}
+
+PaError PortAudioWrap::streamOpen()\r
+{
+ return Pa_OpenStream(
+ &stream,
+ &inputBuffer,
+ &outputBuffer,
+ samplerate,
+ framesPerBuffer,
+ statusFlags,
+ *streamCallback,
+ userData
+ );
+}
+
+PaError PortAudioWrap::streamStart()\r
+{
+ return Pa_StartStream(stream);
+}
+
+PaError PortAudioWrap::streamClose()\r
+{
+ if(isOpen())
+ {
+ PaError rv = Pa_CloseStream(stream);
+// stream = NULL;
+ return rv;
+ }
+ else
+ {
+ return paNoError;
+ }
+}
+\r
+void PortAudioWrap::terminate()\r
+{
+ if(Pa_IsStreamStopped(stream) != paNoError)
+ {
+ Pa_StopStream(stream);
+ }
+ Pa_Terminate();
+}
+\r
+void PortAudioWrap::stop()
+{
+ Pa_StopStream(stream);
+}
+
+void PortAudioWrap::abort()
+{
+ Pa_AbortStream(stream);
+}
+
+bool PortAudioWrap::isStopped() const
+{
+ PaError ret = Pa_IsStreamStopped(stream);
+ return ret;
+}
+
+bool PortAudioWrap::isActive() const
+{
+ PaError ret = Pa_IsStreamActive(stream);
+ return ret;
+}
+
+bool PortAudioWrap::isOpen() const\r
+{\r
+ return (stream != NULL);\r
+}\r
+
+PaDeviceIndex PortAudioWrap::getDefaultInputDevice()
+{
+ return Pa_GetDefaultInputDevice();
+}
+
+PaDeviceIndex PortAudioWrap::getDefaultOutputDevice()
+{
+ return Pa_GetDefaultOutputDevice();
+}
+
+PaError PortAudioWrap::setInputChannelCount(int count)
+{
+ inputBuffer.channelCount = count;
+ return paNoError;
+}
+
+PaError PortAudioWrap::getInputChannelCount()
+{
+ return inputBuffer.channelCount;
+}
+
+PaError PortAudioWrap::setInputSampleFormat(PaSampleFormat format)
+{
+ inputBuffer.sampleFormat = format;
+ return paNoError;
+}
+
+PaError PortAudioWrap::setInputLatency(PaTime latency)
+{
+ inputBuffer.suggestedLatency = latency;
+ return paNoError;
+}
+\r
+void PortAudioWrap::setInputHostApiStreamInfo(void *info)
+{
+ inputBuffer.hostApiSpecificStreamInfo = info;
+}
+\r
+PaTime PortAudioWrap::getInputDefaultLowLatency()
+{
+ return Pa_GetDeviceInfo(inputBuffer.device)->defaultLowInputLatency;
+}
+
+PaError PortAudioWrap::setOutputChannelCount(int count)
+{
+ outputBuffer.channelCount = count;
+ return paNoError;
+}
+
+const int PortAudioWrap::getOutputChannelCount()
+{
+ return outputBuffer.channelCount;
+}
+
+const char *PortAudioWrap::getDeviceName(PaDeviceIndex dev)
+{
+ const PaDeviceInfo *info;
+ info = Pa_GetDeviceInfo(dev);
+ return info->name;
+}
+
+PaError PortAudioWrap::setOutputSampleFormat(PaSampleFormat format)
+{
+ outputBuffer.sampleFormat = format;
+ return paNoError;
+}
+
+PaError PortAudioWrap::setOutputLatency(PaTime latency)
+{
+ outputBuffer.suggestedLatency = latency;
+ return paNoError;
+}
+
+void PortAudioWrap::setOutputHostApiStreamInfo(void *info)
+{
+ outputBuffer.hostApiSpecificStreamInfo = info;
+}
+
+PaTime PortAudioWrap::getOutputDefaultLowLatency()
+{
+ return Pa_GetDeviceInfo(outputBuffer.device)->defaultLowOutputLatency;
+}
+
+PaError PortAudioWrap::setFramesPerBuffer(unsigned long size)
+{
+ framesPerBuffer = size;
+ return paNoError;
+}
+
+PaError PortAudioWrap::setSampleRate(unsigned long rate)\r
+{
+ samplerate = rate;
+ return paNoError;
+}
+
+PaError PortAudioWrap::setStreamFlags(PaStreamFlags flags)\r
+{
+ statusFlags = flags;
+ return paNoError;
+}
+
+PaError PortAudioWrap::setInputDevice(PaDeviceIndex index)\r
+{
+// inputDevice = index;
+ inputBuffer.device = index;
+ return paNoError;
+}
+
+PaError PortAudioWrap::setOutputDevice(PaDeviceIndex index)\r
+{
+// outputDevice = index;
+ outputBuffer.device = index;
+ return paNoError;
+}
+
+PaError PortAudioWrap::setCallback(PaStreamCallback *callback)\r
+{
+ streamCallback = callback;
+ return paNoError;
+}
--- /dev/null
+#include <stdio.h>
+#include <math.h>
+#include "portaudio.h"
+\r
+// Note that many of the older ISA sound cards on PCs do NOT support
+// full duplex audio (simultaneous record and playback).
+// And some only support full duplex at lower sample rates.
+#define SAMPLE_RATE (44100)
+#define PA_SAMPLE_TYPE paFloat32 //paInt16
+#define FRAMES_PER_BUFFER (64)
+
+typedef float SAMPLE;
+
+float CubicAmplifier(float input);
+
+class PortAudioWrap\r
+{\r
+ public:\r
+ PortAudioWrap();\r
+ ~PortAudioWrap();\r
+\r
+ private:\r
+ PaStream *stream;\r
+ PaStreamParameters inputBuffer;
+ PaStreamParameters outputBuffer;
+ void *userData;\r
+ int samplerate;\r
+ unsigned long framesPerBuffer;
+ PaStreamCallbackFlags statusFlags;\r
+ PaStreamCallback *streamCallback;\r
+ PaStreamFinishedCallback *streamFinishedCallback;\r
+ const PaStreamCallbackTimeInfo *timeInfo;
+// PaDeviceIndex inputDevice;
+// PaDeviceIndex outputDevice;
+\r
+ public:\r
+
+ PaError streamOpen();\r
+\r
+ PaDeviceIndex getDefaultInputDevice();
+ PaDeviceIndex getDefaultOutputDevice();\r
+\r
+ PaStreamParameters *getDeviceInfo(PaDeviceIndex idx);\r
+ PaError setFramesPerBuffer(unsigned long size);\r
+ PaError setSampleRate(unsigned long size);\r
+ PaError setStreamFlags(PaStreamFlags flags);\r
+ PaError setCallback(PaStreamCallback *streamCallback);\r
+ PaError setStreamCallback(PaStream *stream, PaStreamCallback* callback ) { streamCallback = callback; return 0;}
+ PaError setStreamFinishedCallback(PaStream *stream, PaStreamFinishedCallback* streamFinishedCallback );
+
+ PaError setInputDevice(PaDeviceIndex dev);\r
+ PaError setInputChannelCount(int count);
+ int getInputChannelCount();
+ PaError setInputSampleFormat(PaSampleFormat format);
+ PaError setInputSampleRate(PaSampleFormat format);
+ PaError setInputLatency(PaTime latency);\r
+ void setInputHostApiStreamInfo(void *info = NULL);\r
+ PaTime getInputDefaultLowLatency();
+ const char *getDeviceName(PaDeviceIndex dev);
+
+ PaError setOutputDevice(PaDeviceIndex dev);\r
+ PaError setOutputChannelCount(int count);
+ const int getOutputChannelCount();
+ PaError setOutputSampleFormat(PaSampleFormat format);
+ PaError setOutputLatency(PaTime latency);
+ void setOutputHostApiStreamInfo(void *info = NULL);
+ PaTime getOutputDefaultLowLatency();
+\r
+// PaError init();\r
+ PaError streamStart();\r
+ PaError streamClose();\r
+ void terminate();\r
+ bool isOpen() const;\r
+ void stop();
+ void abort();
+ bool isStopped() const;
+ bool isActive() const;
+};\r
// Purpose: Implements simple wxWidgets application with GUI.\r
// Created: Apr. 9, 2012
// Initial author: David Witten\r
+// Derived from: code written by David Rowe\r
// License: BSD License (other licenses may apply to other\r
// components of this project)\r
//==========================================================================\r
render(dc);\r
}\r
\r
+// general purpose way of plotting scalar values that are\r
+// updated once per frame\r
+\r
// Purpose: Declares simple wxWidgets application with GUI
// Created: Apr. 10, 2012
// Initial author: David Witten\r
+// Derived from: code written by David Rowe\r
// License: BSD License (other licenses may apply to other\r
// components of this project)\r
//==========================================================================\r
void OnShow(wxShowEvent& event);\r
protected:\r
+ int m_x;
+ int m_y;
+ int m_w;
+ int m_h;
+ int m_prev_w;
+ int m_prev_h;
+ int m_prev_x;
+ int m_prev_y;
bool m_bitmap;\r
bool m_clip;\r
bool m_rubberBand;\r
--- /dev/null
+//==========================================================================\r
+// Name: fdmdv2_plot_scatter.cpp\r
+// Purpose: Implements a scatter plot derivative of fdmdv2_plot.\r
+// Created: June 24, 2012\r
+// Initial author: David Witten\r
+// Derived from: code written by David Rowe\r
+// License: BSD License (other licenses may apply to other\r
+// components of this project)\r
+//==========================================================================\r
+#include <string.h>\r
+#include "wx/wx.h"\r
+#include "fdmdv2_main.h"\r
+#include "fdmdv2_plot.h"\r
+#include "fdmdv2_plot_scatter.h"\r
+\r
+BEGIN_EVENT_TABLE(ScatterPlot, DrawPanel)\r
+ EVT_PAINT (ScatterPlot::OnPaint)\r
+ EVT_MOTION (ScatterPlot::OnMouseMove)\r
+ EVT_LEFT_DOWN (ScatterPlot::OnMouseDown)\r
+ EVT_LEFT_UP (ScatterPlot::OnMouseUp)\r
+ EVT_MOUSEWHEEL (ScatterPlot::OnMouseWheelMoved)\r
+ EVT_SIZE (ScatterPlot::OnSize)\r
+ EVT_SHOW (ScatterPlot::OnShow)\r
+// EVT_ERASE_BACKGROUND(DrawPanel::OnErase)\r
+END_EVENT_TABLE()\r
+\r
+ScatterPlot::ScatterPlot(wxFrame* parent) : DrawPanel(parent)\r
+{\r
+ int i;\r
+
+ //align(FL_ALIGN_TOP);
+ //labelsize(10);
+
+ for(i=0; i<SCATTER_MEM; i++)
+ {
+ m_mem[i].real = 0.0;
+ m_mem[i].imag = 0.0;
+ }
+ m_prev_w = 0;
+ m_prev_h = 0;
+ m_prev_x = 0;
+ m_prev_y = 0;
+}
+
+void ScatterPlot::draw()
+{
+ float x_scale;
+ float y_scale;
+ int i;
+ int j;
+ int x1;
+ int y1;
+
+ //Fl_Box::draw();
+
+ /* detect resizing of window */
+ if((m_h != m_prev_h) || (m_w != m_prev_w) || (m_x != m_prev_x) || (m_y != m_prev_y))
+ {
+ //fl_color(FL_BLACK);
+ //fl_rectf(x(),y(),w(),h());
+ m_prev_h = m_h;
+ m_prev_w = m_w;
+ m_prev_x = m_x;
+ m_prev_y = m_y;
+ }
+
+ //fl_push_clip(x(),y(),w(),h());
+
+ x_scale = m_w/SCATTER_X_MAX;
+ y_scale = m_h/SCATTER_Y_MAX;
+
+ // erase last samples
+ //fl_color(FL_BLACK);
+
+ for(i=0; i<FDMDV_NSYM; i++)
+ {
+ x1 = x_scale * m_mem[i].real + m_x + m_w/2;
+ y1 = y_scale * m_mem[i].imag + m_y + m_h/2;
+ //fl_point(x1, y1);
+ m_mem[i] = m_mem[i+FDMDV_NSYM];
+ }
+
+ // shift memory
+ for(i = FDMDV_NSYM; i < SCATTER_MEM-FDMDV_NSYM; i++)
+ {
+ m_mem[i] = m_mem[i+FDMDV_NSYM];
+ }
+
+ // draw new samples
+ //fl_color(FL_GREEN);
+ for(i = SCATTER_MEM-FDMDV_NSYM, j = 0; i < SCATTER_MEM; i++,j++)
+ {
+ x1 = x_scale * m_new_samples[j].real + m_x + m_w/2;
+ y1 = y_scale * m_new_samples[j].imag + m_y + m_h/2;
+ //fl_point(x1, y1);
+ m_mem[i] = m_new_samples[j];
+ }
+ // fl_pop_clip();
+}
+
+void ScatterPlot::add_new_samples(COMP samples[])
+{
+ int i;
+
+ for(i=0; i<FDMDV_NSYM; i++)
+ {
+ m_new_samples[i] = samples[i];
+ }
+}
--- /dev/null
+//==========================================================================\r
+// Name: fdmdv2_plot_scatter.h\r
+// Purpose: Defines a waterfall plot derivative of fdmdv2_plot.\r
+// Created: June 24, 2012
+// Initial author: David Witten\r
+// Derived from: code written by David Rowe\r
+// License: BSD License (other licenses may apply to other\r
+// components of this project)\r
+//==========================================================================\r
+#ifndef __FDMDV2_PLOT_SCATTER__
+#define __FDMDV2_PLOT_SCATTER__
+
+\r
+#define SCATTER_MEM (FDMDV_NSYM)*50\r
+#define SCATTER_X_MAX 3.0\r
+#define SCATTER_Y_MAX 3.0\r
+
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
+// Class ScattterPlot\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
+class ScatterPlot : public DrawPanel
+{
+public:
+ ScatterPlot(wxFrame* parent);\r
+ ~ScatterPlot(){};
+
+protected:
+ COMP m_mem[SCATTER_MEM];
+ COMP m_new_samples[FDMDV_NSYM];
+
+ void draw();
+ void add_new_samples(COMP samples[]);
+ DECLARE_EVENT_TABLE()\r
+};\r
+
+#endif //__FDMDV2_PLOT_SCATTER__
--- /dev/null
+//==========================================================================\r
+// Name: fdmdv2_plot_waterfall.cpp\r
+// Purpose: Implements a waterfall plot derivative of fdmdv2_plot.\r
+// Created: June 23, 2012\r
+// Initial author: David Witten\r
+// Derived from: code written by David Rowe\r
+// License: BSD License (other licenses may apply to other\r
+// components of this project)\r
+//==========================================================================\r
+#include <string.h>\r
+#include "wx/wx.h"\r
+#include "fdmdv2_main.h"\r
+#include "fdmdv2_plot.h"\r
+\r
+#include "fdmdv2_plot_spectrum.h"\r
+\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
+// Class SpectrumPlot\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
+SpectrumPlot::SpectrumPlot(wxFrame* parent, int x, int y, int w, int h): DrawPanel(parent)\r
+{\r
+// align(FL_ALIGN_TOP);\r
+// labelsize(10);\r
+}\r
+\r
+int SpectrumPlot::handle(int event)\r
+{
+/*\r
+ // detect a left mouse down if inside the spectrum window
+ if((event == FL_NO_EVENT) && (Fl::event_button() == 1))
+ {
+ if((Fl::event_x() > x()) && (Fl::event_x() < (x() + w())) && (Fl::event_y() > y()) && (Fl::event_y() < (y() + h())))
+ {
+ // show zoomed spectrum window
+ zoomSpectrumWindow->show();
+ }
+ }
+*/
+ return 0;
+}
+
+void SpectrumPlot::draw()
+{
+ float x_px_per_point = 0.0;
+ float y_px_per_dB = 0.0;
+ int i, x1, y1, x2, y2;
+ float mag1, mag2;
+ char label[20];
+ float px_per_hz;
+/*
+ Fl_Box::draw();
+ fl_color(FL_BLACK);
+ fl_rectf(x(),y(),w(),h());
+ fl_color(FL_GREEN);
+ fl_line_style(FL_SOLID);
+
+ fl_push_clip(x(),y(),w(),h());
+ //printf("%d %d\n", w(), h());
+*/
+ x_px_per_point = (float)m_w / FDMDV_NSPEC;
+ y_px_per_dB = (float)m_h / (MAX_DB - MIN_DB);
+
+ // plot spectrum
+
+ for(i=0; i<FDMDV_NSPEC-1; i++)
+ {
+// mag1 = av_mag[i];
+// mag2 = av_mag[i+1];
+
+ x1 = m_x + i * x_px_per_point;
+ y1 = m_y + -mag1 * y_px_per_dB;
+ x2 = m_x + (i+1) * x_px_per_point;
+ y2 = m_y + -mag2 * y_px_per_dB;
+// fl_line(x1,y1,x2,y2);
+ }
+
+ // y axis graticule
+// fl_line_style(FL_DOT);
+ for(i=MIN_DB; i<MAX_DB; i+=10)
+ {
+ x1 = m_x;
+ y1 = m_y + -i * y_px_per_dB;
+ x2 = m_x + m_w;
+ y2 = y1;
+ //printf("%d %d %d %d\n", x1, y1, x2, y2);
+// fl_line(x1,y1,x2,y2);
+ sprintf(label, "%d", i);
+// fl_draw(label, x1, y1);
+ }
+
+ // x axis graticule
+ px_per_hz = (float)m_w/(MAX_HZ-MIN_HZ);
+// fl_line_style(FL_DOT);
+ for(i = 500; i < MAX_HZ; i += 500)
+ {
+ x1 = m_x + i * px_per_hz;
+ y1 = m_y;
+ x2 = x1;
+ y2 = m_y + m_h;
+ //printf("i=%d %d %d %d %d\n", i, x1, y1, x2, y2);
+// fl_line(x1,y1,x2,y2);
+ sprintf(label, "%d", i);
+// fl_draw(label, x1, y2);
+ }
+// fl_pop_clip();
+}
--- /dev/null
+//==========================================================================\r
+// Name: fdmdv2_plot_spectrum.h\r
+// Purpose: Defines a spectrum plot derived from fdmdv2_plot class.\r
+// Created: June 22, 2012
+// Initial author: David Witten\r
+// Derived from: code written by David Rowe\r
+// License: BSD License (other licenses may apply to other\r
+// components of this project)\r
+//==========================================================================\r
+#ifndef __FDMDV2_PLOT_SPECTRUM__
+#define __FDMDV2_PLOT_SPECTRUM__
+
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
+// Class Waterfall\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
+class SpectrumPlot : public DrawPanel\r
+{
+ public:
+ SpectrumPlot(wxFrame* parent, int x, int y, int w, int h);
+ ~SpectrumPlot() {};
+ protected:
+ int handle(int event);\r
+ void draw();
+};
+
+\r
+#endif //__FDMDV2_PLOT_SPECTRUM__
--- /dev/null
+//==========================================================================\r
+// Name: fdmdv2_plot_waterfall.cpp\r
+// Purpose: Implements a waterfall plot derivative of fdmdv2_plot.\r
+// Created: June 22, 2012
+// Initial author: David Witten\r
+// Derived from: code written by David Rowe\r
+// License: BSD License (other licenses may apply to other\r
+// components of this project)\r
+//==========================================================================\r
+#include <string.h>\r
+#include "wx/wx.h"\r
+#include "fdmdv2_main.h"\r
+#include "fdmdv2_plot.h"\r
+#include "fdmdv2_plot_waterfall.h"
+\r
+/*\r
+\r
+ Notes:\r
+\r
+ The height h() pixels represents WATERFALL_SECS_Y of data. Every DT\r
+ seconds we get a vector of FDMDV_NSPEC spectrum samples which we use\r
+ to update the last row. The height of each row is dy pixels, which\r
+ maps to DT seconds. We call each dy high rectangle of pixels a\r
+ block.\r
+\r
+*/\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
+// Class WaterfallPlot\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
+//Waterfall::Waterfall(int x, int y, int w, int h): Fl_Box(x, y, w, h, "Waterfall")
+Waterfall::Waterfall(wxFrame* parent, int x, int y, int w, int h, const char name[]): DrawPanel(parent)\r
+{
+ int i;
+
+ for(i=0; i<255; i++)
+ {
+ heatmap_lut[i] = heatmap((float)i, 0.0, 255.0);
+ }
+ greyscale = 0;
+ //align(FL_ALIGN_TOP);
+ //labelsize(10);
+ new_pixel_buf(w,h);
+};
+
+Waterfall::~Waterfall()
+{
+ delete pixel_buf;
+}
+
+void Waterfall::new_pixel_buf(int w, int h)
+{
+ int buf_sz, i;
+
+ prev_w = w; prev_h = h;
+ buf_sz = h*w;
+ pixel_buf = new unsigned[buf_sz];
+ for(i=0; i<buf_sz; i++)
+ {
+ pixel_buf[i] = 0;
+ }
+}
+
+int Waterfall::handle(int event)
+{
+ // detect a left mouse down if inside the window
+/*
+ if ((event == FL_NO_EVENT) && (Fl::event_button() == 1))
+ {
+ if ((Fl::event_x() > x()) && (Fl::event_x() < (x() + w())) && (Fl::event_y() > y()) && (Fl::event_y() < (y() + h())))
+ {
+ // show zoomed spectrum window
+ zoomWaterfallWindow->show();
+ }
+ }
+*/\r
+ return 0;
+}
+
+// map val to a rgb colour
+// from http://eddiema.ca/2011/01/21/c-sharp-heatmaps/
+unsigned Waterfall::heatmap(float val, float min, float max)
+{
+ unsigned r = 0;
+ unsigned g = 0;
+ unsigned b = 0;
+
+ val = (val - min) / (max - min);
+ if(val <= 0.2)
+ {
+ b = (unsigned)((val / 0.2) * 255);
+ }
+ else if(val > 0.2 && val <= 0.7)
+ {
+ b = (unsigned)((1.0 - ((val - 0.2) / 0.5)) * 255);
+ }
+ if(val >= 0.2 && val <= 0.6)
+ {
+ g = (unsigned)(((val - 0.2) / 0.4) * 255);
+ }
+ else if(val > 0.6 && val <= 0.9)
+ {
+ g = (unsigned)((1.0 - ((val - 0.6) / 0.3)) * 255);
+ }
+ if(val >= 0.5)
+ {
+ r = (unsigned)(((val - 0.5) / 0.5) * 255);
+ }
+ //printf("%f %x %x %x\n", val, r, g, b);
+ return (b << 16) + (g << 8) + r;
+}
+
+void Waterfall::draw()
+{
+ float spec_index_per_px, intensity_per_dB;
+ int px_per_sec;
+ int index, dy, dy_blocks, bytes_in_row_of_blocks, b;
+ int px, py, intensity;
+ unsigned *last_row, *pdest, *psrc;
+
+ /* detect resizing of window */
+ if ((m_h != m_prev_h) || (m_w != m_prev_w))
+ {
+ delete pixel_buf;
+ new_pixel_buf(m_w, m_h);
+ }
+// Fl_Box::draw();
+ // determine dy, the height of one "block"
+ px_per_sec = (float)m_h / WATERFALL_SECS_Y;
+ dy = DT * px_per_sec;
+ // number of dy high blocks in spectrogram
+ dy_blocks = m_h / dy;
+ // shift previous bit map
+ bytes_in_row_of_blocks = dy * m_w * sizeof(unsigned);
+ for(b = 0; b < dy_blocks - 1; b++)
+ {
+ pdest = pixel_buf + b * m_w * dy;
+ psrc = pixel_buf + (b + 1) * m_w * dy;
+ memcpy(pdest, psrc, bytes_in_row_of_blocks);
+ }
+ // create a new row of blocks at bottom
+ spec_index_per_px = (float)FDMDV_NSPEC / (float) m_w;
+ intensity_per_dB = (float)256 /(MAX_DB - MIN_DB);
+ last_row = pixel_buf + dy *(dy_blocks - 1)* m_w;
+ for(px = 0; px < m_w; px++)
+ {
+// index = px*spec_index_per_px;
+// intensity = intensity_per_dB * (av_mag[index] - MIN_DB);
+ if (intensity > 255)
+ {
+ intensity = 255;
+ }
+ if (intensity < 0)
+ {
+ intensity = 0;
+ }
+ if (greyscale)
+ {
+ for(py = 0; py < dy; py++)
+ {
+ last_row[px + py * m_w] = intensity<<8;
+ }
+ }
+ else
+ {
+ for(py = 0; py < dy; py++)
+ {
+ last_row[px + py * m_w] = heatmap_lut[intensity];
+ }
+ }
+ }
+ // update bit map
+ //fl_draw_image((unsigned char*)pixel_buf, m_x, m_y, m_w, m_h, 4, 0);
+}
+
+
--- /dev/null
+//==========================================================================\r
+// Name: fdmdv2_plot_waterfall.h\r
+// Purpose: Defines a waterfall plot derivative of fdmdv2_plot.\r
+// Created: June 22, 2012
+// Initial author: David Witten\r
+// Derived from: code written by David Rowe\r
+// License: BSD License (other licenses may apply to other\r
+// components of this project)\r
+//==========================================================================\r
+#ifndef __FDMDV2_PLOT_WATERFALL__
+#define __FDMDV2_PLOT_WATERFALL__
+
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
+// Class Waterfall\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
+class Waterfall : public DrawPanel\r
+{\r
+public:
+ //Waterfall(int x, int y, int w, int h);\r
+ Waterfall(wxFrame* parent, int x, int y, int w, int h, const char name[]);\r
+ ~Waterfall();\r
+
+protected:
+ int prev_w, prev_h;
+ unsigned *pixel_buf;
+ unsigned heatmap_lut[256];
+ int greyscale;
+\r
+ void new_pixel_buf(int w, int h);
+ int handle(int event);
+ unsigned heatmap(float val, float min, float max);
+ void draw();
+\r
+};\r
+\r
+#endif //__FDMDV2_PLOT_WATERFALL__
--- /dev/null
+//==========================================================================\r
+// Name: fdmdv2_plot_waterfall.cpp\r
+// Purpose: Implements a waterfall plot derivative of fdmdv2_plot.\r
+// Created: June 22, 2012
+// Initial author: David Witten\r
+// Derived from: code written by David Rowe\r
+// License: BSD License (other licenses may apply to other\r
+// components of this project)\r
+//==========================================================================\r
+#include <string.h>\r
+#include "wx/wx.h"\r
+#include "fdmdv2_main.h"\r
+#include "fdmdv2_plot.h"\r
+#include "fdmdv2_scalar.h"
+\r
+Scalar::Scalar(wxFrame* parent, int x, int y, int w, int h, int x_max_, int y_max_, const char name[]): DrawPanel(parent)\r
+{
+ int i;\r
+\r
+ //align(FL_ALIGN_TOP);\r
+ //labelsize(10);\r
+\r
+ m_x_max = x_max_;\r
+ m_y_max = y_max_;\r
+ m_mem = new float[m_x_max];\r
+\r
+ for(i = 0; i < m_x_max; i++)\r
+ {\r
+ m_mem[i] = 0.0;\r
+ }\r
+ m_prev_w = 0;\r
+ m_prev_h = 0;\r
+ m_prev_x = 0;\r
+ m_prev_y = 0;\r
+ m_index = 0;\r
+}\r
+\r
+Scalar::~Scalar()\r
+{\r
+ delete m_mem;\r
+}\r
+\r
+void Scalar::add_new_sample(float sample)\r
+{\r
+ m_new_sample = sample;\r
+}\r
+\r
+int Scalar::clip(int y1)\r
+{\r
+ if(y1 > (m_h/2 - 10))
+ {\r
+ y1 = m_h/2 - 10;\r
+ }\r
+ if(y1 < -(m_h/2 - 10))\r
+ {
+ y1 = -(m_h/2 - 10);
+ }\r
+ return y1;\r
+}\r
+\r
+void Scalar::draw()\r
+{\r
+ float x_scale;\r
+ float y_scale;\r
+ int i;
+ int x1;
+ int y1;
+ int x2;
+ int y2;\r
+ char label[100];\r
+\r
+// DrawPanel::draw();\r
+\r
+ /* detect resizing of window */\r
+ if((m_h != m_prev_h) || (m_w != m_prev_w) || (m_x != m_prev_x) || (m_y != m_prev_y))\r
+ {\r
+ //fl_color(FL_BLACK);\r
+ //fl_rectf(m_x, m_y, m_w, m_h);\r
+ m_prev_h = m_h;\r
+ m_prev_w = m_w;\r
+ m_prev_x = m_x;\r
+ m_prev_y = m_y;\r
+ }\r
+\r
+ //fl_push_clip(m_x, m_y, m_w, m_h);\r
+ x_scale = (float)m_x_max;\r
+ y_scale = (float)m_h /(2.0 * m_y_max);\r
+\r
+ // erase last sample\r
+ //fl_color(FL_BLACK);\r
+ x1 = x_scale * m_index + m_x;\r
+ y1 = y_scale * m_mem[m_index];\r
+ y1 = clip(y1);\r
+ y1 = m_y + m_h/2 - y1;\r
+ //fl_point(x1, y1);\r
+\r
+ // draw new sample\r
+ //fl_color(FL_GREEN);\r
+ x1 = x_scale * m_index + m_x;\r
+ y1 = y_scale * m_new_sample;\r
+ y1 = clip(y1);\r
+ y1 = m_y + m_h/2 - y1;\r
+// fl_point(x1, y1);\r
+ m_mem[m_index] = m_new_sample;\r
+ m_index++;\r
+ if(m_index >= m_x_max)\r
+ {\r
+ m_index = 0;\r
+ }\r
+\r
+ // y axis graticule\r
+ m_step = 10;\r
+ while((2.0 * m_y_max/m_step) > 10)\r
+ {\r
+ m_step *= 2.0;\r
+ }\r
+ while((2.0 * m_y_max/m_step) < 4)\r
+ {\r
+ m_step /= 2.0;\r
+ }\r
+ // fl_color(FL_DARK_GREEN);\r
+ // fl_line_style(FL_DOT);\r
+ for(i =- m_y_max; i < m_y_max; i += m_step)\r
+ {\r
+ x1 = m_x;\r
+ y1 = m_y + m_h/2 - i * y_scale;\r
+ x2 = m_x + m_w;\r
+ y2 = y1;\r
+ //fl_line(x1, y1, x2, y2);\r
+ }\r
+\r
+ // y axis graticule labels\r
+ // fl_color(FL_GREEN);\r
+ // fl_line_style(FL_SOLID);\r
+ for(i =- m_y_max; i < m_y_max; i += m_step)\r
+ {\r
+ x1 = m_x;\r
+ y1 = m_y + m_h/2 - i * y_scale;\r
+ sprintf(label, "%d", i);\r
+ //fl_draw(label, x1, y1);\r
+ }\r
+ //fl_pop_clip();\r
+}
+\r
+// // update average of each spectrum point\r
+// void new_data(float mag_dB[])\r
+// {\r
+// int i;\r
+//\r
+// for(i=0; i<FDMDV_NSPEC; i++)
+// {\r
+// av_mag[i] = (1.0 - BETA)*av_mag[i] + BETA*mag_dB[i];
+// }\r
+// }
--- /dev/null
+//==========================================================================\r
+// Name: fdmdv2_scalar.h\r
+// Purpose: Defines a scalar plot derivative of fdmdv2_plot.\r
+// Created: June 22, 2012
+// Initial author: David Witten\r
+// Derived from: code written by David Rowe\r
+// License: BSD License (other licenses may apply to other\r
+// components of this project)\r
+//==========================================================================\r
+#ifndef __FDMDV2_PLOT_SCALAR__
+#define __FDMDV2_PLOT_SCALAR__
+
+\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
+// Class Scalar\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=\r
+class Scalar: public DrawPanel\r
+{\r
+public:\r
+\r
+ Scalar(wxFrame* parent, int x, int y, int w, int h, int x_max_, int y_max_, const char name[]);\r
+ ~Scalar();\r
+ void add_new_sample(float sample);\r
+ \r
+protected:\r
+\r
+ int m_x_max;\r
+ int m_y_max;\r
+ float *m_mem; /* array of x_max samples */\r
+ float m_new_sample;\r
+ int m_index;\r
+ int m_step;\r
+\r
+ int clip(int y1);\r
+ void draw();\r
+};\r
+\r
+//// update average of each spectrum point\r
+//void new_data(float mag_dB[])\r
+//{\r
+// int i;\r
+//\r
+// for(i=0; i<FDMDV_NSPEC; i++)\r
+// {\r
+// av_mag[i] = (1.0 - BETA)*av_mag[i] + BETA*mag_dB[i];\r
+// }\r
+//}\r
+\r
+#endif // __FDMDV2_PLOT_SCALAR__
+\r
+++ /dev/null
-#include "paclass.h"
-
-PortAudioWrap::PortAudioWrap()
-{
- stream = NULL;\r
- userData = NULL;\r
- samplerate = 0;\r
- framesPerBuffer = 0;
- statusFlags = 0;\r
- streamCallback = NULL;\r
- streamFinishedCallback = NULL;\r
- timeInfo = 0;
-}
-
-PortAudioWrap::~PortAudioWrap()
-{
-}
-
-//PaError PortAudioWrap::init()
-//{
-// return Pa_Initialize();
-//}
-
-PaError PortAudioWrap::streamOpen()\r
-{
- return Pa_OpenStream(
- &stream,
- &inputBuffer,
- &outputBuffer,
- samplerate,
- framesPerBuffer,
- statusFlags,
- *streamCallback,
- userData
- );
-}
-
-PaError PortAudioWrap::streamStart()\r
-{
- return Pa_StartStream(stream);
-}
-
-PaError PortAudioWrap::streamClose()\r
-{
- if(isOpen())
- {
- PaError rv = Pa_CloseStream(stream);
-// stream = NULL;
- return rv;
- }
- else
- {
- return paNoError;
- }
-}
-\r
-void PortAudioWrap::terminate()\r
-{
- if(Pa_IsStreamStopped(stream) != paNoError)
- {
- Pa_StopStream(stream);
- }
- Pa_Terminate();
-}
-\r
-void PortAudioWrap::stop()
-{
- Pa_StopStream(stream);
-}
-
-void PortAudioWrap::abort()
-{
- Pa_AbortStream(stream);
-}
-
-bool PortAudioWrap::isStopped() const
-{
- PaError ret = Pa_IsStreamStopped(stream);
- return ret;
-}
-
-bool PortAudioWrap::isActive() const
-{
- PaError ret = Pa_IsStreamActive(stream);
- return ret;
-}
-
-bool PortAudioWrap::isOpen() const\r
-{\r
- return (stream != NULL);\r
-}\r
-
-PaDeviceIndex PortAudioWrap::getDefaultInputDevice()
-{
- return Pa_GetDefaultInputDevice();
-}
-
-PaDeviceIndex PortAudioWrap::getDefaultOutputDevice()
-{
- return Pa_GetDefaultOutputDevice();
-}
-
-PaError PortAudioWrap::setInputChannelCount(int count)
-{
- inputBuffer.channelCount = count;
- return paNoError;
-}
-
-PaError PortAudioWrap::getInputChannelCount()
-{
- return inputBuffer.channelCount;
-}
-
-PaError PortAudioWrap::setInputSampleFormat(PaSampleFormat format)
-{
- inputBuffer.sampleFormat = format;
- return paNoError;
-}
-
-PaError PortAudioWrap::setInputLatency(PaTime latency)
-{
- inputBuffer.suggestedLatency = latency;
- return paNoError;
-}
-\r
-void PortAudioWrap::setInputHostApiStreamInfo(void *info)
-{
- inputBuffer.hostApiSpecificStreamInfo = info;
-}
-\r
-PaTime PortAudioWrap::getInputDefaultLowLatency()
-{
- return Pa_GetDeviceInfo(inputBuffer.device)->defaultLowInputLatency;
-}
-
-PaError PortAudioWrap::setOutputChannelCount(int count)
-{
- outputBuffer.channelCount = count;
- return paNoError;
-}
-
-const int PortAudioWrap::getOutputChannelCount()
-{
- return outputBuffer.channelCount;
-}
-
-const char *PortAudioWrap::getDeviceName(PaDeviceIndex dev)
-{
- const PaDeviceInfo *info;
- info = Pa_GetDeviceInfo(dev);
- return info->name;
-}
-
-PaError PortAudioWrap::setOutputSampleFormat(PaSampleFormat format)
-{
- outputBuffer.sampleFormat = format;
- return paNoError;
-}
-
-PaError PortAudioWrap::setOutputLatency(PaTime latency)
-{
- outputBuffer.suggestedLatency = latency;
- return paNoError;
-}
-
-void PortAudioWrap::setOutputHostApiStreamInfo(void *info)
-{
- outputBuffer.hostApiSpecificStreamInfo = info;
-}
-
-PaTime PortAudioWrap::getOutputDefaultLowLatency()
-{
- return Pa_GetDeviceInfo(outputBuffer.device)->defaultLowOutputLatency;
-}
-
-PaError PortAudioWrap::setFramesPerBuffer(unsigned long size)
-{
- framesPerBuffer = size;
- return paNoError;
-}
-
-PaError PortAudioWrap::setSampleRate(unsigned long rate)\r
-{
- samplerate = rate;
- return paNoError;
-}
-
-PaError PortAudioWrap::setStreamFlags(PaStreamFlags flags)\r
-{
- statusFlags = flags;
- return paNoError;
-}
-
-PaError PortAudioWrap::setInputDevice(PaDeviceIndex index)\r
-{
-// inputDevice = index;
- inputBuffer.device = index;
- return paNoError;
-}
-
-PaError PortAudioWrap::setOutputDevice(PaDeviceIndex index)\r
-{
-// outputDevice = index;
- outputBuffer.device = index;
- return paNoError;
-}
-
-PaError PortAudioWrap::setCallback(PaStreamCallback *callback)\r
-{
- streamCallback = callback;
- return paNoError;
-}
+++ /dev/null
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-\r
-// Note that many of the older ISA sound cards on PCs do NOT support
-// full duplex audio (simultaneous record and playback).
-// And some only support full duplex at lower sample rates.
-#define SAMPLE_RATE (44100)
-#define PA_SAMPLE_TYPE paFloat32 //paInt16
-#define FRAMES_PER_BUFFER (64)
-
-typedef float SAMPLE;
-
-float CubicAmplifier(float input);
-
-class PortAudioWrap\r
-{\r
- public:\r
- PortAudioWrap();\r
- ~PortAudioWrap();\r
-\r
- private:\r
- PaStream *stream;\r
- PaStreamParameters inputBuffer;
- PaStreamParameters outputBuffer;
- void *userData;\r
- int samplerate;\r
- unsigned long framesPerBuffer;
- PaStreamCallbackFlags statusFlags;\r
- PaStreamCallback *streamCallback;\r
- PaStreamFinishedCallback *streamFinishedCallback;\r
- const PaStreamCallbackTimeInfo *timeInfo;
-// PaDeviceIndex inputDevice;
-// PaDeviceIndex outputDevice;
-\r
- public:\r
-
- PaError streamOpen();\r
-\r
- PaDeviceIndex getDefaultInputDevice();
- PaDeviceIndex getDefaultOutputDevice();\r
-\r
- PaStreamParameters *getDeviceInfo(PaDeviceIndex idx);\r
- PaError setFramesPerBuffer(unsigned long size);\r
- PaError setSampleRate(unsigned long size);\r
- PaError setStreamFlags(PaStreamFlags flags);\r
- PaError setCallback(PaStreamCallback *streamCallback);\r
- PaError setStreamCallback(PaStream *stream, PaStreamCallback* callback ) { streamCallback = callback; return 0;}
- PaError setStreamFinishedCallback(PaStream *stream, PaStreamFinishedCallback* streamFinishedCallback );
-
- PaError setInputDevice(PaDeviceIndex dev);\r
- PaError setInputChannelCount(int count);
- int getInputChannelCount();
- PaError setInputSampleFormat(PaSampleFormat format);
- PaError setInputSampleRate(PaSampleFormat format);
- PaError setInputLatency(PaTime latency);\r
- void setInputHostApiStreamInfo(void *info = NULL);\r
- PaTime getInputDefaultLowLatency();
- const char *getDeviceName(PaDeviceIndex dev);
-
- PaError setOutputDevice(PaDeviceIndex dev);\r
- PaError setOutputChannelCount(int count);
- const int getOutputChannelCount();
- PaError setOutputSampleFormat(PaSampleFormat format);
- PaError setOutputLatency(PaTime latency);
- void setOutputHostApiStreamInfo(void *info = NULL);
- PaTime getOutputDefaultLowLatency();
-\r
-// PaError init();\r
- PaError streamStart();\r
- PaError streamClose();\r
- void terminate();\r
- bool isOpen() const;\r
- void stop();
- void abort();
- bool isStopped() const;
- bool isActive() const;
-};\r