pax_global_header00006660000000000000000000000064113103261770014513gustar00rootroot0000000000000052 comment=35cad70109b2abc36c2969e0f9c16b0a1f7524e3 alsoft-conf-1.4.3/000077500000000000000000000000001131032617700137335ustar00rootroot00000000000000alsoft-conf-1.4.3/CMakeLists.txt000066400000000000000000000014771131032617700165040ustar00rootroot00000000000000cmake_minimum_required(VERSION 2.4.7) SET( cmake_verbose_makefile TRUE) PROJECT( alsoft-conf ) SET( OSC_SRCS ./src/main.cpp ./src/main_window.cpp ./src/confirm_close.cpp ./src/new_parser.cpp ./src/speaker.cpp ) # Headers that should be moc'ed SET( OSC_MOC_HDRS ./src/speaker.h ./src/main_window.h ./src/confirm_close.h ) SET( OSC_UIS ./src/ui/main.ui ./src/ui/confirm_close.ui ) ADD_DEFINITIONS( -Wall) FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED) INCLUDE( ${QT_USE_FILE} ) QT4_WRAP_UI( OSC_UI_HDRS ${OSC_UIS} ) QT4_WRAP_CPP( OSC_MOC_SRCS ${OSC_MOC_HDRS} ) INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ) ADD_EXECUTABLE( alsoft-conf ${OSC_SRCS} ${OSC_MOC_SRCS} ${OSC_UI_HDRS} ) TARGET_LINK_LIBRARIES( alsoft-conf ${QT_LIBRARIES} ) INSTALL( PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/alsoft-conf DESTINATION bin) alsoft-conf-1.4.3/COPYING000066400000000000000000000354231131032617700147750ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS alsoft-conf-1.4.3/README000066400000000000000000000002161131032617700146120ustar00rootroot00000000000000BUILDING INSTRUCTIONS ===================== Really simple, just do: # mkdir build && cd build && cmake .. && make Then run: # ./alsoft-conf alsoft-conf-1.4.3/alsoft-conf.1000066400000000000000000000007431131032617700162340ustar00rootroot00000000000000.TH ALSOFT-CONF 1 "December 10, 2009" .SH NAME alsoft-conf \- OpenAL-Soft configuration utility .SH SYNOPSIS .B alsoft-conf .br .SH DESCRIPTION .PP \fBalsoft-conf\fP is GUI program written with Qt4 meant to aid in configuring OpenAL-Soft. .SH SEE ALSO .BR alsoft.conf (5). .br .SH AUTHOR alsoft-conf was written by Matias D'Ambrosio . .PP This manual page was written by Matias D'Ambrosio , for the Debian project (and may be used by others). alsoft-conf-1.4.3/alsoft-conf.desktop000066400000000000000000000001721131032617700175410ustar00rootroot00000000000000[Desktop Entry] Version=1.0 Type=Application Name=OpenAL-Soft Configuration Utility Exec=alsoft-conf Categories=Settings; alsoft-conf-1.4.3/src/000077500000000000000000000000001131032617700145225ustar00rootroot00000000000000alsoft-conf-1.4.3/src/confirm_close.cpp000066400000000000000000000022051131032617700200470ustar00rootroot00000000000000/************************************************************************** * alsoft-conf, a configuration utility for OpenAL-soft. * Copyright (C) 2008-2009 Matias D'Ambrosio * * 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, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. **************************************************************************/ #include "confirm_close.h" #include confirmClose::confirmClose( QDialog *parent) : QDialog (parent) { ui.setupUi( this); } confirmClose::~confirmClose() { } alsoft-conf-1.4.3/src/confirm_close.h000066400000000000000000000022711131032617700175170ustar00rootroot00000000000000/************************************************************************** * alsoft-conf, a configuration utility for OpenAL-soft. * Copyright (C) 2008-2009 Matias D'Ambrosio * * 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, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. **************************************************************************/ #ifndef CONFIRM_CLOSE_H__ #define CONFIRM_CLOSE_H__ #include "ui_confirm_close.h" class confirmClose : public QDialog { Q_OBJECT public: confirmClose( QDialog *parent=0); ~confirmClose(); Ui::Dialog ui; }; #endif alsoft-conf-1.4.3/src/main.cpp000066400000000000000000000026601131032617700161560ustar00rootroot00000000000000/************************************************************************** * alsoft-conf, a configuration utility for OpenAL-soft. * Copyright (C) 2008-2009 Matias D'Ambrosio * * 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, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. **************************************************************************/ #include #include "main_window.h" #ifndef _WIN32 #include #endif int main( int argc, char** argv) { QApplication app(argc, argv); mainWindow main_window; #ifndef _WIN32 if( getuid() == 0){ main_window.loadGlobalConfig(); }else{ main_window.loadLocalConfig(); } #else // Windows doesn't have a global config main_window.loadLocalConfig(); #endif main_window.hideGlobalOrLocalButton(); main_window.show(); return app.exec(); } alsoft-conf-1.4.3/src/main_window.cpp000066400000000000000000001035561131032617700175530ustar00rootroot00000000000000/************************************************************************** * alsoft-conf, a configuration utility for OpenAL-soft. * Copyright (C) 2008-2009 Matias D'Ambrosio * * 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, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. **************************************************************************/ #include "main_window.h" #include #include #include #include #define MONO 0 #define HEADPHONES 1 #define STEREO 2 #define QUAD 3 #define CHN51 4 #define CHN61 5 #define CHN71 6 static int layout_parse( const char *which, const char *entry) { const char *needle = strcasestr( entry, which); if( needle == NULL){ return 0; } int value = 0; int len = strlen( needle); int iter = 0; char *endptr = NULL; while( iter < len){ if( needle[ iter] == '='){ iter++; value = (int) strtol( needle + iter, &endptr, 10); if( endptr == needle + iter){ return 0; } return value; } iter++; } return 0; } void mainWindow::saveSpeakerLayout( int layout) { QString layout_string; if( layout == HEADPHONES){ layout_string = "fl=" + QString::number( speaker_fl->getAngle()) + ", fr=" + QString::number( speaker_fr->getAngle()); np_set_string( dict, "general", "layout_STEREO", layout_string.toAscii().data()); } else if( layout == STEREO){ layout_string = "fl=" + QString::number( speaker_fl->getAngle()) + ", fr=" + QString::number( speaker_fr->getAngle()); np_set_string( dict, "general", "layout_STEREO", layout_string.toAscii().data()); } else if( layout == QUAD){ layout_string = "bl=" + QString::number( speaker_bl->getAngle()) + ", fl=" + QString::number( speaker_fl->getAngle()) + ", fr=" + QString::number( speaker_fr->getAngle()) + ", br=" + QString::number( speaker_br->getAngle()); np_set_string( dict, "general", "layout_QUAD", layout_string.toAscii().data()); } else if( layout == CHN51){ layout_string = "bl=" + QString::number( speaker_bl->getAngle()) + ", fl=" + QString::number( speaker_fl->getAngle()) + ", fc=" + QString::number( speaker_fc->getAngle()) + ", fr=" + QString::number( speaker_fr->getAngle()) + ", br=" + QString::number( speaker_br->getAngle()); np_set_string( dict, "general", "layout_51CHN", layout_string.toAscii().data()); } else if( layout == CHN61){ layout_string = "sl=" + QString::number( speaker_sl->getAngle()) + ", fl=" + QString::number( speaker_fl->getAngle()) + ", fc=" + QString::number( speaker_fc->getAngle()) + ", fr=" + QString::number( speaker_fr->getAngle()) + ", sr=" + QString::number( speaker_sr->getAngle())+ ", bc=" + QString::number( speaker_bc->getAngle()); np_set_string( dict, "general", "layout_61CHN", layout_string.toAscii().data()); } else if( layout == CHN71){ layout_string = "bl=" + QString::number( speaker_bl->getAngle()) + ", sl=" + QString::number( speaker_sl->getAngle()) + ", fl=" + QString::number( speaker_fl->getAngle()) + ", fc=" + QString::number( speaker_fc->getAngle()) + ", fr=" + QString::number( speaker_fr->getAngle()) + ", sr=" + QString::number( speaker_sr->getAngle()) + ", br=" + QString::number( speaker_br->getAngle()); np_set_string( dict, "general", "layout_71CHN", layout_string.toAscii().data()); } } void mainWindow::removeAllSpeakers( void) { ui.speaker_bl_spinBox->setEnabled( false); ui.speaker_bl_label->setEnabled( false); scene->removeItem( speaker_bl); ui.speaker_sl_spinBox->setEnabled( false); ui.speaker_sl_label->setEnabled( false); scene->removeItem( speaker_sl); ui.speaker_fl_spinBox->setEnabled( false); ui.speaker_fl_label->setEnabled( false); scene->removeItem( speaker_fl); ui.speaker_fc_spinBox->setEnabled( false); ui.speaker_fc_label->setEnabled( false); scene->removeItem( speaker_fc); ui.speaker_fr_spinBox->setEnabled( false); ui.speaker_fr_label->setEnabled( false); scene->removeItem( speaker_fr); ui.speaker_sr_spinBox->setEnabled( false); ui.speaker_sr_label->setEnabled( false); scene->removeItem( speaker_sr); ui.speaker_br_spinBox->setEnabled( false); ui.speaker_br_label->setEnabled( false); scene->removeItem( speaker_br); ui.speaker_bc_spinBox->setEnabled( false); ui.speaker_bc_label->setEnabled( false); scene->removeItem( speaker_bc); } mainWindow::mainWindow( QMainWindow *parent) : QMainWindow (parent), modified (false), onGlobal(false), dictionaryFilename (NULL) , dict(NULL) , scene( NULL) { ui.setupUi( this); QValidator *validator = new QIntValidator( 0, 2147483647, this); ui.frequency_comboBox->setValidator( validator); QObject::connect( confirmDialog.ui.buttonBox, SIGNAL( accepted()), this, SLOT( wrapUpAndLeave())); QObject::connect( confirmDialog.ui.buttonBox, SIGNAL( rejected()), this, SLOT( continueEditing())); ui.backends_in_use_listWidget->setDragDropOverwriteMode( true); ui.disabled_backends_listWidget->setDragDropOverwriteMode( true); scene = new QGraphicsScene; speaker_bl = new SpeakerItem( -150, 20); QObject::connect( speaker_bl, SIGNAL( valueChanged( int)), ui.speaker_bl_spinBox, SLOT( setValue( int))); scene->addItem( speaker_bl); speaker_sl = new SpeakerItem( -110, 20); QObject::connect( speaker_sl, SIGNAL( valueChanged( int)), ui.speaker_sl_spinBox, SLOT( setValue( int))); scene->addItem( speaker_sl); speaker_fl = new SpeakerItem( -30, 20); QObject::connect( speaker_fl, SIGNAL( valueChanged( int)), ui.speaker_fl_spinBox, SLOT( setValue( int))); scene->addItem( speaker_fl); speaker_fc = new SpeakerItem( 0, 20); QObject::connect( speaker_fc, SIGNAL( valueChanged( int)), ui.speaker_fc_spinBox, SLOT( setValue( int))); scene->addItem( speaker_fc); speaker_fr = new SpeakerItem( 30, 20); QObject::connect( speaker_fr, SIGNAL( valueChanged( int)), ui.speaker_fr_spinBox, SLOT( setValue( int))); scene->addItem( speaker_fr); speaker_sr = new SpeakerItem( 110, 20); QObject::connect( speaker_sr, SIGNAL( valueChanged( int)), ui.speaker_sr_spinBox, SLOT( setValue( int))); scene->addItem( speaker_sr); speaker_br = new SpeakerItem( 150, 20); QObject::connect( speaker_br, SIGNAL( valueChanged( int)), ui.speaker_br_spinBox, SLOT( setValue( int))); scene->addItem( speaker_br); speaker_bc = new SpeakerItem( 180, 20); QObject::connect( speaker_bc, SIGNAL( valueChanged( int)), ui.speaker_bc_spinBox, SLOT( setValue( int))); scene->addItem( speaker_bc); QGraphicsItem *item = new SpeakerItem( 40, 40, 60); item->setFlag( QGraphicsItem::ItemIsMovable, false); scene->addItem( item); ui.graphicsView->setScene( scene); ui.graphicsView->show(); } mainWindow::~mainWindow() { np_destroy_dictionary( &dict); } void mainWindow::wrapUpAndLeave( void) { exit( 0); } void mainWindow::continueEditing( void) { this->setEnabled( true); } void mainWindow::hideGlobalOrLocalButton( void) { ui.global_or_local_pushButton->hide(); } void mainWindow::loadGlobalConfig(void) { onGlobal = true; loadConfig("/etc/openal/alsoft.conf"); //TODO Do some error checking } void mainWindow::loadLocalConfig(void) { char *filename = NULL; size_t len=0; #ifdef _WIN32 filename = malloc(MAX_PATH); filename[MAX_PATH - 1] = '\0'; if( SHGetSpecialFolderPathA(NULL, filename, CSIDL_APPDATA, FALSE) != FALSE){ len = strlen( filename); _snprintf( filename+len, MAX_PATH-len, "\\alsoft.ini"); loadConfig(filename); //TODO Add error checking } free(filename); #else if( getenv("HOME")){ len = strlen(getenv("HOME")) + strlen("/.alsoftrc") + 1; filename = (char *) malloc( len); snprintf( filename, len, "%s/.alsoftrc", getenv("HOME")); loadConfig(filename); free( filename); #endif }else{ //TODO Do some error reporting. } } bool mainWindow::string2bool( QString duplicate) { duplicate = duplicate.toLower(); bool isNumber=false; if( duplicate == "true" || duplicate == "yes" || duplicate == "on" || (duplicate.toInt(&isNumber) != 0 && isNumber)){ return true; }else{ return false; } } void mainWindow::loadConfig(const char *filename) { np_destroy_dictionary( &dict); FILE *fp = fopen( filename, "rt"); if( fp){ fclose( fp); }else{ fp = fopen( filename, "wt"); if( fp){ fclose( fp); }else{ fprintf(stderr, "ERROR: Can't create %s\n", filename); //TODO Show some kind of error dialog. } } if( np_load_dictionary( filename, &dict) < 0){ //TODO Error checking would be nice. ; } if( dictionaryFilename){ free( dictionaryFilename); } dictionaryFilename = strdup( filename); ui.frequency_comboBox->setEditText( np_get_string( dict, "general", "frequency", "44100")); ui.period_size_spinBox->setValue( np_get_long( dict, "general", "period_size", 1024)); ui.periods_spinBox->setValue( np_get_long( dict, "general", "periods", 4)); ui.sources_spinBox->setValue( np_get_long( dict, "general", "sources", 256)); long cf = np_get_long( dict, "general", "cf_level", 0); if( cf == 0){ ui.easy_crossfeed_checkBox->setEnabled( false); ui.crossfeed_comboBox->setCurrentIndex( 0); }else{ ui.easy_crossfeed_checkBox->setEnabled( true); if( cf > 3){ cf -= 3; ui.easy_crossfeed_checkBox->setChecked( true); } ui.crossfeed_comboBox->setCurrentIndex(cf); } if( string2bool( np_get_string( dict, "general", "stereodup", "no"))){ ui.dupstereo_checkBox->setChecked( true); }else{ ui.dupstereo_checkBox->setChecked( false); } // output format QString output_format ( np_get_string( dict, "general", "format", "AL_FORMAT_STEREO16")); output_format.remove( 0, (int) strlen( "AL_FORMAT_")); int len = output_format.length(); if( output_format.data()[len-1] == '8'){ output_format.chop(1); ui.sample_depth_comboBox->setCurrentIndex(0); }else{ // Ends in 16 output_format.chop(2); ui.sample_depth_comboBox->setCurrentIndex(1); } ui.layout_custom_radioButton->setChecked( true); int speaker_index; if( output_format == "MONO"){ speaker_index = MONO; }else if( output_format == "STEREO"){ QString stereo_layout ( np_get_string( dict, "general", "layout_STEREO", "fl=-90, fr=90")); if( layout_parse( "fl", stereo_layout.toAscii().data()) == -90 && layout_parse( "fr", stereo_layout.toAscii().data()) == 90){ speaker_index = HEADPHONES; } else{ speaker_index = STEREO; } }else if( output_format == "QUAD"){ speaker_index = QUAD; }else if( output_format == "51CHN"){ speaker_index = CHN51; }else if( output_format == "61CHN"){ speaker_index = CHN61; }else if( output_format == "71CHN"){ speaker_index = CHN71; }else{ speaker_index = STEREO; } ui.speakers_comboBox->setCurrentIndex( speaker_index); on_speakers_comboBox_currentIndexChanged( speaker_index); // driver list QString drivers( np_get_string( dict, "general", "drivers", "alsa,oss,solaris,dsound,winmm,wport,pulse,wave")); if( drivers == ""){ drivers = "alsa,oss,solaris,dsound,winmm,wport,pulse,wave"; } ui.backends_in_use_listWidget->clear(); ui.disabled_backends_listWidget->clear(); ui.disabled_backends_listWidget->addItem( getLongName( "alsa")); ui.disabled_backends_listWidget->addItem( getLongName( "dsound")); ui.disabled_backends_listWidget->addItem( getLongName( "oss")); ui.disabled_backends_listWidget->addItem( getLongName( "port")); ui.disabled_backends_listWidget->addItem( getLongName( "pulse")); ui.disabled_backends_listWidget->addItem( getLongName( "solaris")); ui.disabled_backends_listWidget->addItem( getLongName( "winmm")); ui.disabled_backends_listWidget->addItem( getLongName( "wave")); drivers = drivers.simplified(); drivers.remove( QChar(' ')); QStringList enabledDrivers( drivers.split( ",")); QList item_list; for( int q=0; q < enabledDrivers.size(); q++){ item_list = ui.disabled_backends_listWidget->findItems( getLongName(enabledDrivers.at(q)), Qt::MatchExactly); if( item_list.isEmpty()){ continue; } ui.disabled_backends_listWidget->takeItem( ui.disabled_backends_listWidget->row( item_list[0])); ui.backends_in_use_listWidget->addItem( item_list[0]); } // Excluded effects list QString effects( np_get_string( dict, "general", "excludefx", "")); ui.excluded_effects_listWidget->clear(); ui.allowed_effects_listWidget->clear(); ui.allowed_effects_listWidget->addItem( getLongName( "echo")); ui.allowed_effects_listWidget->addItem( getLongName( "reverb")); ui.allowed_effects_listWidget->addItem( getLongName( "eaxreverb")); effects = effects.simplified(); effects.remove( QChar(' ')); QStringList excludedEffects( effects.split( ",")); QList effect_list; for( int q=0; q < excludedEffects.size(); q++){ effect_list = ui.allowed_effects_listWidget->findItems( getLongName(excludedEffects.at(q)), Qt::MatchExactly); if( effect_list.isEmpty()){ continue; } ui.allowed_effects_listWidget->takeItem( ui.allowed_effects_listWidget->row( effect_list[0])); ui.excluded_effects_listWidget->addItem( effect_list[0]); } // Effects EFX ui.EFX_slots_spinBox->setValue( np_get_long( dict, "general", "slots", 4)); ui.EFX_sends_spinBox->setValue( np_get_long( dict, "general", "sends", 2)); // ALSA ui.ALSA_device_lineEdit->setText( np_get_string( dict, "alsa", "device", "default")); ui.ALSA_capture_lineEdit->setText( np_get_string( dict, "alsa", "capture", "default")); if( string2bool( np_get_string( dict, "alsa", "mmap", "yes"))){ ui.ALSA_mmap_checkBox->setChecked( true); }else{ ui.ALSA_mmap_checkBox->setChecked( false); } // OSS ui.OSS_device_lineEdit->setText( np_get_string( dict, "oss", "device", "/dev/dsp")); ui.OSS_capture_lineEdit->setText( np_get_string( dict, "oss", "capture", "/dev/dsp")); // PortAudio ui.PortAudio_device_index_spinBox->setValue( np_get_long( dict, "port", "device", -1)); // PulseAudio // Solaris ui.Solaris_device_lineEdit->setText( np_get_string( dict, "solaris", "device", "/dev/audio")); // DirectSound // Windows MultiMedia // WAVE File Writer ui.WAVE_file_lineEdit->setText( np_get_string( dict, "wave", "file", "")); setModified( false); } void mainWindow::on_speakers_comboBox_currentIndexChanged( int index) { if( index < 0){ return; } setModified( true); saveSpeakerLayout( index); currentSpeakerIndex = index; if( index == 0){ // mono ui.layout_presets_stackedWidget->setCurrentIndex( 1); ui.layout_options_stackedWidget->setCurrentIndex( 2); removeAllSpeakers(); } else if( index == 1){ // headphones ui.layout_presets_stackedWidget->setCurrentIndex( 1); ui.layout_options_stackedWidget->setCurrentIndex( 0); speaker_fl->setAngle( -90); speaker_fr->setAngle( 90); removeAllSpeakers(); ui.speaker_fl_spinBox->setEnabled( true); ui.speaker_fl_label->setEnabled( true); scene->addItem( speaker_fl); ui.speaker_fr_spinBox->setEnabled( true); ui.speaker_fr_label->setEnabled( true); scene->addItem( speaker_fr); } else if( index == 2){ // stereo ui.layout_presets_stackedWidget->setCurrentIndex( 0); ui.layout_options_stackedWidget->setCurrentIndex( 0); char *speakers = np_get_string( dict, "general", "layout_STEREO", "fl=-30, fr=30"); speaker_fl->setAngle( layout_parse( "fl", speakers)); speaker_fr->setAngle( layout_parse( "fr", speakers)); free( speakers); speakers = NULL; removeAllSpeakers(); ui.speaker_fl_spinBox->setEnabled( true); ui.speaker_fl_label->setEnabled( true); scene->addItem( speaker_fl); ui.speaker_fr_spinBox->setEnabled( true); ui.speaker_fr_label->setEnabled( true); scene->addItem( speaker_fr); } else if( index == 3){ // quadraphonic ui.layout_presets_stackedWidget->setCurrentIndex( 1); ui.layout_options_stackedWidget->setCurrentIndex( 1); char *speakers = np_get_string( dict, "general", "layout_QUAD", "bl=-135, fl=-45, fr=45, br=135"); speaker_bl->setAngle( layout_parse( "bl", speakers)); speaker_fl->setAngle( layout_parse( "fl", speakers)); speaker_fr->setAngle( layout_parse( "fr", speakers)); speaker_br->setAngle( layout_parse( "br", speakers)); free( speakers); speakers = NULL; removeAllSpeakers(); ui.speaker_bl_spinBox->setEnabled( true); ui.speaker_bl_label->setEnabled( true); scene->addItem( speaker_bl); ui.speaker_fl_spinBox->setEnabled( true); ui.speaker_fl_label->setEnabled( true); scene->addItem( speaker_fl); ui.speaker_fr_spinBox->setEnabled( true); ui.speaker_fr_label->setEnabled( true); scene->addItem( speaker_fr); ui.speaker_br_spinBox->setEnabled( true); ui.speaker_br_label->setEnabled( true); scene->addItem( speaker_br); } else if( index == 4){ // 5.1 ui.layout_presets_stackedWidget->setCurrentIndex( 1); ui.layout_options_stackedWidget->setCurrentIndex( 1); char *speakers = np_get_string( dict, "general", "layout_51CHN", "bl=-110, fl=-30, fc=0, fr=30, br=110"); speaker_bl->setAngle( layout_parse( "bl", speakers)); speaker_fl->setAngle( layout_parse( "fl", speakers)); speaker_fc->setAngle( layout_parse( "fc", speakers)); speaker_fr->setAngle( layout_parse( "fr", speakers)); speaker_br->setAngle( layout_parse( "br", speakers)); free( speakers); speakers = NULL; removeAllSpeakers(); ui.speaker_bl_spinBox->setEnabled( true); ui.speaker_bl_label->setEnabled( true); scene->addItem( speaker_bl); ui.speaker_fl_spinBox->setEnabled( true); ui.speaker_fl_label->setEnabled( true); scene->addItem( speaker_fl); ui.speaker_fc_spinBox->setEnabled( true); ui.speaker_fc_label->setEnabled( true); scene->addItem( speaker_fc); ui.speaker_fr_spinBox->setEnabled( true); ui.speaker_fr_label->setEnabled( true); scene->addItem( speaker_fr); ui.speaker_br_spinBox->setEnabled( true); ui.speaker_br_label->setEnabled( true); scene->addItem( speaker_br); } else if( index == 5){ // 6.1 ui.layout_presets_stackedWidget->setCurrentIndex( 1); ui.layout_options_stackedWidget->setCurrentIndex( 1); char *speakers = np_get_string( dict, "general", "layout_61CHN", "sl=-90, fl=-30, fc=0, fr=30, br=90, bc=180"); speaker_bl->setAngle( layout_parse( "bl", speakers)); speaker_fl->setAngle( layout_parse( "fl", speakers)); speaker_fc->setAngle( layout_parse( "fc", speakers)); speaker_fr->setAngle( layout_parse( "fr", speakers)); speaker_br->setAngle( layout_parse( "br", speakers)); speaker_bc->setAngle( layout_parse( "bc", speakers)); free( speakers); speakers = NULL; removeAllSpeakers(); ui.speaker_sl_spinBox->setEnabled( true); ui.speaker_sl_label->setEnabled( true); scene->addItem( speaker_sl); ui.speaker_fl_spinBox->setEnabled( true); ui.speaker_fl_label->setEnabled( true); scene->addItem( speaker_fl); ui.speaker_fc_spinBox->setEnabled( true); ui.speaker_fc_label->setEnabled( true); scene->addItem( speaker_fc); ui.speaker_fr_spinBox->setEnabled( true); ui.speaker_fr_label->setEnabled( true); scene->addItem( speaker_fr); ui.speaker_sr_spinBox->setEnabled( true); ui.speaker_sr_label->setEnabled( true); scene->addItem( speaker_sr); ui.speaker_bc_spinBox->setEnabled( true); ui.speaker_bc_label->setEnabled( true); scene->addItem( speaker_bc); } else if( index == 6){ // 7.1 ui.layout_presets_stackedWidget->setCurrentIndex( 1); ui.layout_options_stackedWidget->setCurrentIndex( 1); char *speakers = np_get_string( dict, "general", "layout_71CHN", "bl=-150, sl=-90, fl=-30, fc=0, fr=30, sr=90, br=150"); speaker_bl->setAngle( layout_parse( "bl", speakers)); speaker_sl->setAngle( layout_parse( "sl", speakers)); speaker_fl->setAngle( layout_parse( "fl", speakers)); speaker_fc->setAngle( layout_parse( "fc", speakers)); speaker_fr->setAngle( layout_parse( "fr", speakers)); speaker_sr->setAngle( layout_parse( "sr", speakers)); speaker_br->setAngle( layout_parse( "br", speakers)); free( speakers); speakers = NULL; removeAllSpeakers(); ui.speaker_bl_spinBox->setEnabled( true); ui.speaker_bl_label->setEnabled( true); scene->addItem( speaker_bl); ui.speaker_sl_spinBox->setEnabled( true); ui.speaker_sl_label->setEnabled( true); scene->addItem( speaker_sl); ui.speaker_fl_spinBox->setEnabled( true); ui.speaker_fl_label->setEnabled( true); scene->addItem( speaker_fl); ui.speaker_fc_spinBox->setEnabled( true); ui.speaker_fc_label->setEnabled( true); scene->addItem( speaker_fc); ui.speaker_fr_spinBox->setEnabled( true); ui.speaker_fr_label->setEnabled( true); scene->addItem( speaker_fr); ui.speaker_sr_spinBox->setEnabled( true); ui.speaker_sr_label->setEnabled( true); scene->addItem( speaker_sr); ui.speaker_br_spinBox->setEnabled( true); ui.speaker_br_label->setEnabled( true); scene->addItem( speaker_br); } } void mainWindow::on_crossfeed_comboBox_currentIndexChanged( int index) { if( index < 0){ return; } else if( index == 0){ ui.easy_crossfeed_checkBox->setEnabled( false); } else{ ui.easy_crossfeed_checkBox->setEnabled( true); } setModified( true); } // Feed the three angles, and it returns a valid angle (if it was invalid, it'll move it to the nearest, minus one to the inside) int mainWindow::validAngle( int cwise, int currentAngle, int countercwise) { if( cwise > currentAngle && currentAngle > countercwise) return currentAngle; else if( cwise > currentAngle && cwise < countercwise && currentAngle < countercwise) return currentAngle; else if( currentAngle > countercwise && cwise < currentAngle && cwise < countercwise) return currentAngle; // By this point we know it's the wrong angle if( currentAngle < countercwise && currentAngle < cwise) return countercwise + 1; else if( currentAngle > countercwise && currentAngle > cwise) return cwise - 1; else if( currentAngle - cwise > currentAngle - countercwise) return cwise == -179 ? 180 : cwise - 1; else return countercwise == 180 ? -179 : countercwise + 1; } void mainWindow::speakerOrderCheck( void) { // TODO Not properly implemented yet, so it's disabled return; if( currentSpeakerIndex == MONO || currentSpeakerIndex == HEADPHONES || currentSpeakerIndex == STEREO){ return; } int bl = ui.speaker_bl_spinBox->value(); int sl = ui.speaker_sl_spinBox->value(); int fl = ui.speaker_fl_spinBox->value(); int fc = ui.speaker_fc_spinBox->value(); int fr = ui.speaker_fr_spinBox->value(); int sr = ui.speaker_sr_spinBox->value(); int br = ui.speaker_br_spinBox->value(); int bc = ui.speaker_bc_spinBox->value(); if( currentSpeakerIndex == QUAD){ speaker_bl->setAngle( validAngle( fl, bl, br)); speaker_fl->setAngle( validAngle( fr, fl, bl)); speaker_fr->setAngle( validAngle( br, fr, fl)); } else if( currentSpeakerIndex == CHN51){ speaker_bl->setAngle( validAngle( fl, bl, br)); speaker_fl->setAngle( validAngle( fc, fl, bl)); speaker_fc->setAngle( validAngle( fr, fc, fl)); speaker_fr->setAngle( validAngle( br, fr, fl)); } else if( currentSpeakerIndex == CHN61){ speaker_sl->setAngle( validAngle( fl, sl, bc)); speaker_fl->setAngle( validAngle( fc, fl, sl)); speaker_fc->setAngle( validAngle( fr, fc, fl)); speaker_fr->setAngle( validAngle( sr, fr, fc)); speaker_sr->setAngle( validAngle( bc, sr, fr)); } else if( currentSpeakerIndex == CHN71){ speaker_bl->setAngle( validAngle( sl, bl, bc)); speaker_sl->setAngle( validAngle( fl, sl, bl)); speaker_fl->setAngle( validAngle( fc, fl, sl)); speaker_fc->setAngle( validAngle( fr, fc, fl)); speaker_fr->setAngle( validAngle( sr, fr, fc)); speaker_sr->setAngle( validAngle( bc, sr, fr)); } } void mainWindow::on_speaker_bl_spinBox_valueChanged( int i) { speaker_bl->setAngle( i); speakerOrderCheck(); saveSpeakerLayout( currentSpeakerIndex); setModified( true); } void mainWindow::on_speaker_sl_spinBox_valueChanged( int i) { speaker_sl->setAngle( i); speakerOrderCheck(); saveSpeakerLayout( currentSpeakerIndex); setModified( true); } void mainWindow::on_speaker_fl_spinBox_valueChanged( int i) { speaker_fl->setAngle( i); speakerOrderCheck(); saveSpeakerLayout( currentSpeakerIndex); setModified( true); } void mainWindow::on_speaker_fc_spinBox_valueChanged( int i) { speaker_fc->setAngle( i); speakerOrderCheck(); saveSpeakerLayout( currentSpeakerIndex); setModified( true); } void mainWindow::on_speaker_fr_spinBox_valueChanged( int i) { speaker_fr->setAngle( i); speakerOrderCheck(); saveSpeakerLayout( currentSpeakerIndex); setModified( true); } void mainWindow::on_speaker_sr_spinBox_valueChanged( int i) { speaker_sr->setAngle( i); speakerOrderCheck(); saveSpeakerLayout( currentSpeakerIndex); setModified( true); } void mainWindow::on_speaker_br_spinBox_valueChanged( int i) { speaker_br->setAngle( i); speakerOrderCheck(); saveSpeakerLayout( currentSpeakerIndex); setModified( true); } void mainWindow::on_speaker_bc_spinBox_valueChanged( int i) { speaker_bc->setAngle( i); speakerOrderCheck(); saveSpeakerLayout( currentSpeakerIndex); setModified( true); } void mainWindow::on_layout_default_radioButton_clicked( bool checked) { speaker_fl->setAngle( -40); speaker_fr->setAngle( 40); saveSpeakerLayout( currentSpeakerIndex); setModified( true); } void mainWindow::on_layout_narrow_radioButton_clicked( bool checked) { speaker_fl->setAngle( -20); speaker_fr->setAngle( 20); saveSpeakerLayout( currentSpeakerIndex); setModified( true); } void mainWindow::on_layout_wide_radioButton_clicked( bool checked) { speaker_fl->setAngle( -80); speaker_fr->setAngle( 80); saveSpeakerLayout( currentSpeakerIndex); setModified( true); } void mainWindow::on_global_or_local_pushButton_clicked( bool checked) { if( onGlobal){ onGlobal = false; ui.global_or_local_pushButton->setText(tr("View g&lobal configuration")); loadLocalConfig(); }else{ onGlobal = true; ui.global_or_local_pushButton->setText(tr("View &local configuration")); loadGlobalConfig(); } } void mainWindow::on_close_or_cancel_pushButton_clicked( bool checked) { if( modified){ confirmDialog.show(); // These two aren't needed, I think, I'm leaving them here // for future review on other platforms. // TODO Force the dialog to stay on top //confirmDialog.raise(); //confirmDialog.setFocus(); this->setEnabled( false); }else{ QCoreApplication::instance()->quit(); } } void mainWindow::on_apply_pushButton_clicked( bool checked) { updateDictionary( dict); if( dictionaryFilename){ np_save_dictionary( dict, dictionaryFilename); // TODO Error checking /* FILE *fp = fopen(dictionaryFilename, "wt"); if( fp == NULL){ fprintf(stderr, "ERROR: Failed to open %s\n", dictionaryFilename); } iniparser_dump_ini(dict, fp); fclose( fp); */ }else{ fprintf( stderr, "ERROR: dictionary filename not set\n"); } setModified( false); } void mainWindow::setModified(bool _modified) { modified = _modified; ui.apply_pushButton->setEnabled(_modified); if( modified){ ui.close_or_cancel_pushButton->setText("&Cancel"); }else{ ui.close_or_cancel_pushButton->setText("&Close"); } } const QString mainWindow::getShortName( const QString long_name) { if( long_name == "ALSA"){ return QString("alsa"); }else if( long_name == "Solaris"){ return QString("solaris"); }else if( long_name == "PortAudio"){ return QString("port"); }else if( long_name == "PulseAudio"){ return QString("pulse"); }else if( long_name == "OSS"){ return QString("oss"); }else if( long_name == "DirectSound"){ return QString("dsound"); }else if( long_name == tr("Windows Multimedia")){ return QString("winmm"); }else if( long_name == tr("WAVE File Writer")){ return QString("wave"); }else if( long_name == tr("Echo")){ return QString("echo"); }else if( long_name == tr("Reverb")){ return QString("reverb"); }else if( long_name == tr("EAX Reverb")){ return QString("eaxreverb"); } return QString("ERROR"); } const QString mainWindow::getLongName( const QString short_name) { if( short_name == "alsa"){ return QString("ALSA"); }else if( short_name == "solaris"){ return QString("Solaris"); }else if( short_name == "port"){ return QString("PortAudio"); }else if( short_name == "pulse"){ return QString("PulseAudio"); }else if( short_name == "oss"){ return QString("OSS"); }else if( short_name == "dsound"){ return QString("DirectSound"); }else if( short_name == "winmm"){ return QString(tr("Windows Multimedia")); }else if( short_name == "wave"){ return QString(tr("WAVE File Writer")); }else if( short_name == "echo"){ return QString(tr("Echo")); }else if( short_name == "reverb"){ return QString(tr("Reverb")); }else if( short_name == "eaxreverb"){ return QString(tr("EAX Reverb")); } return QString("ERROR"); } void mainWindow::updateDictionary(NPDict d) { QString depth = ui.sample_depth_comboBox->currentText(); if( depth == "8-bit"){ depth = "8"; } if( depth == "16-bit"){ depth = "16"; } else{ depth = "32"; } int speakers_index = ui.speakers_comboBox->currentIndex(); QString speakers; if( speakers_index == MONO){ speakers = "MONO"; }else if( speakers_index == HEADPHONES){ speakers = "STEREO"; }else if( speakers_index == STEREO){ speakers = "STEREO"; }else if( speakers_index == QUAD){ speakers = "QUAD"; }else if( speakers_index == CHN51){ speakers = "51CHN"; }else if( speakers_index == CHN61){ speakers = "61CHN"; }else if( speakers_index == CHN71){ speakers = "71CHN"; } QString output_format = "AL_FORMAT_" + speakers + depth; np_set_string( d, "general", "format", output_format.toAscii().data()); if( ui.crossfeed_comboBox->currentIndex() > 0){ int cf; cf = ui.crossfeed_comboBox->currentIndex(); cf += ui.easy_crossfeed_checkBox->isChecked() ? 3 : 0; np_set_string( d, "general", "cf_level", QString::number( cf).toAscii().data()); }else{ np_set_string( d, "general", "cf_level", "0"); } np_set_string( d, "general", "sources", ui.sources_spinBox->text().toAscii().data()); np_set_string( d, "general", "frequency", ui.frequency_comboBox->currentText().toAscii().data()); np_set_string( d, "general", "period_size", ui.period_size_spinBox->text().toAscii().data()); np_set_string( d, "general", "periods", ui.periods_spinBox->text().toAscii().data()); np_set_string( d, "general", "stereodup", ui.dupstereo_checkBox->isChecked() ? "true" : "false"); // List of excluded effects QString effects; int max_count, count=0; max_count = ui.excluded_effects_listWidget->count(); for( count=0 ; count < max_count ; count++){ effects += getShortName( ui.excluded_effects_listWidget->item(count)->text()); if( count < max_count-1){ effects += ","; } } np_set_string( d, "general", "excludefx", effects.toAscii().data()); // Effects EFX np_set_string( d, "general", "slots", ui.EFX_slots_spinBox->text().toAscii().data()); np_set_string( d, "general", "sends", ui.EFX_sends_spinBox->text().toAscii().data()); // List of enabled backends QString drivers; count=0; max_count = ui.backends_in_use_listWidget->count(); for( count=0 ; count < max_count ; count++){ drivers += getShortName( ui.backends_in_use_listWidget->item(count)->text()); if( count < max_count-1){ drivers += ","; } } np_set_string( d, "general", "drivers", drivers.toAscii().data()); // Now save the settings for each backend // ALSA np_set_string( d, "alsa", "device", ui.ALSA_device_lineEdit->text().toAscii().data()); np_set_string( d, "alsa", "capture", ui.ALSA_capture_lineEdit->text().toAscii().data()); np_set_string( d, "alsa", "mmap", ui.ALSA_mmap_checkBox->isChecked() ? "true" : "false"); // DirectSound // OSS np_set_string( d, "oss", "device", ui.OSS_device_lineEdit->text().toAscii().data()); np_set_string( d, "oss", "capture", ui.OSS_capture_lineEdit->text().toAscii().data()); // PortAudio np_set_string( d, "port", "device", ui.PortAudio_device_index_spinBox->text().toAscii().data()); // Solaris np_set_string( d, "solaris", "device", ui.Solaris_device_lineEdit->text().toAscii().data()); // WAVE File Writer np_set_string( d, "wave", "file", ui.WAVE_file_lineEdit->text().toAscii().data()); } void mainWindow::setModifiedTrue( void) { setModified( true); } void mainWindow::on_allow_effect_pushButton_clicked( bool checked) { QList item_list; item_list = ui.excluded_effects_listWidget->selectedItems(); if( item_list.isEmpty()){ return; } on_excluded_effects_listWidget_itemDoubleClicked( item_list[0]); } void mainWindow::on_excluded_effects_listWidget_itemDoubleClicked( QListWidgetItem *item) { ui.excluded_effects_listWidget->takeItem( ui.excluded_effects_listWidget->row( item)); ui.allowed_effects_listWidget->addItem( item); setModified( true); } void mainWindow::on_exclude_effect_pushButton_clicked( bool checked) { QList item_list; item_list = ui.allowed_effects_listWidget->selectedItems(); if( item_list.isEmpty()){ return; } on_allowed_effects_listWidget_itemDoubleClicked( item_list[0]); } void mainWindow::on_allowed_effects_listWidget_itemDoubleClicked( QListWidgetItem *item) { ui.allowed_effects_listWidget->takeItem( ui.allowed_effects_listWidget->row( item)); ui.excluded_effects_listWidget->addItem( item); setModified( true); } void mainWindow::on_enable_backend_pushButton_clicked( bool checked) { QList item_list; item_list = ui.disabled_backends_listWidget->selectedItems(); if( item_list.isEmpty()){ return; } on_disabled_backends_listWidget_itemDoubleClicked( item_list[0]); } void mainWindow::on_disabled_backends_listWidget_itemDoubleClicked( QListWidgetItem *item) { ui.disabled_backends_listWidget->takeItem( ui.disabled_backends_listWidget->row( item)); ui.backends_in_use_listWidget->addItem( item); setModified( true); } void mainWindow::on_disable_backend_pushButton_clicked( bool checked) { QList item_list; item_list = ui.backends_in_use_listWidget->selectedItems(); if( item_list.isEmpty()){ return; } on_backends_in_use_listWidget_itemDoubleClicked( item_list[0]); } void mainWindow::on_backends_in_use_listWidget_itemDoubleClicked( QListWidgetItem *item) { if( ui.backends_in_use_listWidget->count() <= 1){ return; } ui.backends_in_use_listWidget->takeItem( ui.backends_in_use_listWidget->row( item)); ui.disabled_backends_listWidget->addItem( item); setModified( true); } alsoft-conf-1.4.3/src/main_window.h000066400000000000000000000076771131032617700172270ustar00rootroot00000000000000/************************************************************************** * alsoft-conf, a configuration utility for OpenAL-soft. * Copyright (C) 2008-2009 Matias D'Ambrosio * * 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, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. **************************************************************************/ #ifndef MAIN_WINDOW_H__ #define MAIN_WINDOW_H__ #include "ui_main.h" #include "new_parser.h" #include "confirm_close.h" #include "speaker.h" #include class mainWindow : public QMainWindow { Q_OBJECT public: mainWindow( QMainWindow *parent=0); ~mainWindow(); void loadGlobalConfig( void); void loadLocalConfig( void); void hideGlobalOrLocalButton( void); private slots: void on_global_or_local_pushButton_clicked( bool checked=false); void on_close_or_cancel_pushButton_clicked( bool checked=false); void on_apply_pushButton_clicked( bool checked=false); void on_enable_backend_pushButton_clicked( bool checked=false); void on_disabled_backends_listWidget_itemDoubleClicked( QListWidgetItem *item); void on_disable_backend_pushButton_clicked( bool checked=false); void on_backends_in_use_listWidget_itemDoubleClicked( QListWidgetItem *item); void on_allow_effect_pushButton_clicked( bool checked=false); void on_exclude_effect_pushButton_clicked( bool checked=false); void on_excluded_effects_listWidget_itemDoubleClicked( QListWidgetItem *item); void on_allowed_effects_listWidget_itemDoubleClicked( QListWidgetItem *item); void on_speakers_comboBox_currentIndexChanged( int index); void on_crossfeed_comboBox_currentIndexChanged( int index); int validAngle( int cwise, int currentAngle, int countercwise); void speakerOrderCheck( void); void on_speaker_bl_spinBox_valueChanged( int i); void on_speaker_sl_spinBox_valueChanged( int i); void on_speaker_fl_spinBox_valueChanged( int i); void on_speaker_fc_spinBox_valueChanged( int i); void on_speaker_fr_spinBox_valueChanged( int i); void on_speaker_sr_spinBox_valueChanged( int i); void on_speaker_br_spinBox_valueChanged( int i); void on_speaker_bc_spinBox_valueChanged( int i); void on_layout_default_radioButton_clicked( bool checked); void on_layout_narrow_radioButton_clicked( bool checked); void on_layout_wide_radioButton_clicked( bool checked); void setModifiedTrue( void); // Used to receive all modification signals void wrapUpAndLeave( void); void continueEditing( void); private: Ui::MainWindow ui; bool modified; // true if the current config has been modified bool onGlobal; // true if viewing global config, false if local char *dictionaryFilename; NPDict dict; confirmClose confirmDialog; QGraphicsScene *scene; int currentSpeakerIndex; SpeakerItem *speaker_bl; SpeakerItem *speaker_sl; SpeakerItem *speaker_fl; SpeakerItem *speaker_fc; SpeakerItem *speaker_fr; SpeakerItem *speaker_sr; SpeakerItem *speaker_br; SpeakerItem *speaker_bc; void loadConfig( const char *filename); void setModified(bool _modified=true); void updateDictionary(NPDict d); void removeAllSpeakers( void); void saveSpeakerLayout( int layout); // Helper functions const QString getShortName( const QString long_name); const QString getLongName( const QString short_name); // Return true if "true", "yes", "on" or number != 0, ignores case bool string2bool( QString duplicate); }; // End of include guard #endif alsoft-conf-1.4.3/src/new_parser.cpp000066400000000000000000000241661131032617700174040ustar00rootroot00000000000000/************************************************************************** * alsoft-conf, a configuration utility for OpenAL-soft. * Copyright (C) 2008-2009 Matias D'Ambrosio * * 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, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. **************************************************************************/ #include "new_parser.h" #ifndef _GNU_SOURCE # define _GNU_SOURCE #endif #include #include #include #include #include // Structures used throughout struct _NPDict; struct _NPSection; struct _NPKey; struct _NPDict{ char *filename; struct _NPSection *sections; }; struct _NPSection{ struct _NPSection *next; char *name; struct _NPKey *keys; }; struct _NPKey{ struct _NPKey *next; char *name; char *value; }; // Helper functions static void _np_add_key( struct _NPKey **first_key, const char *key, const char *value) { struct _NPKey *new_key = *first_key; if( new_key == NULL){ new_key = (struct _NPKey *) calloc( 1, sizeof( struct _NPKey)); *first_key = new_key; } else{ while( new_key->next){ new_key = new_key->next; } new_key->next = (struct _NPKey *) calloc( 1, sizeof( struct _NPKey)); new_key = new_key->next; } new_key->name = strdup( key); new_key->value = strdup( value); } // Public functions int np_load_dictionary( const char *filename, NPDict *dict) { if( filename == NULL || dict == NULL){ return -1; } FILE *fp; fp = fopen( filename, "rt"); if( fp == NULL){ return -1; } struct _NPDict *new_dict = (struct _NPDict *) calloc( 1, sizeof( _NPDict)); new_dict->filename = strdup( filename); new_dict->sections = (struct _NPSection *) calloc( 1, sizeof( _NPSection)); new_dict->sections->name = strdup( "general"); ssize_t read_count = 0; size_t len = 0; char *line = NULL; int iter = 0; int tmp = 0; struct _NPSection *curr_section = new_dict->sections; struct _NPSection *iter_section = NULL; struct _NPKey *iter_key = NULL; while( (read_count = getline( &line, &len, fp)) != -1){ iter = tmp = 0; // Remove leading spaces and tabs (makes it easier to find other stuff) while( isblank( line[ iter])){ iter++; } // Ignore empty lines and comments if( line[ iter] == '\n' || line[ iter] == '#'){ continue; } // New section found if( line[ iter] == '['){ iter++; tmp = iter; while( isalpha( line[ tmp])){ tmp++; } if( line[ tmp] != ']'){ fprintf( stderr, "Error parsing filename %s\n", filename); continue; } // Check if it exists already char *section_name = strndup( (line + iter), (tmp - iter)); iter_section = new_dict->sections; do{ // if it exists, set as active and continue reading file if( strcmp( section_name, iter_section->name) == 0){ curr_section = iter_section; free( section_name); section_name = NULL; break; } } while( (iter_section = iter_section->next)); if( section_name == NULL){ continue; } // Create new section, set name and set as active iter_section = curr_section; while( iter_section->next){ iter_section = iter_section->next; } iter_section->next = (struct _NPSection *) calloc( 1, sizeof( _NPSection)); curr_section = iter_section->next; curr_section->name = section_name; continue; } // This is not a new section, empty line or full line comment, // so attempt to find a key=value pair // If there is no equal sign, then there is no pair. if( strstr( line, "=") == NULL){ continue; } // Find key name length tmp = 0; while( !isblank( line[ iter + tmp]) && line[ iter + tmp] != '=' && line[ iter + tmp] != '#'){ tmp++; } if( line[ iter + tmp] == '#'){ continue; } char *key = strndup( (line + iter), tmp); // Get past the spaces, equal sign and leading spaces iter += tmp; tmp = 0; while( (line[ iter + tmp] == '=' || isblank( line[ iter + tmp])) && line[ iter + tmp] != '#'){ tmp++; } if( line[ iter + tmp] == '#'){ free( key); continue; } //tmp++; /* // Ignore leading whitespace for the value while( isblank( line[ iter + tmp])){ tmp++; if( line + iter + tmp == NULL){ free( key); key = NULL; continue; } } */ iter += tmp; tmp = 0; // Ignore trailing whitespace or comment at the end while( !isspace( line[ iter + tmp]) && line[ iter + tmp] != '#'){ tmp++; if( line + iter + tmp == NULL){ break; } } if( line + iter + tmp == NULL){ free( key); continue; } char *value = strndup( (line + iter), tmp); // Now place the key=value pair in the dictionary structure iter_key = curr_section->keys; // Check if the key already exists while( iter_key != NULL){ if( strcmp( iter_key->name, key) == 0){ free( key); key = NULL; free( iter_key->value); iter_key->value = value; value = NULL; break; } iter_key = iter_key->next; } if( key == NULL){ continue; } // It doesn't exist, create it. if( iter_key == NULL){ iter_key = curr_section->keys; if( iter_key == NULL){ iter_key = (struct _NPKey *) calloc( 1, sizeof( struct _NPKey *)); curr_section->keys = iter_key; } else{ while( iter_key->next){ iter_key = iter_key->next; } iter_key->next = (struct _NPKey *) calloc( 1, sizeof( struct _NPKey)); iter_key = iter_key->next; } iter_key->name = key; iter_key->value = value; continue; } free( key); free( value); } if( line){ free( line); } fclose( fp); *dict = new_dict; return 0; } void np_destroy_dictionary( NPDict *dict) { if( dict == NULL){ return; } struct _NPDict *d = *((struct _NPDict **) dict); if( d == NULL){ return; } free( d->filename); struct _NPSection *iter_section = d->sections; struct _NPKey *iter_key = NULL; do{ free( iter_section->name); while( iter_section->keys){ iter_key = iter_section->keys; free( iter_key->name); free( iter_key->value); iter_section->keys = iter_key->next; free( iter_key); } d->sections = iter_section->next; free( iter_section); } while( (iter_section = d->sections) != NULL); } int np_save_dictionary( NPDict ndict, const char *filename) { struct _NPDict *dict = (struct _NPDict *) ndict; if( dict == NULL || filename == NULL){ return -1; } FILE *fp = fopen( filename, "wt"); if( fp == NULL){ return -2; } struct _NPSection *iter_section = dict->sections; struct _NPKey *iter_key = NULL; do{ if( iter_section->keys){ fprintf( fp, "[%s]\n", iter_section->name); iter_key = iter_section->keys; do{ if( iter_key->name && iter_key->value){ fprintf( fp, "%s = %s\n", iter_key->name, iter_key->value); } } while( (iter_key = iter_key->next) != NULL); } fprintf( fp, "\n"); // This just looks better IMHO } while( (iter_section = iter_section->next) != NULL); fclose( fp); return 0; } int np_set_string( NPDict ndict, const char *section, const char *key, const char *value) { struct _NPDict *dict = (struct _NPDict *) ndict; if( dict == NULL || key == NULL || value == NULL){ return -1; } struct _NPSection *iter_section = dict->sections; struct _NPKey *iter_key = NULL; // First try to find the section. do{ if( strcmp( section, iter_section->name) == 0){ iter_key = iter_section->keys; while( iter_key){ if( strcmp( key, iter_key->name) == 0){ free( iter_key->value); iter_key->value = strdup( value); return 0; } iter_key = iter_key->next; } _np_add_key( &(iter_section->keys), key, value); return 0; } } while( (iter_section = iter_section->next) != NULL); // The section doesn't exist, create it iter_section = dict->sections; while( iter_section->next){ iter_section = iter_section->next; } iter_section->next = (struct _NPSection *) calloc( 1, sizeof( struct _NPSection)); iter_section = iter_section->next; iter_section->name = strdup( section); _np_add_key( &(iter_section->keys), key, value); return 0; } int np_set_long( NPDict dict, const char *section, const char *key, long value) { if( dict == NULL || key == NULL){ return -1; } int size = 2; // One for the final '\0' and one for the sign. long tmp = labs(value); while( tmp > 0){ size += 3; tmp /= 1000; } char *str_value = (char *) calloc( size, sizeof( char)); snprintf( str_value, size - 1, "%ld", value); int retval = np_set_string( dict, section, key, str_value); free( str_value); return retval; } char *np_get_string( NPDict ndict, const char *section, const char *key, const char *default_value) { struct _NPDict *dict = (struct _NPDict *) ndict; if( dict == NULL || section == NULL || key == NULL){ return NULL; } struct _NPSection *iter_section = dict->sections; struct _NPKey *iter_key = NULL; do{ if( strcmp( section, iter_section->name) == 0){ iter_key = iter_section->keys; while( iter_key){ if( strcmp( key, iter_key->name) == 0){ if( iter_key->value){ return strdup( iter_key->value); } goto set_default; } iter_key = iter_key->next; } } } while( (iter_section = iter_section->next) != NULL); set_default: return default_value ? strdup( default_value) : NULL; } long np_get_long( NPDict dict, const char *section, const char *key, long default_value) { if( dict == NULL || section == NULL || key == NULL){ return default_value; } char *str_value = np_get_string( dict, section, key, NULL); if( str_value == NULL){ return default_value; } char *endptr=NULL; long value = strtol( str_value, &endptr, 10); if( endptr == str_value){ free( str_value); return default_value; } free( str_value); return value; } alsoft-conf-1.4.3/src/new_parser.h000066400000000000000000000074251131032617700170500ustar00rootroot00000000000000/************************************************************************** * alsoft-conf, a configuration utility for OpenAL-soft. * Copyright (C) 2008-2009 Matias D'Ambrosio * * 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, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. **************************************************************************/ #ifndef NEW_PARSER_H__ #define NEW_PARSER_H__ //typedef void *NPDict; struct _NPDict; typedef _NPDict * NPDict; /** @brief Load the dictionary from a file. @param filename Filename from which to load the dictionary. @param dict A pointer to a dictionary descriptor (it should be unused). @return A negative value on error, 0 on success. */ int np_load_dictionary( const char *filename, NPDict *dict); /** @brief Free the resources used by a dictionary. @param dict Dictionary to be destroyed. */ void np_destroy_dictionary( NPDict *dict); /** @brief Save the dictionary to a file. @param dict Dictionary to be saved. @param filename Filename in which the dictionary will be saved. @return A negative value on error, 0 on success. */ int np_save_dictionary( NPDict dict, const char *filename); /** @brief Set an entry in the dictionary in char* type. @param dict Dictionary in which to set the entry. @param section Section (also called block) in which the key is found. @param key Name of the key. @param value Value to set the key to. @return A negative value on error, 0 on success. */ int np_set_string( NPDict ndict, const char *section, const char *key, const char *value); /** @brief Set an entry in the dictionary in long type. @param dict Dictionary in which to set the entry. @param section Section (also called block) in which the key is found. @param key Name of the key. @param value Value to set the key to. @return A negative value on error, 0 on success. */ int np_set_long( NPDict dict, const char *section, const char *key, long value); /** @brief Get an entry from the dictionary in char* type. @param dict Dictionary from which to get the entry. @param section Section (also called block) in which the key is found. @param key Name of the key. @param default_value Default value to be returned if the entry does not exist, it may be NULL. @return NULL on error, if the key is not found then a dynamically allocated copy of default_value is returned (which might be NULL). */ char *np_get_string( NPDict ndict, const char *section, const char *key, const char *default_value); /** @brief Get an entry from the dictionary in long type. @param dict Dictionary from which to get the entry. @param section Section (also called block) in which the key is found. @param key Name of the key. @param default_value Default value to be returned if the entry does not exist. @return 0 on error, any value (including 0) on success. */ long np_get_long( NPDict dict, const char *section, const char *key, long default_value); #endif alsoft-conf-1.4.3/src/speaker.cpp000066400000000000000000000070331131032617700166630ustar00rootroot00000000000000/************************************************************************** * alsoft-conf, a configuration utility for OpenAL-soft. * Copyright (C) 2008-2009 Matias D'Ambrosio * * 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, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. **************************************************************************/ #include "speaker.h" #include #include #include #define SPEAKER_CENTRE 40 #define SPREAD_RADIUS 40 SpeakerItem::SpeakerItem( double _x, double _y, double _radius) { setPos( _x, _y); radius = _radius > 0 ? _radius : 20; setFlag( QGraphicsItem::ItemIsMovable); } SpeakerItem::SpeakerItem( double _angle, double _radius) { radius = _radius > 0 ? _radius : 20; setFlag( QGraphicsItem::ItemIsMovable); setAngle( _angle); emit valueChanged( getAngle()); } QRectF SpeakerItem::boundingRect() const { return QRectF( x() - radius, y() - radius, radius*2, radius*2); } void SpeakerItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { painter->setRenderHint( QPainter::Antialiasing); double _x = x(); double _y = y(); painter->setBrush( Qt::black); painter->setPen( Qt::black); painter->drawEllipse( _x - radius/2, _y - radius/2, radius, radius); painter->setPen( Qt::yellow); painter->drawEllipse( _x - radius*0.9/2, _y - radius*0.9/2, radius*0.9, radius*0.9); painter->setBrush( Qt::yellow); painter->drawEllipse( _x - radius/5/2, _y - radius/5/2, radius/5, radius/5); } void SpeakerItem::mouseMoveEvent( QGraphicsSceneMouseEvent *event) { QGraphicsItem::mouseMoveEvent( event); double _x = x() - SPEAKER_CENTRE; double _y = y() - SPEAKER_CENTRE; double len = sqrt( pow( _x, 2) + pow( _y, 2)); setPos( (_x / len) * SPREAD_RADIUS + SPEAKER_CENTRE, (_y / len) * SPREAD_RADIUS + SPEAKER_CENTRE); emit valueChanged( getAngle()); } int SpeakerItem::getAngle( void) { double _x = x() - SPEAKER_CENTRE; double _y = y() - SPEAKER_CENTRE; double len = sqrt( pow( _x, 2) + pow( _y, 2)); _x /= len; _y /= len; if( _x == 0){ if( _y > 0){ return 180; } else{ return 0; } } _y *= -1; double angle = atan( _y / _x) * (180 / M_PI); if( _x < 0){ angle += 180; } else{ if( _y < 0){ angle += 360; } } if( _x < 0){ angle -= 90; if( angle != 180){ // FIXME This if shouldn't be necessary angle *= -1; } } else{ if( _y >= 0){ angle = 90 - angle; } else{ angle -= 270; angle = 180 - angle; } } return (int) round( angle); } void SpeakerItem::setAngle( double _angle) { double _x, _y; if( _angle < 0){ _angle *= -1; _angle += 90; } else{ _angle = 180 - _angle; if( _angle >= 90){ _angle -= 90; } else{ _angle += 270; } } _angle *= M_PI / 180; _y = sin( _angle); _y *= -1; _x = cos( _angle); _x *= SPREAD_RADIUS; _y *= SPREAD_RADIUS; _x += SPEAKER_CENTRE; _y += SPEAKER_CENTRE; setPos( _x, _y); emit valueChanged( getAngle()); } alsoft-conf-1.4.3/src/speaker.h000066400000000000000000000030571131032617700163320ustar00rootroot00000000000000/************************************************************************** * alsoft-conf, a configuration utility for OpenAL-soft. * Copyright (C) 2008-2009 Matias D'Ambrosio * * 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, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. **************************************************************************/ #ifndef SPEAKER_H__ #define SPEAKER_H__ #include #include #include class SpeakerItem : public QObject, public QGraphicsItem { Q_OBJECT private: double radius; signals: void valueChanged( int value); public: SpeakerItem( double _x, double _y, double _radius); SpeakerItem( double _angle, double _radius); QRectF boundingRect() const; void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void mouseMoveEvent( QGraphicsSceneMouseEvent *event); int getAngle( void); void setAngle( double _angle); }; #endif alsoft-conf-1.4.3/src/ui/000077500000000000000000000000001131032617700151375ustar00rootroot00000000000000alsoft-conf-1.4.3/src/ui/confirm_close.ui000066400000000000000000000036541131032617700203300ustar00rootroot00000000000000 Dialog 0 0 373 69 0 0 Dialog Changes have been made, do you want to cancel them? Qt::Horizontal Qt::Horizontal QDialogButtonBox::No|QDialogButtonBox::Yes buttonBox accepted() Dialog accept() 248 254 157 274 buttonBox rejected() Dialog reject() 316 260 286 274 alsoft-conf-1.4.3/src/ui/main.ui000066400000000000000000001512131131032617700164250ustar00rootroot00000000000000 MainWindow 0 0 457 411 oalsoft-conf 0 &General 0 1 Output Format 9 77 87 17 Sample &depth sample_depth_comboBox 219 77 65 27 0 8-bit 16-bit 32-bit float 9 151 67 17 &Frequency frequency_comboBox 219 151 71 27 true 44100 22050 &Update periods Sets the number of update buffers for playback. A value of 0 means auto-select. 4 &Period Size Sets the number of update buffers for playback. A value of 0 means auto-select. 99999 1024 S&ources Sets the number of update buffers for playback. A value of 0 means auto-select. 2048 256 &Backend 0 0 QFrame::StyledPanel QFrame::Raised 0 0 Backends in &use Qt::AlignCenter backends_in_use_listWidget QAbstractItemView::InternalMove ALSA DirectSound OSS PortAudio PulseAudio Solaris Windows Multimedia WAVE File Writer < > 0 0 &Disabled backends Qt::AlignCenter disabled_backends_listWidget QAbstractItemView::InternalMove QFrame::StyledPanel QFrame::Raised ALSA DirectSound OSS PortAudio PulseAudio Solaris WAVE File Writer Windows Multimedia Qt::Horizontal 40 20 0 Sets whether to try using mmap mode (helps reduce latencies and CPU consumption). If mmap isn't available, it will automatically fall back to non-mmap mode. Use mmap true Playback device ALSA_device_lineEdit default Recording device ALSA_capture_lineEdit default No options available for this backend Playback device ALSA_device_lineEdit /dev/dsp Recording device ALSA_capture_lineEdit /dev/dsp Output device index PortAudio_device_index_spinBox Sets the device index for output. Negative values will use the default as given by PortAudio itself. -1 -1 No options available for this backend Device ALSA_device_lineEdit /dev/audio Output file WAVE_file_lineEdit Sets the filename of the wave file to write to. An empty name prevents the backend from opening, even when explicitly requested. THIS WILL OVERWRITE EXISTING FILES WITHOUT QUESTION! No options available for this backend &Effects QFrame::StyledPanel QFrame::Raised Allo&wed effects Qt::AlignCenter allowed_effects_listWidget Sets which effects to exclude, preventing apps from using them. This can help for apps that try to use effects which are too CPU intensive for the system to handle. EAX Reverb Echo Reverb < > E&xcluded effects Qt::AlignCenter excluded_effects_listWidget Sets which effects to exclude, preventing apps from using them. This can help for apps that try to use effects which are too CPU intensive for the system to handle. Auxilia&ry Effect slots EFX_slots_spinBox Sets the maximum number of Auxiliary Effect Slots an app can create. A slot can use a non-negligible amount of CPU time if an effect is set on it even if no sources are feeding it, so this may help when apps use more than the system can handle. 4 Auxiliary sends &per source EFX_sends_spinBox Sets the maximum number of auxiliary sends per source. The total number of sends possible is defined at compile time and thus can not be increased beyond the default. 2 &Speakers 2 mono headphones stereo 4-channel 5.1 6.1 7.1 0 0 0 Default true stereo_layout_buttonGroup Narrow stereo_layout_buttonGroup Wide stereo_layout_buttonGroup Custom stereo_layout_buttonGroup Drag the speaker icons to match your physical layout. Only direction is taken into account, not distance. Qt::ScrollBarAlwaysOff Qt::ScrollBarAlwaysOff 0 0 Back Left speaker_bl_spinBox -179 180 0 0 Side Left speaker_sl_spinBox -179 180 0 0 Front Left speaker_fl_spinBox -179 180 0 0 Front Centre speaker_fc_spinBox -179 180 0 0 Front Right speaker_fr_spinBox -179 180 0 0 Side Right speaker_sr_spinBox -179 180 -179 180 0 0 Back Right speaker_br_spinBox 0 0 Back Centre speaker_br_spinBox -179 180 0 0 0 High crossfeed makes virtual speakers appear closer to each other. Users of headphones may want to try various settings. 1 None Low Middle High Eas&y crossfeed Sets whether to duplicate stereo sounds on the rear and side speakers for 4+ channel output. This can make stereo sources substantially louder than mono or even 4+ channel sources, but provides a "fuller" playback quality. &Duplicate stereo sounds on the rear speakers. true &View global configuration Qt::Horizontal 40 20 false &Apply &Close true true &Global configuration true &Local configuration &Reset &Save &Quit tabWidget sample_depth_comboBox frequency_comboBox backends_in_use_listWidget enable_backend_pushButton disable_backend_pushButton disabled_backends_listWidget comboBox ALSA_mmap_checkBox ALSA_device_lineEdit ALSA_capture_lineEdit OSS_device_lineEdit OSS_capture_lineEdit PortAudio_device_index_spinBox Solaris_device_lineEdit WAVE_file_lineEdit allowed_effects_listWidget allow_effect_pushButton exclude_effect_pushButton excluded_effects_listWidget EFX_slots_spinBox EFX_sends_spinBox speakers_comboBox layout_default_radioButton layout_narrow_radioButton layout_wide_radioButton layout_custom_radioButton graphicsView crossfeed_comboBox easy_crossfeed_checkBox dupstereo_checkBox apply_pushButton close_or_cancel_pushButton global_or_local_pushButton comboBox currentIndexChanged(int) stackedWidget setCurrentIndex(int) 137 239 143 298 sample_depth_comboBox currentIndexChanged(int) MainWindow setModifiedTrue() 295 139 456 97 ALSA_mmap_checkBox stateChanged(int) MainWindow setModifiedTrue() 72 290 3 222 ALSA_device_lineEdit textEdited(QString) MainWindow setModifiedTrue() 433 324 454 273 ALSA_capture_lineEdit textEdited(QString) MainWindow setModifiedTrue() 341 355 233 318 backends_in_use_listWidget indexesMoved(QModelIndexList) MainWindow setModifiedTrue() 89 103 2 118 OSS_device_lineEdit textEdited(QString) MainWindow setModifiedTrue() 433 291 455 205 OSS_capture_lineEdit textEdited(QString) MainWindow setModifiedTrue() 433 322 456 313 WAVE_file_lineEdit textEdited(QString) MainWindow setModifiedTrue() 191 321 251 316 PortAudio_device_index_spinBox valueChanged(int) MainWindow setModifiedTrue() 433 326 236 389 Solaris_device_lineEdit textChanged(QString) MainWindow setModifiedTrue() 232 304 243 375 EFX_sends_spinBox valueChanged(int) MainWindow setModifiedTrue() 261 364 455 352 EFX_slots_spinBox valueChanged(int) MainWindow setModifiedTrue() 411 311 380 384 easy_crossfeed_checkBox clicked(bool) MainWindow setModifiedTrue() 276 350 384 378 dupstereo_checkBox clicked(bool) MainWindow setModifiedTrue() 107 357 231 379 frequency_comboBox currentIndexChanged(int) MainWindow setModifiedTrue() 259 198 385 -13 periods_spinBox valueChanged(int) MainWindow setModifiedTrue() 381 279 415 0 period_size_spinBox valueChanged(int) MainWindow setModifiedTrue() 411 308 457 28 sources_spinBox valueChanged(int) MainWindow setModifiedTrue() 356 349 455 136 disabled_backends_listWidget indexesMoved(QModelIndexList) MainWindow setModifiedTrue() 375 84 457 13 setModifiedTrue()