1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
|
/////////////////////////////////////////////////////////////////////////////
// Name: dlg_audiointerface.cpp
// Purpose:
// Author:
// Modified by:
// Created: 29/03/2007 11:48:34
// RCS-ID:
// Copyright:
// Licence:
/////////////////////////////////////////////////////////////////////////////
/*
* Copyright (C) 2007-2008 Vaclav Peroutka <vaclavpe@seznam.cz>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "dlg_audiointerface.h"
#endif
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
////@begin includes
////@end includes
#include "dlg_audiointerface.h"
#include "event_ids.h"
////@begin XPM images
////@end XPM images
/*!
* AudioInterfaceDialog type definition
*/
IMPLEMENT_DYNAMIC_CLASS( AudioInterfaceDialog, wxDialog )
/*!
* AudioInterfaceDialog event table definition
*/
BEGIN_EVENT_TABLE( AudioInterfaceDialog, wxDialog )
////@begin AudioInterfaceDialog event table entries
////@end AudioInterfaceDialog event table entries
EVT_CHOICE(ID_OUTDEV_CHO, AudioInterfaceDialog::OnChoiceChanged)
EVT_CHOICE(ID_INDEV_CHO, AudioInterfaceDialog::OnChoiceChanged)
END_EVENT_TABLE()
/*!
* AudioInterfaceDialog constructors
*/
AudioInterfaceDialog::AudioInterfaceDialog( )
{
Init();
}
AudioInterfaceDialog::AudioInterfaceDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
Init();
Create(parent, id, caption, pos, size, style);
}
/*!
* AudioInterfaceDialog creator
*/
bool AudioInterfaceDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin AudioInterfaceDialog creation
SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
if (GetSizer())
{
GetSizer()->SetSizeHints(this);
}
Centre();
////@end AudioInterfaceDialog creation
return true;
}
/*!
* Member initialisation
*/
void AudioInterfaceDialog::Init()
{
////@begin AudioInterfaceDialog member initialisation
////@end AudioInterfaceDialog member initialisation
}
/*!
* Control creation for AudioInterfaceDialog
*/
void AudioInterfaceDialog::CreateControls()
{
////@begin AudioInterfaceDialog content construction
AudioInterfaceDialog* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
itemDialog1->SetSizer(itemBoxSizer2);
wxStaticBox * itemFreqStaticBox = new wxStaticBox( itemDialog1, wxID_ANY, _("Available Frequencies [kHz]"));
wxStaticBoxSizer* itemFreqStaticBoxSizer = new wxStaticBoxSizer(itemFreqStaticBox, wxHORIZONTAL);
itemBoxSizer2->Add(itemFreqStaticBoxSizer, 1, wxEXPAND|wxALL, 5);
wxString* itemFreqChoiceStrings = NULL;
wxChoice* itemFreqChoice = new wxChoice( itemDialog1, ID_FREQ_CHO, wxDefaultPosition, wxDefaultSize, 0, itemFreqChoiceStrings, 0 );
itemFreqStaticBoxSizer->Add(itemFreqChoice, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Output Audio Device"));
wxStaticBoxSizer* itemStaticBoxSizer3 = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxHORIZONTAL);
itemBoxSizer2->Add(itemStaticBoxSizer3, 1, wxEXPAND|wxALL, 5);
wxString* itemChoice4Strings = NULL;
wxChoice* itemChoice4 = new wxChoice( itemDialog1, ID_OUTDEV_CHO, wxDefaultPosition, wxDefaultSize, 0, itemChoice4Strings, 0 );
itemStaticBoxSizer3->Add(itemChoice4, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxStaticBox* itemStaticBoxSizer5Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Input Audio Device"));
wxStaticBoxSizer* itemStaticBoxSizer5 = new wxStaticBoxSizer(itemStaticBoxSizer5Static, wxHORIZONTAL);
itemBoxSizer2->Add(itemStaticBoxSizer5, 0, wxEXPAND|wxALL, 5);
wxString* itemChoice6Strings = NULL;
wxChoice* itemChoice6 = new wxChoice( itemDialog1, ID_INDEV_CHO, wxDefaultPosition, wxDefaultSize, 0, itemChoice6Strings, 0 );
itemStaticBoxSizer5->Add(itemChoice6, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer2->Add(itemBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10);
wxButton* itemButton8 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer7->Add(itemButton8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemBoxSizer7->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* itemButton10 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer7->Add(itemButton10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
////@end AudioInterfaceDialog content construction
}
/*!
* Should we show tooltips?
*/
bool AudioInterfaceDialog::ShowToolTips()
{
return true;
}
/*!
* Get bitmap resources
*/
wxBitmap AudioInterfaceDialog::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin AudioInterfaceDialog bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end AudioInterfaceDialog bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon AudioInterfaceDialog::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin AudioInterfaceDialog icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end AudioInterfaceDialog icon retrieval
}
void AudioInterfaceDialog::SetDevices( RWAudioDevList devreclist, RWAudioDevList devpllist)
{
unsigned int i;
m_DevRecList = devreclist;
m_DevPlayList = devpllist;
wxChoice* p_cho = (wxChoice *) FindWindow( ID_OUTDEV_CHO);
if(!p_cho) {
return;
}
p_cho->Clear();
for(i = 0; i< devpllist.card_info.size(); i++) {
wxString newstr(devpllist.card_info[i].name.c_str(), wxConvUTF8);
p_cho->Append( newstr);
}
p_cho->SetSelection(0);
p_cho = (wxChoice *) FindWindow( ID_INDEV_CHO);
if(!p_cho) {
return;
}
p_cho->Clear();
for(i = 0; i< devreclist.card_info.size(); i++) {
wxString newstr(devreclist.card_info[i].name.c_str(), wxConvUTF8);
p_cho->Append( newstr);
}
p_cho->SetSelection(0);
p_cho = (wxChoice *) FindWindow( ID_FREQ_CHO);
if(!p_cho) {
return;
}
p_cho->Clear();
// for(i = 0; i< freqs.GetCount(); i++) {
// p_cho->Append(freqs[i]);
// }
// p_cho->SetSelection(freqs.GetCount()-1);
}
void AudioInterfaceDialog::GetSelectedDevs( unsigned int * recdev, unsigned int * playdev, unsigned long int * newfreq)
{
wxString strfreq;
int seldev;
wxChoice* p_cho = (wxChoice *) FindWindow( ID_OUTDEV_CHO);
if(!p_cho) {
return;
}
seldev = p_cho->GetSelection();
*playdev = m_DevPlayList.card_pos[seldev];
p_cho = (wxChoice *) FindWindow( ID_INDEV_CHO);
if(!p_cho) {
return;
}
seldev = p_cho->GetSelection();
*recdev = m_DevRecList.card_pos[seldev];
p_cho = (wxChoice *) FindWindow( ID_FREQ_CHO);
if(!p_cho) {
return;
}
strfreq = p_cho->GetString(p_cho->GetSelection());
strfreq.ToULong( newfreq);
}
// fill the frequency table
void AudioInterfaceDialog::OnChoiceChanged(wxCommandEvent& WXUNUSED(event))
{
unsigned int pldev, recdev;
wxChoice* p_cho = (wxChoice *) FindWindow( ID_OUTDEV_CHO);
if(!p_cho) {
return;
}
pldev = p_cho->GetSelection();
p_cho = (wxChoice *) FindWindow( ID_INDEV_CHO);
if(!p_cho) {
return;
}
recdev = p_cho->GetSelection();
// clean the frequency list
p_cho = (wxChoice *) FindWindow( ID_FREQ_CHO);
if(!p_cho) {
return;
}
p_cho->Clear();
//std::cout << "\nPred loopou, pldev = " << pldev << " ; recdev = " << recdev ;
// compute the new list - find the same values in DevRecList and DevPlayList
for (unsigned int i = 0; i < m_DevPlayList.card_info[pldev].sampleRates.size(); i++) {
for (unsigned int j = 0; j < m_DevRecList.card_info[recdev].sampleRates.size(); j++) {
unsigned long int srateplay = m_DevPlayList.card_info[pldev].sampleRates[i];
unsigned long int sraterec = m_DevRecList.card_info[recdev].sampleRates[j];
if ( srateplay == sraterec ) {
p_cho->Append( wxString::Format(wxT("%ld "), srateplay));
}
}
}
if ( p_cho->GetCount() > 0) {
p_cho->SetSelection(p_cho->GetCount() -1);
}
}
|