Audio bandwidth menu items

This commit is contained in:
Charles J. Cliffe 2015-03-12 19:41:50 -04:00
parent 84bd856c53
commit 3c5bad4e3d
5 changed files with 66 additions and 9 deletions

View File

@ -230,9 +230,39 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
p++;
}
menuBar->Append(menu, wxT("&Device"));
menuBar->Append(menu, wxT("Input &Device"));
}
menu = new wxMenu;
i = 0;
for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
new wxMenu;
int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * mdevices_i->first;
wxMenu *subMenu = new wxMenu;
menu->AppendSubMenu(subMenu,mdevices_i->second.name, wxT("Description?"));
int j = 0;
for (std::vector<unsigned int>::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end(); srate++) {
std::stringstream srateName;
srateName << ((float)(*srate)/1000.0f) << "kHz";
wxMenuItem *itm = subMenu->AppendRadioItem(menu_id+j, srateName.str(), wxT("Description?"));
if ((*srate) == DEFAULT_AUDIO_SAMPLE_RATE) {
itm->Check(true);
}
audioSampleRateMenuItems[menu_id+j] = itm;
j++;
}
}
menuBar->Append(menu, wxT("Audio &Bandwidth"));
SetMenuBar(menuBar);
CreateStatusBar();
@ -346,6 +376,31 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
if (event.GetId() >= wxID_DEVICE_ID && event.GetId() <= wxID_DEVICE_ID + devs->size()) {
wxGetApp().setDevice(event.GetId() - wxID_DEVICE_ID);
}
if (event.GetId() >= wxID_AUDIO_BANDWIDTH_BASE) {
int evId = event.GetId();
std::vector<RtAudio::DeviceInfo>::iterator devices_i;
std::map<int, RtAudio::DeviceInfo>::iterator mdevices_i;
int i = 0;
for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * mdevices_i->first;
int j = 0;
for (std::vector<unsigned int>::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end(); srate++) {
if (evId == menu_id + j) {
//audioSampleRateMenuItems[menu_id+j];
std::cout << "Would set audio sample rate on device " << mdevices_i->second.name << " (" << mdevices_i->first << ") to " << (*srate) << "Hz" << std::endl;
}
j++;
}
i++;
}
}
}
void AppFrame::OnClose(wxCommandEvent& WXUNUSED(event)) {

View File

@ -33,6 +33,10 @@
#define wxID_DEVICE_ID 3500
#define wxID_AUDIO_BANDWIDTH_BASE 9000
#define wxID_AUDIO_DEVICE_MULTIPLIER 50
// Define a new frame type
class AppFrame: public wxFrame {
@ -60,7 +64,6 @@ private:
MeterCanvas *demodSignalMeter;
MeterCanvas *demodGainMeter;
TuningCanvas *demodTuner;
// event table
DemodulatorInstance *activeDemodulator;
@ -68,9 +71,8 @@ private:
std::map<int,RtAudio::DeviceInfo> inputDevices;
std::map<int,RtAudio::DeviceInfo> outputDevices;
std::map<int, wxMenuItem *> outputDeviceMenuItems;
std::map<int, wxMenuItem *> sampleRateMenuItems;
std::map<int, wxMenuItem *> audioSampleRateMenuItems;
std::string currentSessionFile;

View File

@ -42,7 +42,7 @@ const char filePathSeparator =
#define DEFAULT_FFT_SIZE 2048
#define DEFAULT_FREQ 100000000
#define AUDIO_FREQUENCY 44100
#define DEFAULT_AUDIO_SAMPLE_RATE 44100
#define DEFAULT_DEMOD_TYPE 1
#define DEFAULT_DEMOD_BW 200000

View File

@ -128,7 +128,7 @@ public:
DemodulatorThreadParameters() :
frequency(0), sampleRate(DEFAULT_SAMPLE_RATE), bandwidth(200000), audioSampleRate(
AUDIO_FREQUENCY), demodType(DEMOD_TYPE_FM) {
DEFAULT_AUDIO_SAMPLE_RATE), demodType(DEMOD_TYPE_FM) {
}

View File

@ -47,7 +47,7 @@ void DemodulatorThread::threadMain() {
firfilt_rrrf firStereoRight = NULL;
// Stereo filters / shifters
double firStereoCutoff = 0.5 * ((double) 36000 / (double) AUDIO_FREQUENCY); // filter cutoff frequency
double firStereoCutoff = 0.5 * ((double) 36000 / (double) DEFAULT_AUDIO_SAMPLE_RATE); // filter cutoff frequency
float ft = 0.05f; // filter transition
float As = 120.0f; // stop-band attenuation [dB]
float mu = 0.0f; // fractional timing offset