From: hobbes1069 Date: Tue, 4 Aug 2015 02:32:51 +0000 (+0000) Subject: Initial move to branches and tags structure. X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=6738da9593827704696682aa96bea966ac1ded3f;p=freetel-svn-tracking.git Initial move to branches and tags structure. git-svn-id: https://svn.code.sf.net/p/freetel/code@2251 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2/AUTHORS b/codec2/AUTHORS deleted file mode 100644 index e69de29b..00000000 diff --git a/codec2/CMakeLists.txt b/codec2/CMakeLists.txt deleted file mode 100644 index 9e2b08d1..00000000 --- a/codec2/CMakeLists.txt +++ /dev/null @@ -1,184 +0,0 @@ -# -# Codec2 - Next-Generation Digital Voice for Two-Way Radio -# -# CMake configuration contributed by Richard Shaw (KF5OIM) -# Please report questions, comments, problems, or patches to the freetel -# mailing list: https://lists.sourceforge.net/lists/listinfo/freetel-codec2 -# -project(codec2) - -cmake_minimum_required(VERSION 2.8) - -include(GNUInstallDirs) -mark_as_advanced(CLEAR - CMAKE_INSTALL_BINDIR - CMAKE_INSTALL_INCLUDEDIR - CMAKE_INSTALL_LIBDIR -) - -# -# Prevent in-source builds -# If an in-source build is attempted, you will still need to clean up a few -# files manually. -# -set(CMAKE_DISABLE_SOURCE_CHANGES ON) -set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) -if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - message(FATAL_ERROR "In-source builds in ${CMAKE_BINARY_DIR} are not " - "allowed, please remove ./CMakeCache.txt and ./CMakeFiles/, create a " - "separate build directory and run cmake from there.") -endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - - -# -# Set project version information. This should probably be done via external -# file at some point. -# -set(CODEC2_VERSION_MAJOR 0) -set(CODEC2_VERSION_MINOR 3) -# Set to patch level if needed, otherwise leave FALSE. -set(CODEC2_VERSION_PATCH FALSE) -set(CODEC2_VERSION "${CODEC2_VERSION_MAJOR}.${CODEC2_VERSION_MINOR}") -# Patch level version bumps should not change API/ABI. -set(SOVERSION "${CODEC2_VERSION_MAJOR}.${CODEC2_VERSION_MINOR}") -if(CODEC2_VERSION_PATCH) - set(CODEC2_VERSION "${CODEC2_VERSION}.${CODEC2_VERSION_PATCH}") -endif() -message(STATUS "codec2 version: ${CODEC2_VERSION}") - -# Set default build type -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") -endif() - -# Set default C++ flags. -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") - -# -fPIC is implied on MinGW... -if(NOT WIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") -endif() - - -message(STATUS "Build type is: " ${CMAKE_BUILD_TYPE}) -message(STATUS "Compiler Flags: " ${CMAKE_CXX_FLAGS}) - -# -# Setup Windows/MinGW specifics here. -# -if(MINGW) - message(STATUS "System is MinGW.") -endif(MINGW) - - -# -# Find the svn revision if this is a working copy. -# WORK IN PROGRESS -# Works ok if it is a working copy but errors out if not. -# -#find_package(Subversion) -#if(Subversion_FOUND) -# Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} CODEC2) -# message(STATUS "codec2 svn revision: ${CODEC2_WC_REVISION}") -#else(SUBVERSION_FOUND) -# message(WARNING "Subversion not found. Can not determine svn revision.") -#endif(SUBVERSION_FOUND) - - -# -# Default options -# -option(BUILD_SHARED_LIBS - "Build shared library. Set to OFF for static library." ON) -option(UNITTEST "Build unittest binaries." OFF) -option(INSTALL_EXAMPLES "Install example code." OFF) -if(INSTALL_EXAMPLES) - install(DIRECTORY octave raw script voicing wav - USE_SOURCE_PERMISSIONS - DESTINATION ${CMAKE_INSTALL_DATADIR}/codec2) -endif() - - -# Math library is automatic on windows -if(UNIX) - set(CMAKE_REQUIRED_INCLUDES math.h) - set(CMAKE_REQUIRED_LIBRARIES m) -endif(UNIX) - -include(CheckIncludeFiles) -check_include_files("stdlib.h" HAVE_STDLIB_H) -check_include_files("string.h" HAVE_STRING_H) - -include(CheckFunctionExists) -check_function_exists(floor HAVE_FLOOR) -check_function_exists(ceil HAVE_CEIL) -check_function_exists(pow HAVE_POW) -check_function_exists(sqrt HAVE_SQRT) -check_function_exists(sin HAVE_SIN) -check_function_exists(cos HAVE_COS) -check_function_exists(atan2 HAVE_ATAN2) -check_function_exists(log10 HAVE_LOG10) -check_function_exists(round HAVE_ROUND) -check_function_exists(getopt HAVE_GETOPT) - -configure_file ("${PROJECT_SOURCE_DIR}/cmake/config.h.in" - "${PROJECT_BINARY_DIR}/config.h" ) -include_directories(${PROJECT_BINARY_DIR}) - -# CMake Package setup -include(CMakePackageConfigHelpers) -configure_package_config_file(cmake/codec2-config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/codec2-config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/codec2 - PATH_VARS CMAKE_INSTALL_INCLUDEDIR -) - -# -# codec2 library -# -add_subdirectory(src) - -if(UNITTEST) - # Pthread Library - find_package(Threads REQUIRED) - message(STATUS "Threads library flags: ${CMAKE_THREAD_LIBS_INIT}") - add_subdirectory(unittest) -endif(UNITTEST) - -# -# Cpack NSIS installer configuration for Windows. -# See: http://nsis.sourceforge.net/Download -# -# *nix systems should use "make install" and/or appropriate -# distribution packaging tools. -# -if(WIN32) - # Detect if we're doing a 32-bit or 64-bit windows build. - if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) - set(CMAKE_CL_64 TRUE) - endif() - - configure_file(cmake/GetDependencies.cmake.in cmake/GetDependencies.cmake - @ONLY - ) - install(SCRIPT ${CMAKE_BINARY_DIR}/cmake/GetDependencies.cmake) - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Next-Generation Digital Voice for Two-Way Radio") - set(CPACK_PACKAGE_VENDOR "CMake") - set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") - set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") - set(CPACK_PACKAGE_VERSION_MAJOR ${CODEC2_VERSION_MAJOR}) - set(CPACK_PACKAGE_VERSION_MINOR ${CODEC2_VERSION_MINOR}) - if(CODEC2_VERSION_PATCH) - set(CPACK_PACKAGE_VERSION_PATCH ${CODEC2_VERSION_PATCH}) - else() - set(CPACK_PACKAGE_VERSION_PATCH 0) - endif() - set(CPACK_PACKAGE_INSTALL_DIRECTORY "Codec2") - set(CPACK_CREATE_DESKTOP_LINKS "") - set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}") - set(CPACK_NSIS_URL_INFO_ABOUT "http://codec2.org") - set(CPACK_NSIS_MODIFY_PATH ON) - include(CPack) -endif(WIN32) diff --git a/codec2/COPYING b/codec2/COPYING deleted file mode 100644 index cc40a468..00000000 --- a/codec2/COPYING +++ /dev/null @@ -1,502 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 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. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -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 and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, 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 library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete 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 distribute a copy of this License along with the -Library. - - 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 Library or any portion -of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -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 Library, 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 Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you 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. - - If distribution of 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 satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be 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. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library 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. - - 9. 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 Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -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 with -this License. - - 11. 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 Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library 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 Library. - -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. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library 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. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser 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 Library -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 Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -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 - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "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 -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. 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 LIBRARY 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 -LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see - . - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/codec2/ChangeLog b/codec2/ChangeLog deleted file mode 100644 index e69de29b..00000000 diff --git a/codec2/INSTALL b/codec2/INSTALL deleted file mode 100644 index d0cff595..00000000 --- a/codec2/INSTALL +++ /dev/null @@ -1,43 +0,0 @@ -Installation Instructions for codec2 ------------------------------------- - -The CMake configuration for codec2 should be considered experimental at -this time but has been thouroughly tested on Fedora Linux and cross-compiling -from linux to windows with mingw and has many advanages over the autotools -config. - -1/ Builds against system libraries by default. -2/ Has experimental NSIS packaing support for Windows (WIN32) targets. *nix - systems should rely on 'make install' as the packages (RPM & DEB) created by - CPack are questionable. - - -Building and installing ------------------------ - -Out-of-source builds are preferred. To build codec2, make a directory anywhere -underneath (or outside of) the source directory. - -Linux command line example: - - $ cd /path/to/codec2 - $ mkdir build_linux - $ cd build_linux - $ cmake ../ (defaults to /usr/local, use CMAKE_INSTALL_PREFIX to override) - (if no errors) - $ make - (as root) - $ make install - -Codec2 installs to /usr/local by defailt on *nix systems but can be overriden -by passing options to cmake during configuration. - -Some options that may be of interest: - 1/ CMAKE_INSTALL_PREFIX: Defaults to /usr/local - 2/ CMAKE_BUILD_TYPE: Defaults to Release - 3/ CMAKE_C_FLAGS: Additional build flags. - -These can be modified on the command line by using the "-D" option when running -cmake: - - $ cmake -DCMAKE_INSTALL_PREFIX=/usr diff --git a/codec2/NEWS b/codec2/NEWS deleted file mode 100644 index e69de29b..00000000 diff --git a/codec2/README b/codec2/README deleted file mode 100644 index e4a42fce..00000000 --- a/codec2/README +++ /dev/null @@ -1,80 +0,0 @@ -Codec 2 README --------------- - -Codec 2 is an open source (LGPL licensed) speech codec for 1200-3200 -bit/s. For more information please see: - - http://rowetel.com/codec2.html - -Also included is a FDMDV modem, see README_fdmdv.txt - -Quickstart ----------- - -1/ Listen to Codec 2: - - $ cd codec2 - $ mkdir build_linux - $ cmake ../ && make - $ ./src/c2demo ../raw/hts1a.raw hts1a_c2.raw - $ ../script/menu.sh ../raw/hts1a.raw hts1a_c2.raw - - NOTE: For playback testing, menu.sh requires either the 'play', - 'aplay' or 'ossplay' programs to be installed (see - http://sox.sourceforge.net/, http://www.alsa-project.org/, or - http://www.opensound.com/ respectively). - -2/ Compress and Decompress a file: - - $ ./src/c2enc 2400 ../raw/hts1a.raw hts1a_c2.bit - $ ./src/c2dec 2400 hts1a_c2.bit hts1a_c2.raw - -3/ Same thing with pipes: - - $ ./src/c2enc 1400 ../raw/hts1a.raw - | ./src/c2dec 1400 - - | play -t raw -r 8000 -s -2 - - -Programs --------- - -1/ c2demo encodes a file of speech samples, then decodes them and -saves the result. - -2/ c2enc encodes a file of speech samples to a compressed file of -encoded bits. - -3/ c2dec decodes a compressed file of bits to a file of speech -samples. - -4/ c2sim is a simulation/development version of Codec 2. It allows -selective use of the various Codec 2 algorithms. For example -switching phase modelling or LSP quantisation on and off. - -Debugging ---------- - -1/ For dump file support: - - $ cd codec2/build_dir - $ CFLAGS=-DDUMP make ../ - $ make clean && make - -2/ To use gdb: - - $ libtool --mode=execute gdb c2sim - -Directories ------------ - - fltk - FLTK GUI programs(s) - octave - Octave scripts used for visualising internal signals - during development - portaudio - Portaudio test programs - script - shell scripts for playing and converting raw files - src - C source code - stm32 - STM2F4 uC support - raw - speech files in raw format (16 bits signed linear 8 kHz) - unittest - unit test source code - voicing - hand-estimated voicing files, used for development - wav - speech files in wave file format - win32 - Support for building Windows DLL version of Codec 2 and FDMDV libraries - diff --git a/codec2/README_fdmdv.txt b/codec2/README_fdmdv.txt deleted file mode 100644 index 64c6a854..00000000 --- a/codec2/README_fdmdv.txt +++ /dev/null @@ -1,203 +0,0 @@ - -README_fdmdv.txt -David Rowe -Created March 2012 - -Introduction ------------- - -A 1400 bit/s (nominal) Frequency Division Multiplexed Digital Voice -(FDMDV) modem based on [1]. Used for digital audio over HF SSB. - -The FDMDV modem was first implemented in GNU Octave, then ported to C. -Algorithm development is generally easier in Octave, but for real time -work we need the C version. Automated units tests ensure the -operation of the Octave and C versions are identical. - -Quickstart ----------- - -$ cd codec2 -$ cmake && make -$ cd src - -1. Generate some test bits and modulate them: - - $ ./fdmdv_get_test_bits test.c2 1400 - $ ./fdmdv_mod test.c2 test.raw - $ play -r 8000 -s -2 test.raw - -2. Two seconds of test frame data modulated and sent out of sound device: - - $ ./fdmdv_get_test_bits - 2800 | ./fdmdv_mod - - | play -t raw -r 8000 -s -2 - - -3. Send 14000 modulated bits (10 seconds) to the demod and count errors: - - $ ./fdmdv_get_test_bits - 14000 | ./fdmdv_mod - - | ./fdmdv_demod - - demod_dump.txt | ./fdmdv_put_test_bits - - - Use Octave to look at plots of 1 second (1400 bits) of modem operation: - - $ cd ../octave - $ octave - octave:1> fdmdv_demod_c("../src/demod_dump.txt",1400) - -4. Run Octave simulation of entire modem and AWGN channel: - - $ cd ../octave - $ octave - octave:1> fdmdv_ut - -5. NOTE: If you would like to play modem samples over the air please - convert the 8 kHz samples to 48 kHz. Many PC sound cards have - wildly inaccurate sample clock rates when set to 8 kHz, but seem to - perform OK when set for 48 kHz. If playing and recording files you - can use the sox utility: - - $ sox -r 8000 -s -2 modem_sample_8kHz.raw -r 48000 modem_sample_48kHz.wav - - For real time applications, the fdmdv.[ch] library includes functions to - convert between 48 and 8 kHz sample rates. - -6. Send 20 seconds at 2000 bit/s (20 carriers) to demod and count errors: - - $ ./fdmdv_get_test_bits - 20000 20 | ./fdmdv_mod - - 20 | ./fdmdv_demod - - 20 | ./fdmdv_put_test_bits - 20 - -References ----------- - -[1] http://n1su.com/fdmdv/FDMDV_Docs_Rel_1_4b.pdf -[2] http://n1su.com/fdmdv/ -[3] http://www.rowetel.com/blog/?p=2433 "Testing a FDMDV Modem" -[4] http://www.rowetel.com/blog/?p=2458 "FDMDV Modem Page" on David's web site - -C Code ------- - -src/fdmdv_mod.c - C version of modulator that takes a file of bits and - converts it to a raw file of modulated samples. - -src/fdmdv_demod.c - C version of demodulator that takes a raw file of - modulated samples and outputs a file of bits. - Optionally dumps demod states to a text file which - can be plotted using the Octave script - fdmdv_demod_c.m - -src/fdmdv.h - Header file that exposes FDMDV C API functions. Include - this file in your application program. - -src/fdmdv.c - C functions that implement the FDMDV modem. - -src/fdmdv-internal.h - internal states and constants for FDMDV modem, - shouldn't be exposed to application program. - - -unittest/tfdmdv.c - Used to conjunction with unittest/tfdmdv.m to - automatically test C FDMDV functions against - Octave versions. - -Octave Scripts --------------- - -(Note these require some Octave packages to be installed, see -octave/README.txt). - -fdmdv.m - Functions and variables that implement the Octave version of - the FDMDV modem. - -fdmdv_ut.m - Unit test for fdmdv Octave code, useful while - developing algorithm. Includes tx/rx plus basic channel - simulation. - - Typical run: - - octave:6> fdmdv_ut - Eb/No (meas): 7.30 (8.29) dB - bits........: 2464 - errors......: 20 - BER.........: 0.0081 - PAPR........: 13.54 dB - SNR.........: 4.0 dB - - It also outputs lots of nice plots that show the - operation of the modem. - - For a 1400 bit/s DQPSK modem we expect about 1% BER for - Eb/No = 7.3dB, which corresponds to SNR = 4dB (3kHz - noise BW). The extra dB of measured power is due to the - DBPSK pilot. Currently the noise generation code - doesn't take the pilot power into account, so in this - example the real SNR is actually 5dB. - -fdmdv_mod.m - Octave version of modulator that outputs a raw file. - The modulator is driven by a test frame of bits. This - can then be played over a real channel or through a - channel simulator like PathSim. The sample rate can be - changed using "sox" to simulate differences in tx/rx - sample clocks. - - To generate 10 seconds of modulated signal: - - octave:8> fdmdv_mod("test.raw",1400*10); - -fdmdv_demod.m - Demodulator program that takes a raw file as input, - and works out the bit error rate using the known test - frame. Can be used to test the demod performs with - off-air signals, or signals that have been passed - through a channel simulator. - - To demodulate 2 seconds of the test.raw file generated - above: - - octave:9> fdmdv_demod("test.raw",1400*2); - 2464 bits 0 errors BER: 0.0000 - - It also produces several plots showing the internal - states of the demod. Useful for debugging and - observing what happens with various channels. - -fdmdv_demod_c.m - Takes an output text file from the C demod - fdmdv_demod.c and produces plots and measures BER. - Useful for evaluating fdmdv_demod.c performance. - The plots produced are identical to the Octave - version fdmdv_demod.m, allowing direct comparison of - the C and Octave versions. - -tfdmdv.m - Automatic tests that compare the Octave and C versions of - the FDMDV modem functions. First run unittest/tfdmdv, this - will generate a text file with test vectors from the C - version. Then run the Octave script tfdmdv and it will - generate Octave versions of the test vectors and compare - each vector with the C equivalent. Its plots the vectors - and and errors (green). Its also produces an automatic - check list based on test results. If the Octave or C modem - code is changed, this script should be used to ensure the - C and Octave versions remain identical. - -Modelling sample clock errors using sox ---------------------------------------- - -This introduces a simulated 1000ppm error: - - sox -r 8000 -s -2 mod_dqpsk.raw -s -2 mod_dqpsk_8008hz.raw rate -h 8008 - -TODO ----- - -[ ] implement ppm measurements in fdmdv_get_demod_stats() -[ ] try interfering sine wave - + maybe swept - + does modem fall over? -[ ] try non-flat channel, e.g. 3dB difference between hi and low tones - + make sure all estimators keep working -[ ] test rx level sensitivity, i.e. 0 to 20dB attenuation -[ ] make fine freq indep of amplitude - + use angle rather than imag coord -[ ] document use of fdmdv_ut and fdmdv_demod + PathSim -[ ] more positive form of sync reqd for DV frames? - + like using coarse_fine==1 to decode valid DV frame bit? - + when should we start decoding? -[ ] more robust track/acquite state machine? - + e.g. hang on thru the fades? -[ ] PAPR idea - + automatically tweak phases to reduce PAPR, e.g. slow variations in freq... -[ ] why is pilot noise_est twice as big as other carriers diff --git a/codec2/asterisk-11/README.md b/codec2/asterisk-11/README.md deleted file mode 100644 index 6f5b2442..00000000 --- a/codec2/asterisk-11/README.md +++ /dev/null @@ -1,19 +0,0 @@ -#Asterisk 11 Codec 2 support -=========================== - -##Description -These patches add Codec 2 2400 support to Asterisk 11. -The following patches are provided: - -* asterisk-11.8.1-codec2.patch: plain Asterisk 11. -* asterisk-11.8.1-opus-codec2.patch: Asterisk patched with Meetecho's Opus codec support. - -##Building -Building and installing are integrated within Asterisk building environment. libcodec2 must be installed beforehand. - -##Credits -I've followed the example of [asterisk-opus](https://github.com/meetecho/asterisk-opus), by [@meetecho](https://github.com/meetecho), to adapt Codec2 Asterisk 1.8 patch to version 11. - -Many thanks to the [Codec2](http://www.rowetel.com/blog/codec2.html) team for developing such great codec! - -Developed by [Antonio Eugenio Burriel](https://github.com/aeburriel) diff --git a/codec2/asterisk-11/asterisk-11.8.1-codec2.patch b/codec2/asterisk-11/asterisk-11.8.1-codec2.patch deleted file mode 100644 index a2fa0db0..00000000 --- a/codec2/asterisk-11/asterisk-11.8.1-codec2.patch +++ /dev/null @@ -1,384 +0,0 @@ -diff -urN asterisk-11.8.1-orig/build_tools/menuselect-deps.in asterisk-11.8.1-codec2/build_tools/menuselect-deps.in ---- asterisk-11.8.1-orig/build_tools/menuselect-deps.in 2013-04-11 21:59:35.000000000 +0200 -+++ asterisk-11.8.1-codec2/build_tools/menuselect-deps.in 2014-04-01 10:24:29.368859813 +0200 -@@ -4,6 +4,7 @@ - CRYPTO=@PBX_CRYPTO@ - BFD=@PBX_BFD@ - BISON=@PBX_BISON@ -+CODEC2=@PBX_CODEC2@ - CURL=@PBX_CURL@ - DAHDI=@PBX_DAHDI@ - DLADDR=@PBX_DLADDR@ -diff -urN asterisk-11.8.1-orig/codecs/codec_codec2.c asterisk-11.8.1-codec2/codecs/codec_codec2.c ---- asterisk-11.8.1-orig/codecs/codec_codec2.c 1970-01-01 01:00:00.000000000 +0100 -+++ asterisk-11.8.1-codec2/codecs/codec_codec2.c 2014-04-01 01:28:47.000000000 +0200 -@@ -0,0 +1,190 @@ -+/* -+ * Codec 2 module for Asterisk. -+ * -+ * Credit: codec_gsm.c used as a starting point. -+ * -+ * Copyright (C) 2012 Ed W and David Rowe -+ * -+ * This program is free software, distributed under the terms of -+ * the GNU General Public License Version 2. See the LICENSE file -+ * at the top of the source tree. -+ */ -+ -+/*! \file -+ * -+ * \brief Translate between signed linear and Codec 2 -+ * -+ * \ingroup codecs -+ */ -+ -+/*** MODULEINFO -+ codec2 -+ core -+ ***/ -+ -+#include "asterisk.h" -+ -+#include "asterisk/translate.h" -+#include "asterisk/config.h" -+#include "asterisk/module.h" -+#include "asterisk/utils.h" -+ -+#include -+ -+#define BUFFER_SAMPLES 8000 -+#define CODEC2_SAMPLES 160 -+#define CODEC2_FRAME_LEN 6 -+ -+/* Sample frame data */ -+ -+#include "asterisk/slin.h" -+#include "ex_codec2.h" -+ -+struct codec2_translator_pvt { /* both codec2tolin and codec2togsm */ -+ struct CODEC2 *codec2; -+ int16_t buf[BUFFER_SAMPLES]; /* lintocodec2, temporary storage */ -+}; -+ -+static int codec2_new(struct ast_trans_pvt *pvt) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ -+ tmp->codec2 = codec2_create(CODEC2_MODE_2400); -+ if (!tmp) -+ return -1; -+ -+ return 0; -+} -+ -+/*! \brief decode and store in outbuf. */ -+static int codec2tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ int x; -+ int16_t *dst = pvt->outbuf.i16; -+ int flen = CODEC2_FRAME_LEN; -+ -+ for (x=0; x < f->datalen; x += flen) { -+ unsigned char *src; -+ int len; -+ len = CODEC2_SAMPLES; -+ src = f->data.ptr + x; -+ -+ codec2_decode(tmp->codec2, dst + pvt->samples, src); -+ -+ pvt->samples += CODEC2_SAMPLES; -+ pvt->datalen += 2 * CODEC2_SAMPLES; -+ } -+ return 0; -+} -+ -+/*! \brief store samples into working buffer for later decode */ -+static int lintocodec2_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ -+ if (pvt->samples + f->samples > BUFFER_SAMPLES) { -+ ast_log(LOG_WARNING, "Out of buffer space\n"); -+ return -1; -+ } -+ memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen); -+ pvt->samples += f->samples; -+ return 0; -+} -+ -+/*! \brief encode and produce a frame */ -+static struct ast_frame *lintocodec2_frameout(struct ast_trans_pvt *pvt) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ int datalen = 0; -+ int samples = 0; -+ -+ /* We can't work on anything less than a frame in size */ -+ if (pvt->samples < CODEC2_SAMPLES) -+ return NULL; -+ while (pvt->samples >= CODEC2_SAMPLES) { -+ /* Encode a frame of data */ -+ codec2_encode(tmp->codec2, (unsigned char*)(pvt->outbuf.c + datalen), tmp->buf + samples); -+ datalen += CODEC2_FRAME_LEN; -+ samples += CODEC2_SAMPLES; -+ pvt->samples -= CODEC2_SAMPLES; -+ } -+ -+ /* Move the data at the end of the buffer to the front */ -+ if (pvt->samples) -+ memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); -+ -+ return ast_trans_frameout(pvt, datalen, samples); -+} -+ -+static void codec2_destroy_stuff(struct ast_trans_pvt *pvt) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ if (tmp->codec2) -+ codec2_destroy(tmp->codec2); -+} -+ -+static struct ast_translator codec2tolin = { -+ .name = "codec2tolin", -+ .newpvt = codec2_new, -+ .framein = codec2tolin_framein, -+ .destroy = codec2_destroy_stuff, -+ .sample = codec2_sample, -+ .buffer_samples = BUFFER_SAMPLES, -+ .buf_size = BUFFER_SAMPLES * 2, -+ .desc_size = sizeof (struct codec2_translator_pvt ), -+}; -+ -+static struct ast_translator lintocodec2 = { -+ .name = "lintocodec2", -+ .newpvt = codec2_new, -+ .framein = lintocodec2_framein, -+ .frameout = lintocodec2_frameout, -+ .destroy = codec2_destroy_stuff, -+ .sample = slin8_sample, -+ .desc_size = sizeof (struct codec2_translator_pvt ), -+ .buf_size = (BUFFER_SAMPLES * CODEC2_FRAME_LEN + CODEC2_SAMPLES - 1)/CODEC2_SAMPLES, -+}; -+ -+/*! \brief standard module glue */ -+static int reload(void) -+{ -+ return AST_MODULE_LOAD_SUCCESS; -+} -+ -+static int unload_module(void) -+{ -+ int res; -+ -+ res = ast_unregister_translator(&lintocodec2); -+ if (!res) -+ res = ast_unregister_translator(&codec2tolin); -+ -+ return res; -+} -+ -+static int load_module(void) -+{ -+ int res; -+ -+ ast_format_set(&codec2tolin.src_format, AST_FORMAT_CODEC2, 0); -+ ast_format_set(&codec2tolin.dst_format, AST_FORMAT_SLINEAR, 0); -+ -+ ast_format_set(&lintocodec2.src_format, AST_FORMAT_SLINEAR, 0); -+ ast_format_set(&lintocodec2.dst_format, AST_FORMAT_CODEC2, 0); -+ -+ res = ast_register_translator(&codec2tolin); -+ if (!res) -+ res=ast_register_translator(&lintocodec2); -+ else -+ ast_unregister_translator(&codec2tolin); -+ if (res) -+ return AST_MODULE_LOAD_FAILURE; -+ return AST_MODULE_LOAD_SUCCESS; -+} -+ -+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Codec 2 Coder/Decoder", -+ .load = load_module, -+ .unload = unload_module, -+ .reload = reload, -+ ); -diff -urN asterisk-11.8.1-orig/codecs/ex_codec2.h asterisk-11.8.1-codec2/codecs/ex_codec2.h ---- asterisk-11.8.1-orig/codecs/ex_codec2.h 1970-01-01 01:00:00.000000000 +0100 -+++ asterisk-11.8.1-codec2/codecs/ex_codec2.h 2014-04-01 01:30:29.000000000 +0200 -@@ -0,0 +1,29 @@ -+/*! \file -+ * \brief 8-bit raw data -+ * -+ * Copyright (C) 2012, 2012 Ed W and David Rowe -+ * -+ * Distributed under the terms of the GNU General Public License -+ * -+ */ -+ -+static uint8_t ex_codec2[] = { -+ 0xea,0xca,0x14,0x85,0x91,0x78 -+}; -+ -+static struct ast_frame *codec2_sample(void) -+{ -+ static struct ast_frame f = { -+ .frametype = AST_FRAME_VOICE, -+ .datalen = sizeof(ex_codec2), -+ .samples = CODEC2_SAMPLES, -+ .mallocd = 0, -+ .offset = 0, -+ .src = __PRETTY_FUNCTION__, -+ .data.ptr = ex_codec2, -+ }; -+ -+ ast_format_set(&f.subclass.format, AST_FORMAT_CODEC2, 0); -+ -+ return &f; -+} -diff -urN asterisk-11.8.1-orig/configure.ac asterisk-11.8.1-codec2/configure.ac ---- asterisk-11.8.1-orig/configure.ac 2014-01-08 17:17:32.000000000 +0100 -+++ asterisk-11.8.1-codec2/configure.ac 2014-04-01 10:27:08.503390997 +0200 -@@ -384,6 +384,7 @@ - AST_EXT_LIB_SETUP([BKTR], [Stack Backtrace], [execinfo]) - AST_EXT_LIB_SETUP([BLUETOOTH], [Bluetooth], [bluetooth]) - AST_EXT_LIB_SETUP([CAP], [POSIX 1.e capabilities], [cap]) -+AST_EXT_LIB_SETUP([CODEC2], [Codec 2], [codec2]) - AST_EXT_LIB_SETUP([COROSYNC], [Corosync], [cpg]) - AST_EXT_LIB_SETUP_OPTIONAL([COROSYNC_CFG_STATE_TRACK], [A callback only in corosync 1.x], [COROSYNC], [cfg]) - AST_EXT_LIB_SETUP([CURSES], [curses], [curses]) -@@ -2116,6 +2117,8 @@ - - AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h]) - -+AST_EXT_LIB_CHECK([CODEC2], [codec2], [codec2_create], [codec2/codec2.h]) -+ - AST_EXT_LIB_CHECK([COROSYNC], [cpg], [cpg_join], [corosync/cpg.h], [-lcfg]) - AST_EXT_LIB_CHECK([COROSYNC_CFG_STATE_TRACK], [cfg], [corosync_cfg_state_track], [corosync/cfg.h], [-lcfg]) - -diff -urN asterisk-11.8.1-orig/include/asterisk/format.h asterisk-11.8.1-codec2/include/asterisk/format.h ---- asterisk-11.8.1-orig/include/asterisk/format.h 2012-07-13 20:41:07.000000000 +0200 -+++ asterisk-11.8.1-codec2/include/asterisk/format.h 2014-04-01 10:03:16.120355835 +0200 -@@ -101,6 +101,7 @@ - AST_FORMAT_SLINEAR192 = 27 + AST_FORMAT_TYPE_AUDIO, - AST_FORMAT_SPEEX32 = 28 + AST_FORMAT_TYPE_AUDIO, - AST_FORMAT_CELT = 29 + AST_FORMAT_TYPE_AUDIO, -+ AST_FORMAT_CODEC2 = 31 + AST_FORMAT_TYPE_AUDIO, - - /*! H.261 Video */ - AST_FORMAT_H261 = 1 + AST_FORMAT_TYPE_VIDEO, -diff -urN asterisk-11.8.1-orig/main/channel.c asterisk-11.8.1-codec2/main/channel.c ---- asterisk-11.8.1-orig/main/channel.c 2013-12-31 00:16:04.000000000 +0100 -+++ asterisk-11.8.1-codec2/main/channel.c 2014-04-01 10:06:55.659929991 +0200 -@@ -918,6 +918,8 @@ - AST_FORMAT_SILK, - /*! CELT supports crazy high sample rates */ - AST_FORMAT_CELT, -+ /* Codec 2 */ -+ AST_FORMAT_CODEC2, - /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough - to use it */ - AST_FORMAT_LPC10, -diff -urN asterisk-11.8.1-orig/main/format.c asterisk-11.8.1-codec2/main/format.c ---- asterisk-11.8.1-orig/main/format.c 2013-06-12 04:25:23.000000000 +0200 -+++ asterisk-11.8.1-codec2/main/format.c 2014-04-01 10:11:05.319972320 +0200 -@@ -430,6 +430,9 @@ - /*! SpeeX Wideband (16kHz) Free Compression */ - case AST_FORMAT_SPEEX16: - return (1ULL << 33); -+ /*! Codec 2 (8KHz) */ -+ case AST_FORMAT_CODEC2: -+ return (1ULL << 35); - /*! Raw mu-law data (G.711) */ - case AST_FORMAT_TESTLAW: - return (1ULL << 47); -@@ -532,6 +535,9 @@ - /*! SpeeX Wideband (16kHz) Free Compression */ - case (1ULL << 33): - return ast_format_set(dst, AST_FORMAT_SPEEX16, 0); -+ /*! Codec 2 (8KHz) */ -+ case (1ULL << 35): -+ return ast_format_set(dst, AST_FORMAT_CODEC2, 0); - /*! Raw mu-law data (G.711) */ - case (1ULL << 47): - return ast_format_set(dst, AST_FORMAT_TESTLAW, 0); -@@ -1071,6 +1077,8 @@ - format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR48, 0), "slin48", 48000, "16 bit Signed Linear PCM (48kHz)", 960, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (48kHz) */ - format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR96, 0), "slin96", 96000, "16 bit Signed Linear PCM (96kHz)", 1920, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (96kHz) */ - format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR192, 0), "slin192", 192000, "16 bit Signed Linear PCM (192kHz)", 3840, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (192kHz) */ -+ /* Codec 2 */ -+ format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), "codec2", 8000, "Codec 2", 6, 20, 20, 20, 20, 0, 0); /*!< codec_codec2.c */ - - return 0; - } -diff -urN asterisk-11.8.1-orig/main/frame.c asterisk-11.8.1-codec2/main/frame.c ---- asterisk-11.8.1-orig/main/frame.c 2012-07-24 18:54:26.000000000 +0200 -+++ asterisk-11.8.1-codec2/main/frame.c 2014-04-01 10:13:35.626395684 +0200 -@@ -1083,6 +1083,10 @@ - /* TODO The assumes 20ms delivery right now, which is incorrect */ - samples = ast_format_rate(&f->subclass.format) / 50; - break; -+ /* Codec 2 */ -+ case AST_FORMAT_CODEC2: -+ samples = 160 * (f->datalen / 6); -+ break; - default: - ast_log(LOG_WARNING, "Unable to calculate samples for format %s\n", ast_getformatname(&f->subclass.format)); - } -@@ -1134,6 +1138,10 @@ - /* 48,000 samples per second at 64kbps is 8,000 bytes per second */ - len = (int) samples / ((float) 48000 / 8000); - break; -+ /* Codec 2 */ -+ case AST_FORMAT_CODEC2: -+ len = (samples / 160) * 6; -+ break; - default: - ast_log(LOG_WARNING, "Unable to calculate sample length for format %s\n", ast_getformatname(format)); - } -diff -urN asterisk-11.8.1-orig/main/rtp_engine.c asterisk-11.8.1-codec2/main/rtp_engine.c ---- asterisk-11.8.1-orig/main/rtp_engine.c 2013-12-18 00:35:07.000000000 +0100 -+++ asterisk-11.8.1-codec2/main/rtp_engine.c 2014-04-01 10:17:00.121681465 +0200 -@@ -2289,6 +2289,8 @@ - set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_SIREN7, 0), 0, "audio", "G7221", 16000); - set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_SIREN14, 0), 0, "audio", "G7221", 32000); - set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_G719, 0), 0, "audio", "G719", 48000); -+ /* Codec 2 */ -+ set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), 0, "audio", "CODEC2", 8000); - - /* Define the static rtp payload mappings */ - add_static_payload(0, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0), 0); -@@ -2330,6 +2332,8 @@ - add_static_payload(118, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR16, 0), 0); /* 16 Khz signed linear */ - add_static_payload(119, ast_format_set(&tmpfmt, AST_FORMAT_SPEEX32, 0), 0); - add_static_payload(121, NULL, AST_RTP_CISCO_DTMF); /* Must be type 121 */ -+ /* Codec 2 */ -+ add_static_payload(121, ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), 0); - - return 0; - } -diff -urN asterisk-11.8.1-orig/makeopts.in asterisk-11.8.1-codec2/makeopts.in ---- asterisk-11.8.1-orig/makeopts.in 2013-04-11 21:59:35.000000000 +0200 -+++ asterisk-11.8.1-codec2/makeopts.in 2014-04-01 10:28:49.424993462 +0200 -@@ -120,6 +120,9 @@ - BLUETOOTH_INCLUDE=@BLUETOOTH_INCLUDE@ - BLUETOOTH_LIB=@BLUETOOTH_LIB@ - -+CODEC2_INCLUDE=@CODEC2_INCLUDE@ -+CODEC2_LIB=@CODEC2_LIB@ -+ - CURL_INCLUDE=@CURL_INCLUDE@ - CURL_LIB=@CURL_LIB@ - -diff -urN asterisk-11.8.1-orig/res/res_rtp_asterisk.c asterisk-11.8.1-codec2/res/res_rtp_asterisk.c ---- asterisk-11.8.1-orig/res/res_rtp_asterisk.c 2014-02-27 22:39:30.000000000 +0100 -+++ asterisk-11.8.1-codec2/res/res_rtp_asterisk.c 2014-04-01 10:19:18.727901747 +0200 -@@ -2738,6 +2738,8 @@ - case AST_FORMAT_SIREN7: - case AST_FORMAT_SIREN14: - case AST_FORMAT_G719: -+ /* Codec 2 */ -+ case AST_FORMAT_CODEC2: - /* these are all frame-based codecs and cannot be safely run through - a smoother */ - break; diff --git a/codec2/asterisk-11/asterisk-11.8.1-opus-codec2.patch b/codec2/asterisk-11/asterisk-11.8.1-opus-codec2.patch deleted file mode 100644 index a90d3d60..00000000 --- a/codec2/asterisk-11/asterisk-11.8.1-opus-codec2.patch +++ /dev/null @@ -1,384 +0,0 @@ -diff -urN asterisk-11.8.1-opus/build_tools/menuselect-deps.in asterisk-11.8.1-opus-codec2/build_tools/menuselect-deps.in ---- asterisk-11.8.1-opus/build_tools/menuselect-deps.in 2014-04-01 10:58:52.127106070 +0200 -+++ asterisk-11.8.1-opus-codec2/build_tools/menuselect-deps.in 2014-04-01 10:50:21.490079146 +0200 -@@ -4,6 +4,7 @@ - CRYPTO=@PBX_CRYPTO@ - BFD=@PBX_BFD@ - BISON=@PBX_BISON@ -+CODEC2=@PBX_CODEC2@ - CURL=@PBX_CURL@ - DAHDI=@PBX_DAHDI@ - DLADDR=@PBX_DLADDR@ -diff -urN asterisk-11.8.1-opus/codecs/codec_codec2.c asterisk-11.8.1-opus-codec2/codecs/codec_codec2.c ---- asterisk-11.8.1-opus/codecs/codec_codec2.c 1970-01-01 01:00:00.000000000 +0100 -+++ asterisk-11.8.1-opus-codec2/codecs/codec_codec2.c 2014-04-01 10:50:21.490079146 +0200 -@@ -0,0 +1,190 @@ -+/* -+ * Codec 2 module for Asterisk. -+ * -+ * Credit: codec_gsm.c used as a starting point. -+ * -+ * Copyright (C) 2012 Ed W and David Rowe -+ * -+ * This program is free software, distributed under the terms of -+ * the GNU General Public License Version 2. See the LICENSE file -+ * at the top of the source tree. -+ */ -+ -+/*! \file -+ * -+ * \brief Translate between signed linear and Codec 2 -+ * -+ * \ingroup codecs -+ */ -+ -+/*** MODULEINFO -+ codec2 -+ core -+ ***/ -+ -+#include "asterisk.h" -+ -+#include "asterisk/translate.h" -+#include "asterisk/config.h" -+#include "asterisk/module.h" -+#include "asterisk/utils.h" -+ -+#include -+ -+#define BUFFER_SAMPLES 8000 -+#define CODEC2_SAMPLES 160 -+#define CODEC2_FRAME_LEN 6 -+ -+/* Sample frame data */ -+ -+#include "asterisk/slin.h" -+#include "ex_codec2.h" -+ -+struct codec2_translator_pvt { /* both codec2tolin and codec2togsm */ -+ struct CODEC2 *codec2; -+ int16_t buf[BUFFER_SAMPLES]; /* lintocodec2, temporary storage */ -+}; -+ -+static int codec2_new(struct ast_trans_pvt *pvt) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ -+ tmp->codec2 = codec2_create(CODEC2_MODE_2400); -+ if (!tmp) -+ return -1; -+ -+ return 0; -+} -+ -+/*! \brief decode and store in outbuf. */ -+static int codec2tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ int x; -+ int16_t *dst = pvt->outbuf.i16; -+ int flen = CODEC2_FRAME_LEN; -+ -+ for (x=0; x < f->datalen; x += flen) { -+ unsigned char *src; -+ int len; -+ len = CODEC2_SAMPLES; -+ src = f->data.ptr + x; -+ -+ codec2_decode(tmp->codec2, dst + pvt->samples, src); -+ -+ pvt->samples += CODEC2_SAMPLES; -+ pvt->datalen += 2 * CODEC2_SAMPLES; -+ } -+ return 0; -+} -+ -+/*! \brief store samples into working buffer for later decode */ -+static int lintocodec2_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ -+ if (pvt->samples + f->samples > BUFFER_SAMPLES) { -+ ast_log(LOG_WARNING, "Out of buffer space\n"); -+ return -1; -+ } -+ memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen); -+ pvt->samples += f->samples; -+ return 0; -+} -+ -+/*! \brief encode and produce a frame */ -+static struct ast_frame *lintocodec2_frameout(struct ast_trans_pvt *pvt) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ int datalen = 0; -+ int samples = 0; -+ -+ /* We can't work on anything less than a frame in size */ -+ if (pvt->samples < CODEC2_SAMPLES) -+ return NULL; -+ while (pvt->samples >= CODEC2_SAMPLES) { -+ /* Encode a frame of data */ -+ codec2_encode(tmp->codec2, (unsigned char*)(pvt->outbuf.c + datalen), tmp->buf + samples); -+ datalen += CODEC2_FRAME_LEN; -+ samples += CODEC2_SAMPLES; -+ pvt->samples -= CODEC2_SAMPLES; -+ } -+ -+ /* Move the data at the end of the buffer to the front */ -+ if (pvt->samples) -+ memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); -+ -+ return ast_trans_frameout(pvt, datalen, samples); -+} -+ -+static void codec2_destroy_stuff(struct ast_trans_pvt *pvt) -+{ -+ struct codec2_translator_pvt *tmp = pvt->pvt; -+ if (tmp->codec2) -+ codec2_destroy(tmp->codec2); -+} -+ -+static struct ast_translator codec2tolin = { -+ .name = "codec2tolin", -+ .newpvt = codec2_new, -+ .framein = codec2tolin_framein, -+ .destroy = codec2_destroy_stuff, -+ .sample = codec2_sample, -+ .buffer_samples = BUFFER_SAMPLES, -+ .buf_size = BUFFER_SAMPLES * 2, -+ .desc_size = sizeof (struct codec2_translator_pvt ), -+}; -+ -+static struct ast_translator lintocodec2 = { -+ .name = "lintocodec2", -+ .newpvt = codec2_new, -+ .framein = lintocodec2_framein, -+ .frameout = lintocodec2_frameout, -+ .destroy = codec2_destroy_stuff, -+ .sample = slin8_sample, -+ .desc_size = sizeof (struct codec2_translator_pvt ), -+ .buf_size = (BUFFER_SAMPLES * CODEC2_FRAME_LEN + CODEC2_SAMPLES - 1)/CODEC2_SAMPLES, -+}; -+ -+/*! \brief standard module glue */ -+static int reload(void) -+{ -+ return AST_MODULE_LOAD_SUCCESS; -+} -+ -+static int unload_module(void) -+{ -+ int res; -+ -+ res = ast_unregister_translator(&lintocodec2); -+ if (!res) -+ res = ast_unregister_translator(&codec2tolin); -+ -+ return res; -+} -+ -+static int load_module(void) -+{ -+ int res; -+ -+ ast_format_set(&codec2tolin.src_format, AST_FORMAT_CODEC2, 0); -+ ast_format_set(&codec2tolin.dst_format, AST_FORMAT_SLINEAR, 0); -+ -+ ast_format_set(&lintocodec2.src_format, AST_FORMAT_SLINEAR, 0); -+ ast_format_set(&lintocodec2.dst_format, AST_FORMAT_CODEC2, 0); -+ -+ res = ast_register_translator(&codec2tolin); -+ if (!res) -+ res=ast_register_translator(&lintocodec2); -+ else -+ ast_unregister_translator(&codec2tolin); -+ if (res) -+ return AST_MODULE_LOAD_FAILURE; -+ return AST_MODULE_LOAD_SUCCESS; -+} -+ -+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Codec 2 Coder/Decoder", -+ .load = load_module, -+ .unload = unload_module, -+ .reload = reload, -+ ); -diff -urN asterisk-11.8.1-opus/codecs/ex_codec2.h asterisk-11.8.1-opus-codec2/codecs/ex_codec2.h ---- asterisk-11.8.1-opus/codecs/ex_codec2.h 1970-01-01 01:00:00.000000000 +0100 -+++ asterisk-11.8.1-opus-codec2/codecs/ex_codec2.h 2014-04-01 10:50:21.490079146 +0200 -@@ -0,0 +1,29 @@ -+/*! \file -+ * \brief 8-bit raw data -+ * -+ * Copyright (C) 2012, 2012 Ed W and David Rowe -+ * -+ * Distributed under the terms of the GNU General Public License -+ * -+ */ -+ -+static uint8_t ex_codec2[] = { -+ 0xea,0xca,0x14,0x85,0x91,0x78 -+}; -+ -+static struct ast_frame *codec2_sample(void) -+{ -+ static struct ast_frame f = { -+ .frametype = AST_FRAME_VOICE, -+ .datalen = sizeof(ex_codec2), -+ .samples = CODEC2_SAMPLES, -+ .mallocd = 0, -+ .offset = 0, -+ .src = __PRETTY_FUNCTION__, -+ .data.ptr = ex_codec2, -+ }; -+ -+ ast_format_set(&f.subclass.format, AST_FORMAT_CODEC2, 0); -+ -+ return &f; -+} -diff -urN asterisk-11.8.1-opus/configure.ac asterisk-11.8.1-opus-codec2/configure.ac ---- asterisk-11.8.1-opus/configure.ac 2014-04-01 10:58:52.143106352 +0200 -+++ asterisk-11.8.1-opus-codec2/configure.ac 2014-04-01 10:50:21.494079217 +0200 -@@ -384,6 +384,7 @@ - AST_EXT_LIB_SETUP([BKTR], [Stack Backtrace], [execinfo]) - AST_EXT_LIB_SETUP([BLUETOOTH], [Bluetooth], [bluetooth]) - AST_EXT_LIB_SETUP([CAP], [POSIX 1.e capabilities], [cap]) -+AST_EXT_LIB_SETUP([CODEC2], [Codec 2], [codec2]) - AST_EXT_LIB_SETUP([COROSYNC], [Corosync], [cpg]) - AST_EXT_LIB_SETUP_OPTIONAL([COROSYNC_CFG_STATE_TRACK], [A callback only in corosync 1.x], [COROSYNC], [cfg]) - AST_EXT_LIB_SETUP([CURSES], [curses], [curses]) -@@ -2117,6 +2118,8 @@ - - AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h]) - -+AST_EXT_LIB_CHECK([CODEC2], [codec2], [codec2_create], [codec2/codec2.h]) -+ - AST_EXT_LIB_CHECK([COROSYNC], [cpg], [cpg_join], [corosync/cpg.h], [-lcfg]) - AST_EXT_LIB_CHECK([COROSYNC_CFG_STATE_TRACK], [cfg], [corosync_cfg_state_track], [corosync/cfg.h], [-lcfg]) - -diff -urN asterisk-11.8.1-opus/include/asterisk/format.h asterisk-11.8.1-opus-codec2/include/asterisk/format.h ---- asterisk-11.8.1-opus/include/asterisk/format.h 2014-04-01 10:58:52.143106352 +0200 -+++ asterisk-11.8.1-opus-codec2/include/asterisk/format.h 2014-04-01 10:53:25.961351185 +0200 -@@ -103,6 +103,7 @@ - AST_FORMAT_CELT = 29 + AST_FORMAT_TYPE_AUDIO, - /*! Opus */ - AST_FORMAT_OPUS = 30 + AST_FORMAT_TYPE_AUDIO, -+ AST_FORMAT_CODEC2 = 31 + AST_FORMAT_TYPE_AUDIO, - - /*! H.261 Video */ - AST_FORMAT_H261 = 1 + AST_FORMAT_TYPE_VIDEO, -diff -urN asterisk-11.8.1-opus/main/channel.c asterisk-11.8.1-opus-codec2/main/channel.c ---- asterisk-11.8.1-opus/main/channel.c 2014-04-01 10:58:52.147106422 +0200 -+++ asterisk-11.8.1-opus-codec2/main/channel.c 2014-04-01 10:50:21.498079289 +0200 -@@ -920,6 +920,8 @@ - AST_FORMAT_SILK, - /*! CELT supports crazy high sample rates */ - AST_FORMAT_CELT, -+ /* Codec 2 */ -+ AST_FORMAT_CODEC2, - /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough - to use it */ - AST_FORMAT_LPC10, -diff -urN asterisk-11.8.1-opus/main/format.c asterisk-11.8.1-opus-codec2/main/format.c ---- asterisk-11.8.1-opus/main/format.c 2014-04-01 10:58:52.147106422 +0200 -+++ asterisk-11.8.1-opus-codec2/main/format.c 2014-04-01 10:52:23.820250398 +0200 -@@ -433,6 +433,9 @@ - /*! Opus audio (8kHz, 16kHz, 24kHz, 48Khz) */ - case AST_FORMAT_OPUS: - return (1ULL << 34); -+ /*! Codec 2 (8KHz) */ -+ case AST_FORMAT_CODEC2: -+ return (1ULL << 35); - /*! Raw mu-law data (G.711) */ - case AST_FORMAT_TESTLAW: - return (1ULL << 47); -@@ -541,6 +544,9 @@ - /*! Opus audio (8kHz, 16kHz, 24kHz, 48Khz) */ - case (1ULL << 34): - return ast_format_set(dst, AST_FORMAT_OPUS, 0); -+ /*! Codec 2 (8KHz) */ -+ case (1ULL << 35): -+ return ast_format_set(dst, AST_FORMAT_CODEC2, 0); - /*! Raw mu-law data (G.711) */ - case (1ULL << 47): - return ast_format_set(dst, AST_FORMAT_TESTLAW, 0); -@@ -1090,6 +1096,8 @@ - format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_OPUS, 0), "opus", 48000, "Opus Codec", 10, 20, 60, 20, 20, 0, 0); /*!< codec_opus.c */ - /* VP8 (passthrough) */ - format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_VP8, 0), "vp8", 0, "VP8 Video", 0, 0, 0, 0 ,0 ,0, 0); /*!< Passthrough support, see format_h263.c */ -+ /* Codec 2 */ -+ format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), "codec2", 8000, "Codec 2", 6, 20, 20, 20, 20, 0, 0); /*!< codec_codec2.c */ - - return 0; - } -diff -urN asterisk-11.8.1-opus/main/frame.c asterisk-11.8.1-opus-codec2/main/frame.c ---- asterisk-11.8.1-opus/main/frame.c 2014-04-01 10:58:52.151106493 +0200 -+++ asterisk-11.8.1-opus-codec2/main/frame.c 2014-04-01 10:50:21.502079360 +0200 -@@ -1121,6 +1121,10 @@ - case AST_FORMAT_OPUS: - samples = opus_samples(f->data.ptr, f->datalen); - break; -+ /* Codec 2 */ -+ case AST_FORMAT_CODEC2: -+ samples = 160 * (f->datalen / 6); -+ break; - default: - ast_log(LOG_WARNING, "Unable to calculate samples for format %s\n", ast_getformatname(&f->subclass.format)); - } -@@ -1172,6 +1176,10 @@ - /* 48,000 samples per second at 64kbps is 8,000 bytes per second */ - len = (int) samples / ((float) 48000 / 8000); - break; -+ /* Codec 2 */ -+ case AST_FORMAT_CODEC2: -+ len = (samples / 160) * 6; -+ break; - default: - ast_log(LOG_WARNING, "Unable to calculate sample length for format %s\n", ast_getformatname(format)); - } -diff -urN asterisk-11.8.1-opus/main/rtp_engine.c asterisk-11.8.1-opus-codec2/main/rtp_engine.c ---- asterisk-11.8.1-opus/main/rtp_engine.c 2014-04-01 10:58:52.151106493 +0200 -+++ asterisk-11.8.1-opus-codec2/main/rtp_engine.c 2014-04-01 10:51:17.367071621 +0200 -@@ -2292,6 +2292,8 @@ - /* Opus and VP8 */ - set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_OPUS, 0), 0, "audio", "opus", 48000); - set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_VP8, 0), 0, "video", "VP8", 90000); -+ /* Codec 2 */ -+ set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), 0, "audio", "CODEC2", 8000); - - /* Define the static rtp payload mappings */ - add_static_payload(0, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0), 0); -@@ -2336,6 +2338,8 @@ - /* Opus and VP8 */ - add_static_payload(100, ast_format_set(&tmpfmt, AST_FORMAT_VP8, 0), 0); - add_static_payload(107, ast_format_set(&tmpfmt, AST_FORMAT_OPUS, 0), 0); -+ /* Codec 2 */ -+ add_static_payload(121, ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), 0); - - return 0; - } -diff -urN asterisk-11.8.1-opus/makeopts.in asterisk-11.8.1-opus-codec2/makeopts.in ---- asterisk-11.8.1-opus/makeopts.in 2014-04-01 10:58:52.151106493 +0200 -+++ asterisk-11.8.1-opus-codec2/makeopts.in 2014-04-01 10:50:21.538079999 +0200 -@@ -120,6 +120,9 @@ - BLUETOOTH_INCLUDE=@BLUETOOTH_INCLUDE@ - BLUETOOTH_LIB=@BLUETOOTH_LIB@ - -+CODEC2_INCLUDE=@CODEC2_INCLUDE@ -+CODEC2_LIB=@CODEC2_LIB@ -+ - CURL_INCLUDE=@CURL_INCLUDE@ - CURL_LIB=@CURL_LIB@ - -diff -urN asterisk-11.8.1-opus/res/res_rtp_asterisk.c asterisk-11.8.1-opus-codec2/res/res_rtp_asterisk.c ---- asterisk-11.8.1-opus/res/res_rtp_asterisk.c 2014-04-01 10:58:52.151106493 +0200 -+++ asterisk-11.8.1-opus-codec2/res/res_rtp_asterisk.c 2014-04-01 10:53:02.292932085 +0200 -@@ -2780,6 +2780,8 @@ - case AST_FORMAT_G719: - /* Opus */ - case AST_FORMAT_OPUS: -+ /* Codec 2 */ -+ case AST_FORMAT_CODEC2: - /* these are all frame-based codecs and cannot be safely run through - a smoother */ - break; diff --git a/codec2/asterisk/README b/codec2/asterisk/README deleted file mode 100644 index 9bc814b4..00000000 --- a/codec2/asterisk/README +++ /dev/null @@ -1,109 +0,0 @@ -README for codec2/asterisk -Asterisk Codec 2 support - -Test Configuration ------------------- - -Codec 2 is used to trunk calls between two Asterisk boxes: - - A - SIP phone - Asterisk A - Codec2 - Asterisk B - SIP Phone - B - -The two SIP phones are configured for mulaw. - -Building ---------- - -Asterisk must be patched so that the core understand Codec 2 frames. - -1/ First install Codec 2: - - david@cool:~$ svn co https://freetel.svn.sourceforge.net/svnroot/freetel/codec2 codec2 - david@cool:~/codec2$ cd codec2 - david@cool:~/codec2$ ./configure && make && sudo make install - david@bear:~/codec2$ sudo ldconfig -v - david@cool:~/codec2$ cd ~ - -2/ Then build Asterisk with Codec 2 support: - - david@cool:~$ tar xvzf asterisk-1.8.9.0.tar.gz - david@cool:~/asterisk-1.8.9.0$ patch -p4 < ~/codec2/asterisk/asterisk-codec2.patch - david@cool:~/asterisk-1.8.9.0$ cp ~/codec2/asterisk/codec_codec2.c . - david@cool:~/asterisk-1.8.9.0$ cp ~/codec2/asterisk/ex_codec2.h ./codecs - david@cool:~/asterisk-1.8.9.0$ ./configure && make ASTLDFLAGS=-lcodec2 - david@cool:~/asterisk-1.8.9.0$ sudo make install - david@cool:~/asterisk-1.8.9.0$ sudo make samples - -3/ Add this to the end of sip.conf on Asterisk A: - - [6013] - type=friend - context=default - host=dynamic - user=6013 - secret=6013 - canreinvite=no - callerid=6013 - disallow=all - allow=ulaw - - [potato] - type=peer - username=potato - fromuser=potato - secret=password - context=default - disallow=all - dtmfmode=rfc2833 - callerid=server - canreinvite=no - host=cool - allow=codec2 - -3/ Add this to the end of sip.conf on Asterisk B: - - [6014] - type=friend - context=default - host=dynamic - user=6014 - secret=6014 - canreinvite=no - callerid=6014 - disallow=all - allow=ulaw - - [potato] - type=peer - username=potato - fromuser=potato - secret=password - context=default - disallow=all - dtmfmode=rfc2833 - callerid=server - canreinvite=no - host=bear - allow=codec2 - -4/ Here is the [default] section of extensions.conf on Asterisk B: - - [default] - - exten => 6013,1,Dial(SIP/potato/6013) - ; - ; By default we include the demo. In a production system, you - ; probably don't want to have the demo there. - ; - ;include => demo - -5/ After booting see if the codec2_codec2.so module is loaded with "core show translate" - -6/ To make a test call dial 6013 on the SIP phone connected to Asterisk B - -7/ If codec_codec2.so won't load and you see "can't find codec2_create" try: - - david@cool:~/asterisk-1.8.9.0$ touch codecs/codec_codec2.c - david@cool:~/asterisk-1.8.9.0$ make ASTLDFLAGS=-lcodec2 - david@cool:~/asterisk-1.8.9.0$ sudo cp codecs/codec_codec2.so /usr/lib/asterisk/modules - david@cool:~/asterisk-1.8.9.0$ sudo asterisk -vvvcn - diff --git a/codec2/asterisk/asterisk-codec2.patch b/codec2/asterisk/asterisk-codec2.patch deleted file mode 100644 index 53569ff9..00000000 --- a/codec2/asterisk/asterisk-codec2.patch +++ /dev/null @@ -1,68 +0,0 @@ ---- /home/david/asterisk-1.8.9.0-orig/include/asterisk/frame.h 2011-12-23 05:08:46.000000000 +1030 -+++ /home/david/asterisk-1.8.9.0-codec2/include/asterisk/frame.h 2012-03-27 13:16:55.623452431 +1030 -@@ -299,6 +299,7 @@ - #define AST_FORMAT_G719 (1ULL << 32) - /*! SpeeX Wideband (16kHz) Free Compression */ - #define AST_FORMAT_SPEEX16 (1ULL << 33) -+#define AST_FORMAT_CODEC2 (1ULL << 34) - /*! Raw mu-law data (G.711) */ - #define AST_FORMAT_TESTLAW (1ULL << 47) - /*! Reserved bit - do not use */ ---- /home/david/asterisk-1.8.9.0-orig/main/frame.c 2010-06-18 02:53:43.000000000 +0930 -+++ /home/david/asterisk-1.8.9.0-codec2/main/frame.c 2012-03-28 15:16:16.975581316 +1030 -@@ -102,6 +102,7 @@ - { AST_FORMAT_ADPCM, "adpcm" , 8000, "ADPCM", 40, 10, 300, 10, 20 }, /*!< codec_adpcm.c */ - { AST_FORMAT_SLINEAR, "slin", 8000, "16 bit Signed Linear PCM", 160, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE }, /*!< Signed linear */ - { AST_FORMAT_LPC10, "lpc10", 8000, "LPC10", 7, 20, 20, 20, 20 }, /*!< codec_lpc10.c */ -+ { AST_FORMAT_CODEC2, "codec2", 8000, "Codec 2", 6, 20, 20, 20, 20 }, /*!< codec_codec2.c */ - { AST_FORMAT_G729A, "g729", 8000, "G.729A", 10, 10, 230, 10, 20, AST_SMOOTHER_FLAG_G729 }, /*!< Binary commercial distribution */ - { AST_FORMAT_SPEEX, "speex", 8000, "SpeeX", 10, 10, 60, 10, 20 }, /*!< codec_speex.c */ - { AST_FORMAT_SPEEX16, "speex16", 16000, "SpeeX 16khz", 10, 10, 60, 10, 20 }, /*!< codec_speex.c */ -@@ -1475,6 +1476,9 @@ - samples = 22 * 8; - samples += (((char *)(f->data.ptr))[7] & 0x1) * 8; - break; -+ case AST_FORMAT_CODEC2: -+ samples = 160 * (f->datalen / 6); -+ break; - case AST_FORMAT_ULAW: - case AST_FORMAT_ALAW: - case AST_FORMAT_TESTLAW: -@@ -1519,6 +1523,9 @@ - case AST_FORMAT_GSM: - len = (samples / 160) * 33; - break; -+ case AST_FORMAT_CODEC2: -+ len = (samples / 160) * 6; -+ break; - case AST_FORMAT_G729A: - len = samples / 8; - break; ---- /home/david/asterisk-1.8.9.0-orig/main/channel.c 2011-12-17 10:21:13.000000000 +1030 -+++ /home/david/asterisk-1.8.9.0-codec2/main/channel.c 2012-03-28 15:05:22.395293391 +1030 -@@ -1075,6 +1075,7 @@ - /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough - to use it */ - AST_FORMAT_LPC10, -+ AST_FORMAT_CODEC2, - /*! G.729a is faster than 723 and slightly less expensive */ - AST_FORMAT_G729A, - /*! Down to G.723.1 which is proprietary but at least designed for voice */ ---- /home/david/asterisk-1.8.9.0-orig/main/rtp_engine.c 2011-12-30 01:43:03.000000000 +1030 -+++ /home/david/asterisk-1.8.9.0-codec2/main/rtp_engine.c 2012-03-28 16:42:02.880872891 +1030 -@@ -101,6 +101,7 @@ - {{1, AST_FORMAT_SLINEAR}, "audio", "L16", 8000}, - {{1, AST_FORMAT_SLINEAR16}, "audio", "L16", 16000}, - {{1, AST_FORMAT_LPC10}, "audio", "LPC", 8000}, -+ {{1, AST_FORMAT_CODEC2}, "audio", "CODEC2", 8000}, - {{1, AST_FORMAT_G729A}, "audio", "G729", 8000}, - {{1, AST_FORMAT_G729A}, "audio", "G729A", 8000}, - {{1, AST_FORMAT_G729A}, "audio", "G.729", 8000}, -@@ -178,6 +179,7 @@ - [117] = {1, AST_FORMAT_SPEEX16}, - [118] = {1, AST_FORMAT_SLINEAR16}, /* 16 Khz signed linear */ - [121] = {0, AST_RTP_CISCO_DTMF}, /* Must be type 121 */ -+ [121] = {1, AST_FORMAT_CODEC2}, - }; - - int ast_rtp_engine_register2(struct ast_rtp_engine *engine, struct ast_module *module) diff --git a/codec2/asterisk/codec_codec2.c b/codec2/asterisk/codec_codec2.c deleted file mode 100644 index d161be7e..00000000 --- a/codec2/asterisk/codec_codec2.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Codec 2 module for Asterisk. - * - * Credit: codec_gsm.c used as a starting point. - * - * Copyright (C) 2012 Ed W and David Rowe - * - * This program is free software, distributed under the terms of - * the GNU General Public License Version 2. See the LICENSE file - * at the top of the source tree. - */ - -/*! \file - * - * \brief Translate between signed linear and Codec 2 - * - * \ingroup codecs - */ - -/*** MODULEINFO - core - ***/ - -#include "asterisk.h" - -#include "asterisk/translate.h" -#include "asterisk/config.h" -#include "asterisk/module.h" -#include "asterisk/utils.h" - -#include - -#define BUFFER_SAMPLES 8000 -#define CODEC2_SAMPLES 160 -#define CODEC2_FRAME_LEN 6 - -/* Sample frame data */ - -#include "asterisk/slin.h" -#include "ex_codec2.h" - -struct codec2_translator_pvt { /* both codec2tolin and codec2togsm */ - struct CODEC2 *codec2; - int16_t buf[BUFFER_SAMPLES]; /* lintocodec2, temporary storage */ -}; - -static int codec2_new(struct ast_trans_pvt *pvt) -{ - struct codec2_translator_pvt *tmp = pvt->pvt; - - tmp->codec2 = codec2_create(CODEC2_MODE_2400); - if (!tmp->codec2) - return -1; - - return 0; -} - -/*! \brief decode and store in outbuf. */ -static int codec2tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) -{ - struct codec2_translator_pvt *tmp = pvt->pvt; - int x; - int16_t *dst = pvt->outbuf.i16; - int flen = CODEC2_FRAME_LEN; - - for (x=0; x < f->datalen; x += flen) { - unsigned char *src; - int len; - len = CODEC2_SAMPLES; - src = f->data.ptr + x; - - codec2_decode(tmp->codec2, dst + pvt->samples, src); - - pvt->samples += CODEC2_SAMPLES; - pvt->datalen += 2 * CODEC2_SAMPLES; - } - return 0; -} - -/*! \brief store samples into working buffer for later decode */ -static int lintocodec2_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) -{ - struct codec2_translator_pvt *tmp = pvt->pvt; - - if (pvt->samples + f->samples > BUFFER_SAMPLES) { - ast_log(LOG_WARNING, "Out of buffer space\n"); - return -1; - } - memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen); - pvt->samples += f->samples; - return 0; -} - -/*! \brief encode and produce a frame */ -static struct ast_frame *lintocodec2_frameout(struct ast_trans_pvt *pvt) -{ - struct codec2_translator_pvt *tmp = pvt->pvt; - int datalen = 0; - int samples = 0; - - /* We can't work on anything less than a frame in size */ - if (pvt->samples < CODEC2_SAMPLES) - return NULL; - while (pvt->samples >= CODEC2_SAMPLES) { - /* Encode a frame of data */ - codec2_encode(tmp->codec2, (unsigned char*)(pvt->outbuf.c + datalen), tmp->buf + samples); - datalen += CODEC2_FRAME_LEN; - samples += CODEC2_SAMPLES; - pvt->samples -= CODEC2_SAMPLES; - } - - /* Move the data at the end of the buffer to the front */ - if (pvt->samples) - memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); - - return ast_trans_frameout(pvt, datalen, samples); -} - -static void codec2_destroy_stuff(struct ast_trans_pvt *pvt) -{ - struct codec2_translator_pvt *tmp = pvt->pvt; - if (tmp->codec2) - codec2_destroy(tmp->codec2); -} - -static struct ast_translator codec2tolin = { - .name = "codec2tolin", - .srcfmt = AST_FORMAT_CODEC2, - .dstfmt = AST_FORMAT_SLINEAR, - .newpvt = codec2_new, - .framein = codec2tolin_framein, - .destroy = codec2_destroy_stuff, - .sample = codec2_sample, - .buffer_samples = BUFFER_SAMPLES, - .buf_size = BUFFER_SAMPLES * 2, - .desc_size = sizeof (struct codec2_translator_pvt ), -}; - -static struct ast_translator lintocodec2 = { - .name = "lintocodec2", - .srcfmt = AST_FORMAT_SLINEAR, - .dstfmt = AST_FORMAT_CODEC2, - .newpvt = codec2_new, - .framein = lintocodec2_framein, - .frameout = lintocodec2_frameout, - .destroy = codec2_destroy_stuff, - .sample = slin8_sample, - .desc_size = sizeof (struct codec2_translator_pvt ), - .buf_size = (BUFFER_SAMPLES * CODEC2_FRAME_LEN + CODEC2_SAMPLES - 1)/CODEC2_SAMPLES, -}; - -/*! \brief standard module glue */ -static int reload(void) -{ - return AST_MODULE_LOAD_SUCCESS; -} - -static int unload_module(void) -{ - int res; - - res = ast_unregister_translator(&lintocodec2); - if (!res) - res = ast_unregister_translator(&codec2tolin); - - return res; -} - -static int load_module(void) -{ - int res; - - res = ast_register_translator(&codec2tolin); - if (!res) - res=ast_register_translator(&lintocodec2); - else - ast_unregister_translator(&codec2tolin); - if (res) - return AST_MODULE_LOAD_FAILURE; - return AST_MODULE_LOAD_SUCCESS; -} - -AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Codec 2 Coder/Decoder", - .load = load_module, - .unload = unload_module, - .reload = reload, - ); diff --git a/codec2/asterisk/ex_codec2.h b/codec2/asterisk/ex_codec2.h deleted file mode 100644 index ac5782dd..00000000 --- a/codec2/asterisk/ex_codec2.h +++ /dev/null @@ -1,28 +0,0 @@ -/*! \file - * \brief 8-bit raw data - * - * Copyright (C) 2012, 2012 Ed W and David Rowe - * - * Distributed under the terms of the GNU General Public License - * - */ - -static uint8_t ex_codec2[] = { - 0xea,0xca,0x14,0x85,0x91,0x78 -}; - -static struct ast_frame *codec2_sample(void) -{ - static struct ast_frame f = { - .frametype = AST_FRAME_VOICE, - .subclass.codec = AST_FORMAT_CODEC2, - .datalen = sizeof(ex_codec2), - .samples = CODEC2_SAMPLES, - .mallocd = 0, - .offset = 0, - .src = __PRETTY_FUNCTION__, - .data.ptr = ex_codec2, - }; - - return &f; -} diff --git a/codec2/asterisk/make_asterisk_patch.sh b/codec2/asterisk/make_asterisk_patch.sh deleted file mode 100755 index a642bf7f..00000000 --- a/codec2/asterisk/make_asterisk_patch.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# Create patch for Codec 2 support inside Asterisk - -ORIG=~/asterisk-1.8.9.0-orig -CODEC2=~/asterisk-1.8.9.0-codec2 -diff -ruN $ORIG/include/asterisk/frame.h $CODEC2/include/asterisk/frame.h > asterisk-codec2.patch -diff -ruN $ORIG/main/frame.c $CODEC2/main/frame.c >> asterisk-codec2.patch -diff -ruN $ORIG/main/channel.c $CODEC2/main/channel.c >> asterisk-codec2.patch -diff -ruN $ORIG/main/rtp_engine.c $CODEC2/main/rtp_engine.c >> asterisk-codec2.patch - - diff --git a/codec2/branches/0.3/AUTHORS b/codec2/branches/0.3/AUTHORS new file mode 100644 index 00000000..e69de29b diff --git a/codec2/branches/0.3/CMakeLists.txt b/codec2/branches/0.3/CMakeLists.txt new file mode 100644 index 00000000..9e2b08d1 --- /dev/null +++ b/codec2/branches/0.3/CMakeLists.txt @@ -0,0 +1,184 @@ +# +# Codec2 - Next-Generation Digital Voice for Two-Way Radio +# +# CMake configuration contributed by Richard Shaw (KF5OIM) +# Please report questions, comments, problems, or patches to the freetel +# mailing list: https://lists.sourceforge.net/lists/listinfo/freetel-codec2 +# +project(codec2) + +cmake_minimum_required(VERSION 2.8) + +include(GNUInstallDirs) +mark_as_advanced(CLEAR + CMAKE_INSTALL_BINDIR + CMAKE_INSTALL_INCLUDEDIR + CMAKE_INSTALL_LIBDIR +) + +# +# Prevent in-source builds +# If an in-source build is attempted, you will still need to clean up a few +# files manually. +# +set(CMAKE_DISABLE_SOURCE_CHANGES ON) +set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) +if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") + message(FATAL_ERROR "In-source builds in ${CMAKE_BINARY_DIR} are not " + "allowed, please remove ./CMakeCache.txt and ./CMakeFiles/, create a " + "separate build directory and run cmake from there.") +endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") + + +# +# Set project version information. This should probably be done via external +# file at some point. +# +set(CODEC2_VERSION_MAJOR 0) +set(CODEC2_VERSION_MINOR 3) +# Set to patch level if needed, otherwise leave FALSE. +set(CODEC2_VERSION_PATCH FALSE) +set(CODEC2_VERSION "${CODEC2_VERSION_MAJOR}.${CODEC2_VERSION_MINOR}") +# Patch level version bumps should not change API/ABI. +set(SOVERSION "${CODEC2_VERSION_MAJOR}.${CODEC2_VERSION_MINOR}") +if(CODEC2_VERSION_PATCH) + set(CODEC2_VERSION "${CODEC2_VERSION}.${CODEC2_VERSION_PATCH}") +endif() +message(STATUS "codec2 version: ${CODEC2_VERSION}") + +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") +endif() + +# Set default C++ flags. +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") + +# -fPIC is implied on MinGW... +if(NOT WIN32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") +endif() + + +message(STATUS "Build type is: " ${CMAKE_BUILD_TYPE}) +message(STATUS "Compiler Flags: " ${CMAKE_CXX_FLAGS}) + +# +# Setup Windows/MinGW specifics here. +# +if(MINGW) + message(STATUS "System is MinGW.") +endif(MINGW) + + +# +# Find the svn revision if this is a working copy. +# WORK IN PROGRESS +# Works ok if it is a working copy but errors out if not. +# +#find_package(Subversion) +#if(Subversion_FOUND) +# Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} CODEC2) +# message(STATUS "codec2 svn revision: ${CODEC2_WC_REVISION}") +#else(SUBVERSION_FOUND) +# message(WARNING "Subversion not found. Can not determine svn revision.") +#endif(SUBVERSION_FOUND) + + +# +# Default options +# +option(BUILD_SHARED_LIBS + "Build shared library. Set to OFF for static library." ON) +option(UNITTEST "Build unittest binaries." OFF) +option(INSTALL_EXAMPLES "Install example code." OFF) +if(INSTALL_EXAMPLES) + install(DIRECTORY octave raw script voicing wav + USE_SOURCE_PERMISSIONS + DESTINATION ${CMAKE_INSTALL_DATADIR}/codec2) +endif() + + +# Math library is automatic on windows +if(UNIX) + set(CMAKE_REQUIRED_INCLUDES math.h) + set(CMAKE_REQUIRED_LIBRARIES m) +endif(UNIX) + +include(CheckIncludeFiles) +check_include_files("stdlib.h" HAVE_STDLIB_H) +check_include_files("string.h" HAVE_STRING_H) + +include(CheckFunctionExists) +check_function_exists(floor HAVE_FLOOR) +check_function_exists(ceil HAVE_CEIL) +check_function_exists(pow HAVE_POW) +check_function_exists(sqrt HAVE_SQRT) +check_function_exists(sin HAVE_SIN) +check_function_exists(cos HAVE_COS) +check_function_exists(atan2 HAVE_ATAN2) +check_function_exists(log10 HAVE_LOG10) +check_function_exists(round HAVE_ROUND) +check_function_exists(getopt HAVE_GETOPT) + +configure_file ("${PROJECT_SOURCE_DIR}/cmake/config.h.in" + "${PROJECT_BINARY_DIR}/config.h" ) +include_directories(${PROJECT_BINARY_DIR}) + +# CMake Package setup +include(CMakePackageConfigHelpers) +configure_package_config_file(cmake/codec2-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/codec2-config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/codec2 + PATH_VARS CMAKE_INSTALL_INCLUDEDIR +) + +# +# codec2 library +# +add_subdirectory(src) + +if(UNITTEST) + # Pthread Library + find_package(Threads REQUIRED) + message(STATUS "Threads library flags: ${CMAKE_THREAD_LIBS_INIT}") + add_subdirectory(unittest) +endif(UNITTEST) + +# +# Cpack NSIS installer configuration for Windows. +# See: http://nsis.sourceforge.net/Download +# +# *nix systems should use "make install" and/or appropriate +# distribution packaging tools. +# +if(WIN32) + # Detect if we're doing a 32-bit or 64-bit windows build. + if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + set(CMAKE_CL_64 TRUE) + endif() + + configure_file(cmake/GetDependencies.cmake.in cmake/GetDependencies.cmake + @ONLY + ) + install(SCRIPT ${CMAKE_BINARY_DIR}/cmake/GetDependencies.cmake) + set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Next-Generation Digital Voice for Two-Way Radio") + set(CPACK_PACKAGE_VENDOR "CMake") + set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") + set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") + set(CPACK_PACKAGE_VERSION_MAJOR ${CODEC2_VERSION_MAJOR}) + set(CPACK_PACKAGE_VERSION_MINOR ${CODEC2_VERSION_MINOR}) + if(CODEC2_VERSION_PATCH) + set(CPACK_PACKAGE_VERSION_PATCH ${CODEC2_VERSION_PATCH}) + else() + set(CPACK_PACKAGE_VERSION_PATCH 0) + endif() + set(CPACK_PACKAGE_INSTALL_DIRECTORY "Codec2") + set(CPACK_CREATE_DESKTOP_LINKS "") + set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}") + set(CPACK_NSIS_URL_INFO_ABOUT "http://codec2.org") + set(CPACK_NSIS_MODIFY_PATH ON) + include(CPack) +endif(WIN32) diff --git a/codec2/branches/0.3/COPYING b/codec2/branches/0.3/COPYING new file mode 100644 index 00000000..cc40a468 --- /dev/null +++ b/codec2/branches/0.3/COPYING @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 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. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +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 and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, 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 library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete 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 distribute a copy of this License along with the +Library. + + 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 Library or any portion +of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +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 Library, 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 Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you 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. + + If distribution of 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 satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be 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. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library 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. + + 9. 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 Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +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 with +this License. + + 11. 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 Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library 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 Library. + +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. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library 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. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser 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 Library +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 Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +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 + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "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 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. 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 LIBRARY 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 +LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, see + . + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/codec2/branches/0.3/ChangeLog b/codec2/branches/0.3/ChangeLog new file mode 100644 index 00000000..e69de29b diff --git a/codec2/branches/0.3/INSTALL b/codec2/branches/0.3/INSTALL new file mode 100644 index 00000000..d0cff595 --- /dev/null +++ b/codec2/branches/0.3/INSTALL @@ -0,0 +1,43 @@ +Installation Instructions for codec2 +------------------------------------ + +The CMake configuration for codec2 should be considered experimental at +this time but has been thouroughly tested on Fedora Linux and cross-compiling +from linux to windows with mingw and has many advanages over the autotools +config. + +1/ Builds against system libraries by default. +2/ Has experimental NSIS packaing support for Windows (WIN32) targets. *nix + systems should rely on 'make install' as the packages (RPM & DEB) created by + CPack are questionable. + + +Building and installing +----------------------- + +Out-of-source builds are preferred. To build codec2, make a directory anywhere +underneath (or outside of) the source directory. + +Linux command line example: + + $ cd /path/to/codec2 + $ mkdir build_linux + $ cd build_linux + $ cmake ../ (defaults to /usr/local, use CMAKE_INSTALL_PREFIX to override) + (if no errors) + $ make + (as root) + $ make install + +Codec2 installs to /usr/local by defailt on *nix systems but can be overriden +by passing options to cmake during configuration. + +Some options that may be of interest: + 1/ CMAKE_INSTALL_PREFIX: Defaults to /usr/local + 2/ CMAKE_BUILD_TYPE: Defaults to Release + 3/ CMAKE_C_FLAGS: Additional build flags. + +These can be modified on the command line by using the "-D" option when running +cmake: + + $ cmake -DCMAKE_INSTALL_PREFIX=/usr diff --git a/codec2/branches/0.3/NEWS b/codec2/branches/0.3/NEWS new file mode 100644 index 00000000..e69de29b diff --git a/codec2/branches/0.3/README b/codec2/branches/0.3/README new file mode 100644 index 00000000..e4a42fce --- /dev/null +++ b/codec2/branches/0.3/README @@ -0,0 +1,80 @@ +Codec 2 README +-------------- + +Codec 2 is an open source (LGPL licensed) speech codec for 1200-3200 +bit/s. For more information please see: + + http://rowetel.com/codec2.html + +Also included is a FDMDV modem, see README_fdmdv.txt + +Quickstart +---------- + +1/ Listen to Codec 2: + + $ cd codec2 + $ mkdir build_linux + $ cmake ../ && make + $ ./src/c2demo ../raw/hts1a.raw hts1a_c2.raw + $ ../script/menu.sh ../raw/hts1a.raw hts1a_c2.raw + + NOTE: For playback testing, menu.sh requires either the 'play', + 'aplay' or 'ossplay' programs to be installed (see + http://sox.sourceforge.net/, http://www.alsa-project.org/, or + http://www.opensound.com/ respectively). + +2/ Compress and Decompress a file: + + $ ./src/c2enc 2400 ../raw/hts1a.raw hts1a_c2.bit + $ ./src/c2dec 2400 hts1a_c2.bit hts1a_c2.raw + +3/ Same thing with pipes: + + $ ./src/c2enc 1400 ../raw/hts1a.raw - | ./src/c2dec 1400 - - | play -t raw -r 8000 -s -2 - + +Programs +-------- + +1/ c2demo encodes a file of speech samples, then decodes them and +saves the result. + +2/ c2enc encodes a file of speech samples to a compressed file of +encoded bits. + +3/ c2dec decodes a compressed file of bits to a file of speech +samples. + +4/ c2sim is a simulation/development version of Codec 2. It allows +selective use of the various Codec 2 algorithms. For example +switching phase modelling or LSP quantisation on and off. + +Debugging +--------- + +1/ For dump file support: + + $ cd codec2/build_dir + $ CFLAGS=-DDUMP make ../ + $ make clean && make + +2/ To use gdb: + + $ libtool --mode=execute gdb c2sim + +Directories +----------- + + fltk - FLTK GUI programs(s) + octave - Octave scripts used for visualising internal signals + during development + portaudio - Portaudio test programs + script - shell scripts for playing and converting raw files + src - C source code + stm32 - STM2F4 uC support + raw - speech files in raw format (16 bits signed linear 8 kHz) + unittest - unit test source code + voicing - hand-estimated voicing files, used for development + wav - speech files in wave file format + win32 - Support for building Windows DLL version of Codec 2 and FDMDV libraries + diff --git a/codec2/branches/0.3/README_fdmdv.txt b/codec2/branches/0.3/README_fdmdv.txt new file mode 100644 index 00000000..64c6a854 --- /dev/null +++ b/codec2/branches/0.3/README_fdmdv.txt @@ -0,0 +1,203 @@ + +README_fdmdv.txt +David Rowe +Created March 2012 + +Introduction +------------ + +A 1400 bit/s (nominal) Frequency Division Multiplexed Digital Voice +(FDMDV) modem based on [1]. Used for digital audio over HF SSB. + +The FDMDV modem was first implemented in GNU Octave, then ported to C. +Algorithm development is generally easier in Octave, but for real time +work we need the C version. Automated units tests ensure the +operation of the Octave and C versions are identical. + +Quickstart +---------- + +$ cd codec2 +$ cmake && make +$ cd src + +1. Generate some test bits and modulate them: + + $ ./fdmdv_get_test_bits test.c2 1400 + $ ./fdmdv_mod test.c2 test.raw + $ play -r 8000 -s -2 test.raw + +2. Two seconds of test frame data modulated and sent out of sound device: + + $ ./fdmdv_get_test_bits - 2800 | ./fdmdv_mod - - | play -t raw -r 8000 -s -2 - + +3. Send 14000 modulated bits (10 seconds) to the demod and count errors: + + $ ./fdmdv_get_test_bits - 14000 | ./fdmdv_mod - - | ./fdmdv_demod - - demod_dump.txt | ./fdmdv_put_test_bits - + + Use Octave to look at plots of 1 second (1400 bits) of modem operation: + + $ cd ../octave + $ octave + octave:1> fdmdv_demod_c("../src/demod_dump.txt",1400) + +4. Run Octave simulation of entire modem and AWGN channel: + + $ cd ../octave + $ octave + octave:1> fdmdv_ut + +5. NOTE: If you would like to play modem samples over the air please + convert the 8 kHz samples to 48 kHz. Many PC sound cards have + wildly inaccurate sample clock rates when set to 8 kHz, but seem to + perform OK when set for 48 kHz. If playing and recording files you + can use the sox utility: + + $ sox -r 8000 -s -2 modem_sample_8kHz.raw -r 48000 modem_sample_48kHz.wav + + For real time applications, the fdmdv.[ch] library includes functions to + convert between 48 and 8 kHz sample rates. + +6. Send 20 seconds at 2000 bit/s (20 carriers) to demod and count errors: + + $ ./fdmdv_get_test_bits - 20000 20 | ./fdmdv_mod - - 20 | ./fdmdv_demod - - 20 | ./fdmdv_put_test_bits - 20 + +References +---------- + +[1] http://n1su.com/fdmdv/FDMDV_Docs_Rel_1_4b.pdf +[2] http://n1su.com/fdmdv/ +[3] http://www.rowetel.com/blog/?p=2433 "Testing a FDMDV Modem" +[4] http://www.rowetel.com/blog/?p=2458 "FDMDV Modem Page" on David's web site + +C Code +------ + +src/fdmdv_mod.c - C version of modulator that takes a file of bits and + converts it to a raw file of modulated samples. + +src/fdmdv_demod.c - C version of demodulator that takes a raw file of + modulated samples and outputs a file of bits. + Optionally dumps demod states to a text file which + can be plotted using the Octave script + fdmdv_demod_c.m + +src/fdmdv.h - Header file that exposes FDMDV C API functions. Include + this file in your application program. + +src/fdmdv.c - C functions that implement the FDMDV modem. + +src/fdmdv-internal.h - internal states and constants for FDMDV modem, + shouldn't be exposed to application program. + + +unittest/tfdmdv.c - Used to conjunction with unittest/tfdmdv.m to + automatically test C FDMDV functions against + Octave versions. + +Octave Scripts +-------------- + +(Note these require some Octave packages to be installed, see +octave/README.txt). + +fdmdv.m - Functions and variables that implement the Octave version of + the FDMDV modem. + +fdmdv_ut.m - Unit test for fdmdv Octave code, useful while + developing algorithm. Includes tx/rx plus basic channel + simulation. + + Typical run: + + octave:6> fdmdv_ut + Eb/No (meas): 7.30 (8.29) dB + bits........: 2464 + errors......: 20 + BER.........: 0.0081 + PAPR........: 13.54 dB + SNR.........: 4.0 dB + + It also outputs lots of nice plots that show the + operation of the modem. + + For a 1400 bit/s DQPSK modem we expect about 1% BER for + Eb/No = 7.3dB, which corresponds to SNR = 4dB (3kHz + noise BW). The extra dB of measured power is due to the + DBPSK pilot. Currently the noise generation code + doesn't take the pilot power into account, so in this + example the real SNR is actually 5dB. + +fdmdv_mod.m - Octave version of modulator that outputs a raw file. + The modulator is driven by a test frame of bits. This + can then be played over a real channel or through a + channel simulator like PathSim. The sample rate can be + changed using "sox" to simulate differences in tx/rx + sample clocks. + + To generate 10 seconds of modulated signal: + + octave:8> fdmdv_mod("test.raw",1400*10); + +fdmdv_demod.m - Demodulator program that takes a raw file as input, + and works out the bit error rate using the known test + frame. Can be used to test the demod performs with + off-air signals, or signals that have been passed + through a channel simulator. + + To demodulate 2 seconds of the test.raw file generated + above: + + octave:9> fdmdv_demod("test.raw",1400*2); + 2464 bits 0 errors BER: 0.0000 + + It also produces several plots showing the internal + states of the demod. Useful for debugging and + observing what happens with various channels. + +fdmdv_demod_c.m - Takes an output text file from the C demod + fdmdv_demod.c and produces plots and measures BER. + Useful for evaluating fdmdv_demod.c performance. + The plots produced are identical to the Octave + version fdmdv_demod.m, allowing direct comparison of + the C and Octave versions. + +tfdmdv.m - Automatic tests that compare the Octave and C versions of + the FDMDV modem functions. First run unittest/tfdmdv, this + will generate a text file with test vectors from the C + version. Then run the Octave script tfdmdv and it will + generate Octave versions of the test vectors and compare + each vector with the C equivalent. Its plots the vectors + and and errors (green). Its also produces an automatic + check list based on test results. If the Octave or C modem + code is changed, this script should be used to ensure the + C and Octave versions remain identical. + +Modelling sample clock errors using sox +--------------------------------------- + +This introduces a simulated 1000ppm error: + + sox -r 8000 -s -2 mod_dqpsk.raw -s -2 mod_dqpsk_8008hz.raw rate -h 8008 + +TODO +---- + +[ ] implement ppm measurements in fdmdv_get_demod_stats() +[ ] try interfering sine wave + + maybe swept + + does modem fall over? +[ ] try non-flat channel, e.g. 3dB difference between hi and low tones + + make sure all estimators keep working +[ ] test rx level sensitivity, i.e. 0 to 20dB attenuation +[ ] make fine freq indep of amplitude + + use angle rather than imag coord +[ ] document use of fdmdv_ut and fdmdv_demod + PathSim +[ ] more positive form of sync reqd for DV frames? + + like using coarse_fine==1 to decode valid DV frame bit? + + when should we start decoding? +[ ] more robust track/acquite state machine? + + e.g. hang on thru the fades? +[ ] PAPR idea + + automatically tweak phases to reduce PAPR, e.g. slow variations in freq... +[ ] why is pilot noise_est twice as big as other carriers diff --git a/codec2/branches/0.3/asterisk-11/README.md b/codec2/branches/0.3/asterisk-11/README.md new file mode 100644 index 00000000..6f5b2442 --- /dev/null +++ b/codec2/branches/0.3/asterisk-11/README.md @@ -0,0 +1,19 @@ +#Asterisk 11 Codec 2 support +=========================== + +##Description +These patches add Codec 2 2400 support to Asterisk 11. +The following patches are provided: + +* asterisk-11.8.1-codec2.patch: plain Asterisk 11. +* asterisk-11.8.1-opus-codec2.patch: Asterisk patched with Meetecho's Opus codec support. + +##Building +Building and installing are integrated within Asterisk building environment. libcodec2 must be installed beforehand. + +##Credits +I've followed the example of [asterisk-opus](https://github.com/meetecho/asterisk-opus), by [@meetecho](https://github.com/meetecho), to adapt Codec2 Asterisk 1.8 patch to version 11. + +Many thanks to the [Codec2](http://www.rowetel.com/blog/codec2.html) team for developing such great codec! + +Developed by [Antonio Eugenio Burriel](https://github.com/aeburriel) diff --git a/codec2/branches/0.3/asterisk-11/asterisk-11.8.1-codec2.patch b/codec2/branches/0.3/asterisk-11/asterisk-11.8.1-codec2.patch new file mode 100644 index 00000000..a2fa0db0 --- /dev/null +++ b/codec2/branches/0.3/asterisk-11/asterisk-11.8.1-codec2.patch @@ -0,0 +1,384 @@ +diff -urN asterisk-11.8.1-orig/build_tools/menuselect-deps.in asterisk-11.8.1-codec2/build_tools/menuselect-deps.in +--- asterisk-11.8.1-orig/build_tools/menuselect-deps.in 2013-04-11 21:59:35.000000000 +0200 ++++ asterisk-11.8.1-codec2/build_tools/menuselect-deps.in 2014-04-01 10:24:29.368859813 +0200 +@@ -4,6 +4,7 @@ + CRYPTO=@PBX_CRYPTO@ + BFD=@PBX_BFD@ + BISON=@PBX_BISON@ ++CODEC2=@PBX_CODEC2@ + CURL=@PBX_CURL@ + DAHDI=@PBX_DAHDI@ + DLADDR=@PBX_DLADDR@ +diff -urN asterisk-11.8.1-orig/codecs/codec_codec2.c asterisk-11.8.1-codec2/codecs/codec_codec2.c +--- asterisk-11.8.1-orig/codecs/codec_codec2.c 1970-01-01 01:00:00.000000000 +0100 ++++ asterisk-11.8.1-codec2/codecs/codec_codec2.c 2014-04-01 01:28:47.000000000 +0200 +@@ -0,0 +1,190 @@ ++/* ++ * Codec 2 module for Asterisk. ++ * ++ * Credit: codec_gsm.c used as a starting point. ++ * ++ * Copyright (C) 2012 Ed W and David Rowe ++ * ++ * This program is free software, distributed under the terms of ++ * the GNU General Public License Version 2. See the LICENSE file ++ * at the top of the source tree. ++ */ ++ ++/*! \file ++ * ++ * \brief Translate between signed linear and Codec 2 ++ * ++ * \ingroup codecs ++ */ ++ ++/*** MODULEINFO ++ codec2 ++ core ++ ***/ ++ ++#include "asterisk.h" ++ ++#include "asterisk/translate.h" ++#include "asterisk/config.h" ++#include "asterisk/module.h" ++#include "asterisk/utils.h" ++ ++#include ++ ++#define BUFFER_SAMPLES 8000 ++#define CODEC2_SAMPLES 160 ++#define CODEC2_FRAME_LEN 6 ++ ++/* Sample frame data */ ++ ++#include "asterisk/slin.h" ++#include "ex_codec2.h" ++ ++struct codec2_translator_pvt { /* both codec2tolin and codec2togsm */ ++ struct CODEC2 *codec2; ++ int16_t buf[BUFFER_SAMPLES]; /* lintocodec2, temporary storage */ ++}; ++ ++static int codec2_new(struct ast_trans_pvt *pvt) ++{ ++ struct codec2_translator_pvt *tmp = pvt->pvt; ++ ++ tmp->codec2 = codec2_create(CODEC2_MODE_2400); ++ if (!tmp) ++ return -1; ++ ++ return 0; ++} ++ ++/*! \brief decode and store in outbuf. */ ++static int codec2tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) ++{ ++ struct codec2_translator_pvt *tmp = pvt->pvt; ++ int x; ++ int16_t *dst = pvt->outbuf.i16; ++ int flen = CODEC2_FRAME_LEN; ++ ++ for (x=0; x < f->datalen; x += flen) { ++ unsigned char *src; ++ int len; ++ len = CODEC2_SAMPLES; ++ src = f->data.ptr + x; ++ ++ codec2_decode(tmp->codec2, dst + pvt->samples, src); ++ ++ pvt->samples += CODEC2_SAMPLES; ++ pvt->datalen += 2 * CODEC2_SAMPLES; ++ } ++ return 0; ++} ++ ++/*! \brief store samples into working buffer for later decode */ ++static int lintocodec2_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) ++{ ++ struct codec2_translator_pvt *tmp = pvt->pvt; ++ ++ if (pvt->samples + f->samples > BUFFER_SAMPLES) { ++ ast_log(LOG_WARNING, "Out of buffer space\n"); ++ return -1; ++ } ++ memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen); ++ pvt->samples += f->samples; ++ return 0; ++} ++ ++/*! \brief encode and produce a frame */ ++static struct ast_frame *lintocodec2_frameout(struct ast_trans_pvt *pvt) ++{ ++ struct codec2_translator_pvt *tmp = pvt->pvt; ++ int datalen = 0; ++ int samples = 0; ++ ++ /* We can't work on anything less than a frame in size */ ++ if (pvt->samples < CODEC2_SAMPLES) ++ return NULL; ++ while (pvt->samples >= CODEC2_SAMPLES) { ++ /* Encode a frame of data */ ++ codec2_encode(tmp->codec2, (unsigned char*)(pvt->outbuf.c + datalen), tmp->buf + samples); ++ datalen += CODEC2_FRAME_LEN; ++ samples += CODEC2_SAMPLES; ++ pvt->samples -= CODEC2_SAMPLES; ++ } ++ ++ /* Move the data at the end of the buffer to the front */ ++ if (pvt->samples) ++ memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); ++ ++ return ast_trans_frameout(pvt, datalen, samples); ++} ++ ++static void codec2_destroy_stuff(struct ast_trans_pvt *pvt) ++{ ++ struct codec2_translator_pvt *tmp = pvt->pvt; ++ if (tmp->codec2) ++ codec2_destroy(tmp->codec2); ++} ++ ++static struct ast_translator codec2tolin = { ++ .name = "codec2tolin", ++ .newpvt = codec2_new, ++ .framein = codec2tolin_framein, ++ .destroy = codec2_destroy_stuff, ++ .sample = codec2_sample, ++ .buffer_samples = BUFFER_SAMPLES, ++ .buf_size = BUFFER_SAMPLES * 2, ++ .desc_size = sizeof (struct codec2_translator_pvt ), ++}; ++ ++static struct ast_translator lintocodec2 = { ++ .name = "lintocodec2", ++ .newpvt = codec2_new, ++ .framein = lintocodec2_framein, ++ .frameout = lintocodec2_frameout, ++ .destroy = codec2_destroy_stuff, ++ .sample = slin8_sample, ++ .desc_size = sizeof (struct codec2_translator_pvt ), ++ .buf_size = (BUFFER_SAMPLES * CODEC2_FRAME_LEN + CODEC2_SAMPLES - 1)/CODEC2_SAMPLES, ++}; ++ ++/*! \brief standard module glue */ ++static int reload(void) ++{ ++ return AST_MODULE_LOAD_SUCCESS; ++} ++ ++static int unload_module(void) ++{ ++ int res; ++ ++ res = ast_unregister_translator(&lintocodec2); ++ if (!res) ++ res = ast_unregister_translator(&codec2tolin); ++ ++ return res; ++} ++ ++static int load_module(void) ++{ ++ int res; ++ ++ ast_format_set(&codec2tolin.src_format, AST_FORMAT_CODEC2, 0); ++ ast_format_set(&codec2tolin.dst_format, AST_FORMAT_SLINEAR, 0); ++ ++ ast_format_set(&lintocodec2.src_format, AST_FORMAT_SLINEAR, 0); ++ ast_format_set(&lintocodec2.dst_format, AST_FORMAT_CODEC2, 0); ++ ++ res = ast_register_translator(&codec2tolin); ++ if (!res) ++ res=ast_register_translator(&lintocodec2); ++ else ++ ast_unregister_translator(&codec2tolin); ++ if (res) ++ return AST_MODULE_LOAD_FAILURE; ++ return AST_MODULE_LOAD_SUCCESS; ++} ++ ++AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Codec 2 Coder/Decoder", ++ .load = load_module, ++ .unload = unload_module, ++ .reload = reload, ++ ); +diff -urN asterisk-11.8.1-orig/codecs/ex_codec2.h asterisk-11.8.1-codec2/codecs/ex_codec2.h +--- asterisk-11.8.1-orig/codecs/ex_codec2.h 1970-01-01 01:00:00.000000000 +0100 ++++ asterisk-11.8.1-codec2/codecs/ex_codec2.h 2014-04-01 01:30:29.000000000 +0200 +@@ -0,0 +1,29 @@ ++/*! \file ++ * \brief 8-bit raw data ++ * ++ * Copyright (C) 2012, 2012 Ed W and David Rowe ++ * ++ * Distributed under the terms of the GNU General Public License ++ * ++ */ ++ ++static uint8_t ex_codec2[] = { ++ 0xea,0xca,0x14,0x85,0x91,0x78 ++}; ++ ++static struct ast_frame *codec2_sample(void) ++{ ++ static struct ast_frame f = { ++ .frametype = AST_FRAME_VOICE, ++ .datalen = sizeof(ex_codec2), ++ .samples = CODEC2_SAMPLES, ++ .mallocd = 0, ++ .offset = 0, ++ .src = __PRETTY_FUNCTION__, ++ .data.ptr = ex_codec2, ++ }; ++ ++ ast_format_set(&f.subclass.format, AST_FORMAT_CODEC2, 0); ++ ++ return &f; ++} +diff -urN asterisk-11.8.1-orig/configure.ac asterisk-11.8.1-codec2/configure.ac +--- asterisk-11.8.1-orig/configure.ac 2014-01-08 17:17:32.000000000 +0100 ++++ asterisk-11.8.1-codec2/configure.ac 2014-04-01 10:27:08.503390997 +0200 +@@ -384,6 +384,7 @@ + AST_EXT_LIB_SETUP([BKTR], [Stack Backtrace], [execinfo]) + AST_EXT_LIB_SETUP([BLUETOOTH], [Bluetooth], [bluetooth]) + AST_EXT_LIB_SETUP([CAP], [POSIX 1.e capabilities], [cap]) ++AST_EXT_LIB_SETUP([CODEC2], [Codec 2], [codec2]) + AST_EXT_LIB_SETUP([COROSYNC], [Corosync], [cpg]) + AST_EXT_LIB_SETUP_OPTIONAL([COROSYNC_CFG_STATE_TRACK], [A callback only in corosync 1.x], [COROSYNC], [cfg]) + AST_EXT_LIB_SETUP([CURSES], [curses], [curses]) +@@ -2116,6 +2117,8 @@ + + AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h]) + ++AST_EXT_LIB_CHECK([CODEC2], [codec2], [codec2_create], [codec2/codec2.h]) ++ + AST_EXT_LIB_CHECK([COROSYNC], [cpg], [cpg_join], [corosync/cpg.h], [-lcfg]) + AST_EXT_LIB_CHECK([COROSYNC_CFG_STATE_TRACK], [cfg], [corosync_cfg_state_track], [corosync/cfg.h], [-lcfg]) + +diff -urN asterisk-11.8.1-orig/include/asterisk/format.h asterisk-11.8.1-codec2/include/asterisk/format.h +--- asterisk-11.8.1-orig/include/asterisk/format.h 2012-07-13 20:41:07.000000000 +0200 ++++ asterisk-11.8.1-codec2/include/asterisk/format.h 2014-04-01 10:03:16.120355835 +0200 +@@ -101,6 +101,7 @@ + AST_FORMAT_SLINEAR192 = 27 + AST_FORMAT_TYPE_AUDIO, + AST_FORMAT_SPEEX32 = 28 + AST_FORMAT_TYPE_AUDIO, + AST_FORMAT_CELT = 29 + AST_FORMAT_TYPE_AUDIO, ++ AST_FORMAT_CODEC2 = 31 + AST_FORMAT_TYPE_AUDIO, + + /*! H.261 Video */ + AST_FORMAT_H261 = 1 + AST_FORMAT_TYPE_VIDEO, +diff -urN asterisk-11.8.1-orig/main/channel.c asterisk-11.8.1-codec2/main/channel.c +--- asterisk-11.8.1-orig/main/channel.c 2013-12-31 00:16:04.000000000 +0100 ++++ asterisk-11.8.1-codec2/main/channel.c 2014-04-01 10:06:55.659929991 +0200 +@@ -918,6 +918,8 @@ + AST_FORMAT_SILK, + /*! CELT supports crazy high sample rates */ + AST_FORMAT_CELT, ++ /* Codec 2 */ ++ AST_FORMAT_CODEC2, + /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough + to use it */ + AST_FORMAT_LPC10, +diff -urN asterisk-11.8.1-orig/main/format.c asterisk-11.8.1-codec2/main/format.c +--- asterisk-11.8.1-orig/main/format.c 2013-06-12 04:25:23.000000000 +0200 ++++ asterisk-11.8.1-codec2/main/format.c 2014-04-01 10:11:05.319972320 +0200 +@@ -430,6 +430,9 @@ + /*! SpeeX Wideband (16kHz) Free Compression */ + case AST_FORMAT_SPEEX16: + return (1ULL << 33); ++ /*! Codec 2 (8KHz) */ ++ case AST_FORMAT_CODEC2: ++ return (1ULL << 35); + /*! Raw mu-law data (G.711) */ + case AST_FORMAT_TESTLAW: + return (1ULL << 47); +@@ -532,6 +535,9 @@ + /*! SpeeX Wideband (16kHz) Free Compression */ + case (1ULL << 33): + return ast_format_set(dst, AST_FORMAT_SPEEX16, 0); ++ /*! Codec 2 (8KHz) */ ++ case (1ULL << 35): ++ return ast_format_set(dst, AST_FORMAT_CODEC2, 0); + /*! Raw mu-law data (G.711) */ + case (1ULL << 47): + return ast_format_set(dst, AST_FORMAT_TESTLAW, 0); +@@ -1071,6 +1077,8 @@ + format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR48, 0), "slin48", 48000, "16 bit Signed Linear PCM (48kHz)", 960, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (48kHz) */ + format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR96, 0), "slin96", 96000, "16 bit Signed Linear PCM (96kHz)", 1920, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (96kHz) */ + format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR192, 0), "slin192", 192000, "16 bit Signed Linear PCM (192kHz)", 3840, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (192kHz) */ ++ /* Codec 2 */ ++ format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), "codec2", 8000, "Codec 2", 6, 20, 20, 20, 20, 0, 0); /*!< codec_codec2.c */ + + return 0; + } +diff -urN asterisk-11.8.1-orig/main/frame.c asterisk-11.8.1-codec2/main/frame.c +--- asterisk-11.8.1-orig/main/frame.c 2012-07-24 18:54:26.000000000 +0200 ++++ asterisk-11.8.1-codec2/main/frame.c 2014-04-01 10:13:35.626395684 +0200 +@@ -1083,6 +1083,10 @@ + /* TODO The assumes 20ms delivery right now, which is incorrect */ + samples = ast_format_rate(&f->subclass.format) / 50; + break; ++ /* Codec 2 */ ++ case AST_FORMAT_CODEC2: ++ samples = 160 * (f->datalen / 6); ++ break; + default: + ast_log(LOG_WARNING, "Unable to calculate samples for format %s\n", ast_getformatname(&f->subclass.format)); + } +@@ -1134,6 +1138,10 @@ + /* 48,000 samples per second at 64kbps is 8,000 bytes per second */ + len = (int) samples / ((float) 48000 / 8000); + break; ++ /* Codec 2 */ ++ case AST_FORMAT_CODEC2: ++ len = (samples / 160) * 6; ++ break; + default: + ast_log(LOG_WARNING, "Unable to calculate sample length for format %s\n", ast_getformatname(format)); + } +diff -urN asterisk-11.8.1-orig/main/rtp_engine.c asterisk-11.8.1-codec2/main/rtp_engine.c +--- asterisk-11.8.1-orig/main/rtp_engine.c 2013-12-18 00:35:07.000000000 +0100 ++++ asterisk-11.8.1-codec2/main/rtp_engine.c 2014-04-01 10:17:00.121681465 +0200 +@@ -2289,6 +2289,8 @@ + set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_SIREN7, 0), 0, "audio", "G7221", 16000); + set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_SIREN14, 0), 0, "audio", "G7221", 32000); + set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_G719, 0), 0, "audio", "G719", 48000); ++ /* Codec 2 */ ++ set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), 0, "audio", "CODEC2", 8000); + + /* Define the static rtp payload mappings */ + add_static_payload(0, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0), 0); +@@ -2330,6 +2332,8 @@ + add_static_payload(118, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR16, 0), 0); /* 16 Khz signed linear */ + add_static_payload(119, ast_format_set(&tmpfmt, AST_FORMAT_SPEEX32, 0), 0); + add_static_payload(121, NULL, AST_RTP_CISCO_DTMF); /* Must be type 121 */ ++ /* Codec 2 */ ++ add_static_payload(121, ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), 0); + + return 0; + } +diff -urN asterisk-11.8.1-orig/makeopts.in asterisk-11.8.1-codec2/makeopts.in +--- asterisk-11.8.1-orig/makeopts.in 2013-04-11 21:59:35.000000000 +0200 ++++ asterisk-11.8.1-codec2/makeopts.in 2014-04-01 10:28:49.424993462 +0200 +@@ -120,6 +120,9 @@ + BLUETOOTH_INCLUDE=@BLUETOOTH_INCLUDE@ + BLUETOOTH_LIB=@BLUETOOTH_LIB@ + ++CODEC2_INCLUDE=@CODEC2_INCLUDE@ ++CODEC2_LIB=@CODEC2_LIB@ ++ + CURL_INCLUDE=@CURL_INCLUDE@ + CURL_LIB=@CURL_LIB@ + +diff -urN asterisk-11.8.1-orig/res/res_rtp_asterisk.c asterisk-11.8.1-codec2/res/res_rtp_asterisk.c +--- asterisk-11.8.1-orig/res/res_rtp_asterisk.c 2014-02-27 22:39:30.000000000 +0100 ++++ asterisk-11.8.1-codec2/res/res_rtp_asterisk.c 2014-04-01 10:19:18.727901747 +0200 +@@ -2738,6 +2738,8 @@ + case AST_FORMAT_SIREN7: + case AST_FORMAT_SIREN14: + case AST_FORMAT_G719: ++ /* Codec 2 */ ++ case AST_FORMAT_CODEC2: + /* these are all frame-based codecs and cannot be safely run through + a smoother */ + break; diff --git a/codec2/branches/0.3/asterisk-11/asterisk-11.8.1-opus-codec2.patch b/codec2/branches/0.3/asterisk-11/asterisk-11.8.1-opus-codec2.patch new file mode 100644 index 00000000..a90d3d60 --- /dev/null +++ b/codec2/branches/0.3/asterisk-11/asterisk-11.8.1-opus-codec2.patch @@ -0,0 +1,384 @@ +diff -urN asterisk-11.8.1-opus/build_tools/menuselect-deps.in asterisk-11.8.1-opus-codec2/build_tools/menuselect-deps.in +--- asterisk-11.8.1-opus/build_tools/menuselect-deps.in 2014-04-01 10:58:52.127106070 +0200 ++++ asterisk-11.8.1-opus-codec2/build_tools/menuselect-deps.in 2014-04-01 10:50:21.490079146 +0200 +@@ -4,6 +4,7 @@ + CRYPTO=@PBX_CRYPTO@ + BFD=@PBX_BFD@ + BISON=@PBX_BISON@ ++CODEC2=@PBX_CODEC2@ + CURL=@PBX_CURL@ + DAHDI=@PBX_DAHDI@ + DLADDR=@PBX_DLADDR@ +diff -urN asterisk-11.8.1-opus/codecs/codec_codec2.c asterisk-11.8.1-opus-codec2/codecs/codec_codec2.c +--- asterisk-11.8.1-opus/codecs/codec_codec2.c 1970-01-01 01:00:00.000000000 +0100 ++++ asterisk-11.8.1-opus-codec2/codecs/codec_codec2.c 2014-04-01 10:50:21.490079146 +0200 +@@ -0,0 +1,190 @@ ++/* ++ * Codec 2 module for Asterisk. ++ * ++ * Credit: codec_gsm.c used as a starting point. ++ * ++ * Copyright (C) 2012 Ed W and David Rowe ++ * ++ * This program is free software, distributed under the terms of ++ * the GNU General Public License Version 2. See the LICENSE file ++ * at the top of the source tree. ++ */ ++ ++/*! \file ++ * ++ * \brief Translate between signed linear and Codec 2 ++ * ++ * \ingroup codecs ++ */ ++ ++/*** MODULEINFO ++ codec2 ++ core ++ ***/ ++ ++#include "asterisk.h" ++ ++#include "asterisk/translate.h" ++#include "asterisk/config.h" ++#include "asterisk/module.h" ++#include "asterisk/utils.h" ++ ++#include ++ ++#define BUFFER_SAMPLES 8000 ++#define CODEC2_SAMPLES 160 ++#define CODEC2_FRAME_LEN 6 ++ ++/* Sample frame data */ ++ ++#include "asterisk/slin.h" ++#include "ex_codec2.h" ++ ++struct codec2_translator_pvt { /* both codec2tolin and codec2togsm */ ++ struct CODEC2 *codec2; ++ int16_t buf[BUFFER_SAMPLES]; /* lintocodec2, temporary storage */ ++}; ++ ++static int codec2_new(struct ast_trans_pvt *pvt) ++{ ++ struct codec2_translator_pvt *tmp = pvt->pvt; ++ ++ tmp->codec2 = codec2_create(CODEC2_MODE_2400); ++ if (!tmp) ++ return -1; ++ ++ return 0; ++} ++ ++/*! \brief decode and store in outbuf. */ ++static int codec2tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) ++{ ++ struct codec2_translator_pvt *tmp = pvt->pvt; ++ int x; ++ int16_t *dst = pvt->outbuf.i16; ++ int flen = CODEC2_FRAME_LEN; ++ ++ for (x=0; x < f->datalen; x += flen) { ++ unsigned char *src; ++ int len; ++ len = CODEC2_SAMPLES; ++ src = f->data.ptr + x; ++ ++ codec2_decode(tmp->codec2, dst + pvt->samples, src); ++ ++ pvt->samples += CODEC2_SAMPLES; ++ pvt->datalen += 2 * CODEC2_SAMPLES; ++ } ++ return 0; ++} ++ ++/*! \brief store samples into working buffer for later decode */ ++static int lintocodec2_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) ++{ ++ struct codec2_translator_pvt *tmp = pvt->pvt; ++ ++ if (pvt->samples + f->samples > BUFFER_SAMPLES) { ++ ast_log(LOG_WARNING, "Out of buffer space\n"); ++ return -1; ++ } ++ memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen); ++ pvt->samples += f->samples; ++ return 0; ++} ++ ++/*! \brief encode and produce a frame */ ++static struct ast_frame *lintocodec2_frameout(struct ast_trans_pvt *pvt) ++{ ++ struct codec2_translator_pvt *tmp = pvt->pvt; ++ int datalen = 0; ++ int samples = 0; ++ ++ /* We can't work on anything less than a frame in size */ ++ if (pvt->samples < CODEC2_SAMPLES) ++ return NULL; ++ while (pvt->samples >= CODEC2_SAMPLES) { ++ /* Encode a frame of data */ ++ codec2_encode(tmp->codec2, (unsigned char*)(pvt->outbuf.c + datalen), tmp->buf + samples); ++ datalen += CODEC2_FRAME_LEN; ++ samples += CODEC2_SAMPLES; ++ pvt->samples -= CODEC2_SAMPLES; ++ } ++ ++ /* Move the data at the end of the buffer to the front */ ++ if (pvt->samples) ++ memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); ++ ++ return ast_trans_frameout(pvt, datalen, samples); ++} ++ ++static void codec2_destroy_stuff(struct ast_trans_pvt *pvt) ++{ ++ struct codec2_translator_pvt *tmp = pvt->pvt; ++ if (tmp->codec2) ++ codec2_destroy(tmp->codec2); ++} ++ ++static struct ast_translator codec2tolin = { ++ .name = "codec2tolin", ++ .newpvt = codec2_new, ++ .framein = codec2tolin_framein, ++ .destroy = codec2_destroy_stuff, ++ .sample = codec2_sample, ++ .buffer_samples = BUFFER_SAMPLES, ++ .buf_size = BUFFER_SAMPLES * 2, ++ .desc_size = sizeof (struct codec2_translator_pvt ), ++}; ++ ++static struct ast_translator lintocodec2 = { ++ .name = "lintocodec2", ++ .newpvt = codec2_new, ++ .framein = lintocodec2_framein, ++ .frameout = lintocodec2_frameout, ++ .destroy = codec2_destroy_stuff, ++ .sample = slin8_sample, ++ .desc_size = sizeof (struct codec2_translator_pvt ), ++ .buf_size = (BUFFER_SAMPLES * CODEC2_FRAME_LEN + CODEC2_SAMPLES - 1)/CODEC2_SAMPLES, ++}; ++ ++/*! \brief standard module glue */ ++static int reload(void) ++{ ++ return AST_MODULE_LOAD_SUCCESS; ++} ++ ++static int unload_module(void) ++{ ++ int res; ++ ++ res = ast_unregister_translator(&lintocodec2); ++ if (!res) ++ res = ast_unregister_translator(&codec2tolin); ++ ++ return res; ++} ++ ++static int load_module(void) ++{ ++ int res; ++ ++ ast_format_set(&codec2tolin.src_format, AST_FORMAT_CODEC2, 0); ++ ast_format_set(&codec2tolin.dst_format, AST_FORMAT_SLINEAR, 0); ++ ++ ast_format_set(&lintocodec2.src_format, AST_FORMAT_SLINEAR, 0); ++ ast_format_set(&lintocodec2.dst_format, AST_FORMAT_CODEC2, 0); ++ ++ res = ast_register_translator(&codec2tolin); ++ if (!res) ++ res=ast_register_translator(&lintocodec2); ++ else ++ ast_unregister_translator(&codec2tolin); ++ if (res) ++ return AST_MODULE_LOAD_FAILURE; ++ return AST_MODULE_LOAD_SUCCESS; ++} ++ ++AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Codec 2 Coder/Decoder", ++ .load = load_module, ++ .unload = unload_module, ++ .reload = reload, ++ ); +diff -urN asterisk-11.8.1-opus/codecs/ex_codec2.h asterisk-11.8.1-opus-codec2/codecs/ex_codec2.h +--- asterisk-11.8.1-opus/codecs/ex_codec2.h 1970-01-01 01:00:00.000000000 +0100 ++++ asterisk-11.8.1-opus-codec2/codecs/ex_codec2.h 2014-04-01 10:50:21.490079146 +0200 +@@ -0,0 +1,29 @@ ++/*! \file ++ * \brief 8-bit raw data ++ * ++ * Copyright (C) 2012, 2012 Ed W and David Rowe ++ * ++ * Distributed under the terms of the GNU General Public License ++ * ++ */ ++ ++static uint8_t ex_codec2[] = { ++ 0xea,0xca,0x14,0x85,0x91,0x78 ++}; ++ ++static struct ast_frame *codec2_sample(void) ++{ ++ static struct ast_frame f = { ++ .frametype = AST_FRAME_VOICE, ++ .datalen = sizeof(ex_codec2), ++ .samples = CODEC2_SAMPLES, ++ .mallocd = 0, ++ .offset = 0, ++ .src = __PRETTY_FUNCTION__, ++ .data.ptr = ex_codec2, ++ }; ++ ++ ast_format_set(&f.subclass.format, AST_FORMAT_CODEC2, 0); ++ ++ return &f; ++} +diff -urN asterisk-11.8.1-opus/configure.ac asterisk-11.8.1-opus-codec2/configure.ac +--- asterisk-11.8.1-opus/configure.ac 2014-04-01 10:58:52.143106352 +0200 ++++ asterisk-11.8.1-opus-codec2/configure.ac 2014-04-01 10:50:21.494079217 +0200 +@@ -384,6 +384,7 @@ + AST_EXT_LIB_SETUP([BKTR], [Stack Backtrace], [execinfo]) + AST_EXT_LIB_SETUP([BLUETOOTH], [Bluetooth], [bluetooth]) + AST_EXT_LIB_SETUP([CAP], [POSIX 1.e capabilities], [cap]) ++AST_EXT_LIB_SETUP([CODEC2], [Codec 2], [codec2]) + AST_EXT_LIB_SETUP([COROSYNC], [Corosync], [cpg]) + AST_EXT_LIB_SETUP_OPTIONAL([COROSYNC_CFG_STATE_TRACK], [A callback only in corosync 1.x], [COROSYNC], [cfg]) + AST_EXT_LIB_SETUP([CURSES], [curses], [curses]) +@@ -2117,6 +2118,8 @@ + + AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h]) + ++AST_EXT_LIB_CHECK([CODEC2], [codec2], [codec2_create], [codec2/codec2.h]) ++ + AST_EXT_LIB_CHECK([COROSYNC], [cpg], [cpg_join], [corosync/cpg.h], [-lcfg]) + AST_EXT_LIB_CHECK([COROSYNC_CFG_STATE_TRACK], [cfg], [corosync_cfg_state_track], [corosync/cfg.h], [-lcfg]) + +diff -urN asterisk-11.8.1-opus/include/asterisk/format.h asterisk-11.8.1-opus-codec2/include/asterisk/format.h +--- asterisk-11.8.1-opus/include/asterisk/format.h 2014-04-01 10:58:52.143106352 +0200 ++++ asterisk-11.8.1-opus-codec2/include/asterisk/format.h 2014-04-01 10:53:25.961351185 +0200 +@@ -103,6 +103,7 @@ + AST_FORMAT_CELT = 29 + AST_FORMAT_TYPE_AUDIO, + /*! Opus */ + AST_FORMAT_OPUS = 30 + AST_FORMAT_TYPE_AUDIO, ++ AST_FORMAT_CODEC2 = 31 + AST_FORMAT_TYPE_AUDIO, + + /*! H.261 Video */ + AST_FORMAT_H261 = 1 + AST_FORMAT_TYPE_VIDEO, +diff -urN asterisk-11.8.1-opus/main/channel.c asterisk-11.8.1-opus-codec2/main/channel.c +--- asterisk-11.8.1-opus/main/channel.c 2014-04-01 10:58:52.147106422 +0200 ++++ asterisk-11.8.1-opus-codec2/main/channel.c 2014-04-01 10:50:21.498079289 +0200 +@@ -920,6 +920,8 @@ + AST_FORMAT_SILK, + /*! CELT supports crazy high sample rates */ + AST_FORMAT_CELT, ++ /* Codec 2 */ ++ AST_FORMAT_CODEC2, + /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough + to use it */ + AST_FORMAT_LPC10, +diff -urN asterisk-11.8.1-opus/main/format.c asterisk-11.8.1-opus-codec2/main/format.c +--- asterisk-11.8.1-opus/main/format.c 2014-04-01 10:58:52.147106422 +0200 ++++ asterisk-11.8.1-opus-codec2/main/format.c 2014-04-01 10:52:23.820250398 +0200 +@@ -433,6 +433,9 @@ + /*! Opus audio (8kHz, 16kHz, 24kHz, 48Khz) */ + case AST_FORMAT_OPUS: + return (1ULL << 34); ++ /*! Codec 2 (8KHz) */ ++ case AST_FORMAT_CODEC2: ++ return (1ULL << 35); + /*! Raw mu-law data (G.711) */ + case AST_FORMAT_TESTLAW: + return (1ULL << 47); +@@ -541,6 +544,9 @@ + /*! Opus audio (8kHz, 16kHz, 24kHz, 48Khz) */ + case (1ULL << 34): + return ast_format_set(dst, AST_FORMAT_OPUS, 0); ++ /*! Codec 2 (8KHz) */ ++ case (1ULL << 35): ++ return ast_format_set(dst, AST_FORMAT_CODEC2, 0); + /*! Raw mu-law data (G.711) */ + case (1ULL << 47): + return ast_format_set(dst, AST_FORMAT_TESTLAW, 0); +@@ -1090,6 +1096,8 @@ + format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_OPUS, 0), "opus", 48000, "Opus Codec", 10, 20, 60, 20, 20, 0, 0); /*!< codec_opus.c */ + /* VP8 (passthrough) */ + format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_VP8, 0), "vp8", 0, "VP8 Video", 0, 0, 0, 0 ,0 ,0, 0); /*!< Passthrough support, see format_h263.c */ ++ /* Codec 2 */ ++ format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), "codec2", 8000, "Codec 2", 6, 20, 20, 20, 20, 0, 0); /*!< codec_codec2.c */ + + return 0; + } +diff -urN asterisk-11.8.1-opus/main/frame.c asterisk-11.8.1-opus-codec2/main/frame.c +--- asterisk-11.8.1-opus/main/frame.c 2014-04-01 10:58:52.151106493 +0200 ++++ asterisk-11.8.1-opus-codec2/main/frame.c 2014-04-01 10:50:21.502079360 +0200 +@@ -1121,6 +1121,10 @@ + case AST_FORMAT_OPUS: + samples = opus_samples(f->data.ptr, f->datalen); + break; ++ /* Codec 2 */ ++ case AST_FORMAT_CODEC2: ++ samples = 160 * (f->datalen / 6); ++ break; + default: + ast_log(LOG_WARNING, "Unable to calculate samples for format %s\n", ast_getformatname(&f->subclass.format)); + } +@@ -1172,6 +1176,10 @@ + /* 48,000 samples per second at 64kbps is 8,000 bytes per second */ + len = (int) samples / ((float) 48000 / 8000); + break; ++ /* Codec 2 */ ++ case AST_FORMAT_CODEC2: ++ len = (samples / 160) * 6; ++ break; + default: + ast_log(LOG_WARNING, "Unable to calculate sample length for format %s\n", ast_getformatname(format)); + } +diff -urN asterisk-11.8.1-opus/main/rtp_engine.c asterisk-11.8.1-opus-codec2/main/rtp_engine.c +--- asterisk-11.8.1-opus/main/rtp_engine.c 2014-04-01 10:58:52.151106493 +0200 ++++ asterisk-11.8.1-opus-codec2/main/rtp_engine.c 2014-04-01 10:51:17.367071621 +0200 +@@ -2292,6 +2292,8 @@ + /* Opus and VP8 */ + set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_OPUS, 0), 0, "audio", "opus", 48000); + set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_VP8, 0), 0, "video", "VP8", 90000); ++ /* Codec 2 */ ++ set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), 0, "audio", "CODEC2", 8000); + + /* Define the static rtp payload mappings */ + add_static_payload(0, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0), 0); +@@ -2336,6 +2338,8 @@ + /* Opus and VP8 */ + add_static_payload(100, ast_format_set(&tmpfmt, AST_FORMAT_VP8, 0), 0); + add_static_payload(107, ast_format_set(&tmpfmt, AST_FORMAT_OPUS, 0), 0); ++ /* Codec 2 */ ++ add_static_payload(121, ast_format_set(&tmpfmt, AST_FORMAT_CODEC2, 0), 0); + + return 0; + } +diff -urN asterisk-11.8.1-opus/makeopts.in asterisk-11.8.1-opus-codec2/makeopts.in +--- asterisk-11.8.1-opus/makeopts.in 2014-04-01 10:58:52.151106493 +0200 ++++ asterisk-11.8.1-opus-codec2/makeopts.in 2014-04-01 10:50:21.538079999 +0200 +@@ -120,6 +120,9 @@ + BLUETOOTH_INCLUDE=@BLUETOOTH_INCLUDE@ + BLUETOOTH_LIB=@BLUETOOTH_LIB@ + ++CODEC2_INCLUDE=@CODEC2_INCLUDE@ ++CODEC2_LIB=@CODEC2_LIB@ ++ + CURL_INCLUDE=@CURL_INCLUDE@ + CURL_LIB=@CURL_LIB@ + +diff -urN asterisk-11.8.1-opus/res/res_rtp_asterisk.c asterisk-11.8.1-opus-codec2/res/res_rtp_asterisk.c +--- asterisk-11.8.1-opus/res/res_rtp_asterisk.c 2014-04-01 10:58:52.151106493 +0200 ++++ asterisk-11.8.1-opus-codec2/res/res_rtp_asterisk.c 2014-04-01 10:53:02.292932085 +0200 +@@ -2780,6 +2780,8 @@ + case AST_FORMAT_G719: + /* Opus */ + case AST_FORMAT_OPUS: ++ /* Codec 2 */ ++ case AST_FORMAT_CODEC2: + /* these are all frame-based codecs and cannot be safely run through + a smoother */ + break; diff --git a/codec2/branches/0.3/asterisk/README b/codec2/branches/0.3/asterisk/README new file mode 100644 index 00000000..9bc814b4 --- /dev/null +++ b/codec2/branches/0.3/asterisk/README @@ -0,0 +1,109 @@ +README for codec2/asterisk +Asterisk Codec 2 support + +Test Configuration +------------------ + +Codec 2 is used to trunk calls between two Asterisk boxes: + + A - SIP phone - Asterisk A - Codec2 - Asterisk B - SIP Phone - B + +The two SIP phones are configured for mulaw. + +Building +--------- + +Asterisk must be patched so that the core understand Codec 2 frames. + +1/ First install Codec 2: + + david@cool:~$ svn co https://freetel.svn.sourceforge.net/svnroot/freetel/codec2 codec2 + david@cool:~/codec2$ cd codec2 + david@cool:~/codec2$ ./configure && make && sudo make install + david@bear:~/codec2$ sudo ldconfig -v + david@cool:~/codec2$ cd ~ + +2/ Then build Asterisk with Codec 2 support: + + david@cool:~$ tar xvzf asterisk-1.8.9.0.tar.gz + david@cool:~/asterisk-1.8.9.0$ patch -p4 < ~/codec2/asterisk/asterisk-codec2.patch + david@cool:~/asterisk-1.8.9.0$ cp ~/codec2/asterisk/codec_codec2.c . + david@cool:~/asterisk-1.8.9.0$ cp ~/codec2/asterisk/ex_codec2.h ./codecs + david@cool:~/asterisk-1.8.9.0$ ./configure && make ASTLDFLAGS=-lcodec2 + david@cool:~/asterisk-1.8.9.0$ sudo make install + david@cool:~/asterisk-1.8.9.0$ sudo make samples + +3/ Add this to the end of sip.conf on Asterisk A: + + [6013] + type=friend + context=default + host=dynamic + user=6013 + secret=6013 + canreinvite=no + callerid=6013 + disallow=all + allow=ulaw + + [potato] + type=peer + username=potato + fromuser=potato + secret=password + context=default + disallow=all + dtmfmode=rfc2833 + callerid=server + canreinvite=no + host=cool + allow=codec2 + +3/ Add this to the end of sip.conf on Asterisk B: + + [6014] + type=friend + context=default + host=dynamic + user=6014 + secret=6014 + canreinvite=no + callerid=6014 + disallow=all + allow=ulaw + + [potato] + type=peer + username=potato + fromuser=potato + secret=password + context=default + disallow=all + dtmfmode=rfc2833 + callerid=server + canreinvite=no + host=bear + allow=codec2 + +4/ Here is the [default] section of extensions.conf on Asterisk B: + + [default] + + exten => 6013,1,Dial(SIP/potato/6013) + ; + ; By default we include the demo. In a production system, you + ; probably don't want to have the demo there. + ; + ;include => demo + +5/ After booting see if the codec2_codec2.so module is loaded with "core show translate" + +6/ To make a test call dial 6013 on the SIP phone connected to Asterisk B + +7/ If codec_codec2.so won't load and you see "can't find codec2_create" try: + + david@cool:~/asterisk-1.8.9.0$ touch codecs/codec_codec2.c + david@cool:~/asterisk-1.8.9.0$ make ASTLDFLAGS=-lcodec2 + david@cool:~/asterisk-1.8.9.0$ sudo cp codecs/codec_codec2.so /usr/lib/asterisk/modules + david@cool:~/asterisk-1.8.9.0$ sudo asterisk -vvvcn + diff --git a/codec2/branches/0.3/asterisk/asterisk-codec2.patch b/codec2/branches/0.3/asterisk/asterisk-codec2.patch new file mode 100644 index 00000000..53569ff9 --- /dev/null +++ b/codec2/branches/0.3/asterisk/asterisk-codec2.patch @@ -0,0 +1,68 @@ +--- /home/david/asterisk-1.8.9.0-orig/include/asterisk/frame.h 2011-12-23 05:08:46.000000000 +1030 ++++ /home/david/asterisk-1.8.9.0-codec2/include/asterisk/frame.h 2012-03-27 13:16:55.623452431 +1030 +@@ -299,6 +299,7 @@ + #define AST_FORMAT_G719 (1ULL << 32) + /*! SpeeX Wideband (16kHz) Free Compression */ + #define AST_FORMAT_SPEEX16 (1ULL << 33) ++#define AST_FORMAT_CODEC2 (1ULL << 34) + /*! Raw mu-law data (G.711) */ + #define AST_FORMAT_TESTLAW (1ULL << 47) + /*! Reserved bit - do not use */ +--- /home/david/asterisk-1.8.9.0-orig/main/frame.c 2010-06-18 02:53:43.000000000 +0930 ++++ /home/david/asterisk-1.8.9.0-codec2/main/frame.c 2012-03-28 15:16:16.975581316 +1030 +@@ -102,6 +102,7 @@ + { AST_FORMAT_ADPCM, "adpcm" , 8000, "ADPCM", 40, 10, 300, 10, 20 }, /*!< codec_adpcm.c */ + { AST_FORMAT_SLINEAR, "slin", 8000, "16 bit Signed Linear PCM", 160, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE }, /*!< Signed linear */ + { AST_FORMAT_LPC10, "lpc10", 8000, "LPC10", 7, 20, 20, 20, 20 }, /*!< codec_lpc10.c */ ++ { AST_FORMAT_CODEC2, "codec2", 8000, "Codec 2", 6, 20, 20, 20, 20 }, /*!< codec_codec2.c */ + { AST_FORMAT_G729A, "g729", 8000, "G.729A", 10, 10, 230, 10, 20, AST_SMOOTHER_FLAG_G729 }, /*!< Binary commercial distribution */ + { AST_FORMAT_SPEEX, "speex", 8000, "SpeeX", 10, 10, 60, 10, 20 }, /*!< codec_speex.c */ + { AST_FORMAT_SPEEX16, "speex16", 16000, "SpeeX 16khz", 10, 10, 60, 10, 20 }, /*!< codec_speex.c */ +@@ -1475,6 +1476,9 @@ + samples = 22 * 8; + samples += (((char *)(f->data.ptr))[7] & 0x1) * 8; + break; ++ case AST_FORMAT_CODEC2: ++ samples = 160 * (f->datalen / 6); ++ break; + case AST_FORMAT_ULAW: + case AST_FORMAT_ALAW: + case AST_FORMAT_TESTLAW: +@@ -1519,6 +1523,9 @@ + case AST_FORMAT_GSM: + len = (samples / 160) * 33; + break; ++ case AST_FORMAT_CODEC2: ++ len = (samples / 160) * 6; ++ break; + case AST_FORMAT_G729A: + len = samples / 8; + break; +--- /home/david/asterisk-1.8.9.0-orig/main/channel.c 2011-12-17 10:21:13.000000000 +1030 ++++ /home/david/asterisk-1.8.9.0-codec2/main/channel.c 2012-03-28 15:05:22.395293391 +1030 +@@ -1075,6 +1075,7 @@ + /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough + to use it */ + AST_FORMAT_LPC10, ++ AST_FORMAT_CODEC2, + /*! G.729a is faster than 723 and slightly less expensive */ + AST_FORMAT_G729A, + /*! Down to G.723.1 which is proprietary but at least designed for voice */ +--- /home/david/asterisk-1.8.9.0-orig/main/rtp_engine.c 2011-12-30 01:43:03.000000000 +1030 ++++ /home/david/asterisk-1.8.9.0-codec2/main/rtp_engine.c 2012-03-28 16:42:02.880872891 +1030 +@@ -101,6 +101,7 @@ + {{1, AST_FORMAT_SLINEAR}, "audio", "L16", 8000}, + {{1, AST_FORMAT_SLINEAR16}, "audio", "L16", 16000}, + {{1, AST_FORMAT_LPC10}, "audio", "LPC", 8000}, ++ {{1, AST_FORMAT_CODEC2}, "audio", "CODEC2", 8000}, + {{1, AST_FORMAT_G729A}, "audio", "G729", 8000}, + {{1, AST_FORMAT_G729A}, "audio", "G729A", 8000}, + {{1, AST_FORMAT_G729A}, "audio", "G.729", 8000}, +@@ -178,6 +179,7 @@ + [117] = {1, AST_FORMAT_SPEEX16}, + [118] = {1, AST_FORMAT_SLINEAR16}, /* 16 Khz signed linear */ + [121] = {0, AST_RTP_CISCO_DTMF}, /* Must be type 121 */ ++ [121] = {1, AST_FORMAT_CODEC2}, + }; + + int ast_rtp_engine_register2(struct ast_rtp_engine *engine, struct ast_module *module) diff --git a/codec2/branches/0.3/asterisk/codec_codec2.c b/codec2/branches/0.3/asterisk/codec_codec2.c new file mode 100644 index 00000000..d161be7e --- /dev/null +++ b/codec2/branches/0.3/asterisk/codec_codec2.c @@ -0,0 +1,187 @@ +/* + * Codec 2 module for Asterisk. + * + * Credit: codec_gsm.c used as a starting point. + * + * Copyright (C) 2012 Ed W and David Rowe + * + * This program is free software, distributed under the terms of + * the GNU General Public License Version 2. See the LICENSE file + * at the top of the source tree. + */ + +/*! \file + * + * \brief Translate between signed linear and Codec 2 + * + * \ingroup codecs + */ + +/*** MODULEINFO + core + ***/ + +#include "asterisk.h" + +#include "asterisk/translate.h" +#include "asterisk/config.h" +#include "asterisk/module.h" +#include "asterisk/utils.h" + +#include + +#define BUFFER_SAMPLES 8000 +#define CODEC2_SAMPLES 160 +#define CODEC2_FRAME_LEN 6 + +/* Sample frame data */ + +#include "asterisk/slin.h" +#include "ex_codec2.h" + +struct codec2_translator_pvt { /* both codec2tolin and codec2togsm */ + struct CODEC2 *codec2; + int16_t buf[BUFFER_SAMPLES]; /* lintocodec2, temporary storage */ +}; + +static int codec2_new(struct ast_trans_pvt *pvt) +{ + struct codec2_translator_pvt *tmp = pvt->pvt; + + tmp->codec2 = codec2_create(CODEC2_MODE_2400); + if (!tmp->codec2) + return -1; + + return 0; +} + +/*! \brief decode and store in outbuf. */ +static int codec2tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) +{ + struct codec2_translator_pvt *tmp = pvt->pvt; + int x; + int16_t *dst = pvt->outbuf.i16; + int flen = CODEC2_FRAME_LEN; + + for (x=0; x < f->datalen; x += flen) { + unsigned char *src; + int len; + len = CODEC2_SAMPLES; + src = f->data.ptr + x; + + codec2_decode(tmp->codec2, dst + pvt->samples, src); + + pvt->samples += CODEC2_SAMPLES; + pvt->datalen += 2 * CODEC2_SAMPLES; + } + return 0; +} + +/*! \brief store samples into working buffer for later decode */ +static int lintocodec2_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) +{ + struct codec2_translator_pvt *tmp = pvt->pvt; + + if (pvt->samples + f->samples > BUFFER_SAMPLES) { + ast_log(LOG_WARNING, "Out of buffer space\n"); + return -1; + } + memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen); + pvt->samples += f->samples; + return 0; +} + +/*! \brief encode and produce a frame */ +static struct ast_frame *lintocodec2_frameout(struct ast_trans_pvt *pvt) +{ + struct codec2_translator_pvt *tmp = pvt->pvt; + int datalen = 0; + int samples = 0; + + /* We can't work on anything less than a frame in size */ + if (pvt->samples < CODEC2_SAMPLES) + return NULL; + while (pvt->samples >= CODEC2_SAMPLES) { + /* Encode a frame of data */ + codec2_encode(tmp->codec2, (unsigned char*)(pvt->outbuf.c + datalen), tmp->buf + samples); + datalen += CODEC2_FRAME_LEN; + samples += CODEC2_SAMPLES; + pvt->samples -= CODEC2_SAMPLES; + } + + /* Move the data at the end of the buffer to the front */ + if (pvt->samples) + memmove(tmp->buf, tmp->buf + samples, pvt->samples * 2); + + return ast_trans_frameout(pvt, datalen, samples); +} + +static void codec2_destroy_stuff(struct ast_trans_pvt *pvt) +{ + struct codec2_translator_pvt *tmp = pvt->pvt; + if (tmp->codec2) + codec2_destroy(tmp->codec2); +} + +static struct ast_translator codec2tolin = { + .name = "codec2tolin", + .srcfmt = AST_FORMAT_CODEC2, + .dstfmt = AST_FORMAT_SLINEAR, + .newpvt = codec2_new, + .framein = codec2tolin_framein, + .destroy = codec2_destroy_stuff, + .sample = codec2_sample, + .buffer_samples = BUFFER_SAMPLES, + .buf_size = BUFFER_SAMPLES * 2, + .desc_size = sizeof (struct codec2_translator_pvt ), +}; + +static struct ast_translator lintocodec2 = { + .name = "lintocodec2", + .srcfmt = AST_FORMAT_SLINEAR, + .dstfmt = AST_FORMAT_CODEC2, + .newpvt = codec2_new, + .framein = lintocodec2_framein, + .frameout = lintocodec2_frameout, + .destroy = codec2_destroy_stuff, + .sample = slin8_sample, + .desc_size = sizeof (struct codec2_translator_pvt ), + .buf_size = (BUFFER_SAMPLES * CODEC2_FRAME_LEN + CODEC2_SAMPLES - 1)/CODEC2_SAMPLES, +}; + +/*! \brief standard module glue */ +static int reload(void) +{ + return AST_MODULE_LOAD_SUCCESS; +} + +static int unload_module(void) +{ + int res; + + res = ast_unregister_translator(&lintocodec2); + if (!res) + res = ast_unregister_translator(&codec2tolin); + + return res; +} + +static int load_module(void) +{ + int res; + + res = ast_register_translator(&codec2tolin); + if (!res) + res=ast_register_translator(&lintocodec2); + else + ast_unregister_translator(&codec2tolin); + if (res) + return AST_MODULE_LOAD_FAILURE; + return AST_MODULE_LOAD_SUCCESS; +} + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Codec 2 Coder/Decoder", + .load = load_module, + .unload = unload_module, + .reload = reload, + ); diff --git a/codec2/branches/0.3/asterisk/ex_codec2.h b/codec2/branches/0.3/asterisk/ex_codec2.h new file mode 100644 index 00000000..ac5782dd --- /dev/null +++ b/codec2/branches/0.3/asterisk/ex_codec2.h @@ -0,0 +1,28 @@ +/*! \file + * \brief 8-bit raw data + * + * Copyright (C) 2012, 2012 Ed W and David Rowe + * + * Distributed under the terms of the GNU General Public License + * + */ + +static uint8_t ex_codec2[] = { + 0xea,0xca,0x14,0x85,0x91,0x78 +}; + +static struct ast_frame *codec2_sample(void) +{ + static struct ast_frame f = { + .frametype = AST_FRAME_VOICE, + .subclass.codec = AST_FORMAT_CODEC2, + .datalen = sizeof(ex_codec2), + .samples = CODEC2_SAMPLES, + .mallocd = 0, + .offset = 0, + .src = __PRETTY_FUNCTION__, + .data.ptr = ex_codec2, + }; + + return &f; +} diff --git a/codec2/branches/0.3/asterisk/make_asterisk_patch.sh b/codec2/branches/0.3/asterisk/make_asterisk_patch.sh new file mode 100755 index 00000000..a642bf7f --- /dev/null +++ b/codec2/branches/0.3/asterisk/make_asterisk_patch.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# Create patch for Codec 2 support inside Asterisk + +ORIG=~/asterisk-1.8.9.0-orig +CODEC2=~/asterisk-1.8.9.0-codec2 +diff -ruN $ORIG/include/asterisk/frame.h $CODEC2/include/asterisk/frame.h > asterisk-codec2.patch +diff -ruN $ORIG/main/frame.c $CODEC2/main/frame.c >> asterisk-codec2.patch +diff -ruN $ORIG/main/channel.c $CODEC2/main/channel.c >> asterisk-codec2.patch +diff -ruN $ORIG/main/rtp_engine.c $CODEC2/main/rtp_engine.c >> asterisk-codec2.patch + + diff --git a/codec2/branches/0.3/cmake/GetDependencies.cmake.in b/codec2/branches/0.3/cmake/GetDependencies.cmake.in new file mode 100644 index 00000000..067ad5e8 --- /dev/null +++ b/codec2/branches/0.3/cmake/GetDependencies.cmake.in @@ -0,0 +1,24 @@ +# As this script is run in a new cmake instance, it does not have access to +# the existing cache variables. Pass them in via the configure_file command. +set(CMAKE_BINARY_DIR @CMAKE_BINARY_DIR@) +set(CMAKE_SOURCE_DIR @CMAKE_SOURCE_DIR@) +set(UNIX @UNIX@) +set(WIN32 @WIN32@) +set(CMAKE_CROSSCOMPILING @CMAKE_CROSSCOMPILING@) +set(CMAKE_FIND_LIBRARY_SUFFIXES @CMAKE_FIND_LIBRARY_SUFFIXES@) +set(CMAKE_FIND_LIBRARY_PREFIXES @CMAKE_FIND_LIBRARY_PREFIXES@) +set(CMAKE_SYSTEM_LIBRARY_PATH @CMAKE_SYSTEM_LIBRARY_PATH@) +set(CMAKE_FIND_ROOT_PATH @CMAKE_FIND_ROOT_PATH@) +set(CODEC2_DLL ${CMAKE_BINARY_DIR}/src/libcodec2.dll) + +include(GetPrerequisites) +get_prerequisites(${CODEC2_DLL} _deps 1 1 "" "") +foreach(_runtime ${_deps}) + message("Looking for ${_runtime}") + find_library(RUNTIME_${_runtime} ${_runtime}) + message("${RUNTIME_${_runtime}}") + if(RUNTIME_${_runtime}) + file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" + TYPE EXECUTABLE FILES "${RUNTIME_${_runtime}}") + endif() +endforeach() diff --git a/codec2/branches/0.3/cmake/codec2-config.cmake.in b/codec2/branches/0.3/cmake/codec2-config.cmake.in new file mode 100644 index 00000000..db79a539 --- /dev/null +++ b/codec2/branches/0.3/cmake/codec2-config.cmake.in @@ -0,0 +1,5 @@ +set(CODEC2_VERSION ${CODEC2_VERSION}) + +@PACKAGE_INIT@ + +set_and_check(CODEC2_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@") diff --git a/codec2/branches/0.3/cmake/config.h.in b/codec2/branches/0.3/cmake/config.h.in new file mode 100644 index 00000000..60ee7d62 --- /dev/null +++ b/codec2/branches/0.3/cmake/config.h.in @@ -0,0 +1,23 @@ +/*-------------------------------------------------------------------------- + ** This file is autogenerated from config.h.in + ** during the cmake configuration of your project. If you need to make changes + ** edit the original file NOT THIS FILE. + ** --------------------------------------------------------------------------*/ +#ifndef _CONFIGURATION_HEADER_GUARD_H_ +#define _CONFIGURATION_HEADER_GUARD_H_ + +#define SIZEOF_INT @SIZEOF_INT@ +#cmakedefine HAVE_STDLIB_H @HAVE_STDLIB_H@ +#cmakedefine HAVE_STRING_H @HAVE_STRING_H@ +#cmakedefine HAVE_FLOOR @HAVE_FLOOR@ +#cmakedefine HAVE_CEIL @HAVE_CEIL@ +#cmakedefine HAVE_MEMSET @HAVE_MEMSET@ +#cmakedefine HAVE_POW @HAVE_POW@ +#cmakedefine HAVE_SQRT @HAVE_SQRT@ +#cmakedefine HAVE_SIN @HAVE_SIN@ +#cmakedefine HAVE_COS @HAVE_COS@ +#cmakedefine HAVE_ATAN2 @HAVE_ATAN2@ +#cmakedefine HAVE_LOG10 @HAVE_LOG10@ +#cmakedefine HAVE_ROUND @HAVE_ROUND@ +#cmakedefine HAVE_GETOPT @HAVE_GETOPT@ +#endif diff --git a/codec2/branches/0.3/fltk/Makefile b/codec2/branches/0.3/fltk/Makefile new file mode 100644 index 00000000..f29d2cd6 --- /dev/null +++ b/codec2/branches/0.3/fltk/Makefile @@ -0,0 +1,19 @@ +# Requires FLTK 1.3 & Portaudio V19 + +FLTK_VER = $(shell fltk-config --api-version) +ifneq ($(FLTK_VER),1.3) +$(error Must use FLTK version 1.3, you have $(FLTK_VER)) +endif + +FLTK_CFLAGS += $(shell fltk-config --ldstaticflags) +CFLAGS = -O3 -g -Wall +LIBS = ../src/.libs/libcodec2.a -lm -lrt -lportaudio -pthread +LC2POC_C = fl_fdmdv.cxx + +all: fl_fdmdv + +fl_fdmdv: Makefile $(LC2POC_C) + g++ $(LC2POC_C) -I../src/ -o fl_fdmdv $(CFLAGS) $(FLTK_CFLAGS) $(LIBS) + +clean: + rm -f fl_fdmdv diff --git a/codec2/branches/0.3/fltk/fl_fdmdv.cxx b/codec2/branches/0.3/fltk/fl_fdmdv.cxx new file mode 100644 index 00000000..30c67aab --- /dev/null +++ b/codec2/branches/0.3/fltk/fl_fdmdv.cxx @@ -0,0 +1,1158 @@ +/* + fl_fdmdv.cxx + Created 14 June 2012 + David Rowe + + Fltk 1.3 based GUI program to prototype FDMDV & Codec 2 integration + issues such as: + + + spectrum, waterfall, and other FDMDV GUI displays + + integration with real time audio I/O using portaudio + + what we do with audio when out of sync +*/ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "portaudio.h" + +#include "fdmdv.h" +#include "codec2.h" + +#define MIN_DB -40.0 +#define MAX_DB 0.0 +#define BETA 0.1 // constant for time averageing spectrum data +#define MIN_HZ 0 +#define MAX_HZ 4000 +#define WATERFALL_SECS_Y 5 // number of seconds respresented by y axis of waterfall +#define DT 0.02 // time between samples +#define FS 8000 // FDMDV modem sample rate + +#define SCATTER_MEM (FDMDV_NSYM)*50 +#define SCATTER_X_MAX 3.0 +#define SCATTER_Y_MAX 3.0 + +// main window params + +#define W 1200 +#define W3 (W/3) +#define H 600 +#define H2 (H/2) +#define SP 20 + +// sound card + +#define SAMPLE_RATE 48000 /* 48 kHz sampling rate rec. as we + can trust accuracy of sound + card */ +#define N8 FDMDV_NOM_SAMPLES_PER_FRAME /* processing buffer size at 8 kHz */ +#define MEM8 (FDMDV_OS_TAPS/FDMDV_OS) +#define N48 (N8*FDMDV_OS) /* processing buffer size at 48 kHz */ +#define NUM_CHANNELS 2 /* I think most sound cards prefer stereo, + we will convert to mono */ + +#define BITS_PER_CODEC_FRAME (2*FDMDV_BITS_PER_FRAME) +#define BYTES_PER_CODEC_FRAME (BITS_PER_CODEC_FRAME/8) + +// forward class declarations + +class Spectrum; +class Waterfall; +class Scatter; +class Scalar; + +// Globals -------------------------------------- + +char *fin_name = NULL; +char *fout_name = NULL; +char *sound_dev_name = NULL; +FILE *fin = NULL; +FILE *fout = NULL; +struct FDMDV *fdmdv; +struct CODEC2 *codec2; +float av_mag[FDMDV_NSPEC]; // shared between a few classes + +// GUI variables -------------------------------- + +Fl_Group *agroup; +Fl_Window *window; +Fl_Window *zoomSpectrumWindow = NULL; +Fl_Window *zoomWaterfallWindow = NULL; +Spectrum *aSpectrum; +Spectrum *aZoomedSpectrum; +Waterfall *aWaterfall; +Waterfall *aZoomedWaterfall; +Scatter *aScatter; +Scalar *aTimingEst; +Scalar *aFreqEst; +Scalar *aSNR; +int zoom_spectrum = 0; + +// Main processing loop states ------------------ + +float Ts = 0.0; +short input_buf[2*FDMDV_NOM_SAMPLES_PER_FRAME]; +int n_input_buf = 0; +int nin = FDMDV_NOM_SAMPLES_PER_FRAME; +short *output_buf; +int n_output_buf = 0; +int codec_bits[2*FDMDV_BITS_PER_FRAME]; +int state = 0; + +// Portaudio states ----------------------------- + +PaStream *stream = NULL; +PaError err; + +typedef struct { + float in48k[FDMDV_OS_TAPS + N48]; + float in8k[MEM8 + N8]; +} paCallBackData; + +// Class for each window type ------------------ + +class Spectrum: public Fl_Box { +protected: + int handle(int event) { + + // detect a left mouse down if inside the spectrum window + + if ((event == FL_NO_EVENT) && (Fl::event_button() == 1)) { + if ((Fl::event_x() > x()) && (Fl::event_x() < (x() + w())) && + (Fl::event_y() > y()) && (Fl::event_y() < (y() + h()))) { + + // show zoomed spectrum window + + zoomSpectrumWindow->show(); + } + + } + return 0; + } + + void draw() { + float x_px_per_point = 0.0; + float y_px_per_dB = 0.0; + int i, x1, y1, x2, y2; + float mag1, mag2; + char label[20]; + float px_per_hz; + + Fl_Box::draw(); + fl_color(FL_BLACK); + fl_rectf(x(),y(),w(),h()); + fl_color(FL_GREEN); + fl_line_style(FL_SOLID); + + fl_push_clip(x(),y(),w(),h()); + //printf("%d %d\n", w(), h()); + x_px_per_point = (float)w()/FDMDV_NSPEC; + y_px_per_dB = (float)h()/(MAX_DB - MIN_DB); + + // plot spectrum + + for(i=0; i x()) && (Fl::event_x() < (x() + w())) && + (Fl::event_y() > y()) && (Fl::event_y() < (y() + h()))) { + + // show zoomed spectrum window + + zoomWaterfallWindow->show(); + } + + } + return 0; + } + + // map val to a rgb colour + // from http://eddiema.ca/2011/01/21/c-sharp-heatmaps/ + + unsigned heatmap(float val, float min, float max) { + unsigned r = 0; + unsigned g = 0; + unsigned b = 0; + + val = (val - min) / (max - min); + if(val <= 0.2) { + b = (unsigned)((val / 0.2) * 255); + } else if(val > 0.2 && val <= 0.7) { + b = (unsigned)((1.0 - ((val - 0.2) / 0.5)) * 255); + } + if(val >= 0.2 && val <= 0.6) { + g = (unsigned)(((val - 0.2) / 0.4) * 255); + } else if(val > 0.6 && val <= 0.9) { + g = (unsigned)((1.0 - ((val - 0.6) / 0.3)) * 255); + } + if(val >= 0.5) { + r = (unsigned)(((val - 0.5) / 0.5) * 255); + } + + //printf("%f %x %x %x\n", val, r, g, b); + + return (b << 16) + (g << 8) + r; + } + + void draw() { + float spec_index_per_px, intensity_per_dB; + int px_per_sec; + int index, dy, dy_blocks, bytes_in_row_of_blocks, b; + int px, py, intensity; + unsigned *last_row, *pdest, *psrc; + + /* detect resizing of window */ + + if ((h() != prev_h) || (w() != prev_w)) { + delete pixel_buf; + new_pixel_buf(w(), h()); + } + + Fl_Box::draw(); + + // determine dy, the height of one "block" + + px_per_sec = (float)h()/WATERFALL_SECS_Y; + dy = DT*px_per_sec; + + // number of dy high blocks in spectrogram + + dy_blocks = h()/dy; + + // shift previous bit map + + bytes_in_row_of_blocks = dy*w()*sizeof(unsigned); + + for(b=0; b 255) intensity = 255; + if (intensity < 0) intensity = 0; + + if (greyscale) { + for(py=0; py (h()/2 - 10)) + y1 = h()/2 - 10; + if (y1 < -(h()/2 - 10)) + y1 = -(h()/2 - 10); + return y1; + } + + void draw() { + float x_scale; + float y_scale; + int i, x1, y1, x2, y2; + char label[100]; + + Fl_Box::draw(); + + /* detect resizing of window */ + + if ((h() != prev_h) || (w() != prev_w) || (x() != prev_x) || (y() != prev_y)) { + fl_color(FL_BLACK); + fl_rectf(x(),y(),w(),h()); + prev_h = h(); prev_w = w(); prev_x = x(); prev_y = y(); + } + + fl_push_clip(x(),y(),w(),h()); + + x_scale = (float)w()/x_max; + y_scale = (float)h()/(2.0*y_max); + + // erase last sample + + fl_color(FL_BLACK); + x1 = x_scale * index + x(); + y1 = y_scale * mem[index]; + y1 = clip(y1); + y1 = y() + h()/2 - y1; + fl_point(x1, y1); + + // draw new sample + + fl_color(FL_GREEN); + x1 = x_scale * index + x(); + y1 = y_scale * new_sample; + y1 = clip(y1); + y1 = y() + h()/2 - y1; + fl_point(x1, y1); + mem[index] = new_sample; + + index++; + if (index >= x_max) + index = 0; + + // y axis graticule + + step = 10; + + while ((2.0*y_max/step) > 10) + step *= 2.0; + while ((2.0*y_max/step) < 4) + step /= 2.0; + + fl_color(FL_DARK_GREEN); + fl_line_style(FL_DOT); + for(i=-y_max; i= *nin) { + + // demod per frame processing + + for(i=0; i<*nin; i++) + rx_fdm[i] = (float)input_buf[i]/FDMDV_SCALE; + nin_prev = *nin; + fdmdv_demod(fdmdv, rx_bits, &sync_bit, rx_fdm, nin); + *n_input_buf -= nin_prev; + assert(*n_input_buf >= 0); + + // shift input buffer + + for(i=0; i<*n_input_buf; i++) + input_buf[i] = input_buf[i+nin_prev]; + + // compute rx spectrum & get demod stats, and update GUI plot data + + fdmdv_get_rx_spectrum(fdmdv, rx_spec, rx_fdm, nin_prev); + fdmdv_get_demod_stats(fdmdv, &stats); + new_data(rx_spec); + aScatter->add_new_samples(stats.rx_symbols); + aTimingEst->add_new_sample(stats.rx_timing); + aFreqEst->add_new_sample(stats.foff); + aSNR->add_new_sample(stats.snr_est); + + /* + State machine to: + + + Mute decoded audio when out of sync. The demod is synced + when we are using the fine freq estimate and SNR is above + a thresh. + + + Decode codec bits only if we have a 0,1 sync bit + sequence. Collects two frames of demod bits to decode + one frame of codec bits. + */ + + next_state = *state; + switch (*state) { + case 0: + /* mute output audio when out of sync */ + + if (*n_output_buf < 2*codec2_samples_per_frame(c2) - N8) { + for(i=0; i 3.0)) + next_state = 1; + + break; + case 1: + if (sync_bit == 0) { + next_state = 2; + + /* first half of frame of codec bits */ + + memcpy(codec_bits, rx_bits, FDMDV_BITS_PER_FRAME*sizeof(int)); + } + else + next_state = 1; + + if (stats.fest_coarse_fine == 0) + next_state = 0; + + break; + case 2: + next_state = 1; + + if (stats.fest_coarse_fine == 0) + next_state = 0; + + if (sync_bit == 1) { + /* second half of frame of codec bits */ + + memcpy(&codec_bits[FDMDV_BITS_PER_FRAME], rx_bits, FDMDV_BITS_PER_FRAME*sizeof(int)); + + /* pack bits, MSB received first */ + + bit = 7; byte = 0; + memset(packed_bits, 0, BYTES_PER_CODEC_FRAME); + for(i=0; i= DT) { + *Ts -= DT; + if (!zoomSpectrumWindow->shown() && !zoomWaterfallWindow->shown()) { + aSpectrum->redraw(); + aWaterfall->redraw(); + aScatter->redraw(); + aTimingEst->redraw(); + aFreqEst->redraw(); + aSNR->redraw(); + } + if (zoomSpectrumWindow->shown()) + aZoomedSpectrum->redraw(); + if (zoomWaterfallWindow->shown()) + aZoomedWaterfall->redraw(); + } +} + + +/* + idle() is the FLTK function that gets continusouly called when FLTK + is not doing GUI work. We use this function for providing file + input to update the GUI when simulating real time operation. +*/ + +void idle(void*) { + int ret, i; + + if (fin_name != NULL) { + ret = fread(&input_buf[n_input_buf], + sizeof(short), + FDMDV_NOM_SAMPLES_PER_FRAME, + fin); + n_input_buf += FDMDV_NOM_SAMPLES_PER_FRAME; + + per_frame_rx_processing(output_buf, &n_output_buf, + codec_bits, + input_buf, &n_input_buf, + &nin, &state, codec2); + + if (fout_name != NULL) { + if (n_output_buf >= N8) { + ret = fwrite(output_buf, sizeof(short), N8, fout); + n_output_buf -= N8; + assert(n_output_buf >= 0); + + /* shift speech sample output buffer */ + + for(i=0; iin8k; + float *in48k = cbData->in48k; + float out8k[N8]; + float out48k[N48]; + short out48k_short[N48]; + + (void) timeInfo; + (void) statusFlags; + + assert(inputBuffer != NULL); + + /* Convert input model samples from 48 to 8 kHz ------------ */ + + /* just use left channel */ + + for(i=0; i= N8) { + if (state == 0) { + for(i=0; i= 0); + + /* shift speech samples in output buffer */ + + for(i=0; i<(uint)n_output_buf; i++) + output_buf[i] = output_buf[i+N8]; + + /* Convert output speech to 48 kHz sample rate ------------- */ + + /* upsample and update filter memory */ + + fdmdv_8_to_48(out48k, &in8k[MEM8], N8); + for(i=0; i= argc) + return 0; + fin_name = argv[i+1]; + i += 2; + return 2; + } + if (argv[i][1] == 'o') { + if ((i+1) >= argc) + return 0; + fout_name = argv[i+1]; + i += 2; + return 2; + } + if (argv[i][1] == 's') { + if ((i+1) >= argc) + return 0; + sound_dev_name = argv[i+1]; + i += 2; + return 2; + } + return 0; +} + +/*------------------------------------------------------------*\ + + MAIN + +\*------------------------------------------------------------*/ + +int main(int argc, char **argv) { + int ret; + int i; + PaStreamParameters inputParameters, outputParameters; + paCallBackData cbData; + + i = 1; + Fl::args(argc,argv,i,arg_callback); + + if (argc == 1) { + printf("usage: %s [-i inputFdmdvRawFile] [-o outputRawSoundFile] [-s inputSoundDevice]\n", argv[0]); + exit(0); + } + + if (fin_name != NULL) { + fin = fopen(fin_name,"rb"); + if (fin == NULL) { + fprintf(stderr, "Error opening input fdmdv raw file %s\n", fin_name); + exit(1); + } + } + + if (fout_name != NULL) { + fout = fopen(fout_name,"wb"); + if (fout == NULL) { + fprintf(stderr, "Error opening output speech raw file %s\n", fout_name); + exit(1); + } + } + + for(i=0; idefaultLowInputLatency; + inputParameters.hostApiSpecificStreamInfo = NULL; + + outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */ + if (outputParameters.device == paNoDevice) { + fprintf(stderr,"Error: No default output device.\n"); + goto pa_error; + } + outputParameters.channelCount = NUM_CHANNELS; /* stereo output */ + outputParameters.sampleFormat = paInt16; + outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; + outputParameters.hostApiSpecificStreamInfo = NULL; + + err = Pa_OpenStream( + &stream, + &inputParameters, + &outputParameters, + SAMPLE_RATE, + N48, + paClipOff, + callback, + &cbData); + + if( err != paNoError ) goto pa_error; + } + + /*------------------------------------------------------------------------*\ + + Init GUI + + \*------------------------------------------------------------------------*/ + + // recommended to prevent dithering and stopped display being + // covered by black flickering squares + + Fl::visual(FL_RGB); + + // set up main window + + window = new Fl_Window(W, SP+H2+SP+SP+H2+SP, "fl_fmdv"); + //window->size_range(100, 100); + //window->resizable(); + aSpectrum = new Spectrum(SP, SP, W3-2*SP, H2); + aWaterfall = new Waterfall(SP, SP+H2+SP+SP, W3-2*SP, H2); + aScatter = new Scatter(W3+SP, SP, W3-2*SP, H2); + aTimingEst = new Scalar(W3+SP, SP+H2+SP+SP, W3-2*SP, H2, 100, 80, "Timing Est"); + aFreqEst = new Scalar(2*W3+SP, SP, W3-2*SP, H2, 100, 100, "Frequency Est"); + aSNR = new Scalar(2*W3+SP, SP+H2+SP+SP, W3-2*SP, H2, 100, 20, "SNR"); + + Fl::add_idle(idle); + + window->end(); + + // set up zoomed spectrum window + + zoomSpectrumWindow = new Fl_Window(W, H, "Spectrum"); + aZoomedSpectrum = new Spectrum(SP, SP, W-2*SP, H-2*SP); + zoomSpectrumWindow->end(); + + // set up zoomed waterfall window + + zoomWaterfallWindow = new Fl_Window(W, H, "Waterfall"); + aZoomedWaterfall = new Waterfall(SP, SP, W-2*SP, H-2*SP); + zoomWaterfallWindow->end(); + + if (sound_dev_name != NULL) { + err = Pa_StartStream( stream ); + if( err != paNoError ) goto pa_error; + } + + // show the main window and start running + + window->show(argc, argv); + Fl::run(); + + if (sound_dev_name != NULL) { + err = Pa_StopStream( stream ); + if( err != paNoError ) goto pa_error; + Pa_CloseStream( stream ); + Pa_Terminate(); + } + + fdmdv_destroy(fdmdv); + codec2_destroy(codec2); + free(output_buf); + + if (fin_name != NULL) + fclose(fin); + if (fout_name != NULL) + fclose(fout); + + return ret; + + // Portaudio error handling + +pa_error: + if( stream ) { + Pa_AbortStream( stream ); + Pa_CloseStream( stream ); + } + Pa_Terminate(); + fprintf( stderr, "An error occured while using the portaudio stream\n" ); + fprintf( stderr, "Error number: %d\n", err ); + fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + return -1; +} diff --git a/codec2/branches/0.3/octave/README.txt b/codec2/branches/0.3/octave/README.txt new file mode 100644 index 00000000..05d63f20 --- /dev/null +++ b/codec2/branches/0.3/octave/README.txt @@ -0,0 +1,17 @@ +README.txt +For codec2/octave directory +Created 24 June 2012 by David Rowe + +1/ To support some of the Octave scripts (in particular fdmdv) in this + directory the following Octave packages need to be installed: + + control image miscellaneous optim signal specfun struct + +2/ Download these tar balls from: + + http://octave.sourceforge.net/packages.php + +3/ Install each package from the Octave command line with: + + octave:3> pkg install package_file_name.tar.gz + diff --git a/codec2/branches/0.3/octave/av_imp.m b/codec2/branches/0.3/octave/av_imp.m new file mode 100644 index 00000000..8b7fa608 --- /dev/null +++ b/codec2/branches/0.3/octave/av_imp.m @@ -0,0 +1,43 @@ +% av_imp.m +% David Rowe Aug 2012 +% Averages the impulse response samples + +function imp = av_imp(imp_filename, period_in_secs, st, en) + f = fopen(imp_filename,"rb"); + s = fread(f, Inf, "short")'; + + Fs = 8000; + n = period_in_secs * Fs; + + [r c] = size(s); + + imp = zeros(1,n); + for i=1:n:c-n + imp = imp + s(i:i+n-1); + endfor + + % user supplies start and end samples after viweing plot + + if (nargin == 4) + imp = imp(st:en); + end + + % normalise + + imp /= sqrt(sum(imp .^ 2)); + + [h w] = freqz(imp, 1, 4000); + + figure(1); + clf; + plot(imp); + + figure(2); + clf; + subplot(211) + plot(10*log10(abs(h))) + subplot(212) + plot(angle(h)) + +endfunction + diff --git a/codec2/branches/0.3/octave/cbphase.m b/codec2/branches/0.3/octave/cbphase.m new file mode 100644 index 00000000..8e82da1c --- /dev/null +++ b/codec2/branches/0.3/octave/cbphase.m @@ -0,0 +1,98 @@ +% cbphase.m +% David Rowe Aug 2012 +% Used to experiment with critical band phase perception and smoothing + +function cbphase + + Wo = 100.0*pi/4000; + L = floor(pi/Wo); + + A = zeros(1,L); + phi = zeros(1,L); + + % three harmonics in this band + + b = 4; a = b-1; c = b+1; + + % set up phases and mags for 2nd order system (see phasesecord.m) + + wres = b*Wo; + phi(a) = 3*pi/4 + wres; + phi(b) = pi/2 + wres; + phi(c) = pi/4 + wres; + + A(a) = 0.707; + A(b) = 1; + A(c) = 0.707; + + % add linear component + + phi(1) = pi; + phi(2:L) = phi(2:L) + (2:L)*phi(1); + phi = phi - 2*pi*(floor(phi/(2*pi)) + 0.5); + + N = 16000; + Nplot = 250; + s = zeros(1,N); + + for m=a:c + s_m = A(m)*cos(m*Wo*(0:(N-1)) + phi(m)); + s = s + s_m; + endfor + + figure(2); + clf; + subplot(211) + plot((1:L)*Wo*4000/pi, A,'+'); + subplot(212) + plot((1:L)*Wo*4000/pi, phi,'+'); + + %v = A(a)*exp(j*phi(a)) + A(b)*exp(j*phi(b)) + A(c)*exp(j*phi(c)); + %compass(v,"r") + %hold off; + + % est phi1 + + diff = phi(b) - phi(a) + sumi = sin(diff); + sumr = cos(diff); + diff = phi(c) - phi(b) + sumi += sin(diff); + sumr += cos(diff); + phi1_ = atan2(sumi, sumr) + s_v = cos(Wo*(0:(N-1)) + phi1_); + + figure(1); + clf; + subplot(211) + plot(s(1:Nplot)); + hold on; + plot(s_v(1:Nplot),"r"); + hold off; + + % build (hopefully) perceptually similar phase + + phi_(a) = a*phi1_; + phi_(b) = b*phi1_; + phi_(c) = c*phi1_; + + s_ = zeros(1,N); + + for m=a:c + s_m = A(m)*cos(m*Wo*(0:(N-1)) + phi_(m)); + s_ = s_ + s_m; + endfor + + subplot(212) + plot(s_(1:Nplot)); + + gain = 8000; + fs=fopen("orig_ph.raw","wb"); + fwrite(fs,gain*s,"short"); + fclose(fs); + fs=fopen("mod_ph.raw","wb"); + fwrite(fs,gain*s_,"short"); + fclose(fs); + +endfunction + diff --git a/codec2/branches/0.3/octave/codec2_demo.m b/codec2/branches/0.3/octave/codec2_demo.m new file mode 100644 index 00000000..6cd26970 --- /dev/null +++ b/codec2/branches/0.3/octave/codec2_demo.m @@ -0,0 +1,108 @@ +% Copyright David Rowe 2012 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% codec2_demo.m + +% Designed as an educational tool to explain the operation of Codec 2 +% for conference and user group presentations on a projector. An +% alternative to static overhead slides. +% +% Derived from codec2/octave/plamp.m +% +% usage: +% octave:1> plamp("../src/hts2a",40) +% +% Then press: +% c - to cycle through the wavform being displayed on the figure +% n - next frame +% b - back one frame +% +% tip: hold down n or b to animate the display +% +% The text files used as input are generated using c2sim: +% +% /codec2/src$ c2sim ../raw/hts2a.raw --dump hts2a +% +% The Codec 2 README explains how to build c2sim with dump files +% enabled. + +function codec2_demo(samname, f) + + sn_name = strcat(samname,"_sn.txt"); + Sn = load(sn_name); + + sw_name = strcat(samname,"_sw.txt"); + Sw = load(sw_name); + + model_name = strcat(samname,"_model.txt"); + model = load(model_name); + + figure(1); + + k = ' '; + wf = "Sn"; + do + + if strcmp(wf,"Sn") + clf; + s = [ Sn(2*f-1,:) Sn(2*f,:) ]; + plot(s); + axis([1 length(s) -20000 20000]); + end + + if (strcmp(wf,"Sw")) + clf; + plot((0:255)*4000/256, Sw(f,:),";Sw;"); + end + + if strcmp(wf,"SwAm") + Wo = model(f,1); + L = model(f,2); + Am = model(f,3:(L+2)); + plot((0:255)*4000/256, Sw(f,:),";Sw;"); + hold on; + plot((1:L)*Wo*4000/pi, 20*log10(Am),"+;Am;r"); + axis([1 4000 -10 80]); + hold off; + end + + if strcmp(wf,"Am") + Wo = model(f,1); + L = model(f,2); + Am = model(f,3:(L+2)); + plot((1:L)*Wo*4000/pi, 20*log10(Am),"+;Am;r"); + axis([1 4000 -10 80]); + end + + % interactive menu + + printf("\rframe: %d menu: n-next b-back w-cycle window q-quit", f); + fflush(stdout); + k = kbhit(); + if (k == 'n') + f = f + 1; + end + if (k == 'b') + f = f - 1; + end + if (k == 'w') + if strcmp(wf,"Sn") + next_wf = "Sw"; + end + if strcmp(wf,"Sw") + next_wf = "SwAm"; + end + if strcmp(wf,"SwAm") + next_wf = "Am"; + end + if strcmp(wf,"Am") + next_wf = "Sn"; + end + wf = next_wf; + end + + until (k == 'q') + printf("\n"); + +endfunction diff --git a/codec2/branches/0.3/octave/cspec.m b/codec2/branches/0.3/octave/cspec.m new file mode 100644 index 00000000..e0ca15b6 --- /dev/null +++ b/codec2/branches/0.3/octave/cspec.m @@ -0,0 +1,54 @@ +% cspec.m +% David Rowe Aug 2012 +% Used to compare spectromgrams while experimenting with phase + +function cspec(s1,s2) + f1 = fopen(s1,"rb"); + s1 = fread(f1,Inf,"short"); + f2 = fopen(s2,"rb"); + s2 = fread(f2,Inf,"short"); + + Fs = 8000; + spec_win = 512; + + state = 's1'; + do + if strcmp(state,'s1') + spec(s1,Fs,spec_win); + %title(s1); + end + if strcmp(state,'s2') + spec(s2,Fs,spec_win); + %title(s2); + end + if strcmp(state,'diff') + spec(s1-s2,Fs,spec_win); + %title("difference"); + end + + printf("\rstate: %s space-toggle d-diff q-quit", state); + fflush(stdout); + k = kbhit(); + + if k == ' ' + if strcmp(state,"diff") + next_state = 's1'; + end + if strcmp(state,"s1") + next_state = 's2'; + end + if strcmp(state,'s2') + next_state = 's1'; + end + end + + if k == 'd' + next_state = 'diff'; + end + + state = next_state; + until (k == 'q') + + printf("\n"); + +endfunction diff --git a/codec2/branches/0.3/octave/diff_codec.m b/codec2/branches/0.3/octave/diff_codec.m new file mode 100644 index 00000000..2ad204ff --- /dev/null +++ b/codec2/branches/0.3/octave/diff_codec.m @@ -0,0 +1,96 @@ +% diff_codec.m +% +% Plots differences between two states in two runs of the codec, +% e.g. x86 and embedded. +% +% Copyright David Rowe 2013 +% +% This program is distributed under the terms of the GNU General Public License +% Version 2 + +function diff_codec(samname1, samname2, model1_prefix, model2_prefix) + + fs1=fopen(samname1,"rb"); + s1=fread(fs1,Inf,"short"); + fs2=fopen(samname2,"rb"); + s2=fread(fs2,Inf,"short"); + + st = 1; + en = length(s1); + + figure(1); + clf; + subplot(211); + l1 = strcat("r;",samname1,";"); + plot(s1(st:en), l1); + axis([1 en-st min(s1(st:en)) max(s1(st:en))]); + subplot(212); + l2 = strcat("r;",samname2,";"); + plot(s2(st:en),l2); + axis([1 en-st min(s1(st:en)) max(s1(st:en))]); + + figure(2) + plot(s1(st:en)-s2(st:en)); + max(s1(st:en)-s2(st:en)); + + model_name1 = strcat(model1_prefix,"_model.txt"); + model1 = load(model_name1); + model_name1q = strcat(model1_prefix,"_qmodel.txt"); + model1q = load(model_name1q); + + model_name2 = strcat(model2_prefix,"_model.txt"); + model2 = load(model_name2); + model_name2q = strcat(model2_prefix,"_qmodel.txt"); + model2q = load(model_name2q); + + Wo1 = model1(:,1); + L1 = model1(:,2); + Am1 = model1(:,3:82); + Wo1q = model1q(:,1); + L1q = model1q(:,2); + Am1q = model1q(:,3:82); + + Wo2 = model2(:,1); + L2 = model2(:,2); + Am2 = model2(:,3:82); + Wo2q = model2q(:,1); + L2q = model2q(:,2); + Am2q = model2q(:,3:82); + + figure(3) + subplot(211) + plot(Wo1) + title('Wo1'); + subplot(212) + plot(Wo1-Wo2) + figure(4) + subplot(211) + plot(Wo1q) + title('Wo1q'); + subplot(212) + plot(Wo1q-Wo2q) + + figure(5) + subplot(211) + plot(L1) + title('L1'); + subplot(212) + plot(L1-L2) + figure(6) + subplot(211) + plot(L1q) + title('L1q'); + subplot(212) + plot(L1q-L2q) + + figure(7) + l=length(L1q); + sm=zeros(1,l); + for f=1:l + %printf("f %d L1q %d L2q %d\n",f,L1q(f),L2q(f)); + sm(f) = sum(10*log10(Am1q(f,1:L1q(f))) - 10*log10(Am2q(f,1:L2q(f)))); + end + plot(sm) + title('Am1q - Am2q'); + +endfunction diff --git a/codec2/branches/0.3/octave/fdmdv.m b/codec2/branches/0.3/octave/fdmdv.m new file mode 100644 index 00000000..f64fe895 --- /dev/null +++ b/codec2/branches/0.3/octave/fdmdv.m @@ -0,0 +1,1087 @@ +% fdmdv.m +% +% Functions that implement a Frequency Divison Multiplexed Modem for +% Digital Voice (FDMDV) over HF channels. +% +% Copyright David Rowe 2012 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% + +% reqd to mak sure we get same random bits at mod and demod + +rand('state',1); +randn('state',1); + +% Constants + +global Fs = 8000; % sample rate in Hz +global T = 1/Fs; % sample period in seconds +global Rs; + Rs = 50; % symbol rate in Hz +global Nc; % number of carriers +if isempty(NumCarriers) + Nc = 14; +else + Nc = NumCarriers; +end +global Nb; + Nb = 2; % Bits/symbol for PSK modulation +global Rb; + Rb = Nc*Rs*Nb; % bit rate +global M = Fs/Rs; % oversampling factor +global Nsym = 6; % number of symbols to filter over +global Fsep; + Fsep = 75; % Separation between carriers (Hz) +global Fcentre = 1500; % Centre frequency, Nc/2 carriers below this, N/c carriers above (Hz) +global Nt = 5; % number of symbols we estimate timing over +global P = 4; % oversample factor used for rx symbol filtering +global Nfilter = Nsym*M; +global Nfiltertiming = M+Nfilter+M; +alpha = 0.5; +global snr_coeff; + snr_coeff = 0.9;% SNR est averaging filter coeff +global Nph; + Nph = 9; % number of symbols to estimate phase over + % must be odd number as we take centre symbol + +% root raised cosine (Root Nyquist) filter + +global gt_alpha5_root; +gt_alpha5_root = gen_rn_coeffs(alpha, T, Rs, Nsym, M); + +% Converts gray code to natural binary + +global m4_gray_to_binary = [ + bin2dec("00") + bin2dec("01") + bin2dec("11") + bin2dec("10") + ]; +global m8_gray_to_binary = [ + bin2dec("000") + bin2dec("001") + bin2dec("011") + bin2dec("010") + bin2dec("111") + bin2dec("110") + bin2dec("100") + bin2dec("101") + ]; + +% Convert natural binary to gray code + +global m4_binary_to_gray = [ + bin2dec("00") + bin2dec("01") + bin2dec("11") + bin2dec("10") + ]; + +global m8_binary_to_gray = [ + bin2dec("000") + bin2dec("001") + bin2dec("011") + bin2dec("010") + bin2dec("110") + bin2dec("111") + bin2dec("101") + bin2dec("100") + ]; + +% Functions ---------------------------------------------------- + + +% generate Nc+1 PSK symbols from vector of (1,Nc*Nb) input bits. The +% Nc+1 symbol is the +1 -1 +1 .... BPSK sync carrier + +function tx_symbols = bits_to_psk(prev_tx_symbols, tx_bits) + global Nc; + global Nb; + global pilot_bit; + global m4_gray_to_binary; + global m8_gray_to_binary; + + assert(length(tx_bits) == Nc*Nb, "Incorrect number of bits"); + + m = 2 .^ Nb; + assert((m == 4) || (m == 8)); + + for c=1:Nc + + % extract bits for this symbol + + bits_binary = tx_bits((c-1)*Nb+1:c*Nb); + bits_decimal = sum(bits_binary .* 2.^(Nb-1:-1:0)); + + % determine phase shift using gray code mapping + + if m == 4 + phase_shift = (2*pi/m)*m4_gray_to_binary(bits_decimal+1); + else + phase_shift = (2*pi/m)*m8_gray_to_binary(bits_decimal+1); + end + + % apply phase shift from previous symbol + + tx_symbols(c) = exp(j*phase_shift) * prev_tx_symbols(c); + end + + % +1 -1 +1 -1 BPSK sync carrier, once filtered becomes two spectral + % lines at +/- Rs/2 + + if pilot_bit + tx_symbols(Nc+1) = -prev_tx_symbols(Nc+1); + else + tx_symbols(Nc+1) = prev_tx_symbols(Nc+1); + end + if pilot_bit + pilot_bit = 0; + else + pilot_bit = 1; + end + +endfunction + + +% Given Nc*Nb bits construct M samples (1 symbol) of Nc filtered +% symbols streams + +function tx_baseband = tx_filter(tx_symbols) + global Nc; + global M; + global tx_filter_memory; + global Nfilter; + global gt_alpha5_root; + + tx_baseband = zeros(Nc+1,M); + + % tx filter each symbol, generate M filtered output samples for each symbol. + % Efficient polyphase filter techniques used as tx_filter_memory is sparse + + tx_filter_memory(:,Nfilter) = sqrt(2)/2*tx_symbols; + + for i=1:M + tx_baseband(:,i) = M*tx_filter_memory(:,M:M:Nfilter) * gt_alpha5_root(M-i+1:M:Nfilter)'; + end + tx_filter_memory(:,1:Nfilter-M) = tx_filter_memory(:,M+1:Nfilter); + tx_filter_memory(:,Nfilter-M+1:Nfilter) = zeros(Nc+1,M); + +endfunction + + +% Construct FDM signal by frequency shifting each filtered symbol +% stream. Returns complex signal so we can apply frequency offsets +% easily. + +function tx_fdm = fdm_upconvert(tx_filt) + global Fs; + global M; + global Nc; + global Fsep; + global phase_tx; + global freq; + + tx_fdm = zeros(1,M); + + % Nc/2 tones below centre freq + + for c=1:Nc/2 + for i=1:M + phase_tx(c) = phase_tx(c) * freq(c); + tx_fdm(i) = tx_fdm(i) + tx_filt(c,i)*phase_tx(c); + end + end + + % Nc/2 tones above centre freq + + for c=Nc/2+1:Nc + for i=1:M + phase_tx(c) = phase_tx(c) * freq(c); + tx_fdm(i) = tx_fdm(i) + tx_filt(c,i)*phase_tx(c); + end + end + + % add centre pilot tone + + c = Nc+1; + for i=1:M + phase_tx(c) = phase_tx(c) * freq(c); + pilot(i) = 2*tx_filt(c,i)*phase_tx(c); + tx_fdm(i) = tx_fdm(i) + pilot(i); + end + + % Scale such that total Carrier power C of real(tx_fdm) = Nc. This + % excludes the power of the pilot tone. + % We return the complex (single sided) signal to make frequency + % shifting for the purpose of testing easier + + tx_fdm = 2*tx_fdm; +endfunction + + +% Frequency shift each modem carrier down to Nc+1 baseband signals + +function rx_baseband = fdm_downconvert(rx_fdm, nin) + global Fs; + global M; + global Nc; + global Fsep; + global phase_rx; + global freq; + + rx_baseband = zeros(1,nin); + + % Nc/2 tones below centre freq + + for c=1:Nc/2 + for i=1:nin + phase_rx(c) = phase_rx(c) * freq(c); + rx_baseband(c,i) = rx_fdm(i)*phase_rx(c)'; + end + end + + % Nc/2 tones above centre freq + + for c=Nc/2+1:Nc + for i=1:nin + phase_rx(c) = phase_rx(c) * freq(c); + rx_baseband(c,i) = rx_fdm(i)*phase_rx(c)'; + end + end + + % Pilot + + c = Nc+1; + for i=1:nin + phase_rx(c) = phase_rx(c) * freq(c); + rx_baseband(c,i) = rx_fdm(i)*phase_rx(c)'; + end + +endfunction + + +% Receive filter each baseband signal at oversample rate P + +function rx_filt = rx_filter(rx_baseband, nin) + global Nc; + global M; + global P; + global rx_filter_memory; + global Nfilter; + global gt_alpha5_root; + global Fsep; + + rx_filt = zeros(Nc+1,nin*P/M); + + % rx filter each symbol, generate P filtered output samples for each symbol. + % Note we keep memory at rate M, it's just the filter output at rate P + + N=M/P; + j=1; + for i=1:N:nin + rx_filter_memory(:,Nfilter-N+1:Nfilter) = rx_baseband(:,i:i-1+N); + rx_filt(:,j) = rx_filter_memory * gt_alpha5_root'; + rx_filter_memory(:,1:Nfilter-N) = rx_filter_memory(:,1+N:Nfilter); + j+=1; + end +endfunction + + +% LPF and peak pick part of freq est, put in a function as we call it twice + +function [foff imax pilot_lpf S] = lpf_peak_pick(pilot_baseband, pilot_lpf, nin) + global M; + global Npilotlpf; + global Npilotcoeff; + global Fs; + global Mpilotfft; + global pilot_coeff; + + % LPF cutoff 200Hz, so we can handle max +/- 200 Hz freq offset + + pilot_lpf(1:Npilotlpf-nin) = pilot_lpf(nin+1:Npilotlpf); + j = 1; + for i = Npilotlpf-nin+1:Npilotlpf + pilot_lpf(i) = pilot_baseband(j:j+Npilotcoeff-1) * pilot_coeff'; + j++; + end + + % decimate to improve DFT resolution, window and DFT + + Mpilot = Fs/(2*200); % calc decimation rate given new sample rate is twice LPF freq + h = hanning(Npilotlpf); + s = pilot_lpf(1:Mpilot:Npilotlpf) .* h(1:Mpilot:Npilotlpf)'; + s = [s zeros(1,Mpilotfft-Npilotlpf/Mpilot)]; + S = fft(s, Mpilotfft); + + % peak pick and convert to Hz + + [imax ix] = max(S); + r = 2*200/Mpilotfft; % maps FFT bin to frequency in Hz + + if ix > Mpilotfft/2 + foff = (ix - Mpilotfft - 1)*r; + else + foff = (ix - 1)*r; + endif + +endfunction + + +% Estimate frequency offset of FDM signal using BPSK pilot. This is quite +% sensitive to pilot tone level wrt other carriers + +function [foff S1 S2] = rx_est_freq_offset(rx_fdm, pilot, pilot_prev, nin) + global M; + global Npilotbaseband; + global pilot_baseband1; + global pilot_baseband2; + global pilot_lpf1; + global pilot_lpf2; + + % down convert latest nin samples of pilot by multiplying by + % ideal BPSK pilot signal we have generated locally. This + % peak of the resulting signal is sensitive to the time shift between + % the received and local version of the pilot, so we do it twice at + % different time shifts and choose the maximum. + + pilot_baseband1(1:Npilotbaseband-nin) = pilot_baseband1(nin+1:Npilotbaseband); + pilot_baseband2(1:Npilotbaseband-nin) = pilot_baseband2(nin+1:Npilotbaseband); + for i=1:nin + pilot_baseband1(Npilotbaseband-nin+i) = rx_fdm(i) * conj(pilot(i)); + pilot_baseband2(Npilotbaseband-nin+i) = rx_fdm(i) * conj(pilot_prev(i)); + end + + [foff1 max1 pilot_lpf1 S1] = lpf_peak_pick(pilot_baseband1, pilot_lpf1, nin); + [foff2 max2 pilot_lpf2 S2] = lpf_peak_pick(pilot_baseband2, pilot_lpf2, nin); + + if max1 > max2 + foff = foff1; + else + foff = foff2; + end +endfunction + + +% Estimate optimum timing offset, re-filter receive symbols + +function [rx_symbols rx_timing env] = rx_est_timing(rx_filt, rx_baseband, nin) + global M; + global Nt; + global Nc; + global rx_filter_mem_timing; + global rx_baseband_mem_timing; + global P; + global Nfilter; + global Nfiltertiming; + global gt_alpha5_root; + + % nin adjust + % -------------------------------- + % 120 -1 (one less rate P sample) + % 160 0 (nominal) + % 200 1 (one more rate P sample) + + adjust = P - nin*P/M; + + % update buffer of Nt rate P filtered symbols + + rx_filter_mem_timing(:,1:(Nt-1)*P+adjust) = rx_filter_mem_timing(:,P+1-adjust:Nt*P); + rx_filter_mem_timing(:,(Nt-1)*P+1+adjust:Nt*P) = rx_filt(:,:); + + % sum envelopes of all carriers + + env = sum(abs(rx_filter_mem_timing(:,:))); % use all Nc+1 carriers for timing + %env = abs(rx_filter_mem_timing(Nc+1,:)); % just use BPSK pilot + [n m] = size(env); + + % The envelope has a frequency component at the symbol rate. The + % phase of this frequency component indicates the timing. So work out + % single DFT at frequency 2*pi/P + + x = env * exp(-j*2*pi*(0:m-1)/P)'; + + % map phase to estimated optimum timing instant at rate M + % the M/4 part was adjusted by experiment, I know not why.... + + rx_timing = angle(x)*M/(2*pi) + M/4; + if (rx_timing > M) + rx_timing -= M; + end + if (rx_timing < -M) + rx_timing += M; + end + + % rx_baseband_mem_timing contains M + Nfilter + M samples of the + % baseband signal at rate M this enables us to resample the filtered + % rx symbol with M sample precision once we have rx_timing + + rx_baseband_mem_timing(:,1:Nfiltertiming-nin) = rx_baseband_mem_timing(:,nin+1:Nfiltertiming); + rx_baseband_mem_timing(:,Nfiltertiming-nin+1:Nfiltertiming) = rx_baseband; + + % sample right in the middle of the timing estimator window, by filtering + % at rate M + + s = round(rx_timing) + M; + rx_symbols = rx_baseband_mem_timing(:,s+1:s+Nfilter) * gt_alpha5_root'; + +endfunction + + +% Experimental "feed forward" phase estimation function - estimates +% phase over a windows of Nph (e.g. Nph = 9) symbols. May not work +% well on HF channels but lets see. Has a phase ambiguity of m(pi/4) +% where m=0,1,2 which needs to be corrected outside of this function + +function [phase_offsets ferr] = rx_est_phase(rx_symbols) + global rx_symbols_mem; + global prev_phase_offsets; + global phase_amb; + global Nph; + global Nc; + + % keep record of Nph symbols + + rx_symbols_mem(:,1:Nph-1) = rx_symbols_mem(:,2:Nph); + rx_symbols_mem(:,Nph) = rx_symbols; + + % estimate and correct phase offset based of modulation stripped samples + + phase_offsets = zeros(Nc+1,1); + for c=1:Nc+1 + + % rotate QPSK constellation to a single point + mod_stripped = abs(rx_symbols_mem(c,:)) .* exp(j*4*angle(rx_symbols_mem(c,:))); + + % find average phase offset, which will be on -pi/4 .. pi/4 + sum_real = sum(real(mod_stripped)); + sum_imag = sum(imag(mod_stripped)); + phase_offsets(c) = atan2(sum_imag, sum_real)/4; + + % determine if phase has jumped from - -> + + if (prev_phase_offsets(c) < -pi/8) && (phase_offsets(c) > pi/8) + phase_amb(c) -= pi/2; + if (phase_amb(c) < -pi) + phase_amb(c) += 2*pi; + end + end + + % determine if phase has jumped from + -> - + if (prev_phase_offsets(c) > pi/8) && (phase_offsets(c) < -pi/8) + phase_amb(c) += pi/2; + if (phase_amb(c) > pi) + phase_amb(c) -= 2*pi; + end + end + end + + ferr = mean(phase_offsets - prev_phase_offsets); + prev_phase_offsets = phase_offsets; + +endfunction + + +% convert symbols back to an array of bits + +function [rx_bits sync_bit f_err phase_difference] = psk_to_bits(prev_rx_symbols, rx_symbols, modulation) + global Nc; + global Nb; + global m4_binary_to_gray; + global m8_binary_to_gray; + + m = 2 .^ Nb; + assert((m == 4) || (m == 8)); + + phase_difference = zeros(Nc+1,1); + phase_difference(1:Nc) = rx_symbols(1:Nc) .* conj(prev_rx_symbols(1:Nc)./(1E-6+abs(prev_rx_symbols(1:Nc)))); + + for c=1:Nc + + % determine index of constellation point received 0,1,...,m-1 + + index = floor(angle(phase_difference(c))*m/(2*pi) + 0.5); + + if index < 0 + index += m; + end + + % map to decimal version of bits encoded in symbol + + if m == 4 + bits_decimal = m4_binary_to_gray(index+1); + else + bits_decimal = m8_binary_to_gray(index+1); + end + + % convert back to an array of received bits + + for i=1:Nb + if bitand(bits_decimal, 2.^(Nb-i)) + rx_bits((c-1)*Nb+i) = 1; + else + rx_bits((c-1)*Nb+i) = 0; + end + end + + end + + assert(length(rx_bits) == Nc*Nb); + + % Extract DBPSK encoded Sync bit + + phase_difference(Nc+1,1) = rx_symbols(Nc+1) .* conj(prev_rx_symbols(Nc+1)./(1E-6+abs(prev_rx_symbols(Nc+1)))); + if (real(phase_difference(Nc+1)) < 0) + sync_bit = 1; + f_err = imag(phase_difference(Nc+1)); + else + sync_bit = 0; + f_err = -imag(phase_difference(Nc+1)); + end + + % extra pi/4 rotation as we need for snr_update and scatter diagram + + phase_difference *= exp(j*pi/4); + +endfunction + + +% given phase differences update estimates of signal and noise levels + +function [sig_est noise_est] = snr_update(sig_est, noise_est, phase_difference) + global snr_coeff; + global Nc; + + % mag of each symbol is distance from origin, this gives us a + % vector of mags, one for each carrier. + + s = abs(phase_difference); + + % signal mag estimate for each carrier is a smoothed version + % of instantaneous magntitude, this gives us a vector of smoothed + % mag estimates, one for each carrier. + + sig_est = snr_coeff*sig_est + (1 - snr_coeff)*s; + + %printf("s: %f sig_est: %f snr_coeff: %f\n", s(1), sig_est(1), snr_coeff); + + % noise mag estimate is distance of current symbol from average + % location of that symbol. We reflect all symbols into the first + % quadrant for convenience. + + refl_symbols = abs(real(phase_difference)) + j*abs(imag(phase_difference)); + n = abs(exp(j*pi/4)*sig_est - refl_symbols); + + % noise mag estimate for each carrier is a smoothed version of + % instantaneous noise mag, this gives us a vector of smoothed + % noise power estimates, one for each carrier. + + noise_est = snr_coeff*noise_est + (1 - snr_coeff)*n; + +endfunction + + +% calculate current sig estimate for eeach carrier + +function snr_dB = calc_snr(sig_est, noise_est) + global Rs; + + % find total signal power by summing power in all carriers + + S = sum(sig_est .^2); + SdB = 10*log10(S); + + % Average noise mag across all carriers and square to get an average + % noise power. This is an estimate of the noise power in Rs = 50Hz of + % BW (note for raised root cosine filters Rs is the noise BW of the + % filter) + + N50 = mean(noise_est).^2; + N50dB = 10*log10(N50); + + % Now multiply by (3000 Hz)/(50 Hz) to find the total noise power in + % 3000 Hz + + N3000dB = N50dB + 10*log10(3000/Rs); + + snr_dB = SdB - N3000dB; + +endfunction + + +% returns nbits from a repeating sequence of random data + +function bits = get_test_bits(nbits) + global Ntest_bits; % length of test sequence + global current_test_bit; + global test_bits; + + for i=1:nbits + bits(i) = test_bits(current_test_bit++); + %if (mod(i,2) == 0) + % bits(i) = 1; + %else + % bits(i) = 0; + %end + + if (current_test_bit > Ntest_bits) + current_test_bit = 1; + endif + end + +endfunction + + +% Accepts nbits from rx and attempts to sync with test_bits sequence. +% if sync OK measures bit errors + +function [sync bit_errors error_pattern] = put_test_bits(test_bits, rx_bits) + global Ntest_bits; % length of test sequence + global rx_test_bits_mem; + + % Append to our memory + + [m n] = size(rx_bits); + rx_test_bits_mem(1:Ntest_bits-n) = rx_test_bits_mem(n+1:Ntest_bits); + rx_test_bits_mem(Ntest_bits-n+1:Ntest_bits) = rx_bits; + + % see how many bit errors we get when checked against test sequence + + error_pattern = xor(test_bits,rx_test_bits_mem); + bit_errors = sum(error_pattern); + + % if less than a thresh we are aligned and in sync with test sequence + + ber = bit_errors/Ntest_bits; + + sync = 0; + if (ber < 0.2) + sync = 1; + endif +endfunction + + + +% Generate M samples of DBPSK pilot signal for Freq offset estimation + +function [pilot_fdm bit symbol filter_mem phase] = generate_pilot_fdm(bit, symbol, filter_mem, phase, freq) + global M; + global Nfilter; + global gt_alpha5_root; + + % +1 -1 +1 -1 DBPSK sync carrier, once filtered becomes two spectral + % lines at +/- Rs/2 + + if bit + symbol = -symbol; + else + symbol = symbol; + end + if bit + bit = 0; + else + bit = 1; + end + + % filter DPSK symbol to create M baseband samples + + filter_mem(Nfilter) = (sqrt(2)/2)*symbol; + for i=1:M + tx_baseband(i) = M*filter_mem(M:M:Nfilter) * gt_alpha5_root(M-i+1:M:Nfilter)'; + end + filter_mem(1:Nfilter-M) = filter_mem(M+1:Nfilter); + filter_mem(Nfilter-M+1:Nfilter) = zeros(1,M); + + % upconvert + + for i=1:M + phase = phase * freq; + pilot_fdm(i) = sqrt(2)*2*tx_baseband(i)*phase; + end + +endfunction + + +% Generate a 4M sample vector of DBPSK pilot signal. As the pilot signal +% is periodic in 4M samples we can then use this vector as a look up table +% for pilot signal generation in the demod. + +function pilot_lut = generate_pilot_lut() + global Nc; + global Nfilter; + global M; + global freq; + + % pilot states + + pilot_rx_bit = 0; + pilot_symbol = sqrt(2); + pilot_freq = freq(Nc+1); + pilot_phase = 1; + pilot_filter_mem = zeros(1, Nfilter); + %prev_pilot = zeros(M,1); + + pilot_lut = []; + + F=8; + + for f=1:F + [pilot pilot_rx_bit pilot_symbol pilot_filter_mem pilot_phase] = generate_pilot_fdm(pilot_rx_bit, pilot_symbol, pilot_filter_mem, pilot_phase, pilot_freq); + %prev_pilot = pilot; + pilot_lut = [pilot_lut pilot]; + end + + % discard first 4 symbols as filter memory is filling, just keep last + % four symbols + + pilot_lut = pilot_lut(4*M+1:M*F); + +endfunction + + +% grab next pilot samples for freq offset estimation at demod + +function [pilot prev_pilot pilot_lut_index prev_pilot_lut_index] = get_pilot(pilot_lut_index, prev_pilot_lut_index, nin) + global M; + global pilot_lut; + + for i=1:nin + pilot(i) = pilot_lut(pilot_lut_index); + pilot_lut_index++; + if pilot_lut_index > 4*M + pilot_lut_index = 1; + end + prev_pilot(i) = pilot_lut(prev_pilot_lut_index); + prev_pilot_lut_index++; + if prev_pilot_lut_index > 4*M + prev_pilot_lut_index = 1; + end + end +endfunction + + + +% Change the sample rate by a small amount, for example 1000ppm (ratio +% = 1.001). Always returns nout samples in buf_out, but uses a +% variable number of input samples nin to accomodate the change in +% sample rate. nin is nominally set to nout, but may use nout +/- 2 +% samples to accomodate the different sample rates. buf_in should be +% of length nout+6 samples to accomodate this, and buf_in should be +% updated externally based on the nin returned each time. "ratio" is +% Fs_in/Fs_out, for example 48048/48000 = 1.001 (+1000ppm) or +% 47952/48000 = 0.999 (-1000ppm). Uses linear interpolation to +% perform the resampling. This requires a highly over-sampled signal, +% for example 48000Hz sample rate for the modem signal centred on +% 1kHz, otherwise linear interpolation will have a low pass filter effect +% (for example an 8000Hz sample rate for modem signal centred on 1kHz +% would cause problems). + +function [buf_out t nin] = resample(buf_in, t, ratio, nout) + + for i=1:nout + c = floor(t); + a = t - c; + b = 1 - a; + buf_out(i) = buf_in(c)*b + buf_in(c+1)*a; + t += ratio; + end + + t -= nout; + + % adjust nin and t so that on next call we start with 3 < t < 4, + % this gives us +/- 2 samples room to move before we hit start or + % end of buf_in + + delta = floor(t - 3); + nin = nout + delta; + t -= delta; + +endfunction + + +% freq offset state machine. Moves between acquire and track states based +% on BPSK pilot sequence. Freq offset estimator occasionally makes mistakes +% when used continuously. So we use it until we have acquired the BPSK pilot, +% then switch to a more robust tracking algorithm. If we lose sync we switch +% back to acquire mode for fast-requisition. + +function [entered_track track state bad_sync] = freq_state(sync_bit, state, bad_sync) + + entered_track = 0; + + % acquire state, look for 6 symbol 010101 sequence from sync bit + + next_state = state; + if state == 0 + if sync_bit == 0 + next_state = 1; + end + end + if state == 1 + if sync_bit == 1 + next_state = 2; + else + next_state = 0; + end + end + if state == 2 + if sync_bit == 0 + next_state = 3; + else + next_state = 0; + end + end + if state == 3 + if sync_bit == 1 + next_state = 4; + else + next_state = 0; + end + end + if state == 4 + if sync_bit == 0 + next_state = 5; + else + next_state = 0; + end + end + if state == 5 + if sync_bit == 1 + entered_track = 1; + next_state = 6; + bad_sync = 0; + else + next_state = 0; + end + end + + % states 6 and above are track mode, make sure we keep getting 0101 sync bit sequence + + if state == 6 + next_state = 7; + if sync_bit == 0 + bad_sync = 0; + else + bad_sync++; + if bad_sync > 2 + next_state = 0; + end + end + end + + if state == 7 + next_state = 6; + if sync_bit == 1 + bad_sync = 0; + else + bad_sync++; + if bad_sync > 2 + next_state = 0; + end + end + end + + %printf("state: %d next_state: %d sync_bit: %d bad_sync: %d\n", state, next_state, sync_bit, bad_sync); + + state = next_state; + if state >= 6 + track = 1; + else + track = 0; + end +endfunction + + +% Save test bits to a text file in the form of a C array + +function test_bits_file(filename) + global test_bits; + global Ntest_bits; + + f=fopen(filename,"wt"); + fprintf(f,"/* Generated by test_bits_file() Octave function */\n\n"); + fprintf(f,"const int test_bits[]={\n"); + for m=1:Ntest_bits-1 + fprintf(f," %d,\n",test_bits(m)); + endfor + fprintf(f," %d\n};\n",test_bits(Ntest_bits)); + fclose(f); +endfunction + + +% Saves RN filter coeffs to a text file in the form of a C array + +function rn_file(filename) + global gt_alpha5_root; + global Nfilter; + + f=fopen(filename,"wt"); + fprintf(f,"/* Generated by rn_file() Octave function */\n\n"); + fprintf(f,"const float gt_alpha5_root[]={\n"); + for m=1:Nfilter-1 + fprintf(f," %g,\n",gt_alpha5_root(m)); + endfor + fprintf(f," %g\n};\n",gt_alpha5_root(Nfilter)); + fclose(f); +endfunction + +function pilot_coeff_file(filename) + global pilot_coeff; + global Npilotcoeff; + + f=fopen(filename,"wt"); + fprintf(f,"/* Generated by pilot_coeff_file() Octave function */\n\n"); + fprintf(f,"const float pilot_coeff[]={\n"); + for m=1:Npilotcoeff-1 + fprintf(f," %g,\n",pilot_coeff(m)); + endfor + fprintf(f," %g\n};\n",pilot_coeff(Npilotcoeff)); + fclose(f); +endfunction + + +% Saves hanning window coeffs to a text file in the form of a C array + +function hanning_file(filename) + global Npilotlpf; + + h = hanning(Npilotlpf); + + f=fopen(filename,"wt"); + fprintf(f,"/* Generated by hanning_file() Octave function */\n\n"); + fprintf(f,"const float hanning[]={\n"); + for m=1:Npilotlpf-1 + fprintf(f," %g,\n", h(m)); + endfor + fprintf(f," %g\n};\n", h(Npilotlpf)); + fclose(f); +endfunction + + +function png_file(fig, pngfilename) + figure(fig); + + pngname = sprintf("%s.png",pngfilename); + print(pngname, '-dpng', "-S500,500") + pngname = sprintf("%s_large.png",pngfilename); + print(pngname, '-dpng', "-S800,600") +endfunction + + +% dump rx_bits in hex + +function dump_bits(rx_bits) + + % pack into bytes, MSB first + + packed = zeros(1,floor(length(rx_bits)+7)/8); + bit = 7; byte = 1; + for i=1:length(rx_bits) + packed(byte) = bitor(packed(byte), bitshift(rx_bits(i),bit)); + bit--; + if (bit < 0) + bit = 7; + byte++; + end + end + + for i=1:length(packed) + printf("0x%02x ", packed(i)); + end + printf("\n"); + +endfunction + + +% Initialise ---------------------------------------------------- + +global pilot_bit; +pilot_bit = 0; % current value of pilot bit + +global tx_filter_memory; +tx_filter_memory = zeros(Nc+1, Nfilter); +global rx_filter_memory; +rx_filter_memory = zeros(Nc+1, Nfilter); + +% phasors used for up and down converters + +global freq; +freq = zeros(Nc+1,1); +for c=1:Nc/2 + carrier_freq = (-Nc/2 - 1 + c)*Fsep + Fcentre; + freq(c) = exp(j*2*pi*carrier_freq/Fs); +end +for c=Nc/2+1:Nc + carrier_freq = (-Nc/2 + c)*Fsep + Fcentre; + freq(c) = exp(j*2*pi*carrier_freq/Fs); +end + +freq(Nc+1) = exp(j*2*pi*Fcentre/Fs); + +% Spread initial FDM carrier phase out as far as possible. This +% helped PAPR for a few dB. We don't need to adjust rx phase as DQPSK +% takes care of that. + +global phase_tx; +phase_tx = ones(Nc+1,1); +phase_tx = exp(j*2*pi*(0:Nc)/(Nc+1)); +%phase_tx = exp(j*2*pi*(0:Nc)/4); +%phase_tx(Nc+1) = -1; +global phase_rx; +phase_rx = ones(Nc+1,1); + +% Freq offset estimator constants + +global Mpilotfft = 256; +global Npilotcoeff = 30; % number of pilot LPF coeffs +global pilot_coeff = fir1(Npilotcoeff-1, 200/(Fs/2))'; % 200Hz LPF +global Npilotbaseband = Npilotcoeff + M + M/P; % number of pilot baseband samples reqd for pilot LPF +global Npilotlpf = 4*M; % number of samples we DFT pilot over, pilot est window + +% pilot LUT, used for copy of pilot at rx + +global pilot_lut; +pilot_lut = generate_pilot_lut(); +pilot_lut_index = 1; +prev_pilot_lut_index = 3*M+1; + +% Freq offset estimator states + +global pilot_baseband1; +global pilot_baseband2; +pilot_baseband1 = zeros(1, Npilotbaseband); % pilot baseband samples +pilot_baseband2 = zeros(1, Npilotbaseband); % pilot baseband samples +global pilot_lpf1 +global pilot_lpf2 +pilot_lpf1 = zeros(1, Npilotlpf); % LPF pilot samples +pilot_lpf2 = zeros(1, Npilotlpf); % LPF pilot samples + +% Timing estimator states + +global rx_filter_mem_timing; +rx_filter_mem_timing = zeros(Nc+1, Nt*P); +global rx_baseband_mem_timing; +rx_baseband_mem_timing = zeros(Nc+1, Nfiltertiming); + +% Test bit stream constants + +global Ntest_bits; + Ntest_bits = Nc*Nb*4; % length of test sequence +global test_bits; + test_bits = rand(1,Ntest_bits) > 0.5; + +% Test bit stream state variables + +global current_test_bit = 1; +current_test_bit = 1; +global rx_test_bits_mem; +rx_test_bits_mem = zeros(1,Ntest_bits); + +% Experimental phase estimator states ---------------------- + +global rx_symbols_mem; +rx_symbols_mem = zeros(Nc+1, Nph); +global prev_phase_offsets; +prev_phase_offsets = zeros(Nc+1, 1); +global phase_amb; +phase_amb = zeros(Nc+1, 1); diff --git a/codec2/branches/0.3/octave/fdmdv_demod.m b/codec2/branches/0.3/octave/fdmdv_demod.m new file mode 100644 index 00000000..2e403cc6 --- /dev/null +++ b/codec2/branches/0.3/octave/fdmdv_demod.m @@ -0,0 +1,350 @@ +% fdmdv_demod.m +% +% Demodulator function for FDMDV modem (Octave version). Requires +% 8kHz sample rate raw files as input +% +% Copyright David Rowe 2012 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% + +function fdmdv_demod(rawfilename, nbits, NumCarriers, errorpatternfilename, symbolfilename) + + fdmdv; % include modem code + + modulation = 'dqpsk'; + + fin = fopen(rawfilename, "rb"); + gain = 1000; + frames = nbits/(Nc*Nb); + + prev_rx_symbols = ones(Nc+1,1); + foff_phase = 1; + + % BER stats + + total_bit_errors = 0; + total_bits = 0; + bit_errors_log = []; + sync_log = []; + test_frame_sync_log = []; + test_frame_sync_state = 0; + error_pattern_log = []; + + % SNR states + + sig_est = zeros(Nc+1,1); + noise_est = zeros(Nc+1,1); + + % logs of various states for plotting + + rx_symbols_log = []; + rx_timing_log = []; + foff_log = []; + rx_fdm_log = []; + snr_est_log = []; + + % misc states + + nin = M; % timing correction for sample rate differences + foff = 0; + track_log = []; + track = 0; + fest_state = 0; + bad_sync = 0; + sync_track = 0; + entered_track_log = []; + + % spectrum states + + Nspec=1024; + spec_mem=zeros(1,Nspec); + SdB = zeros(1,Nspec); + + % optionally save output symbols + + if nargin == 5 + fm = fopen(symbolfilename,"wb"); + dual_rx_symbols = zeros(1, 2*Nc); + dual_rx_bits = zeros(1,2*Nc*Nb); + end + + % Main loop ---------------------------------------------------- + + for f=1:frames + + % obtain nin samples of the test input signal + + for i=1:nin + rx_fdm(i) = fread(fin, 1, "short")/gain; + end + + rx_fdm_log = [rx_fdm_log rx_fdm(1:nin)]; + + % update spectrum + + l=length(rx_fdm); + spec_mem(1:Nspec-l) = spec_mem(l+1:Nspec); + spec_mem(Nspec-l+1:Nspec) = rx_fdm; + S=fft(spec_mem.*hanning(Nspec)',Nspec); + SdB = 0.9*SdB + 0.1*20*log10(abs(S)); + + % frequency offset estimation and correction + + [pilot prev_pilot pilot_lut_index prev_pilot_lut_index] = get_pilot(pilot_lut_index, prev_pilot_lut_index, nin); + [foff_coarse S1 S2] = rx_est_freq_offset(rx_fdm, pilot, prev_pilot, nin); + + if track == 0 + foff = foff_coarse = 0; + end + foff_log = [ foff_log foff ]; + foff_rect = exp(j*2*pi*foff/Fs); + + for i=1:nin + foff_phase *= foff_rect'; + rx_fdm(i) = rx_fdm(i)*foff_phase; + end + + % baseband processing + + rx_baseband = fdm_downconvert(rx_fdm, nin); + rx_filt = rx_filter(rx_baseband, nin); + + [rx_symbols rx_timing] = rx_est_timing(rx_filt, rx_baseband, nin); + + rx_timing_log = [rx_timing_log rx_timing]; + nin = M; + if rx_timing > 2*M/P + nin += M/P; + end + if rx_timing < 0; + nin -= M/P; + end + + if strcmp(modulation,'dqpsk') + rx_symbols_log = [rx_symbols_log rx_symbols.*conj(prev_rx_symbols./abs(prev_rx_symbols))*exp(j*pi/4)]; + else + rx_symbols_log = [rx_symbols_log rx_symbols]; + endif + [rx_bits sync f_err pd] = psk_to_bits(prev_rx_symbols, rx_symbols, modulation); + + % optionally save output symbols + + if (nargin == 5) + + % this free runs, and is reset by an "entered sync" state + + if (sync_track == 0) + sync_track = 1; + else + sync_track = 0; + end + + if (track == 1) && (sync_track == 1) + dual_rx_symbols(Nc+1:2*Nc) = rx_symbols(1:Nc).*conj(prev_rx_symbols(1:Nc)./abs(prev_rx_symbols(1:Nc))); + dual_rx_symbols_float32 = []; k = 1; + for i=1:2*Nc + dual_rx_symbols_float32(k++) = real(dual_rx_symbols(i)); + dual_rx_symbols_float32(k++) = imag(dual_rx_symbols(i)); + end + fwrite(fm, dual_rx_symbols_float32, "float32"); + dual_rx_bits(Nc*Nb+1:2*Nc*Nb) = rx_bits; + %dump_bits(dual_rx_bits); + else + dual_rx_symbols(1:Nc) = rx_symbols(1:Nc).*conj(prev_rx_symbols(1:Nc)./abs(prev_rx_symbols(1:Nc))); + dual_rx_bits(1:Nc*Nb) = rx_bits; + end + end + + % update some states + + [sig_est noise_est] = snr_update(sig_est, noise_est, pd); + snr_est = calc_snr(sig_est, noise_est); + snr_est_log = [snr_est_log snr_est]; + foff -= 0.5*f_err; + prev_rx_symbols = rx_symbols; + sync_log = [sync_log sync]; + + % freq est state machine + + [entered_track track fest_state bad_sync] = freq_state(sync, fest_state, bad_sync); + track_log = [track_log track]; + if (entered_track == 1) + sync_track = 1; + end + entered_track_log = [entered_track_log entered_track]; + + % count bit errors if we find a test frame + + [test_frame_sync bit_errors error_pattern] = put_test_bits(test_bits, rx_bits); + if (test_frame_sync == 1) + total_bit_errors = total_bit_errors + bit_errors; + total_bits = total_bits + Ntest_bits; + bit_errors_log = [bit_errors_log bit_errors/Ntest_bits]; + else + bit_errors_log = [bit_errors_log 0]; + end + + % test frame sync state machine, just for more informative plots + + next_test_frame_sync_state = test_frame_sync_state; + if (test_frame_sync_state == 0) + if (test_frame_sync == 1) + next_test_frame_sync_state = 1; + test_frame_count = 0; + end + end + + if (test_frame_sync_state == 1) + % we only expect another test_frame_sync pulse every 4 symbols + test_frame_count++; + if (test_frame_count == 4) + test_frame_count = 0; + if ((test_frame_sync == 0)) + next_test_frame_sync_state = 0; + else + error_pattern_log = [error_pattern_log error_pattern]; + end + end + end + test_frame_sync_state = next_test_frame_sync_state; + test_frame_sync_log = [test_frame_sync_log test_frame_sync_state]; + end + + if nargin == 5 + fclose(fm); + etfilename = strcat(strtok(symbolfilename,"."),"_et.bin"); + fet = fopen(etfilename, "wb"); + fwrite(fet, entered_track_log, "short"); + fclose(fet); + end + + % --------------------------------------------------------------------- + % Print Stats + % --------------------------------------------------------------------- + + % Peak to Average Power Ratio calcs from http://www.dsplog.com + + papr = max(rx_fdm_log.*conj(rx_fdm_log)) / mean(rx_fdm_log.*conj(rx_fdm_log)); + papr_dB = 10*log10(papr); + + ber = total_bit_errors / total_bits; + printf("%d bits %d errors BER: %1.4f PAPR(rx): %1.2f dB\n",total_bits, total_bit_errors, ber, papr_dB); + + % --------------------------------------------------------------------- + % Plots + % --------------------------------------------------------------------- + + xt = (1:frames)/Rs; + secs = frames/Rs; + + figure(1) + clf; + [n m] = size(rx_symbols_log); + plot(real(rx_symbols_log(1:Nc+1,15:m)),imag(rx_symbols_log(1:Nc+1,15:m)),'+') + axis([-2 2 -2 2]); + title('Scatter Diagram'); + + figure(2) + clf; + subplot(211) + plot(xt, rx_timing_log) + title('timing offset (samples)'); + subplot(212) + plot(xt, foff_log, '-;freq offset;') + hold on; + plot(xt, track_log*75, 'r;course-fine;'); + hold off; + title('Freq offset (Hz)'); + grid + + figure(3) + clf; + spec(rx_fdm_log,8000); + + figure(4) + clf; + subplot(311) + stem(xt, sync_log) + axis([0 secs 0 1.5]); + title('BPSK Sync') + subplot(312) + stem(xt, bit_errors_log); + title('Bit Errors for test frames') + subplot(313) + plot(xt, test_frame_sync_log); + axis([0 secs 0 1.5]); + title('Test Frame Sync') + + figure(5) + clf; + subplot(211); + plot(xt, snr_est_log); + title('SNR Estimates') + subplot(212) + snrdB_pc = 20*log10(sig_est(1:Nc+1)) - 20*log10(noise_est(1:Nc+1)); + bar(snrdB_pc(1:Nc) - mean(snrdB_pc(1:Nc))) + axis([0 Nc+1 -3 3]); + + figure(6) + clf; + hold on; + lep = length(error_pattern_log); + if lep != 0 + for p=1:Nc + plot(p + 0.25*error_pattern_log((p-1)*2+1:Nc*Nb:lep)); + plot(0.30 + p + 0.25*error_pattern_log(p*2:Nc*Nb:lep),'r') + end + hold off; + axis([1 lep/(Nc*Nb) 0 Nc]) + end + + figure(7) + clf; + subplot(211) + [a b] = size(rx_fdm_log); + xt1 = (1:b)/Fs; + plot(xt1, rx_fdm_log); + title('Rx FDM Signal'); + subplot(212) + plot((0:Nspec/2-1)*Fs/Nspec, SdB(1:Nspec/2) - 20*log10(Nspec/2)) + axis([0 Fs/2 -40 0]) + grid + title('FDM Rx Spectrum'); + +if 0 + % interleaving tests + + load ../unittest/inter560.txt + lep = length(error_pattern_log); + lep = floor(lep/560)*560; + error_pattern_log_inter = zeros(1,lep); + for i=1:560:lep + for j=1:560 + %printf("i: %4d j: %4d inter560(j): %4d\n", i,j,inter560(j)); + index = inter560(j); + error_pattern_log_inter(i-1+index+1) = error_pattern_log(i-1+j); + end + end + + figure(8) + clf; + hold on; + for p=1:Nc + plot(p + 0.25*error_pattern_log_inter((p-1)*2+1:Nc*Nb:lep)); + plot(0.30 + p + 0.25*error_pattern_log_inter(p*2:Nc*Nb:lep),'r') + end + hold off; + axis([1 lep/(Nc*Nb) 0 Nc]) +end + + % optionally save error pattern file + + if nargin == 4 + fout = fopen(errorpatternfilename, "wb"); + fwrite(fout, error_pattern_log, "short"); + fclose(fout); + end + + +endfunction diff --git a/codec2/branches/0.3/octave/fdmdv_demod_c.m b/codec2/branches/0.3/octave/fdmdv_demod_c.m new file mode 100644 index 00000000..c2813e62 --- /dev/null +++ b/codec2/branches/0.3/octave/fdmdv_demod_c.m @@ -0,0 +1,129 @@ +% fdmdv_demod_c.m +% +% Plots Octave dump file information from C FDMDV demodulator program, +% to give a similar set of plots to fdmdv_demod.m. Useful for off +% line analysis of demod performance. +% +% Copyright David Rowe 2012 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% + +function fdmdv_demod_c(dumpfilename, bits) + + fdmdv; % include modem code + + frames = bits/(Nc*Nb); + + load(dumpfilename); + + % BER stats + + total_bit_errors = 0; + total_bits = 0; + bit_errors_log = []; + sync_log = []; + test_frame_sync_log = []; + test_frame_sync_state = 0; + + % Run thru received bits to look for test pattern + + bits_per_frame = Nc*Nb; + + for f=1:frames + + rx_bits = rx_bits_log_c((f-1)*bits_per_frame+1:f*bits_per_frame); + + % count bit errors if we find a test frame + + [test_frame_sync bit_errors] = put_test_bits(test_bits, rx_bits); + if (test_frame_sync == 1) + total_bit_errors = total_bit_errors + bit_errors; + total_bits = total_bits + Ntest_bits; + bit_errors_log = [bit_errors_log bit_errors/Ntest_bits]; + else + bit_errors_log = [bit_errors_log 0]; + end + + % test frame sync state machine, just for more informative plots + + next_test_frame_sync_state = test_frame_sync_state; + if (test_frame_sync_state == 0) + if (test_frame_sync == 1) + next_test_frame_sync_state = 1; + test_frame_count = 0; + end + end + + if (test_frame_sync_state == 1) + % we only expect another test_frame_sync pulse every 4 symbols + test_frame_count++; + if (test_frame_count == 4) + test_frame_count = 0; + if ((test_frame_sync == 0)) + next_test_frame_sync_state = 0; + end + end + end + test_frame_sync_state = next_test_frame_sync_state; + test_frame_sync_log = [test_frame_sync_log test_frame_sync_state]; + end + + % --------------------------------------------------------------------- + % Plots + % --------------------------------------------------------------------- + + xt = (1:frames)/Rs; + secs = frames/Rs; + + figure(1) + clf; + plot(real(rx_symbols_log_c(1:Nc+1,15:frames)),imag(rx_symbols_log_c(1:Nc+1,15:frames)),'+') + %plot(real(rx_symbols_log_c(Nc+1,15:frames)),imag(rx_symbols_log_c(Nc+1,15:frames)),'+') + axis([-2 2 -2 2]); + title('Scatter Diagram'); + + figure(2) + clf; + subplot(211) + plot(xt, rx_timing_log_c(1:frames)) + title('timing offset (samples)'); + subplot(212) + plot(xt, foff_log_c(1:frames), '-;freq offset;') + hold on; + plot(xt, coarse_fine_log_c(1:frames)*75, 'r;course-fine;'); + hold off; + title('Freq offset (Hz)'); + grid + + figure(3) + clf; + subplot(211) + b = M*frames; + xt1 = (1:b)/Fs; + plot(xt1, rx_fdm_log_c(1:b)); + title('Rx FDM Signal'); + subplot(212) + spec(rx_fdm_log_c(1:b),8000); + title('FDM Rx Spectrogram'); + + figure(4) + clf; + subplot(311) + stem(xt, sync_bit_log_c(1:frames)) + axis([0 secs 0 1.5]); + title('BPSK Sync') + subplot(312) + stem(xt, bit_errors_log); + title('Bit Errors for test frames') + subplot(313) + plot(xt, test_frame_sync_log); + axis([0 secs 0 1.5]); + title('Test Frame Sync') + + figure(5) + clf; + plot(xt, snr_est_log_c(1:frames)); + title('SNR Estimates') + +endfunction diff --git a/codec2/branches/0.3/octave/fdmdv_demod_coh.m b/codec2/branches/0.3/octave/fdmdv_demod_coh.m new file mode 100644 index 00000000..94b08802 --- /dev/null +++ b/codec2/branches/0.3/octave/fdmdv_demod_coh.m @@ -0,0 +1,253 @@ +% fdmdv_demod_coh.m +% +% Demodulator function for FDMDV modem (Octave version). Requires +% 8kHz sample rate raw files as input. This version uses experimental +% psuedo coherent demodulation. +% +% Copyright David Rowe 2013 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% + +function fdmdv_demod_coh(rawfilename, nbits, pngname) + + fdmdv; % include modem code + + modulation = 'dqpsk'; + + fin = fopen(rawfilename, "rb"); + gain = 1000; + frames = nbits/(Nc*Nb); + + prev_rx_symbols = ones(Nc+1,1); + foff_phase = 1; + + % BER stats + + total_bit_errors = 0; + total_bits = 0; + bit_errors_log = []; + sync_log = []; + test_frame_sync_log = []; + test_frame_sync_state = 0; + + % SNR states + + sig_est = zeros(Nc+1,1); + noise_est = zeros(Nc+1,1); + + % logs of various states for plotting + + rx_symbols_log = []; + rx_timing_log = []; + foff_log = []; + rx_fdm_log = []; + snr_est_log = []; + + % misc states + + nin = M; % timing correction for sample rate differences + foff = 0; + track_log = []; + track = 0; + fest_state = 0; + + % psuedo coherent demod states + + rx_symbols_ph_log = []; + prev_rx_symbols_ph = ones(Nc+1,1); + rx_phase_offsets_log = []; + phase_amb_log = []; + + % Main loop ---------------------------------------------------- + + for f=1:frames + + % obtain nin samples of the test input signal + + for i=1:nin + rx_fdm(i) = fread(fin, 1, "short")/gain; + end + + rx_fdm_log = [rx_fdm_log rx_fdm(1:nin)]; + + % frequency offset estimation and correction + + [pilot prev_pilot pilot_lut_index prev_pilot_lut_index] = get_pilot(pilot_lut_index, prev_pilot_lut_index, nin); + [foff_coarse S1 S2] = rx_est_freq_offset(rx_fdm, pilot, prev_pilot, nin); + + if track == 0 + foff = foff_coarse; + end + foff_log = [ foff_log foff ]; + foff_rect = exp(j*2*pi*foff/Fs); + + for i=1:nin + foff_phase *= foff_rect'; + rx_fdm(i) = rx_fdm(i)*foff_phase; + end + + % baseband processing + + rx_baseband = fdm_downconvert(rx_fdm, nin); + rx_filt = rx_filter(rx_baseband, nin); + + [rx_symbols rx_timing] = rx_est_timing(rx_filt, rx_baseband, nin); + rx_timing_log = [rx_timing_log rx_timing]; + + nin = M; + if rx_timing > 2*M/P + nin += M/P; + end + if rx_timing < 0; + nin -= M/P; + end + + rx_symbols_log = [rx_symbols_log rx_symbols.*(conj(prev_rx_symbols)./abs(prev_rx_symbols))*exp(j*pi/4)]; + + % coherent phase offset estimation ------------------------------------ + + [rx_phase_offsets ferr] = rx_est_phase(rx_symbols); + rx_phase_offsets_log = [rx_phase_offsets_log rx_phase_offsets]; + phase_amb_log = [phase_amb_log phase_amb]; + rx_symbols_ph = rx_symbols_mem(:,floor(Nph/2)+1) .* exp(-j*(rx_phase_offsets + phase_amb)); + rx_symbols_ph_log = [rx_symbols_ph_log rx_symbols_ph .* exp(j*pi/4)]; + rx_symbols_ph = -1 + 2*(real(rx_symbols_ph .* exp(j*pi/4)) > 0) + j*(-1 + 2*(imag(rx_symbols_ph .* exp(j*pi/4)) > 0)); + + % Std differential (used for freq offset est and BPSK sync) and psuedo coherent detection ----------------------- + + [rx_bits_unused sync f_err pd ] = qpsk_to_bits(prev_rx_symbols, rx_symbols, modulation); + [rx_bits sync_unused ferr_unused pd_unused] = qpsk_to_bits(prev_rx_symbols_ph, rx_symbols_ph, 'dqpsk'); + + foff -= 0.5*f_err; + prev_rx_symbols = rx_symbols; + prev_rx_symbols_ph = rx_symbols_ph; + sync_log = [sync_log sync]; + + [sig_est noise_est] = snr_update(sig_est, noise_est, pd); + snr_est = calc_snr(sig_est, noise_est); + snr_est_log = [snr_est_log snr_est]; + + % freq est state machine + + [track fest_state] = freq_state(sync, fest_state); + track_log = [track_log track]; + + % count bit errors if we find a test frame + + [test_frame_sync bit_errors] = put_test_bits(test_bits, rx_bits); + if (test_frame_sync == 1) + total_bit_errors = total_bit_errors + bit_errors; + total_bits = total_bits + Ntest_bits; + bit_errors_log = [bit_errors_log bit_errors/Ntest_bits]; + else + bit_errors_log = [bit_errors_log 0]; + end + + % test frame sync state machine, just for more informative plots + + next_test_frame_sync_state = test_frame_sync_state; + if (test_frame_sync_state == 0) + if (test_frame_sync == 1) + next_test_frame_sync_state = 1; + test_frame_count = 0; + end + end + + if (test_frame_sync_state == 1) + % we only expect another test_frame_sync pulse every 4 symbols + test_frame_count++; + if (test_frame_count == 4) + test_frame_count = 0; + if ((test_frame_sync == 0)) + next_test_frame_sync_state = 0; + end + end + end + test_frame_sync_state = next_test_frame_sync_state; + test_frame_sync_log = [test_frame_sync_log test_frame_sync_state]; + + end + + % --------------------------------------------------------------------- + % Print Stats + % --------------------------------------------------------------------- + + ber = total_bit_errors / total_bits; + + printf("%d bits %d errors BER: %1.4f\n",total_bits, total_bit_errors, ber); + + % --------------------------------------------------------------------- + % Plots + % --------------------------------------------------------------------- + + xt = (1:frames)/Rs; + secs = frames/Rs; + + figure(1) + clf; + [n m] = size(rx_symbols_log); + plot(real(rx_symbols_log(1:Nc+1,15:m)),imag(rx_symbols_log(1:Nc+1,15:m)),'+') + axis([-2 2 -2 2]); + title('Scatter Diagram'); + + figure(2) + clf; + subplot(211) + plot(xt, rx_timing_log) + title('timing offset (samples)'); + subplot(212) + plot(xt, foff_log, '-;freq offset;') + hold on; + plot(xt, track_log*75, 'r;course-fine;'); + hold off; + title('Freq offset (Hz)'); + grid + + figure(3) + clf; + subplot(211) + [a b] = size(rx_fdm_log); + xt1 = (1:b)/Fs; + plot(xt1, rx_fdm_log); + title('Rx FDM Signal'); + subplot(212) + spec(rx_fdm_log,8000); + title('FDM Rx Spectrogram'); + + figure(4) + clf; + subplot(311) + stem(xt, sync_log) + axis([0 secs 0 1.5]); + title('BPSK Sync') + subplot(312) + stem(xt, bit_errors_log); + title('Bit Errors for test frames') + subplot(313) + plot(xt, test_frame_sync_log); + axis([0 secs 0 1.5]); + title('Test Frame Sync') + + figure(5) + clf; + plot(xt, snr_est_log); + title('SNR Estimates') + + figure(6) + clf; + [n m] = size(rx_symbols_ph_log); + plot(real(rx_symbols_ph_log(1:Nc+1,15:m)),imag(rx_symbols_ph_log(1:Nc+1,15:m)),'+') + %plot(real(rx_symbols_ph_log(2,15:m)),imag(rx_symbols_ph_log(2,15:m)),'+') + axis([-2 2 -2 2]); + title('Scatter Diagram - after phase correction'); + + figure(7) + clf; + subplot(211) + plot(rx_phase_offsets_log(1,:)) + subplot(212) + plot(phase_amb_log(1,:)) + title('Rx Phase Offset Est') + +endfunction diff --git a/codec2/branches/0.3/octave/fdmdv_mod.m b/codec2/branches/0.3/octave/fdmdv_mod.m new file mode 100644 index 00000000..eed85a2b --- /dev/null +++ b/codec2/branches/0.3/octave/fdmdv_mod.m @@ -0,0 +1,32 @@ +% fdmdv_mod.m +% +% Modulator function for FDMDV modem, uses test frames as input and +% outputs a raw file of 16 bit shorts at a sample rate of 8 kHz. +% +% Copyright David Rowe 2012 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% + +function tx_fdm = fdmdv_mod(rawfilename, nbits) + + fdmdv; % include modem code + + frames = floor(nbits/(Nc*Nb)) + tx_fdm = []; + gain = 1000; % Scale up to 16 bit shorts + prev_tx_symbols = ones(Nc+1,1); + + for i=1:frames + tx_bits = get_test_bits(Nc*Nb); + tx_symbols = bits_to_qpsk(prev_tx_symbols, tx_bits,'dqpsk'); + prev_tx_symbols = tx_symbols; + tx_baseband = tx_filter(tx_symbols); + tx_fdm = [tx_fdm real(fdm_upconvert(tx_baseband))]; + end + + tx_fdm *= gain; + fout = fopen(rawfilename,"wb"); + fwrite(fout, tx_fdm, "short"); + fclose(fout); +endfunction diff --git a/codec2/branches/0.3/octave/fdmdv_sweep.m b/codec2/branches/0.3/octave/fdmdv_sweep.m new file mode 100644 index 00000000..fd617431 --- /dev/null +++ b/codec2/branches/0.3/octave/fdmdv_sweep.m @@ -0,0 +1,30 @@ +% fdmdv_sweep.m +% David Rowe Feb 2013 +% Produces a raw file that sweeps between 1000 and 2000 Hz to test freq +% response of transmitters. + +secs=10; +fmin=1000; +fmax=2000; +Fs=8000; +rms = 4200; % roughly RMS value of fdmdv signal +amp = sqrt(2)*rms; +nsamples=Fs*secs; +theta = 0; +s=zeros(1,nsamples); + +for i=1:nsamples + f(i) = fmin + i*(fmax-fmin)/nsamples; + w = 2*pi*f(i)/Fs; + theta += w; + theta -= 2*pi*floor(theta/(2*pi)); + s(i) = amp*cos(theta); +end + +figure(1) +clf +plot(s(1:100)); +fout = fopen("1k_2k_sweep.raw", "wb"); +fwrite(fout, s, "short"); +fclose(fout); + diff --git a/codec2/branches/0.3/octave/fdmdv_ut.m b/codec2/branches/0.3/octave/fdmdv_ut.m new file mode 100644 index 00000000..6021c77c --- /dev/null +++ b/codec2/branches/0.3/octave/fdmdv_ut.m @@ -0,0 +1,346 @@ +% fdmdv_ut.m +% +% Unit Test program for FDMDV modem. Useful for general development as it has +% both tx and rx sides, and basic AWGN channel simulation. +% +% Copyright David Rowe 2012 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% + +fdmdv; % load modem code + +% Simulation Parameters -------------------------------------- + +frames = 100; +EbNo_dB = 7.3; +Foff_hz = 0; +modulation = 'dqpsk'; +hpa_clip = 150; + +% ------------------------------------------------------------ + +tx_filt = zeros(Nc,M); +rx_symbols_log = []; +rx_phase_log = 0; +rx_timing_log = 0; +tx_pwr = 0; +noise_pwr = 0; +rx_fdm_log = []; +rx_baseband_log = []; +rx_bits_offset = zeros(Nc*Nb*2); +prev_tx_symbols = ones(Nc+1,1); +prev_rx_symbols = ones(Nc+1,1); +ferr = 0; +foff = 0; +foff_log = []; +tx_baseband_log = []; +tx_fdm_log = []; + +% BER stats + +total_bit_errors = 0; +total_bits = 0; +bit_errors_log = []; +sync_log = []; +test_frame_sync_log = []; +test_frame_sync_state = 0; + +% SNR estimation states + +sig_est = zeros(Nc+1,1); +noise_est = zeros(Nc+1,1); + +% fixed delay simuation + +Ndelay = M+20; +rx_fdm_delay = zeros(Ndelay,1); + +% --------------------------------------------------------------------- +% Eb/No calculations. We need to work out Eb/No for each FDM carrier. +% Total power is sum of power in all FDM carriers +% --------------------------------------------------------------------- + +C = 1; % power of each FDM carrier (energy/sample). Total Carrier power should = Nc*C = Nc +N = 1; % total noise power (energy/sample) of noise source across entire bandwidth + +% Eb = Carrier power * symbol time / (bits/symbol) +% = C *(1/Rs) / Nb +Eb_dB = 10*log10(C) - 10*log10(Rs) - 10*log10(Nb); + +No_dBHz = Eb_dB - EbNo_dB; + +% Noise power = Noise spectral density * bandwidth +% Noise power = Noise spectral density * Fs/2 for real signals +N_dB = No_dBHz + 10*log10(Fs/2); +Ngain_dB = N_dB - 10*log10(N); +Ngain = 10^(Ngain_dB/20); + +% C/No = Carrier Power/noise spectral density +% = power per carrier*number of carriers / noise spectral density +CNo_dB = 10*log10(C) + 10*log10(Nc) - No_dBHz; + +% SNR in equivalent 3000 Hz SSB channel + +B = 3000; +SNR = CNo_dB - 10*log10(B); + +% freq offset simulation states + +phase_offset = 1; +freq_offset = exp(j*2*pi*Foff_hz/Fs); +foff_phase = 1; +t = 0; +foff = 0; +fest_state = 0; +bad_sync = 0; +track = 0; +track_log = []; + +snr_log = []; + +Nspec=1024; +spec_mem=zeros(1,Nspec); +SdB = zeros(1,Nspec); + +% --------------------------------------------------------------------- +% Main loop +% --------------------------------------------------------------------- + +for f=1:frames + + % ------------------- + % Modulator + % ------------------- + + tx_bits = get_test_bits(Nc*Nb); + tx_symbols = bits_to_psk(prev_tx_symbols, tx_bits, modulation); + prev_tx_symbols = tx_symbols; + tx_baseband = tx_filter(tx_symbols); + tx_baseband_log = [tx_baseband_log tx_baseband]; + tx_fdm = fdm_upconvert(tx_baseband); + tx_pwr = 0.9*tx_pwr + 0.1*real(tx_fdm)*real(tx_fdm)'/(M); + + % ------------------- + % Channel simulation + % ------------------- + + % frequency offset + + %Foff_hz += 1/Rs; + Foff = Foff_hz; + for i=1:M + % Time varying freq offset + %Foff = Foff_hz + 100*sin(t*2*pi/(300*Fs)); + %t++; + freq_offset = exp(j*2*pi*Foff/Fs); + phase_offset *= freq_offset; + tx_fdm(i) = phase_offset*tx_fdm(i); + end + + tx_fdm = real(tx_fdm); + + % HPA non-linearity + + tx_fdm(find(abs(tx_fdm) > hpa_clip)) = hpa_clip; + tx_fdm_log = [tx_fdm_log tx_fdm]; + + rx_fdm = tx_fdm; + + % AWGN noise + + noise = Ngain*randn(1,M); + noise_pwr = 0.9*noise_pwr + 0.1*noise*noise'/M; + rx_fdm += noise; + rx_fdm_log = [rx_fdm_log rx_fdm]; + + % update spectrum + + l=length(rx_fdm); + spec_mem(1:Nspec-l) = spec_mem(l+1:Nspec); + spec_mem(Nspec-l+1:Nspec) = rx_fdm; + S=fft(spec_mem.*hanning(Nspec)',Nspec); + SdB = 0.9*SdB + 0.1*20*log10(abs(S)); + + % Delay + + rx_fdm_delay(1:Ndelay-M) = rx_fdm_delay(M+1:Ndelay); + rx_fdm_delay(Ndelay-M+1:Ndelay) = rx_fdm; + %rx_fdm_delay = rx_fdm; + + % ------------------- + % Demodulator + % ------------------- + + % frequency offset estimation and correction, need to call rx_est_freq_offset even in track + % mode to keep states updated + + [pilot prev_pilot pilot_lut_index prev_pilot_lut_index] = get_pilot(pilot_lut_index, prev_pilot_lut_index, M); + [foff_course S1 S2] = rx_est_freq_offset(rx_fdm_delay, pilot, prev_pilot, M); + if track == 0 + foff = foff_course; + end + foff_log = [ foff_log foff ]; + foff_rect = exp(j*2*pi*foff/Fs); + + for i=1:M + foff_phase *= foff_rect'; + rx_fdm_delay(i) = rx_fdm_delay(i)*foff_phase; + end + + % baseband processing + + rx_baseband = fdm_downconvert(rx_fdm_delay(1:M), M); + rx_baseband_log = [rx_baseband_log rx_baseband]; + rx_filt = rx_filter(rx_baseband, M); + + [rx_symbols rx_timing] = rx_est_timing(rx_filt, rx_baseband, M); + rx_timing_log = [rx_timing_log rx_timing]; + + %rx_phase = rx_est_phase(rx_symbols); + %rx_phase_log = [rx_phase_log rx_phase]; + %rx_symbols = rx_symbols*exp(j*rx_phase); + + [rx_bits sync foff_fine pd] = psk_to_bits(prev_rx_symbols, rx_symbols, modulation); + if strcmp(modulation,'dqpsk') + rx_symbols_log = [rx_symbols_log pd]; + else + rx_symbols_log = [rx_symbols_log rx_symbols]; + endif + foff -= 0.5*ferr; + prev_rx_symbols = rx_symbols; + sync_log = [sync_log sync]; + + % freq est state machine + + [track fest_state bad_sync] = freq_state(sync, fest_state, bad_sync); + track_log = [track_log track]; + + % Update SNR est + + [sig_est noise_est] = snr_update(sig_est, noise_est, pd); + snr_log = [snr_log calc_snr(sig_est, noise_est)]; + + % count bit errors if we find a test frame + % Allow 15 frames for filter memories to fill and time est to settle + + [test_frame_sync bit_errors] = put_test_bits(test_bits, rx_bits); + + if test_frame_sync == 1 + total_bit_errors = total_bit_errors + bit_errors; + total_bits = total_bits + Ntest_bits; + bit_errors_log = [bit_errors_log bit_errors]; + else + bit_errors_log = [bit_errors_log 0]; + end + + % test frame sync state machine, just for more informative plots + + next_test_frame_sync_state = test_frame_sync_state; + if (test_frame_sync_state == 0) + if (test_frame_sync == 1) + next_test_frame_sync_state = 1; + test_frame_count = 0; + end + end + + if (test_frame_sync_state == 1) + % we only expect another test_frame_sync pulse every 4 symbols + test_frame_count++; + if (test_frame_count == 4) + test_frame_count = 0; + if ((test_frame_sync == 0)) + next_test_frame_sync_state = 0; + end + end + end + test_frame_sync_state = next_test_frame_sync_state; + test_frame_sync_log = [test_frame_sync_log test_frame_sync_state]; +end + +% --------------------------------------------------------------------- +% Print Stats +% --------------------------------------------------------------------- + +ber = total_bit_errors / total_bits; + +% Peak to Average Power Ratio calcs from http://www.dsplog.com + +papr = max(tx_fdm_log.*conj(tx_fdm_log)) / mean(tx_fdm_log.*conj(tx_fdm_log)); +papr_dB = 10*log10(papr); + +% Note Eb/No set point is for Nc data carriers only, excluding pilot. +% This is convenient for testing BER versus Eb/No. Measured SNR & +% Eb/No includes power of pilot. Similar for SNR, first number is SNR +% excluding pilot pwr for Eb/No set point, 2nd value is measured SNR +% which will be a little higher as pilot power is included. Note current SNR +% est algorithm only works for QPSK, gives silly values for 8PSK. + +printf("Bits/symbol.: %d\n", Nb); +printf("Num carriers: %d\n", Nc); +printf("Bit Rate....: %d bits/s\n", Rb); +printf("Eb/No (meas): %2.2f (%2.2f) dB\n", EbNo_dB, 10*log10(0.25*tx_pwr*Fs/(Rs*Nc*noise_pwr))); +printf("bits........: %d\n", total_bits); +printf("errors......: %d\n", total_bit_errors); +printf("BER.........: %1.4f\n", ber); +printf("PAPR........: %1.2f dB\n", papr_dB); +printf("SNR...(meas): %2.2f (%2.2f) dB\n", SNR, calc_snr(sig_est, noise_est)); + +% --------------------------------------------------------------------- +% Plots +% --------------------------------------------------------------------- + +figure(1) +clf; +[n m] = size(rx_symbols_log); +plot(real(rx_symbols_log(1:Nc+1,15:m)),imag(rx_symbols_log(1:Nc+1,15:m)),'+') +axis([-3 3 -3 3]); +title('Scatter Diagram'); + +figure(2) +clf; +subplot(211) +plot(rx_timing_log) +title('timing offset (samples)'); +subplot(212) +plot(foff_log, '-;freq offset;') +hold on; +plot(track_log*75, 'r;course-fine;'); +hold off; +title('Freq offset (Hz)'); + +figure(3) +clf; +subplot(211) +plot(real(tx_fdm_log)); +title('FDM Tx Signal'); +subplot(212) +plot((0:Nspec/2-1)*Fs/Nspec, SdB(1:Nspec/2) - 20*log10(Nspec/2)) +axis([0 Fs/2 -40 0]) +grid +title('FDM Rx Spectrum'); + +figure(4) +clf; +subplot(311) +stem(sync_log) +axis([0 frames 0 1.5]); +title('BPSK Sync') +subplot(312) +stem(bit_errors_log); +title('Bit Errors for test frames') +subplot(313) +plot(test_frame_sync_log); +axis([0 frames 0 1.5]); +title('Test Frame Sync') + +figure(5) +clf +subplot(211) +plot(snr_log) +subplot(212) +%plot(20*log10(sig_est(1:Nc))-20*log10(sig_est(Nc+1))+6) +%axis([1 Nc -6 6]); +sdB_pc = 20*log10(sig_est(1:Nc+1)); +bar(sdB_pc(1:Nc) - mean(sdB_pc(1:Nc))) +axis([0 Nc+1 -3 3]); diff --git a/codec2/branches/0.3/octave/fdmdv_ut_coh.m b/codec2/branches/0.3/octave/fdmdv_ut_coh.m new file mode 100644 index 00000000..a1598878 --- /dev/null +++ b/codec2/branches/0.3/octave/fdmdv_ut_coh.m @@ -0,0 +1,341 @@ +% fdmdv_ut_coh.m +% + +% Unit Test program for coherent version of FDMDV modem. Used to +% build up the ability to test coherent demodulation of FDMDV +% signals sampled off air. These signals are differentially encoded +% but we can treat the symbols after the diff encoder as PSK symbols. +% +% We keep most of the existing DPSK modem to handle acquisition, frame sync, +% and just the the PSK demo in parallel. The goal here is to measure the BER +% of the test data using coherent PSK, it's not actually a practical modem. + +% Copyright David Rowe 2012 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% + +fdmdv; % load modem code + +% Simulation Parameters -------------------------------------- + +frames = 200; +EbNo_dB = 7; +Foff_hz = -100; +hpa_clip = 150; + +% ------------------------------------------------------------ + +tx_filt = zeros(Nc,M); +rx_symbols_log = []; +rx_phase_log = 0; +rx_timing_log = 0; +tx_pwr = 0; +noise_pwr = 0; +rx_fdm_log = []; +rx_baseband_log = []; +rx_bits_offset = zeros(Nc*Nb*2); +prev_tx_symbols = ones(Nc+1,1); +prev_rx_symbols = ones(Nc+1,1); +ferr = 0; +foff = 0; +foff_log = []; +tx_baseband_log = []; +tx_fdm_log = []; + +% BER stats + +total_bit_errors = 0; +total_bits = 0; +bit_errors_log = []; +sync_log = []; +test_frame_sync_log = []; +test_frame_sync_state = 0; + +% SNR estimation states + +sig_est = zeros(Nc+1,1); +noise_est = zeros(Nc+1,1); + +% fixed delay simuation + +Ndelay = M+20; +rx_fdm_delay = zeros(Ndelay,1); + +% --------------------------------------------------------------------- +% Eb/No calculations. We need to work out Eb/No for each FDM carrier. +% Total power is sum of power in all FDM carriers +% --------------------------------------------------------------------- + +C = 1; % power of each FDM carrier (energy/sample). Total Carrier power should = Nc*C = Nc +N = 1; % total noise power (energy/sample) of noise source across entire bandwidth + +% Eb = Carrier power * symbol time / (bits/symbol) +% = C *(1/Rs) / 2 +Eb_dB = 10*log10(C) - 10*log10(Rs) - 10*log10(2); + +No_dBHz = Eb_dB - EbNo_dB; + +% Noise power = Noise spectral density * bandwidth +% Noise power = Noise spectral density * Fs/2 for real signals +N_dB = No_dBHz + 10*log10(Fs/2); +Ngain_dB = N_dB - 10*log10(N); +Ngain = 10^(Ngain_dB/20); + +% C/No = Carrier Power/noise spectral density +% = power per carrier*number of carriers / noise spectral density +CNo_dB = 10*log10(C) + 10*log10(Nc) - No_dBHz; + +% SNR in equivalent 3000 Hz SSB channel + +B = 3000; +SNR = CNo_dB - 10*log10(B); + +% freq offset simulation states + +phase_offset = exp(j*0); +freq_offset = exp(j*2*pi*Foff_hz/Fs); +foff_phase = 1; +t = 0; +foff = 0; +fest_state = 0; +track = 0; +track_log = []; + +snr_log = []; + +rx_symbols_ph_log = []; +prev_rx_symbols_ph = ones(Nc+1,1); +rx_phase_offsets_log = []; +phase_amb_log = []; + +% --------------------------------------------------------------------- +% Main loop +% --------------------------------------------------------------------- + +for f=1:frames + + % ------------------- + % Modulator + % ------------------- + + tx_bits = get_test_bits(Nc*Nb); + tx_symbols = bits_to_qpsk(prev_tx_symbols, tx_bits, 'dqpsk'); + prev_tx_symbols = tx_symbols; + tx_baseband = tx_filter(tx_symbols); + tx_baseband_log = [tx_baseband_log tx_baseband]; + tx_fdm = fdm_upconvert(tx_baseband); + tx_pwr = 0.9*tx_pwr + 0.1*real(tx_fdm)*real(tx_fdm)'/(M); + + % ------------------- + % Channel simulation + % ------------------- + + % frequency offset + + %Foff_hz += 1/Rs; + Foff = Foff_hz; + for i=1:M + % Time varying freq offset + %Foff = Foff_hz + 100*sin(t*2*pi/(300*Fs)); + %t++; + freq_offset = exp(j*2*pi*Foff/Fs); + phase_offset *= freq_offset; + tx_fdm(i) = phase_offset*tx_fdm(i); + end + + tx_fdm = real(tx_fdm); + + % HPA non-linearity + + tx_fdm(find(abs(tx_fdm) > hpa_clip)) = hpa_clip; + tx_fdm_log = [tx_fdm_log tx_fdm]; + + rx_fdm = tx_fdm; + + % AWGN noise + + noise = Ngain*randn(1,M); + noise_pwr = 0.9*noise_pwr + 0.1*noise*noise'/M; + rx_fdm += noise; + rx_fdm_log = [rx_fdm_log rx_fdm]; + + % Delay + + %rx_fdm_delay(1:Ndelay-M) = rx_fdm_delay(M+1:Ndelay); + %rx_fdm_delay(Ndelay-M+1:Ndelay) = rx_fdm; + rx_fdm_delay = rx_fdm; + + % ------------------- + % Demodulator + % ------------------- + + % frequency offset estimation and correction, need to call + % rx_est_freq_offset even in track mode to keep states updated + + [pilot prev_pilot pilot_lut_index prev_pilot_lut_index] = get_pilot(pilot_lut_index, prev_pilot_lut_index, M); + [foff_course S1 S2] = rx_est_freq_offset(rx_fdm_delay, pilot, prev_pilot, M); + if track == 0 + foff = foff_course; + end + + %foff = 0; % disable for now + + foff_log = [ foff_log foff ]; + foff_rect = exp(j*2*pi*foff/Fs); + + for i=1:M + foff_phase *= foff_rect'; + rx_fdm_delay(i) = rx_fdm_delay(i)*foff_phase; + end + + % baseband processing + + rx_baseband = fdm_downconvert(rx_fdm_delay(1:M), M); + rx_baseband_log = [rx_baseband_log rx_baseband]; + rx_filt = rx_filter(rx_baseband, M); + + [rx_symbols rx_timing] = rx_est_timing(rx_filt, rx_baseband, M); + rx_symbols_log = [rx_symbols_log rx_symbols.*(conj(prev_rx_symbols)./abs(prev_rx_symbols))*exp(j*pi/4)]; + rx_timing_log = [rx_timing_log rx_timing]; + + % coherent phase offset estimation ------------------------------------ + + [rx_phase_offsets ferr] = rx_est_phase(rx_symbols); + rx_phase_offsets_log = [rx_phase_offsets_log rx_phase_offsets]; + phase_amb_log = [phase_amb_log phase_amb]; + rx_symbols_ph = rx_symbols_mem(:,floor(Nph/2)+1) .* exp(-j*(rx_phase_offsets + phase_amb)); + rx_symbols_ph_log = [rx_symbols_ph_log rx_symbols_ph .* exp(j*pi/4)]; + rx_symbols_ph = -1 + 2*(real(rx_symbols_ph .* exp(j*pi/4)) > 0) + j*(-1 + 2*(imag(rx_symbols_ph .* exp(j*pi/4)) > 0)); + + % Std differential (used for freq offset est and BPSK sync) and psuedo coherent detection ----------------------- + + [rx_bits_unused sync ferr pd] = qpsk_to_bits(prev_rx_symbols, rx_symbols, 'dqpsk'); + [rx_bits sync_unused ferr_unused pd] = qpsk_to_bits(prev_rx_symbols_ph, rx_symbols_ph, 'dqpsk'); + + %---------------------------------------------------------------------- + + foff -= 0.5*ferr; + prev_rx_symbols = rx_symbols; + prev_rx_symbols_ph = rx_symbols_ph; + sync_log = [sync_log sync]; + + % freq est state machine + + [track fest_state] = freq_state(sync, fest_state); + track_log = [track_log track]; + + % Update SNR est + + [sig_est noise_est] = snr_update(sig_est, noise_est, pd); + snr_log = [snr_log calc_snr(sig_est, noise_est)]; + + % count bit errors if we find a test frame + + [test_frame_sync bit_errors] = put_test_bits(test_bits, rx_bits); + + if (test_frame_sync == 1) && (f > 15) + total_bit_errors = total_bit_errors + bit_errors; + total_bits = total_bits + Ntest_bits; + bit_errors_log = [bit_errors_log bit_errors]; + else + bit_errors_log = [bit_errors_log 0]; + end + + % test frame sync state machine, just for more informative plots + + next_test_frame_sync_state = test_frame_sync_state; + if (test_frame_sync_state == 0) + if (test_frame_sync == 1) + next_test_frame_sync_state = 1; + test_frame_count = 0; + end + end + + if (test_frame_sync_state == 1) + % we only expect another test_frame_sync pulse every 4 symbols + test_frame_count++; + if (test_frame_count == 4) + test_frame_count = 0; + if ((test_frame_sync == 0)) + next_test_frame_sync_state = 0; + end + end + end + test_frame_sync_state = next_test_frame_sync_state; + test_frame_sync_log = [test_frame_sync_log test_frame_sync_state]; +end + +% --------------------------------------------------------------------- +% Print Stats +% --------------------------------------------------------------------- + +ber = total_bit_errors / total_bits; + +% Note Eb/No set point is for Nc data carriers only, excluding pilot. +% This is convenient for testing BER versus Eb/No. Measured Eb/No +% includes power of pilot. Similar for SNR, first number is SNR excluding +% pilot pwr for Eb/No set point, 2nd value is measured SNR which will be a little +% higher as pilot power is included. + +printf("\n"); +printf("Eb/No (meas): %2.2f (%2.2f) dB\n", EbNo_dB, 10*log10(0.25*tx_pwr*Fs/(Rs*Nc*noise_pwr))); +printf("SNR...(meas): %2.2f (%2.2f) dB\n", SNR, calc_snr(sig_est, noise_est)); +printf("\nDPSK\n"); +printf(" bits......: %d\n", total_bits); +printf(" errors....: %d\n", total_bit_errors); +printf(" BER.......: %1.4f\n", ber); + +% --------------------------------------------------------------------- +% Plots +% --------------------------------------------------------------------- + +figure(1) +clf; +[n m] = size(rx_symbols_log); +plot(real(rx_symbols_log(1:Nc+1,15:m)),imag(rx_symbols_log(1:Nc+1,15:m)),'+') +%plot(real(rx_symbols_log(2,15:m)),imag(rx_symbols_log(2,15:m)),'+') +axis([-3 3 -3 3]); +title('Scatter Diagram'); + +figure(2) +clf; +subplot(211) +plot(rx_timing_log) +title('timing offset (samples)'); +subplot(212) +plot(foff_log, '-;freq offset;') +hold on; +plot(track_log*75, 'r;course-fine;'); +hold off; +title('Freq offset (Hz)'); + +figure(3) +clf; +subplot(311) +stem(sync_log) +axis([0 frames 0 1.5]); +title('BPSK Sync') +subplot(312) +stem(bit_errors_log); +title('Bit Errors for test frames') +subplot(313) +plot(test_frame_sync_log); +axis([0 frames 0 1.5]); +title('Test Frame Sync') + +figure(4) +clf; +[n m] = size(rx_symbols_ph_log); +plot(real(rx_symbols_ph_log(1:Nc+1,15:m)),imag(rx_symbols_ph_log(1:Nc+1,15:m)),'+') +%plot(real(rx_symbols_ph_log(2,15:m)),imag(rx_symbols_ph_log(2,15:m)),'+') +axis([-3 3 -3 3]); +title('Scatter Diagram - after phase correction'); + +figure(5) +clf; +subplot(211) +plot(rx_phase_offsets_log(1,:)) +subplot(212) +plot(phase_amb_log(1,:)) +title('Rx Phase Offset Est') diff --git a/codec2/branches/0.3/octave/fuzzy_gray.m b/codec2/branches/0.3/octave/fuzzy_gray.m new file mode 100644 index 00000000..425f8d7c --- /dev/null +++ b/codec2/branches/0.3/octave/fuzzy_gray.m @@ -0,0 +1,586 @@ +% fuzzy_gray.m +% David Rowe +% 10 April 2014 +% +% Various experiments in fuzzy gray codes and quantising and +% transmitting scalars. + +1; + +% fuzzy gray coding idea: use an extra parity bit, if we get a single +% bit error the value will be "close: to the original, so effect of +% error will be soft. Unlike data we don't need 0 bit errors. I +% struggled to extend this to larger m. + +function three_bit_code + m=4; + log2_m=2; + value_to_codeword = ["000"; "001"; "101"; "111"]; + codeword_to_value = [0 1 1 2 1 2 2 3 3]; + + printf("tx_value tx_codeword rx_codeword rx_value distance\n"); + for i=1:m + tx_codeword = bin2dec(value_to_codeword(i,:)); + tx_codeword_bin = value_to_codeword(i,:); + rx_value = codeword_to_value(tx_codeword+1); + distance = abs((i-1) - rx_value); + printf("%8d %11s %11s %8d %8d\n", i-1, tx_codeword_bin, tx_codeword_bin, ... + rx_value, distance ); + end + printf("\n"); + for i=1:m + tx_codeword = bin2dec(value_to_codeword(i,:)); + tx_codeword_bin = value_to_codeword(i,:); + for j=1:(log2_m+1) + rx_codeword = bitxor(tx_codeword, bitset(0,j)); + rx_codeword_bin = dec2bin(rx_codeword, 3); + rx_value = codeword_to_value(rx_codeword+1); + distance = abs((i-1) - rx_value); + printf("%8d %11s %11s %8d %8d\n", i-1, tx_codeword_bin, rx_codeword_bin, ... + rx_value, distance ); + end + end +endfunction + +% regular natural binary quantiser + +function index = quantise_value(value, min_value, max_value, num_levels) + norm = (value - min_value)/(max_value - min_value); + index = floor(num_levels * norm + 0.5); + if (index < 0 ) + index = 0; + end + if (index > (num_levels-1)) + index = num_levels-1; + end +endfunction + +function value = unquantise_value(index, min_value, max_value, num_levels) + step = (max_value - min_value)/num_levels; + value = min_value + step*(index); +endfunction + +% converting natural binary to gray + +function gray = binary_to_gray(natural) + gray = bitxor(bitshift(natural,-1),natural); +endfunction + +function natural = gray_to_binary(gray) + for i=1:length(gray) + mask = bitshift(gray(i),-1); + num = gray(i); + while(mask) + num = bitxor(num, mask); + mask = bitshift(mask,-1); + end + natural(i) = num; + end +endfunction + +function sim_out = test_baseline_uncoded(Ebvec, Nbits, Ntrials, enable_error_log, enable_gray) + Nlevels = 2.^ Nbits; powersOfTwo = 2 .^ fliplr(0:(Nbits-1)); + Nsymb = Nbits; + + sim_out.qnoise_log = zeros(length(Ebvec),Ntrials); + sim_out.error_log = []; + + for ne = 1:length(Ebvec) + EbNodB = Ebvec(ne); + EbNo = 10^(EbNodB/10); + + variance = 1/EbNo; + + Terrs = 0; Tbits = 0; + qsignal = qnoise = 0; + + for nn = 1:Ntrials + + tx_value = rand(1,1); + tx_index = quantise_value(tx_value, 0, 1, Nlevels); + if enable_gray + tx_index = binary_to_gray(tx_index); + end + tx_bits = dec2bin(tx_index, Nbits) - '0'; + tx_symbols = -1 + 2*tx_bits; + + % AWGN noise and phase/freq offset channel simulation + % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im + + noise = sqrt(variance*0.5)*(randn(1,Nsymb) + j*randn(1,Nsymb)); + rx_symbols = tx_symbols + noise; + + rx_bits = rx_symbols > 0; + + error_positions = xor(rx_bits, tx_bits); + Nerrs = sum(error_positions); + Terrs += Nerrs; + Tbits += length(tx_bits); + if enable_error_log + sim_out.error_log = [sim_out.error_log error_positions]; + end + + rx_index = (powersOfTwo * rx_bits'); + if enable_gray + rx_index = gray_to_binary(rx_index); + end + rx_value = unquantise_value(rx_index, 0, 1, Nlevels); + + qsignal += tx_value*tx_value; + qnoise += (tx_value - rx_value) .^ 2; + sim_out.qnoise_log(ne,nn) = tx_value - rx_value; + end + + sim_out.TERvec(ne) = Terrs; + sim_out.BERvec(ne) = Terrs/Tbits; + sim_out.QSNRvec(ne) = 10*log10(qsignal/qnoise); + printf("EbNo (dB): %3.2f Terrs: %6d BER %1.4f QSNR (dB): %3.2f\n", + EbNodB, Terrs, Terrs/Tbits, 10*log10(qsignal/qnoise)); + end + +endfunction + +function sim_out = test_varpower(Ebvec, Nbits, Ntrials, amps, enable_error_log) + Nlevels = 2.^ Nbits; powersOfTwo = 2 .^ fliplr(0:(Nbits-1)); + Nsymb = Nbits; + + sim_out.qnoise_log = zeros(length(Ebvec), Ntrials); + sim_out.error_log = []; + + for ne = 1:length(Ebvec) + EbNodB = Ebvec(ne); + EbNo = 10^(EbNodB/10); + + variance = 1/EbNo; + + Terrs = 0; Tbits = 0; + qsignal = qnoise = 0; + + for nn = 1:Ntrials + + tx_value = rand(1,1); + tx_index = quantise_value(tx_value, 0, 1, Nlevels); + tx_bits = dec2bin(tx_index, Nbits) - '0'; + tx_symbols = (-1 + 2*tx_bits) .* amps; + + % AWGN noise and phase/freq offset channel simulation + % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im + + noise = sqrt(variance*0.5)*(randn(1,Nsymb) + j*randn(1,Nsymb)); + rx_symbols = tx_symbols + noise; + + rx_bits = rx_symbols > 0; + + error_positions = xor(rx_bits, tx_bits); + if enable_error_log + sim_out.error_log = [sim_out.error_log error_positions]; + end + Nerrs = sum(error_positions); + Terrs += Nerrs; + Tbits += length(tx_bits); + + rx_index = (powersOfTwo * rx_bits'); + rx_value = unquantise_value(rx_index, 0, 1, Nlevels); + + qsignal += tx_value*tx_value; + qnoise += (tx_value - rx_value) .^ 2; + sim_out.qnoise_log(ne,nn) = tx_value - rx_value; + end + + sim_out.TERvec(ne) = Terrs; + sim_out.BERvec(ne) = Terrs/Tbits; + sim_out.QSNRvec(ne) = 10*log10(qsignal/qnoise); + printf("EbNo (dB): %3.2f Terrs: %6d BER %1.4f QSNR (dB): %3.2f\n", + EbNodB, Terrs, Terrs/Tbits, 10*log10(qsignal/qnoise)); + end + +endfunction + +% gray codes with specified number of data and parity bits. Soft +% decision decoding. Didn't really work out. + +function valid_codewords = fuzzy_code_create(ndata,nparity) + Nbits = ndata + nparity; + Nvalid = 2 .^ ndata; + codewords = binary_to_gray(0:(2 .^ Nbits)-1); + valid_codewords = dec2bin(codewords(1:2:(2 .^ Nbits)), Nbits) - '0'; + + % check all valid codewords have a hamming distance of at least 2^nparity + + bad_distance = 0; + for i=1:Nvalid + for k=i+1:Nvalid + distance = sum(bitxor(valid_codewords(i,:), valid_codewords(k,:))); + if distance < 2 + bad_distance++; + end + end + end + if bad_distance != 0 + printf("Error: Nvalid: %d bad_distance: %d\n", Nvalid, bad_distance); + return; + end + +endfunction + +function tx_codeword = fuzzy_code_encode(codewords, value) + tx_codeword = codewords(value+1,:); +endfunction + +function [value, best_codeword] = fuzzy_code_decode(codewords, rx_symbols) + max_corr = 0; + value = 0; + [rows,cols] = size(codewords); + for i=1:rows + corr = (-1 + 2*codewords(i,:)) * transpose(rx_symbols); + if (corr > max_corr) + max_corr = corr; + value = i-1; + best_codeword = codewords(i,:); + end + end +endfunction + + +function sim_out = test_fuzzy_code(Ebvec, Ndata, Nparity, Ntrials) + Nbits = Ndata + Nparity; + Nlevels = 2 .^ Ndata; + Nsymb = Nbits; + powersOfTwo = 2 .^ fliplr(0:(Nbits-1)); + + codewords = fuzzy_code_create(Ndata,Nparity); + sim_out.qnoise_log = zeros(length(Ebvec), Ntrials); + + for ne = 1:length(Ebvec) + EbNodB = Ebvec(ne); + EbNo = 10^(EbNodB/10); + + variance = 1/EbNo; + + Terrs = 0; Terrs_coded = 0; Tbits = 0; + Nsingle = Nsingle_corrected = 0; + qsignal = qnoise = 0; + + for nn = 1:Ntrials + + tx_value = rand(1,1); + tx_index = quantise_value(tx_value, 0, 1, Nlevels); + tx_codeword = fuzzy_code_encode(codewords, tx_index); + tx_symbols = -1 + 2*tx_codeword; + + % AWGN noise and phase/freq offset channel simulation + % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im + + noise = sqrt(variance*0.5)*(randn(1,Nsymb) + j*randn(1,Nsymb)); + rx_symbols = tx_symbols + noise; + + % uncoded BER + + rx_bits = rx_symbols > 0; + error_positions = xor(rx_bits(1:Ndata), tx_codeword(1:Ndata)); + Nerrs = sum(error_positions); + Terrs += Nerrs; + Tbits += Ndata; + + % decode and determine QSNR + + [rx_index, rx_codeword] = fuzzy_code_decode(codewords, rx_symbols); + rx_value = unquantise_value(rx_index, 0, 1, Nlevels); + qsignal += tx_value*tx_value; + qnoise += (tx_value - rx_value) .^ 2; + sim_out.qnoise_log(ne,nn) = tx_value - rx_value; + + % coded BER + + error_positions = xor(rx_codeword(1:Ndata), tx_codeword(1:Ndata)); + Nerrs_coded = sum(error_positions); + if Nerrs == 1 + Nsingle++; + if Nerrs_coded == 0 + Nsingle_corrected++; + end + end + Terrs_coded += Nerrs_coded; + + end + + sim_out.BERvec(ne) = Terrs/Tbits; + sim_out.BERvec_coded(ne) = Terrs_coded/Tbits; + sim_out.Nsingle(ne) = Nsingle; + sim_out.Nsingle_corrected(ne) = Nsingle_corrected; + + sim_out.QSNRvec(ne) = 10*log10(qsignal/qnoise); + printf("EbNo (dB): %3.2f Terrs: %6d BER %1.4f Terrs_coded: %6d BER_coded %1.4f QSNR (dB): %3.2f", + EbNodB, Terrs, Terrs/Tbits, Terrs_coded, Terrs_coded/Tbits, sim_out.QSNRvec(ne)); + printf(" Nsingle: %d Nsingle_corrected: %d corrected: %3.1f\n", Nsingle, Nsingle_corrected, Nsingle_corrected*100/Nsingle); + end +endfunction + +function compare_baseline_fuzzy + Ebvec = 0:3; + Ntrials = 5000; + Nbits = 4; Nparity = 1; + + baseline = test_baseline_uncoded(Ebvec, Nbits, Ntrials, 0, 0); + fuzzy = test_fuzzy_code(Ebvec, Nbits, Nparity, Ntrials); + + figure(1); + clf; + semilogy(Ebvec, baseline.BERvec) + xlabel('Eb/N0') + ylabel('BER') + grid("minor") + + figure(2); + clf; + plot(Ebvec, baseline.QSNRvec,'b;baseline;') + hold on; + plot(Ebvec, fuzzy.QSNRvec,'r;fuzzy;') + hold off; + xlabel('Eb/N0') + ylabel('SNR') + grid("minor") + + figure(3); + subplot(211) + hist(baseline.qnoise_log(4,:),50); + subplot(212) + hist(fuzzy.qnoise_log(4,:),50); + + figure(4) + subplot(211) + plot(baseline.qnoise_log(4,1:250),'b;baseline;') + subplot(212) + plot(fuzzy.qnoise_log(4,1:250),'r;fuzzy;') +endfunction + +% compare baseline and variable power schemes and make plots + +function compare_baseline_varpower_plot + Ebvec = -2:5; + Ntrials = 5000; + Nbits = 5; + + baseline = test_baseline_uncoded(Ebvec, Nbits, Ntrials, 0, 0); + amps = [2 1.5 1.0 0.5 0.5]; + av_pwr = (amps*amps')/length(amps); + amps_norm = amps/sqrt(av_pwr); + varpower = test_varpower(Ebvec, Nbits, Ntrials, amps_norm, 0); + + figure(1); + clf; + semilogy(Ebvec, baseline.BERvec) + xlabel('Eb/No (dB)') + ylabel('BER') + grid("minor") + title('BER versus Eb/No') + + figure(2); + clf; + plot(Ebvec, baseline.QSNRvec,'b;baseline;') + hold on; + plot(Ebvec, varpower.QSNRvec,'r;varpower;') + hold off; + xlabel('Eb/No (dB)') + ylabel('SNR (dB)') + grid("minor") + title('Quantiser SNR versus Eb/No') + + figure(3); + subplot(211) + hist(baseline.qnoise_log(1,:),50); + title('Baseline and Variable Power Error Histograms') + subplot(212) + hist(varpower.qnoise_log(1,:),50); + + figure(4) + subplot(211) + plot(baseline.qnoise_log(1,1:250),'b;baseline;') + title('Baseline and Variable Power Error plots for Eb/No = -2dB') + subplot(212) + plot(varpower.qnoise_log(1,1:250),'r;varpower;') +endfunction + +% Compare baseline and variable power schemes and make error pattern +% files for inserting into codec bit stream so we can listen to +% result. + +function compare_baseline_varpower_error_files + Ebvec = -2; + Fs = 25; % number of samples per second + Nsec = 15; % seconds to simulate + Ntrials = Fs*Nsec; + Nbits = 5; + bits_per_frame = 52; + bits_per_frame_rounded = ceil(bits_per_frame/8)*8; % c2enc uses integer number of bytes/frame + start_bit = 12; % first energy bit (after 4 voicing, 7 Wo bits) + + baseline = test_baseline_uncoded(Ebvec, Nbits, Ntrials, 1, 0); + amps = [2 1.5 1.0 0.5 0.5]; + av_pwr = (amps*amps')/length(amps); + amps_norm = amps/sqrt(av_pwr); + varpower = test_varpower(Ebvec, Nbits, Ntrials, amps_norm, 1); + + % construct error patterns to apply to c2enc bit stream + + baseline_errors = []; + for i=1:Ntrials + error_positions = baseline.error_log(Nbits*(i-1)+1:Nbits*i); + baseline_errors = [baseline_errors zeros(1,start_bit-1) error_positions ... + zeros(1, bits_per_frame_rounded - Nbits - (start_bit-1))]; + end + + varpower_errors = []; + for i=1:Ntrials + error_positions = varpower.error_log(Nbits*(i-1)+1:Nbits*i); + varpower_errors = [varpower_errors zeros(1,start_bit-1) error_positions ... + zeros(1, bits_per_frame_rounded - Nbits - (start_bit-1))]; + end + + % save error patterns + + fep=fopen("energy_errors_baseline.bin","wb"); fwrite(fep, baseline_errors, "short"); fclose(fep); + fep=fopen("energy_errors_varpower.bin","wb"); fwrite(fep, varpower_errors, "short"); fclose(fep); +endfunction + +% compare natural and gray coding and make plots + +function compare_natural_gray_plot + Ebvec = -2:10; + Ntrials = 5000; + Nbits = 7; + + natural = test_baseline_uncoded(Ebvec, Nbits, Ntrials, 0, 0); + gray = test_baseline_uncoded(Ebvec, Nbits, Ntrials, 0, 1); + + figure(1); + clf; + semilogy(Ebvec, natural.BERvec) + xlabel('Eb/No (dB)') + ylabel('BER') + grid("minor") + title('BER versus Eb/No') + + figure(2); + clf; + plot(Ebvec, natural.QSNRvec,'b;natural;') + hold on; + plot(Ebvec, gray.QSNRvec,'r;gray;') + hold off; + xlabel('Eb/No (dB)') + ylabel('SNR (dB)') + grid("minor") + title('Quantiser SNR versus Eb/No') + + figure(3); + subplot(211) + hist(natural.qnoise_log(1,:),50); + title('Natural and Gray coded Error Histograms') + subplot(212) + hist(gray.qnoise_log(1,:),50); + + figure(4) + subplot(211) + plot(natural.qnoise_log(1,1:250),'b;natural;') + axis([0 250 -1 1]) + title('Natural and Gray coded Error plots for Eb/No = -2dB') + subplot(212) + plot(gray.qnoise_log(1,1:250),'r;gray;') + axis([0 250 -1 1]) +endfunction + +% compare natural at different Eb/No and Nbitsmake plots + +function compare_natural_nbit_plot + Ebvec = -2:10; + Ntrials = 5000; + + figure(1); + clf; + for n = 2:7 + natural = test_baseline_uncoded(Ebvec, n, Ntrials, 0, 0); + plot(Ebvec, natural.QSNRvec) + if n == 2 + hold on; + end + end + hold off; + + xlabel('Eb/No (dB)') + ylabel('SNR (dB)') + grid("minor") + title('Quantiser SNR versus Eb/No') +endfunction + +function generate_varpower_error_files(EbNo, start_bit, end_bit, amps, error_file_name) + Fs = 25; % number of samples per second + Nsec = 3; % seconds to simulate + Ntrials = Fs*Nsec; + Nbits = end_bit - start_bit + 1; + bits_per_frame = 52; + bits_per_frame_rounded = ceil(bits_per_frame/8)*8; % c2enc uses integer number of bytes/frame + % first energy bit (after 4 voicing, 7 Wo bits) + + % normalise powers and run test + + av_pwr = (amps*amps')/length(amps); + amps_norm = amps/sqrt(av_pwr); + av_pwr2 = (amps_norm*amps_norm')/length(amps_norm) + varpower = test_varpower(EbNo, Nbits, Ntrials, amps_norm, 1); + + % construct error patterns to apply to c2enc bit stream + + varpower_errors = []; + for i=1:Ntrials + error_positions = varpower.error_log(Nbits*(i-1)+1:Nbits*i); + + if 0 + % reset single errors to tes effect of ideal single bit error correcting code + for i=1:7 + st = 4*(i-1)+1 + en = 4*i + if sum(error_positions(st:en)) == 1 + error_positions(st:en) = 0; + end + end + for i=1:2 + st = 7*4+3*(i-1)+1 + en = 7*4+3*i + if sum(error_positions(st:en)) == 1 + error_positions(st:en) = 0; + end + end + st = 7*4+3*2+1 + en = 7*4+3*2+2 + if sum(error_positions(st:en)) == 1 + error_positions(st:en) = 0; + end + end + + num_errors(i) = sum(error_positions); + varpower_errors = [varpower_errors zeros(1,start_bit-1) error_positions ... + zeros(1, bits_per_frame_rounded - Nbits - (start_bit-1))]; + end + + % save error pattern to file + + fep=fopen(error_file_name,"wb"); fwrite(fep, varpower_errors, "short"); fclose(fep); + + figure(1) + clf + hist(num_errors) +endfunction + +more off; + +%generate_varpower_error_files(0, 17, 52, ones(1,36), "lsp_baseline_errors_0dB.bin") +%amps = [1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 ]; +%generate_varpower_error_files(0, 17, 52, amps, "lsp_varpower_errors_0dB.bin") + +%compare_natural_nbit_plot +%compare_natural_gray_plot +%compare_baseline_varpower_plot +%compare_baseline_varpower_error_files + +compare_baseline_fuzzy +%fuzzy_code_create(3,1) diff --git a/codec2/branches/0.3/octave/gen_rn_coeffs.m b/codec2/branches/0.3/octave/gen_rn_coeffs.m new file mode 100644 index 00000000..bfc214e0 --- /dev/null +++ b/codec2/branches/0.3/octave/gen_rn_coeffs.m @@ -0,0 +1,40 @@ +% gen_rn_coeffs.m +% David Rowe 13 april 2012 +% +% Generate root raised cosine (Root Nyquist) filter coefficients +% thanks http://www.dsplog.com/db-install/wp-content/uploads/2008/05/raised_cosine_filter.m + +function coeffs = gen_rn_coeffs(alpha, T, Rs, Nsym, M) + + Ts = 1/Rs; + + n = -Nsym*Ts/2:T:Nsym*Ts/2; + Nfilter = Nsym*M; + Nfiltertiming = M+Nfilter+M; + + sincNum = sin(pi*n/Ts); % numerator of the sinc function + sincDen = (pi*n/Ts); % denominator of the sinc function + sincDenZero = find(abs(sincDen) < 10^-10); + sincOp = sincNum./sincDen; + sincOp(sincDenZero) = 1; % sin(pix/(pix) =1 for x =0 + + cosNum = cos(alpha*pi*n/Ts); + cosDen = (1-(2*alpha*n/Ts).^2); + cosDenZero = find(abs(cosDen)<10^-10); + cosOp = cosNum./cosDen; + cosOp(cosDenZero) = pi/4; + gt_alpha5 = sincOp.*cosOp; + Nfft = 4096; + GF_alpha5 = fft(gt_alpha5,Nfft)/M; + + % sqrt causes stop band to be amplified, this hack pushes it down again + + for i=1:Nfft + if (abs(GF_alpha5(i)) < 0.02) + GF_alpha5(i) *= 0.001; + endif + end + GF_alpha5_root = sqrt(abs(GF_alpha5)) .* exp(j*angle(GF_alpha5)); + ifft_GF_alpha5_root = ifft(GF_alpha5_root); + coeffs = real((ifft_GF_alpha5_root(1:Nfilter))); +endfunction diff --git a/codec2/branches/0.3/octave/glottal.m b/codec2/branches/0.3/octave/glottal.m new file mode 100644 index 00000000..46675e7d --- /dev/null +++ b/codec2/branches/0.3/octave/glottal.m @@ -0,0 +1,29 @@ +% glottal.m +% David Rowe 12 Sep 2009 +% Matlab script to generate the phase spectra of a glottal pulse + +% lpc10 pulse from spandsp. When the file glottal.c was used as a part of the +% excitation phase component in phase.c, phase_synth_zero_order(), no difference +% in speech quality was apparent. So left out of code for now. + +sh=12 +kexc = [ 8, -16, 26, -48, 86, -162, 294, -502, 718, -728, 184 672, -610, -672, 184, 728, 718, 502, 294, 162, 86, 48, 26, 16, 8]; +kexc = shift(kexc,sh); +kexc = [kexc(1:sh) zeros(1,512-25) kexc(sh+1:25)]; +figure(1) +clf +plot(kexc) +figure(2) +G = fft(kexc); +subplot(211) +plot((1:256)*(4000/256),unwrap(angle(G(1:256)))) +subplot(212) +plot(20*log10(abs(G))) + +f=fopen("glottal.c","wt"); +fprintf(f,"const float glottal[]={\n"); +for m=1:255 + fprintf(f," %f,\n",angle(G(m))); +endfor +fprintf(f," %f};\n",angle(G(256))); +fclose(f); diff --git a/codec2/branches/0.3/octave/hf_sim.m b/codec2/branches/0.3/octave/hf_sim.m new file mode 100644 index 00000000..90458283 --- /dev/null +++ b/codec2/branches/0.3/octave/hf_sim.m @@ -0,0 +1,74 @@ +% hf_sim.m +% David Rowe March 2014 +% +% HF channel simulation. + +function sim_out = hf_sim(sim_in, snr3kHz) + + % Init HF channel model from stored sample files of spreading signal ---------------------------------- + + % convert "spreading" samples from 1kHz carrier at Fs to complex + % baseband, generated by passing a 1kHz sine wave through PathSim + % with the ccir-poor model, enabling one path at a time. + + Fc = 1000; Fs=8000; + fspread = fopen("../raw/sine1k_2Hz_spread.raw","rb"); + spread1k = fread(fspread, "int16")/10000; + fclose(fspread); + fspread = fopen("../raw/sine1k_2ms_delay_2Hz_spread.raw","rb"); + spread1k_2ms = fread(fspread, "int16")/10000; + fclose(fspread); + + % down convert to complex baseband + spreadbb = spread1k.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k))'); + spreadbb_2ms = spread1k_2ms.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k_2ms))'); + + % remove -2000 Hz image + b = fir1(50, 5/Fs); + spread = filter(b,1,spreadbb); + spread_2ms = filter(b,1,spreadbb_2ms); + + % discard first 1000 samples as these were near 0, probably as + % PathSim states were ramping up + + spread = spread(1000:length(spread)); + spread_2ms = spread_2ms(1000:length(spread_2ms)); + + hf_gain = 1.0/sqrt(var(spread)+var(spread_2ms)); + + % 300 - 3000 Hz filter + + b = fir1(100,[300/4000, 3000/4000], 'pass'); + + % det power of unit variance noise passed through this filter + + filter_var = var(filter(b,1,randn(1000,1))); + + % Start simulation + + s = hilbert(filter(b,1,sim_in)); + n1 = length(s); n2 = length(spread); + n = min(n1,n2); + path1 = s(1:n) .* spread(1:n); + path2 = s(1:n) .* spread_2ms(1:n); + delay = floor(0.002*Fs); + + combined = path1(delay+1:n) + path2(1:n-delay); + + snr = 10 .^ (snr3kHz/10); + variance = (combined'*combined)/(snr*n); + noise = sqrt(variance*0.5/filter_var)*(randn(n-delay,1) + j*randn(n-delay,1)); + filtered_noise = filter(b,1,noise); + + sim_out = real(combined+filtered_noise); + printf("measured SNR: %3.2fdB\n", 10*log10(var(real(combined))/var(real(filtered_noise)))); + + figure(1); + plot(s); + figure(2) + plot(real(combined)) + figure(2) + plot(sim_out) + +endfunction + diff --git a/codec2/branches/0.3/octave/hfper.m b/codec2/branches/0.3/octave/hfper.m new file mode 100644 index 00000000..b3396342 --- /dev/null +++ b/codec2/branches/0.3/octave/hfper.m @@ -0,0 +1,57 @@ +% hfper.m +% David Rowe 2 June 2014 +% Quick and dirty HF PER calculator/simulator + +function hfper(ber, nbits, ntrials) + + % Raw PER with no FEC -------------------------------------- + + nper = 0; + for i=1:ntrials + nerr = sum(rand(1,nbits) < ber); + if nerr >0 + nper++; + end + end + printf("Raw PER..................: %0.3f\n", nper/ntrials); + + % Half rate block code, e.g. Golay (23,12) with 3 bit error + % correcting capability + + % Golay (23,12) that can correct 3 errors (fails at 4) ------ + + ncodeword = 23; + ncorrect = 3; + nper = 0; + for i=1:ntrials + nerr = sum(rand(1,ncodeword) < ber); + if nerr > ncorrect + nper++; + end + end + printf("One Golay codeword.......: %0.3f\n", nper/ntrials); + + % Several Golay codewords concatenated ---------------------- + + m = floor(nbits/12); % number of codewords + + nper = 0; + for i=1:ntrials + + % test each codeword in packet, if any of the codewords has > 4 + % errors, entire packet is a dud + + no_errors = 1; + for k=1:m + nerr = sum(rand(1,ncodeword) < ber); + if (nerr > ncorrect) && no_errors + nper++; + no_errors = 0; + end + end + + end + printf("Packet protected by Golay: %0.3f\n", nper/ntrials); + +endfunction + diff --git a/codec2/branches/0.3/octave/hp_filt.m b/codec2/branches/0.3/octave/hp_filt.m new file mode 100644 index 00000000..1087bb91 --- /dev/null +++ b/codec2/branches/0.3/octave/hp_filt.m @@ -0,0 +1,12 @@ +% hp_filt.m +% David Rowe 20 Feb 2012 + +function hp_filt(in_file, out_file) + fin = fopen(in_file,"rb"); + s = fread(fin,Inf,"short"); + b = fir1(256, 300/4000, "high"); + freqz(b); + s_hpf = filter(b,1,s); + fout = fopen(out_file,"wb"); + fwrite(fout, s_hpf, "short"); +endfunction diff --git a/codec2/branches/0.3/octave/ldpc.m b/codec2/branches/0.3/octave/ldpc.m new file mode 100644 index 00000000..7ce4a87a --- /dev/null +++ b/codec2/branches/0.3/octave/ldpc.m @@ -0,0 +1,209 @@ +% ldpc.m +% LDPC functions + +1; + + +function code_param = ldpc_init(rate, framesize, modulation, mod_order, mapping) + [code_param.H_rows, code_param.H_cols, code_param.P_matrix] = InitializeWiMaxLDPC( rate, framesize, 0 ); + code_param.data_bits_per_frame = length(code_param.H_cols) - length( code_param.P_matrix ); + code_param.S_matrix = CreateConstellation( modulation, mod_order, mapping ); + code_param.bits_per_symbol = log2(mod_order); +endfunction + + +% Gray coded QPSK modulation function + +function symbol = qpsk_mod(two_bits) + two_bits_decimal = sum(two_bits .* [2 1]); + switch(two_bits_decimal) + case (0) symbol = 1; + case (1) symbol = j; + case (2) symbol = -j; + case (3) symbol = -1; + endswitch +endfunction + + +% Gray coded QPSK demodulation function + +function two_bits = qpsk_demod(symbol) + bit0 = real(symbol*exp(j*pi/4)) < 0; + bit1 = imag(symbol*exp(j*pi/4)) < 0; + two_bits = [bit1 bit0]; +endfunction + + +% inserts a unique word into a frame of bits. The UW bits are spread +% throughout the input frame 2 bits at a time. + +function frameout = insert_uw(framein, uw) + + luw = length(uw); + lframein = length(framein); + spacing = 2*lframein/luw; + + frameout = []; + + pin = 1; pout = 1; puw = 1; + while (luw) + %printf("pin %d pout %d puw %d luw %d\n", pin, pout, puw, luw); + frameout(pout:pout+spacing-1) = framein(pin:pin+spacing-1); + pin += spacing; + pout += spacing; + frameout(pout:pout+1) = uw(puw:puw+1); + puw += 2; + pout += 2; + luw -= 2; + end +endfunction + +% removes a unique word from a frame of bits. The UW bits are spread +% throughout the input frame 2 bits at a time. + +function frameout = remove_uw(framein, lvd, luw) + + spacing = 2*lvd/luw; + + frameout = []; + + pin = 1; pout = 1; + while (luw) + %printf("pin %d pout %d luw %d ", pin, pout, luw); + %printf("pin+spacing-1 %d lvd %d lframein: %d\n", pin+spacing-1, lvd, length(framein)); + frameout(pout:pout+spacing-1) = framein(pin:pin+spacing-1); + pin += spacing + 2; + pout += spacing; + luw -= 2; + end + +endfunction + + +% removes a unique word from a frame of symbols. The UW symbols are spread +% throughout the input frame 1 symbol at a time. + +function framesymbolsout = remove_uw_symbols(framesymbolsin, ldatasymbols, luwsymbols) + + spacing = ldatasymbols/luwsymbols; + + framesymbolsout = []; + + pin = 1; pout = 1; + while (luwsymbols) + %printf("pin %d pout %d luw %d ", pin, pout, luwsymbols); + %printf("pin+spacing-1 %d ldatasymbols %d lframein: %d\n", pin+spacing-1, ldatasymbols, length(framesymbolsin)); + framesymbolsout(pout:pout+spacing-1) = framesymbolsin(pin:pin+spacing-1); + pin += spacing + 1; + pout += spacing; + luwsymbols--; + end + +endfunction + + + +% builds up a sparse QPSK modulated version version of the UW for use +% in UW sync at the rx + +function mod_uw = build_mod_uw(uw, spacing) + luw = length(uw); + + mod_uw = []; + + pout = 1; puw = 1; + while (luw) + %printf("pin %d pout %d puw %d luw %d\n", pin, pout, puw, luw); + pout += spacing/2; + mod_uw(pout) = qpsk_mod(uw(puw:puw+1)); + puw += 2; + pout += 1; + luw -= 2; + end +endfunction + + +% Uses the UW to determine when we have a full codeword ready for decoding + +function [found_uw corr] = look_for_uw(mem_rx_symbols, mod_uw) + sparse_mem_rx_symbols = mem_rx_symbols(find(mod_uw)); + + % correlate with ref UW + + num = (mem_rx_symbols * mod_uw') .^ 2; + den = (sparse_mem_rx_symbols * sparse_mem_rx_symbols') * (mod_uw * mod_uw'); + + corr = abs(num/(den+1E-6)); + found_uw = corr > 0.8; +endfunction + + +function [codeword s] = ldpc_enc(data, code_param) + codeword = LdpcEncode( data, code_param.H_rows, code_param.P_matrix ); + s = Modulate( codeword, code_param.S_matrix ); +endfunction + + +function detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, r, EsNo, fading) + symbol_likelihood = Demod2D( r, code_param.S_matrix, EsNo, fading); + + % initialize the extrinsic decoder input + input_somap_c = zeros(1, code_param.code_bits_per_frame ); + bit_likelihood = Somap( symbol_likelihood, demod_type, input_somap_c ); + + input_decoder_c = bit_likelihood(1:code_param.code_bits_per_frame); + + x_hat= MpDecode( -input_decoder_c, code_param.H_rows, code_param.H_cols, ... + max_iterations, decoder_type, 1, 1); + detected_data = x_hat(max_iterations,:); +endfunction + + +% Packs a binary array into an array of 8 bit bytes, MSB first + +function packed = packmsb(unpacked) + packed = zeros(1,floor(length(unpacked)+7)/8); + bit = 7; byte = 1; + for i=1:length(unpacked) + packed(byte) = bitor(packed(byte), bitshift(unpacked(i),bit)); + bit--; + if (bit < 0) + bit = 7; + byte++; + end + end +endfunction + + +% unpacks an array of 8 bit bytes into a binary array of unpacked bits, MSB first + +function unpacked = unpackmsb(packed) + bit = 7; byte = 1; + for i=1:length(packed)*8 + unpacked(i) = bitand(bitshift(packed(byte), -bit), 1); + bit--; + if (bit < 0) + bit = 7; + byte++; + end + end +endfunction + + +% symbol interleaver that acts on bits 2 at a time + +function y = interleave_bits(interleaver, x) + y = zeros(1,length(x)); + for i = 1:length(interleaver) + dst = interleaver(i); + y(2*(dst-1)+1:2*dst) = x(2*(i-1)+1:2*(i)); + end +endfunction + +% symbol de-interleaver + +function x = deinterleave_symbols(interleaver, y) + for i = 1:length(interleaver) + x(i) = y(interleaver(i)); + end +endfunction diff --git a/codec2/branches/0.3/octave/ldpcdec.m b/codec2/branches/0.3/octave/ldpcdec.m new file mode 100644 index 00000000..6f71f832 --- /dev/null +++ b/codec2/branches/0.3/octave/ldpcdec.m @@ -0,0 +1,300 @@ +% ldpcdec.m +% David Rowe 31 Dec 2013 +% +% LDPC decoder test program, given a file of QPSK symbols (IQIQ floats), +% performs frame sync, decodes, and measures BER. + +function ldpcdec(filename, Eprob) + + % Start CML library + + currentdir = pwd; + addpath '/home/david/tmp/cml/mat' % assume the source files stored here + cd /home/david/tmp/cml + CmlStartup % note that this is not in the cml path! + cd(currentdir) + + % Our LDPC library + + ldpc; + + % Start simulation + + rand('state',1); + + rate = 3/4; + framesize = 576; + + mod_order = 4; + modulation = 'QPSK'; + mapping = 'gray'; + + demod_type = 0; + decoder_type = 0; + max_iterations = 100; + EsNo = 4; + if (nargin == 1) + Eprob = 0.0; + end + + nbitspervocoderframe = 52; + nvocoderframes = 8; + nbitspermodemframe = 72; + + code_param = ldpc_init(rate, framesize, modulation, mod_order, mapping); + code_param.code_bits_per_frame = 576; + + data = []; + r = []; + load interleaver.txt + interleaver = interleaver + 1; + + Nframes = 100; + uw = [1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0]; + + Nc = 18; + + % repeat same simulated vocoder data to ease testing + + vd = round( rand( 1, nbitspervocoderframe*nvocoderframes) ); + + % Decoder: Sync with LDPC frames, de-interleave, LDPC decode, strip off UW, measure BER ------- + + mcwfilename = strcat(filename,"_modcodeword.bin"); + fm=fopen(mcwfilename,"rb"); + etfilename = strcat(filename,"_modcodeword_et.bin"); + fet=fopen(etfilename ,"rb"); + epfilename = strcat(filename,".err"); + fep=fopen(epfilename ,"wb"); + printf("Input QPSK symbols: %s\n", mcwfilename); + if (fet == -1) + printf("Input entered track file: none\n"); + else + printf("Input entered track file: %s\n", etfilename); + end + printf("Output error pattern file: %s\n", epfilename); + + mod_uw = build_mod_uw(uw, 2*length(vd)/length(uw)); + + mod_codeword = zeros(1, code_param.code_bits_per_frame/2); + lmod_codeword = code_param.code_bits_per_frame/2; + + Terrs = 0; Trawerrs = 0; Ferrs = 0; Tbits = 0; Tframes = 0; nerr = []; nrawerr = []; + corr = []; n = 0; + sync_state = 0; sync_count = 0; + mod_unpackedmodem_log = []; + sync_state_log = []; + entered_track_log = []; + sig_pwr_log = []; + + symbols = erasures = 0; + + [mod_unpackedmodem_float32, count] = fread(fm,nbitspermodemframe, "float32"); + if (fet == -1) + entered_track = 0; + else + entered_track = fread(fet, 1, "int"); + end + + while (count == nbitspermodemframe) + n++; + + mod_unpackedmodem = mod_unpackedmodem_float32(1:2:nbitspermodemframe) + j*mod_unpackedmodem_float32(2:2:nbitspermodemframe); + mod_unpackedmodem_log = [mod_unpackedmodem_log mod_unpackedmodem]; + %erasures = rand(1,length(mod_unpackedmodem)) < Eprob; + %mod_unpackedmodem(erasures) = 0; + + % keep buffer of one entire codeword + + mod_codeword(1:lmod_codeword-length(mod_unpackedmodem)) = mod_codeword(length(mod_unpackedmodem)+1:lmod_codeword); + mod_codeword(lmod_codeword-length(mod_unpackedmodem)+1:lmod_codeword) = mod_unpackedmodem; + + [uw_sync corr(n)] = look_for_uw(mod_codeword(1:length(mod_uw)), mod_uw); + + next_sync_state = sync_state; + if ((sync_state == 0) && (uw_sync == 1)) + next_sync_state = 1; + sync_count = 0; + end + if ((sync_state == 1) && (entered_track != 0)) + next_sync_state = 0; + end + sync_state = next_sync_state; + sync_state_log = [sync_state_log sync_state]; + entered_track_log = [entered_track_log entered_track]; + + if (sync_state && (sync_count == 0)) + Tframes++; + + % remove UW symbols + + mod_codeword_no_uw = remove_uw_symbols(mod_codeword, code_param.data_bits_per_frame/2 - length(uw)/2, length(uw)/2); + mod_codeword_no_uw = [mod_codeword_no_uw mod_codeword((code_param.data_bits_per_frame/2+1):code_param.code_bits_per_frame/2)]; + + % de-interleave + + tmp = deinterleave_symbols(interleaver, mod_codeword_no_uw); + + % insert known symbols at end of data + + mod_codeword_deinter = [ tmp(1:(code_param.data_bits_per_frame/2 - length(uw)/2)) ... + ones(1,length(uw)/2) * qpsk_mod([0 0]) ... + tmp((code_param.data_bits_per_frame/2 - length(uw)/2+1):length(tmp)) ]; + + % determine BER stats of raw data before decoding + + raw_bits = zeros(1, code_param.data_bits_per_frame - length(uw)); + for i=1:(code_param.data_bits_per_frame - length(uw))/2 + raw_bits(2*(i-1)+1:2*i) = qpsk_demod(mod_codeword_deinter(i)); + end + error_positions = xor(vd, raw_bits); + Nerrs = sum(error_positions); + Trawerrs += Nerrs; + nrawerr(Tframes) = Nerrs; + + % Determine Es/N for each carrier. For this codeword we assume + % across codeword (currently 320ms) signal is stationary. + % So for each carrier signal level is constant, so we can + % average across all symols of that carrier to get a better + % estimate of the carrier power. The spectral noise density + % No will be the same for the bandwidth of each carrier. So + % we can use noise samples from all symbols together to get + % a better estimate of the noise power. + + sig_pwr(Tframes,:) = zeros(1,Nc); + noise_samples = []; + for n=1:Nc + + % extract a vector of one carrier's symbols for this codeword + % rotate so that decision boundaries are now real and imag axis + + r = mod_codeword(n:Nc:length(mod_codeword)) .* exp(j*pi/4); + + sig_est = mean(abs(r)); + + % The noise is the variance of symbols (samples) about the actual symbol position + % we reflect all symbols into the first quadrant to simplify things, as the actual + % received symbol isn't matter, just the noise around it. We model the received + % symbol based on the estimated signal level. + + refl_symbols = abs(real(r)) + j*abs(imag(r)); + est_symbols = exp(j*pi/4)*sig_est*ones(1,length(r)); + noise_samples = [ noise_samples (est_symbols - refl_symbols)]; + + sig_pwr(Tframes,n) = sig_est .^ 2; + end + noise_pwr(Tframes) = var(noise_samples); + %plot(real(refl_symbols), imag(refl_symbols), '+'); + %hold on; + %plot(real(exp(j*pi/4)*sig_est*ones(1,length(r))), imag(exp(j*pi/4)*sig_est*ones(1,length(r))), 'r+'); + %hold off; + %printf("SNR: %f\n", 10*log10(sig_est*sig_est/noise_pwr(Tframes))); + + % Set erasures for carrier beneath a certain Es/N + + for n=1:Nc + symbols++; + EsN(n) = 10*log10(sig_pwr(Tframes,n)/noise_pwr(Tframes)); + if (EsN(n) < 1) + %mod_codeword(n:Nc:length(mod_codeword)) = 0; + %printf("Tframes: %d n: %d EsN = %3.2fdB\n", Tframes, n, EsN(n)); + erasures++; + end + end + + % De-interleave again with erasures set ---------------------- + + % remove UW symbols + + mod_codeword_no_uw = remove_uw_symbols(mod_codeword, code_param.data_bits_per_frame/2 - length(uw)/2, length(uw)/2); + mod_codeword_no_uw = [mod_codeword_no_uw mod_codeword((code_param.data_bits_per_frame/2+1):code_param.code_bits_per_frame/2)]; + + tmp = deinterleave_symbols(interleaver, mod_codeword_no_uw); + + % insert known symbols at end of data + + mod_codeword_deinter = [ tmp(1:(code_param.data_bits_per_frame/2 - length(uw)/2)) ... + ones(1,length(uw)/2) * qpsk_mod([0 0]) ... + tmp((code_param.data_bits_per_frame/2 - length(uw)/2+1):length(tmp)) ]; + + % LDPC decode ------------------------------------------------ + + detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, mod_codeword_deinter, EsNo); + + % unpack payload data, removing UW + + vd_rx = detected_data(1:(code_param.data_bits_per_frame - length(uw))); + + % measure coded BER + + error_positions = xor(vd, vd_rx); + Nerrs = sum(error_positions); + if Nerrs>0, fprintf(1,'x'); Ferrs++; , else fprintf(1,'.'), end + Tbits += length(vd); + Terrs += Nerrs; + nerr(Tframes) = Nerrs; + + % save error patterns is simulated vocoder data to disk + + fwrite(fep, error_positions, "short"); + + end + + if (sync_state) + sync_count++; + if (sync_count == 8) + sync_count = 0; + end + end + + % read in one modulated modem frame at a time + + [mod_unpackedmodem_float32, count] = fread(fm, nbitspermodemframe, "float32"); + if (fet == -1) + entered_track = 0; + else + entered_track = fread(fet, 1, "int"); + end + end + + fclose(fep); + + printf("\nFrames: %d bits: %d errors: %d Raw BER = %f Coded BER = %f FER = %f\n", Tframes, Tbits, Terrs, Trawerrs/Tbits, Terrs/Tbits, Ferrs/Tframes); + printf("Symbols: %d Erasures: %d %f\n", symbols, erasures, erasures/symbols); + figure(8) + clf; + [n m] = size(mod_unpackedmodem_log); + plot( real(mod_unpackedmodem_log), imag(mod_unpackedmodem_log), '+') + axis([-2 2 -2 2]); + title('Scatter Diagram'); + + figure(9) + subplot(311) + plot(sync_state_log); + subplot(312) + plot(nrawerr); + subplot(313) + plot(nerr); + + figure(10); + plot(10*log10(sig_pwr(:,3)./noise_pwr(:)),'b'); + hold on; + plot(10+10*log10(noise_pwr(:))); + plot(10+10*log10(sig_pwr(:,3)),'r'); +% for n=2:Nc +% plot(n*10+10*log10(sig_pwr(:,n)./noise_pwr(:,n))); +% plot(n*10+10*log10(sig_pwr(:,n)),'r'); +% end + hold off; + + y = 1:Tframes; + x = 1:Nc; + z = 10*log10(sig_pwr(:,:)./((noise_pwr(:)*ones(1, Nc)))); + %printf("mean SNR = %3.2fdB\n", mean(z)); + figure(11); + imagesc(x,y,z); + figure(12); + mesh(x,y,z); + axis([1 Nc 1 Tframes 5 15]); + +endfunction diff --git a/codec2/branches/0.3/octave/ldpcenc.m b/codec2/branches/0.3/octave/ldpcenc.m new file mode 100644 index 00000000..023c5172 --- /dev/null +++ b/codec2/branches/0.3/octave/ldpcenc.m @@ -0,0 +1,125 @@ +% ldpcenc.m +% David Rowe 20 Dec 2013 +% +% LDPC encoder function. Takes a random data pattern, LDPC Encodes and +% inserts Unique Word (UW) sync bits and ouputs this as a packed +% binary file suitable for the Nc=18 carrier FDMDV modulator, +% fdmdv_mod. Also produces a "modulated" output file of QPSK +% symbols, suitable for feeding into ldpcdec for testing. + +function ldpcenc(filename) + + % Start CML library + + currentdir = pwd; + addpath '/home/david/tmp/cml/mat' % assume the source files stored here + cd /home/david/tmp/cml + CmlStartup % note that this is not in the cml path! + cd(currentdir) + + % Our LDPC library + + ldpc; + + % Start simulation + + rand('state',1); + + rate = 3/4; + framesize = 576; + + mod_order = 4; + modulation = 'QPSK'; + mapping = 'gray'; + + demod_type = 0; + decoder_type = 0; + max_iterations = 100; + + nbitspervocoderframe = 52; + nvocoderframes = 8; + nbitspermodemframe = 72; + + code_param = ldpc_init(rate, framesize, modulation, mod_order, mapping); + + data = []; + r = []; + load interleaver.txt + interleaver = interleaver + 1; + + % Encoder: Generate simulated vocoder data + % LPDC encode + % interleave + % insert UW bits + + Nframes = 100; + uw = [1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0]; + + % repeat same simulated vocoder data to ease testing + + vd = round( rand( 1, nbitspervocoderframe*nvocoderframes) ); + + % pad data with zeros the size of UW + + vdpad = [vd zeros(1, length(uw))]; + + % LDPC encode + + [codewordpad, s] = ldpc_enc(vdpad, code_param); + code_param.code_bits_per_frame = length(codewordpad); + code_param.symbols_per_frame = length(s); + + % remove padded zeros after encoding to leave room for UW bits (code + % is systematic) + + codeword = [ codewordpad(1:length(vd)) codewordpad((length(vd)+length(uw)+1):length(codewordpad)) ]; + + % interleave, insert UW bits, and pack bits (as C modulator likes packed bits) + + codeword_interleaved = interleave_bits(interleaver, codeword); + codeword_interleaved_uw = [insert_uw(codeword_interleaved(1:length(vd)), uw) codeword_interleaved(length(vd)+1:length(codeword_interleaved)) ]; + packedcodeword = packmsb(codeword_interleaved_uw); + + cwfilename = strcat(filename,"_codeword.bin"); + fc=fopen(cwfilename,"wb"); + for nn = 1: Nframes + fwrite(fc,packedcodeword,"uchar"); + end + fclose(fc); + + %printf("framesize: %d data_bits_per_frame: %d code_bits_per_frame: %d\n", ... + % framesize, code_param.data_bits_per_frame, code_param.code_bits_per_frame); + + printf("Encoded %d LDPC codewords, saved in packed file: %s\n", Nframes, cwfilename); + + % Modulator: Modulate to QPSK symbols ------------------------------------------ + + nbytespackedcodeword=length(packedcodeword); + fc=fopen(cwfilename,"rb"); + mcwfilename = strcat(filename,"_modcodeword.bin"); + fm=fopen(mcwfilename,"wb"); + nbytespackedmodemframe = nbitspermodemframe/8; + n = 0; + + [packedmodem, count] = fread(fc,nbytespackedmodemframe,"uchar"); + while (count == nbytespackedmodemframe) + n++; + unpackedmodem = unpackmsb(packedmodem); + + ii = 1; + for i=1:2:length(unpackedmodem) + mod_unpackedmodem(ii) = qpsk_mod(unpackedmodem(i:i+1)); + mod_unpackedmodem_float32(i) = real(mod_unpackedmodem(ii)); + mod_unpackedmodem_float32(i+1) = imag(mod_unpackedmodem(ii)); + ii += 1; + end + + fwrite(fm, mod_unpackedmodem_float32, "float32"); + [packedmodem, count] = fread(fc,nbytespackedmodemframe,"uchar"); + end + fclose(fc); + fclose(fm); + printf("Modulated %d modem frames to file: %s\n", n, mcwfilename); +endfunction + + diff --git a/codec2/branches/0.3/octave/ldpcut.m b/codec2/branches/0.3/octave/ldpcut.m new file mode 100644 index 00000000..80142ba6 --- /dev/null +++ b/codec2/branches/0.3/octave/ldpcut.m @@ -0,0 +1,69 @@ +% LDPC unit test script +% David Rowe 18 Dec 2013 +% Based on siulation by Bill Cowley + +% Start CML library + +currentdir = pwd; +addpath '/home/david/tmp/cml/mat' % assume the source files stored here +cd /home/david/tmp/cml +CmlStartup % note that this is not in the cml path! +cd(currentdir) + +% Our LDPC library + +ldpc; + +% Start simulation + +rate = 3/4; +framesize = 576; + +mod_order = 4; +modulation = 'QPSK'; +mapping = 'gray'; + +demod_type = 0; +decoder_type = 0; +max_iterations = 100; + +code_param = ldpc_init(rate, framesize, modulation, mod_order, mapping); + +Ntrials = 84; +EsNo=10; + +Tbits = Terrs = Ferrs = 0; + +data = []; +r = []; + +% Encode a bunch of frames + +for nn = 1: Ntrials + d = round( rand( 1, code_param.data_bits_per_frame ) ); + data = [data d]; + [codeword, s] = ldpc_enc(d, code_param); + code_param.code_bits_per_frame = length(codeword); + code_param.symbols_per_frame = length(s); + r = [r s]; +end + +% Decode a bunch of frames + +for nn = 1: Ntrials + st = (nn-1)*code_param.symbols_per_frame + 1; + en = (nn)*code_param.symbols_per_frame; + detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, r(st:en), EsNo); + st = (nn-1)*code_param.data_bits_per_frame + 1; + en = (nn)*code_param.data_bits_per_frame; + error_positions = xor( detected_data(1:code_param.data_bits_per_frame), data(st:en) ); + Nerrs = sum( error_positions); + + if Nerrs>0, fprintf(1,'x'), else fprintf(1,'.'), end + if (rem(nn, 50)==0), fprintf(1,'\n'), end + if Nerrs>0, Ferrs = Ferrs +1; end + Terrs = Terrs + Nerrs; + Tbits = Tbits + code_param.data_bits_per_frame; +end +fprintf(1,'\n') + diff --git a/codec2/branches/0.3/octave/load_raw.m b/codec2/branches/0.3/octave/load_raw.m new file mode 100644 index 00000000..1f7868d4 --- /dev/null +++ b/codec2/branches/0.3/octave/load_raw.m @@ -0,0 +1,8 @@ +% load_raw.m +% David Rowe 7 Oct 2009 + +function s = load_raw(fn) + fs=fopen(fn,"rb"); + s = fread(fs,Inf,"short"); + plot(s) +endfunction diff --git a/codec2/branches/0.3/octave/lpcpf.m b/codec2/branches/0.3/octave/lpcpf.m new file mode 100644 index 00000000..f1e0982c --- /dev/null +++ b/codec2/branches/0.3/octave/lpcpf.m @@ -0,0 +1,46 @@ +% lpcpf.m +% David Rowe Aug 27 2012 +% Experiments with LPC post filtering + +function lpcpf(ak_filename, f) + aks = load(ak_filename); + + ak = aks(f,:); + [tmp p] = size(ak); + p -= 1; + + A = freqz(1,ak, 4000); + AdB = 20*log10(abs(A)); + + gamma = 0.5; + gammas = gamma .^ (0:p); + W = freqz(ak .* gammas,1, 4000); + WdB = 20*log10(abs(W)); + + beta = 0.2; + R = abs(freqz(ak .* gammas, ak, 4000)); + %P = (R/max(R)) .^ beta; + P = R .^ beta; + AP = abs(A) .* P; + + eA = sum(abs(A) .^ 2); + eAP = sum(AP .^ 2); + gain = sqrt(eA/eAP) + AP *= gain; + + PdB = 20*log10(P); + + APdB = 20*log10(AP); + 10*log10(sum(AP .^ 2))/10*log10(sum(abs(A) .^ 2)) + + figure(1); + clf; + plot(AdB); + hold on; + plot(WdB,'g'); + plot(PdB,'r'); + plot(APdB,'b.'); + hold off; + +endfunction + diff --git a/codec2/branches/0.3/octave/lsp_pdf.m b/codec2/branches/0.3/octave/lsp_pdf.m new file mode 100644 index 00000000..4fc1359a --- /dev/null +++ b/codec2/branches/0.3/octave/lsp_pdf.m @@ -0,0 +1,91 @@ +% lsp_pdf.m +% David Rowe 2 Oct 2009 +% Plots histograms (PDF estimates) of LSP training data + +function lsp_pdf(lsp) + [r,c] = size(lsp); + + % LSPs + + figure(1); + clf; + [x,y] = hist(lsp(:,1),100); + plot(y*4000/pi,x,"+;1;"); + hold on; + for i=2:5 + [x,y] = hist(lsp(:,i),100); + legend = sprintf("+%d;%d;",i,i); + plot(y*4000/pi,x,legend); + endfor + for i=6:c + [x,y] = hist(lsp(:,i),100); + legend = sprintf("+%d;%d;",i-5,i); + plot(y*4000/pi,x,legend); + endfor + hold off; + grid; + + % LSP differences + + figure(2); + clf; + subplot(211) + [x,y] = hist(lsp(:,1),100); + plot(y*4000/pi,x,"1;1;"); + hold on; + for i=2:5 + [x,y] = hist(lsp(:,i) - lsp(:,i-1),100); + legend = sprintf("%d;%d;",i,i); + plot(y*4000/pi,x,legend); + endfor + hold off; + grid; + + subplot(212) + [x,y] = hist(lsp(:,6)-lsp(:,5),100); + plot(y*4000/pi,x,"1;6;"); + hold on; + for i=7:c + [x,y] = hist(lsp(:,i) - lsp(:,i-1),100); + legend = sprintf("%d;%d;",i-5,i); + plot(y*4000/pi,x,legend); + endfor + hold off; + grid; + + % LSP differences delta from last frame + + lspd(:,1) = lsp(:,1); + lspd(:,2:10) = lsp(:,2:10) - lsp(:,1:9); + + [m,n] = size(lspd); + lspdd = lspd(5:m,:) - lspd(1:m-4,:); + + figure(3); + clf; + subplot(211) + for i=1:5 + [x,y] = hist(lspdd(:,i),100); + legend = sprintf("%d;%d;",i,i); + plot(y*4000/pi,x,legend); + hold on; + endfor + hold off; + grid; + axis([-200 200 0 35000]); + + subplot(212) + for i=6:10 + [x,y] = hist(lspdd(:,i),100); + legend = sprintf("%d;%d;",i-5,i); + plot(y*4000/pi,x,legend); + hold on; + endfor + hold off; + grid; + axis([-200 200 0 16000]); + + figure(4); + clf; + plot((4000/pi)*(lsp(2:r,3)-lsp(1:r-1,3))) +endfunction diff --git a/codec2/branches/0.3/octave/lspwarp.m b/codec2/branches/0.3/octave/lspwarp.m new file mode 100644 index 00000000..2d2f2c99 --- /dev/null +++ b/codec2/branches/0.3/octave/lspwarp.m @@ -0,0 +1,40 @@ +% lspwarp.m +% David Rowe Sep 2012 +% +% Experimenting with non-linear LSP frequency axis for LSP quantisation +% Plots a scaled mel axis. + +1; + +function mel = freq2mel(f) + mel = 70*log10(1 + f/700); +endfunction + +function freq = mel2freq(m) + freq = 700*(10 ^ (m/70) - 1); +endfunction + +x = []; y = []; + +for freq = 100:25:4000 + mel = freq2mel(freq); + x = [x freq]; + y = [y mel]; +end + +plot(x,y) +grid + +mel_start = floor(freq2mel(100)); +mel_end = floor(freq2mel(4000)); + +x = []; y = []; +for mel=mel_start:mel_end + freq = mel2freq(mel); + x = [x freq]; + y = [y mel]; +end + +hold on; +plot(x,y, '+') +hold off; diff --git a/codec2/branches/0.3/octave/phase.m b/codec2/branches/0.3/octave/phase.m new file mode 100644 index 00000000..f9735903 --- /dev/null +++ b/codec2/branches/0.3/octave/phase.m @@ -0,0 +1,56 @@ +% phase.m +% David Rowe August 2009 +% experiments with phase for sinusoidal codecs + +function phase(samname, F0, png) + Wo=2*pi*F0/8000; + P=2*pi/Wo; + L = floor(pi/Wo); + Nsam = 16000; + N = 80; + F = Nsam/N; + A = 10000/L; + phi = zeros(1,L); + s = zeros(1,Nsam); + + for m=floor(L/2):L + phi_off(m) = -m*Wo*8; + end + + for f=1:F + phi(1) = phi(1) + Wo*N; + phi(1) = mod(phi(1),2*pi); + + for m=1:L + phi(m) = m*phi(1); + end + + x = zeros(1,N); + for m=1:L + x = x + A*cos(m*Wo*(0:(N-1)) + phi(m)); + endfor + s((f-1)*N+1:f*N) = x; + endfor + + figure(1); + clf; + plot(s(1:250)); + + fs=fopen(samname,"wb"); + fwrite(fs,s,"short"); + fclose(fs); + + if (nargin == 3) + % small image to fit blog + + __gnuplot_set__ terminal png size 450,300 + ss = sprintf("__gnuplot_set__ output \"%s.png\"", samname); + eval(ss) + replot; + + % for some reason I need this to stop large plot getting wiped + __gnuplot_set__ output "/dev/null" + endif + +endfunction + diff --git a/codec2/branches/0.3/octave/phase2.m b/codec2/branches/0.3/octave/phase2.m new file mode 100644 index 00000000..5c148f38 --- /dev/null +++ b/codec2/branches/0.3/octave/phase2.m @@ -0,0 +1,57 @@ +% phase2.m +% David Rowe Sep 2009 +% experiments with phase for sinusoidal codecs, looking at phase +% of excitation with real Am samples from hts1 + +function phase2(samname, png) + N = 16000; + + f=43; + model = load("../src/hts1a_phase_model.txt"); + phase = load("../src/hts1a_phase_phase.txt"); + Wo = model(f,1); + P=2*pi/Wo; + L = model(f,2); + A = model(f,3:(L+2)); + phi = phase(f,1:L); + phi = zeros(1,L); + phi(3) = -pi/2; + phi(4) = -pi/4; + phi(5) = pi/2; + + s = zeros(1,N); + + for m=3:5 + s_m = A(m)*cos(m*Wo*(0:(N-1)) + phi(m)); + s = s + s_m; + endfor + + figure(1); + clf; + plot(s(1:250)); + + figure(2); + clf; + subplot(211) + plot((1:L)*Wo*4000/pi, 20*log10(A),'+'); + subplot(212) + plot((1:L)*Wo*4000/pi, phi,'+'); + + fs=fopen(samname,"wb"); + fwrite(fs,s,"short"); + fclose(fs); + + if (nargin == 2) + % small image to fit blog + + __gnuplot_set__ terminal png size 450,300 + ss = sprintf("__gnuplot_set__ output \"%s.png\"", samname); + eval(ss) + replot; + + % for some reason I need this to stop large plot getting wiped + __gnuplot_set__ output "/dev/null" + endif + +endfunction + diff --git a/codec2/branches/0.3/octave/phasesecord.m b/codec2/branches/0.3/octave/phasesecord.m new file mode 100644 index 00000000..a3cf2516 --- /dev/null +++ b/codec2/branches/0.3/octave/phasesecord.m @@ -0,0 +1,47 @@ +% phasesecord.m +% David Rowe Aug 2012 +% Used to experiment with aproximations of phase of 2nd order systems + +function phasesecord(w,beta) + + a = [1 -2*cos(w)*beta beta*beta]; + b = 1; + + [h w1] = freqz(b,a); + + figure(1) + subplot(211) + plot(abs(h)) + subplot(212) + plot(angle(h)) + + % for beta close to 1, we approximate 3 dB points as 1-beta above + % and below the resonance freq. Note this fails if w=0 as there is a + % double pole. Lets sample the freq response at the 3dB points and + % w: + + ws = [w-(1-beta) w w+(1-beta)]; + [h w1] = freqz(b,a,ws); + + % gain as a fraction of max, should be 3dB. Within 1.3 dB or for w > pi/8, + % gets innacurate near w=0 due to 2nd pole + + printf("mag measured...:"); printf("% 4.3f ", abs(h)/max(abs(h))); + + % measured angle, 45 deg from angle at w + + printf("\nangle measured.: "); printf("% 5.3f ", angle(h)); + + % Our estimate of angle, (pi+w) is phase at resonance, at lower 3dB + % phase is pi/4 ahead, at upper 3B pi/4 behind. -pi/2 is contribution of + % other pole at at -w to phase + + ph_lower = (pi+w) + pi/4 - pi/2; + ph_res =(pi+w) - pi/2; + ph_upper = (pi+w) - pi/4 - pi/2; + ph_ests = [ph_lower ph_res ph_upper]; + ph_ests = ph_ests - 2*pi*(floor(ph_ests/(2*pi)) + 0.5); + printf("\nangle estimated:"); printf("% 5.3f ", ph_ests); + printf("\n"); +endfunction + diff --git a/codec2/branches/0.3/octave/pitch_test.m b/codec2/branches/0.3/octave/pitch_test.m new file mode 100644 index 00000000..3fe0d1ad --- /dev/null +++ b/codec2/branches/0.3/octave/pitch_test.m @@ -0,0 +1,39 @@ +% pitch_test.m +% David Rowe Sep 2009 +% Constructs a sequence to test the pitch estimator + +function pitch_test(samname) + M=320; + F=200; + + fs=fopen(samname,"wb"); + + f0 = 100; + for f=1:200 + Wo=2*pi*f0/8000; + P=2*pi/Wo; + L = floor(pi/Wo); + A = 10000/L; + phi = zeros(1,L); + s = zeros(1,M); + + for m=1:L + s = s + A*cos(m*Wo*(0:(M-1)) + phi(m)); + endfor + + figure(1); + clf; + plot(s); + + fwrite(fs,s,"short"); + + f0 = f0 + 5; + if (f0 > 400) + f0 = 100; + endif + endfor + + fclose(fs); + +endfunction + diff --git a/codec2/branches/0.3/octave/pl.m b/codec2/branches/0.3/octave/pl.m new file mode 100644 index 00000000..0d547882 --- /dev/null +++ b/codec2/branches/0.3/octave/pl.m @@ -0,0 +1,45 @@ +% Copyright David Rowe 2009 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% Plots a raw speech sample file, you can optionally specify the start and end +% samples and create a large and small PNGs + +function pl(samname1, start_sam, end_sam, pngname) + + fs=fopen(samname1,"rb"); + s=fread(fs,Inf,"short"); + + st = 1; + en = length(s); + if (nargin >= 2) + st = start_sam; + endif + if (nargin >= 3) + en = end_sam; + endif + + figure(1); + clf; + plot(s(st:en)); + axis([1 en-st 1.1*min(s) 1.1*max(s)]); + + if (nargin == 4) + + % small image + + __gnuplot_set__ terminal png size 420,300 + ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname); + eval(ss) + replot; + + % larger image + + __gnuplot_set__ terminal png size 800,600 + ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname); + eval(ss) + replot; + + endif + +endfunction diff --git a/codec2/branches/0.3/octave/pl2.m b/codec2/branches/0.3/octave/pl2.m new file mode 100644 index 00000000..17671c08 --- /dev/null +++ b/codec2/branches/0.3/octave/pl2.m @@ -0,0 +1,41 @@ +% Copyright David Rowe 2009 +% This program is distributed under the terms of the GNU General Public License +% Version 2 + +function pl2(samname1, samname2, start_sam, end_sam, offset) + + fs1=fopen(samname1,"rb"); + s1=fread(fs1,Inf,"short"); + fs2=fopen(samname2,"rb"); + s2=fread(fs2,Inf,"short"); + + st1 = st2 = 1; + en1 = en2 = length(s1); + if (nargin >= 3) + st1 = st2 = start_sam; + endif + if (nargin >= 4) + en1 = en2 = end_sam; + endif + + if (nargin == 5) + st2 += offset + en2 += offset + endif + + figure(1); + clf; + subplot(211); + l1 = strcat("r;",samname1,";"); + plot(s1(st1:en1), l1); + axis([1 en1-st1 min(s1(st1:en1)) max(s1(st1:en1))]); + subplot(212); + l2 = strcat("r;",samname2,";"); + plot(s2(st2:en2),l2); + axis([1 en2-st2 min(s1(st2:en2)) max(s1(st2:en2))]); + + figure(2) + plot(s1(st1:en1)-s2(st2:en2)); + + +endfunction diff --git a/codec2/branches/0.3/octave/plamp.m b/codec2/branches/0.3/octave/plamp.m new file mode 100644 index 00000000..62b6893a --- /dev/null +++ b/codec2/branches/0.3/octave/plamp.m @@ -0,0 +1,197 @@ +% Copyright David Rowe 2009 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% Plot ampltiude modelling information from dump files. + +function plamp(samname, f, samname2) + + % switch some stuff off to unclutter display + + plot_lsp = 0; + plot_snr = 0; + plot_vsnr = 0; + plot_sw = 0; + plot_pw = 0; + + sn_name = strcat(samname,"_sn.txt"); + Sn = load(sn_name); + + sw_name = strcat(samname,"_sw.txt"); + Sw = load(sw_name); + + sw__name = strcat(samname,"_sw_.txt"); + if (file_in_path(".",sw__name)) + Sw_ = load(sw__name); + endif + + ew_name = strcat(samname,"_ew.txt"); + if (file_in_path(".",ew_name)) + Ew = load(ew_name); + endif + + rk_name = strcat(samname,"_rk.txt"); + if (file_in_path(".",rk_name)) + Rk = load(rk_name); + endif + + model_name = strcat(samname,"_model.txt"); + model = load(model_name); + + modelq_name = strcat(samname,"_qmodel.txt"); + if (file_in_path(".",modelq_name)) + modelq = load(modelq_name); + endif + + pw_name = strcat(samname,"_pw.txt"); + if (file_in_path(".",pw_name)) + Pw = load(pw_name); + endif + + lsp_name = strcat(samname,"_lsp.txt"); + if (file_in_path(".",lsp_name)) + lsp = load(lsp_name); + endif + + phase_name = strcat(samname,"_phase.txt"); + if (file_in_path(".",phase_name)) + phase = load(phase_name); + endif + + phase_name_ = strcat(samname,"_phase_.txt"); + if (file_in_path(".",phase_name_)) + phase_ = load(phase_name_); + endif + + snr_name = strcat(samname,"_snr.txt"); + if (file_in_path(".",snr_name)) + snr = load(snr_name); + endif + + % optional second file, for exploring post filter + + model2q_name = " "; + if nargin == 3 + model2q_name = strcat(samname2,"_qmodel.txt"); + if file_in_path(".",modelq_name) + model2q = load(model2q_name); + end + end + + Ew_on = 1; + k = ' '; + do + figure(1); + clf; +% s = [ Sn(2*(f-2)-1,:) Sn(2*(f-2),:) ]; + s = [ Sn(2*f-1,:) Sn(2*f,:) ]; + size(s); + plot(s); + axis([1 length(s) -20000 20000]); + + figure(2); + Wo = model(f,1); + L = model(f,2); + Am = model(f,3:(L+2)); + plot((1:L)*Wo*4000/pi, 20*log10(Am),";Am;r"); + axis([1 4000 -10 80]); + hold on; + if plot_sw + plot((0:255)*4000/256, Sw(f,:),";Sw;"); + end + + if (file_in_path(".",modelq_name)) + Amq = modelq(f,3:(L+2)); + plot((1:L)*Wo*4000/pi, 20*log10(Amq),";Amq;g" ); + if (file_in_path(".",pw_name) && plot_pw) + plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;c"); + endif + signal = Am * Am'; + noise = (Am-Amq) * (Am-Amq)'; + snr1 = 10*log10(signal/noise); + Am_err_label = sprintf(";Am error SNR %4.2f dB;m",snr1); + plot((1:L)*Wo*4000/pi, 20*log10(Amq) - 20*log10(Am), Am_err_label); + endif + + if file_in_path(".",model2q_name) + Amq2 = model2q(f,3:(L+2)); + plot((1:L)*Wo*4000/pi, 20*log10(Amq2),";Amq2;m" ); + end + + if (file_in_path(".",snr_name) && plot_vsnr) + snr_label = sprintf(";Voicing SNR %4.2f dB;",snr(f)); + plot(1,1,snr_label); + endif + + % phase model - determine SNR and error spectrum for phase model 1 + + if (file_in_path(".",phase_name_)) + orig = Am.*exp(j*phase(f,1:L)); + synth = Am.*exp(j*phase_(f,1:L)); + signal = orig * orig'; + noise = (orig-synth) * (orig-synth)'; + snr_phase = 10*log10(signal/noise); + + %phase_err_label = sprintf(";phase_err SNR %4.2f dB;",snr_phase); + %plot((1:L)*Wo*4000/pi, 20*log10(orig-synth), phase_err_label); + endif + + if (file_in_path(".",lsp_name) && plot_lsp) + for l=1:10 + plot([lsp(f,l)*4000/pi lsp(f,l)*4000/pi], [60 80], 'r'); + endfor + endif + + hold off; + + %if (file_in_path(".",phase_name)) + %figure(3); + %plot((1:L)*Wo*4000/pi, phase(f,1:L), ";phase;"); + %axis; + %if (file_in_path(".",phase_name_)) + %hold on; + %plot((1:L)*Wo*4000/pi, phase_(f,1:L), ";phase_;"); + %hold off; + %endif + %figure(2); + %endif + + % interactive menu + + printf("\rframe: %d menu: n-next b-back p-png q-quit e-toggle Ew", f); + fflush(stdout); + k = kbhit(); + if (k == 'n') + f = f + 1; + endif + if (k == 'b') + f = f - 1; + endif + if (k == 'e') + if (Ew_on == 1) + Ew_on = 0; + else + Ew_on = 1; + endif + endif + + % optional print to PNG + + if (k == 'p') + figure(1); + pngname = sprintf("%s_%d_sn.png",samname,f); + print(pngname, '-dpng', "-S500,500") + pngname = sprintf("%s_%d_sn_large.png",samname,f); + print(pngname, '-dpng', "-S800,600") + + figure(2); + pngname = sprintf("%s_%d_sw.png",samname,f); + print(pngname, '-dpng', "-S500,500") + pngname = sprintf("%s_%d_sw_large.png",samname,f); + print(pngname, '-dpng', "-S1200,800") + endif + + until (k == 'q') + printf("\n"); + +endfunction diff --git a/codec2/branches/0.3/octave/plinterp.m b/codec2/branches/0.3/octave/plinterp.m new file mode 100644 index 00000000..794a0853 --- /dev/null +++ b/codec2/branches/0.3/octave/plinterp.m @@ -0,0 +1,11 @@ +load ../unittest/tinterp_prev.txt; +load ../unittest/tinterp_interp.txt; +load ../unittest/tinterp_next.txt; + +clf; +plot(tinterp_prev(:,1), 20.0*log10(tinterp_prev(:,2)),";prev;") +hold on; +plot(tinterp_interp(:,1), 20.0*log10(tinterp_interp(:,2)),'g+-;interp;') +plot(tinterp_next(:,1), 20.0*log10(tinterp_next(:,2)),'ro-;next;') +hold off; +axis([0 pi 0 80]) diff --git a/codec2/branches/0.3/octave/pllpcpf.m b/codec2/branches/0.3/octave/pllpcpf.m new file mode 100644 index 00000000..924e045a --- /dev/null +++ b/codec2/branches/0.3/octave/pllpcpf.m @@ -0,0 +1,150 @@ +% Copyright David Rowe 2012 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% Plot amplitude modelling information from dump files to test and develop +% LPC post filter. + +function pllpcpf(samname, f) + + % switch some stuff off to unclutter display + + plot_Am = 0; + plot_Amq = 0; + plot_err = 0; + plot_lsp = 0; + plot_snr = 0; + plot_vsnr = 0; + plot_sw = 0; + plot_pw = 1; + plot_pwb = 1; + plot_rw = 1; + + sn_name = strcat(samname,"_sn.txt"); + Sn = load(sn_name); + + sw_name = strcat(samname,"_sw.txt"); + Sw = load(sw_name); + + sw__name = strcat(samname,"_sw_.txt"); + if (file_in_path(".",sw__name)) + Sw_ = load(sw__name); + endif + + model_name = strcat(samname,"_model.txt"); + model = load(model_name); + + modelq_name = strcat(samname,"_qmodel.txt"); + if (file_in_path(".",modelq_name)) + modelq = load(modelq_name); + endif + + % Pw (LPC synth filter spectrum) before post filter + + pwb_name = strcat(samname,"_pwb.txt"); + if (file_in_path(".",pwb_name)) + Pwb = load(pwb_name); + endif + + % Rw (Post filter spectrum) + + rw_name = strcat(samname,"_rw.txt"); + if (file_in_path(".",rw_name)) + Rw = load(rw_name); + endif + + % Pw (LPC synth filter spectrum) after post filter + + pw_name = strcat(samname,"_pw.txt"); + if (file_in_path(".",pw_name)) + Pw = load(pw_name); + endif + + + Ew_on = 1; + k = ' '; + do + figure(1); + clf; + s = [ Sn(2*f-1,:) Sn(2*f,:) ]; + size(s); + plot(s); + axis([1 length(s) -20000 20000]); + + figure(2); + clf; + Wo = model(f,1); + L = model(f,2); + Am = model(f,3:(L+2)); + if plot_Am + plot((1:L)*Wo*4000/pi, 20*log10(Am),";Am;r"); + end + axis([1 4000 -10 80]); + hold on; + if plot_sw + plot((0:255)*4000/256, Sw(f,:),";Sw;"); + end + + if (file_in_path(".",modelq_name)) + + Amq = modelq(f,3:(L+2)); + if plot_Amq + plot((1:L)*Wo*4000/pi, 20*log10(Amq),";Amq;g" ); + end + + if (file_in_path(".",pwb_name) && plot_pwb) + plot((0:255)*4000/256, 10*log10(Pwb(f,:)),";Pwb;r"); + endif + + if (file_in_path(".",rw_name) && plot_rw) + plot((0:255)*4000/256, 10*log10(Rw(f,:)),";Rw;b"); + endif + + if (file_in_path(".",pw_name) && plot_pw) + plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;g."); + endif + + signal = Am * Am'; + noise = (Am-Amq) * (Am-Amq)'; + snr1 = 10*log10(signal/noise); + Am_err_label = sprintf(";Am error SNR %4.2f dB;m",snr1); + if plot_err + plot((1:L)*Wo*4000/pi, 20*log10(Amq) - 20*log10(Am), Am_err_label); + end + endif + + + hold off; + + % interactive menu + + printf("\rframe: %d menu: n-next b-back p-png q-quit", f); + fflush(stdout); + k = kbhit(); + if (k == 'n') + f = f + 1; + endif + if (k == 'b') + f = f - 1; + endif + + % optional print to PNG + + if (k == 'p') + figure(1); + pngname = sprintf("%s_%d_sn.png",samname,f); + print(pngname, '-dpng', "-S500,500") + pngname = sprintf("%s_%d_sn_large.png",samname,f); + print(pngname, '-dpng', "-S800,600") + + figure(2); + pngname = sprintf("%s_%d_sw.png",samname,f); + print(pngname, '-dpng', "-S500,500") + pngname = sprintf("%s_%d_sw_large.png",samname,f); + print(pngname, '-dpng', "-S1200,800") + endif + + until (k == 'q') + printf("\n"); + +endfunction diff --git a/codec2/branches/0.3/octave/pllsp.m b/codec2/branches/0.3/octave/pllsp.m new file mode 100644 index 00000000..0606d3ca --- /dev/null +++ b/codec2/branches/0.3/octave/pllsp.m @@ -0,0 +1,46 @@ +% Copyright David Rowe 2010 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% Plots a bunch of information related to LSP quantisation: +% - speech file +% - LSPs before and after quantisation +% - SNR for each frame +% +% Note: there is a 160 sample (two frame delay) from the when a sample +% enters the input buffer until it is at the centre of the analysis window + +function pllsp(rawfile, + dumpfile_prefix_lpc_only, + dumpfile_prefix_lsp, + start_f, end_f) + + fs=fopen(rawfile,"rb"); + s=fread(fs,Inf,"short"); + + lpc_snr_name = strcat(dumpfile_prefix_lpc_only,"_lpc_snr.txt"); + lpc10_snr = load(lpc_snr_name); + lpc_snr_name = strcat(dumpfile_prefix_lsp,"_lpc_snr.txt"); + lsp_snr = load(lpc_snr_name); + + lsp_name = strcat(dumpfile_prefix_lsp,"_lsp.txt"); + lsps = load(lsp_name); + [m,n]=size(lsps); + lsp = lsps(1:2:m,:); + lsp_ = lsps(2:2:m,:); + + figure(1); + clf; + subplot(211); + sp = s((start_f-2)*80:(end_f-2)*80); + plot(sp); + + subplot(212); + plot(lpc10_snr((start_f+1):end_f)-lsp_snr((start_f+1):end_f)); + + figure(2); + plot((4000/pi)*lsp((start_f+1):end_f,:)); + hold on; + plot((4000/pi)*lsp_((start_f+1):end_f,:),'+-'); + hold off; +endfunction diff --git a/codec2/branches/0.3/octave/pllspdt.m b/codec2/branches/0.3/octave/pllspdt.m new file mode 100644 index 00000000..c711aa46 --- /dev/null +++ b/codec2/branches/0.3/octave/pllspdt.m @@ -0,0 +1,27 @@ +% pllspdt.m +% Copyright David Rowe 2010 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% Test script to plot differences in LSps between frames + +function pllspdt(rawfile,dumpfile_prefix_lsp,lspn, start_f, end_f) + + fs=fopen(rawfile,"rb"); + s=fread(fs,Inf,"short"); + + lsp_name = strcat(dumpfile_prefix_lsp,"_lsp.txt"); + lsps = load(lsp_name); + [m,n]=size(lsps); + lsp = lsps(1:2:m,:); + lsp_ = lsps(2:2:m,:); + lspdt = lsp(2:m/2,:) - lsp(1:m/2-1,:); + + figure(1); + clf; + sp = s((start_f-2)*80:(end_f-2)*80); + plot(sp); + + figure(2); + plot((4000/pi)*lspdt((start_f+1):end_f,lspn)); +endfunction diff --git a/codec2/branches/0.3/octave/plnlp.m b/codec2/branches/0.3/octave/plnlp.m new file mode 100644 index 00000000..01b49311 --- /dev/null +++ b/codec2/branches/0.3/octave/plnlp.m @@ -0,0 +1,134 @@ +% Copyright David Rowe 2009 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% Plot NLP states from dump files. + +function plnlp(samname, f) + + sn_name = strcat(samname,"_sn.txt"); + Sn = load(sn_name); + + sw_name = strcat(samname,"_sw.txt"); + Sw = load(sw_name); + + fw_name = strcat(samname,"_fw.txt"); + if (file_in_path(".",fw_name)) + fw = load(fw_name); + endif + + e_name = strcat(samname,"_e.txt"); + if (file_in_path(".",e_name)) + e = load(e_name); + endif + + p_name = strcat(samname,".p"); + if (file_in_path(".",p_name)) + p = load(p_name); + endif + + sq_name = strcat(samname,"_sq.txt"); + if (file_in_path(".",sq_name)) + sq = load(sq_name); + endif + + dec_name = strcat(samname,"_dec.txt"); + if (file_in_path(".",dec_name)) + dec = load(dec_name); + endif + + do + figure(1); + clf; + s = [ Sn(2*f-1,:) Sn(2*f,:) ]; + plot(s, ";Sn;"); + grid + axis([1 length(s) -20000 20000]); + + figure(2); + plot((0:255)*4000/256, Sw(f,:),";Sw;"); + grid + axis([1 4000 -10 80]); + hold on; + + f0 = 8000/p(f); + Wo = 2*pi/p(f); + L = floor(pi/Wo); + f0_label = sprintf("b;P=%3.1f F0=%3.0f;",p(f),f0); + for m=1:L-1 + plot([ m*Wo*4000/pi m*Wo*4000/pi], [10 60], 'b'); + endfor + plot([ L*Wo*4000/pi L*Wo*4000/pi], [10 60], f0_label); + + hold off; + + if (file_in_path(".",fw_name)) + figure(3); + if (file_in_path(".",e_name)) + subplot(211); + endif + plot((0:255)*800/256, fw(f,:)/max(fw(f,:)), ";Fw;"); + axis([1 400 0 1]); + if (file_in_path(".",e_name)) + subplot(212); + e_concat = [ e(2*f-1,:) e(2*f,:) ]; + plot(e_concat(1:400)/max(e_concat(1:400)), "+;MBE E(f);"); + axis([1 400 0 1]); + endif + endif + + if (file_in_path(".",sq_name)) + figure(4); + sq_concat = [ sq(2*f-1,:) sq(2*f,:) ]; + axis + plot(sq_concat, ";sq;"); + endif + + if (file_in_path(".",dec_name)) + figure(5); + plot(dec(f,:), ";dec;"); + endif + + figure(2); + + % interactive menu + + printf("\rframe: %d menu: n-next b-back p-png q-quit ", f); + fflush(stdout); + k = kbhit(); + if (k == 'n') + f = f + 1; + endif + if (k == 'b') + f = f - 1; + endif + + % optional print to PNG + + if (k == 'p') + + pngname = sprintf("%s_%d",samname,f); + + % small image + + __gnuplot_set__ terminal png size 420,300 + ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname); + eval(ss) + replot; + + % larger image + + __gnuplot_set__ terminal png size 800,600 + ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname); + eval(ss) + replot; + + % for some reason I need this to stop large plot getting wiped + __gnuplot_set__ output "/dev/null" + + endif + + until (k == 'q') + printf("\n"); + +endfunction diff --git a/codec2/branches/0.3/octave/plphase.m b/codec2/branches/0.3/octave/plphase.m new file mode 100644 index 00000000..c12422ea --- /dev/null +++ b/codec2/branches/0.3/octave/plphase.m @@ -0,0 +1,198 @@ +% Copyright David Rowe 2009 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% Plot phase modelling information from dump files. + +function plphase(samname, f) + + sn_name = strcat(samname,"_sn.txt"); + Sn = load(sn_name); + + sw_name = strcat(samname,"_sw.txt"); + Sw = load(sw_name); + + model_name = strcat(samname,"_model.txt"); + model = load(model_name); + + sw__name = strcat(samname,"_sw_.txt"); + if (file_in_path(".",sw__name)) + Sw_ = load(sw__name); + endif + + pw_name = strcat(samname,"_pw.txt"); + if (file_in_path(".",pw_name)) + Pw = load(pw_name); + endif + + ak_name = strcat(samname,"_ak.txt"); + if (file_in_path(".",ak_name)) + ak = load(ak_name); + endif + + phase_name = strcat(samname,"_phase.txt"); + if (file_in_path(".",phase_name)) + phase = load(phase_name); + endif + + phase_name_ = strcat(samname,"_phase_.txt"); + if (file_in_path(".",phase_name_)) + phase_ = load(phase_name_); + endif + + snr_name = strcat(samname,"_snr.txt"); + if (file_in_path(".",snr_name)) + snr = load(snr_name); + endif + + sn_name_ = strcat(samname,".raw"); + if (file_in_path(".",sn_name_)) + fs_ = fopen(sn_name_,"rb"); + sn_ = fread(fs_,Inf,"short"); + endif + + k = ' '; + do + figure(1); + clf; + s = [ Sn(2*f-1,:) Sn(2*f,:) ]; + plot(s); + grid; + axis([1 length(s) -20000 20000]); + if (k == 'p') + pngname = sprintf("%s_%d_sn",samname,f); + png(pngname); + endif + + figure(2); + Wo = model(f,1); + L = model(f,2); + Am = model(f,3:(L+2)); + plot((1:L)*Wo*4000/pi, 20*log10(Am),"r;Am;"); + axis([1 4000 -10 80]); + hold on; + plot((0:255)*4000/256, Sw(f,:),";Sw;"); + grid; + + if (file_in_path(".",sw__name)) + plot((0:255)*4000/256, Sw_(f,:),"g;Sw_;"); + endif + + if (file_in_path(".",pw_name)) + plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;"); + endif + + if (file_in_path(".",snr_name)) + snr_label = sprintf(";phase SNR %4.2f dB;",snr(f)); + plot(1,1,snr_label); + endif + + % phase model - determine SNR and error spectrum for phase model 1 + + if (file_in_path(".",phase_name_)) + orig = Am.*exp(j*phase(f,1:L)); + synth = Am.*exp(j*phase_(f,1:L)); + signal = orig * orig'; + noise = (orig-synth) * (orig-synth)'; + snr_phase = 10*log10(signal/noise); + + phase_err_label = sprintf("g;phase_err SNR %4.2f dB;",snr_phase); + plot((1:L)*Wo*4000/pi, 20*log10(orig-synth), phase_err_label); + endif + + hold off; + if (k == 'p') + pngname = sprintf("%s_%d_sw",samname,f); + png(pngname); + endif + + if (file_in_path(".",phase_name)) + figure(3); + plot((1:L)*Wo*4000/pi, phase(f,1:L)*180/pi, "-o;phase;"); + axis; + if (file_in_path(".", phase_name_)) + hold on; + plot((1:L)*Wo*4000/pi, phase_(f,1:L)*180/pi, "g;phase after;"); + grid + hold off; + endif + if (k == 'p') + pngname = sprintf("%s_%d_phase",samname,f); + png(pngname); + endif + endif + + % synthesised speech + + if (file_in_path(".",sn_name_)) + figure(4); + s_ = sn_((f-3)*80+1:(f+1)*80); + plot(s_); + axis([1 length(s_) -20000 20000]); + if (k == 'p') + pngname = sprintf("%s_%d_sn_",samname,f) + png(pngname); + endif + endif + + if (file_in_path(".",ak_name)) + figure(5); + axis; + akw = ak(f,:); + weight = 1.0 .^ (0:length(akw)-1); + akw = akw .* weight; + H = 1./fft(akw,8000); + subplot(211); + plot(20*log10(abs(H(1:4000))),";LPC mag spec;"); + grid; + subplot(212); + plot(angle(H(1:4000))*180/pi,";LPC phase spec;"); + grid; + if (k == 'p') + % stops multimode errors from gnuplot, I know not why... + figure(2); + figure(5); + + pngname = sprintf("%s_%d_lpc",samname,f); + png(pngname); + endif + endif + + + % autocorrelation function to research voicing est + + %M = length(s); + %sw = s .* hanning(M)'; + %for k=0:159 + % R(k+1) = sw(1:320-k) * sw(1+k:320)'; + %endfor + %figure(4); + %R_label = sprintf(";R(k) %3.2f;",max(R(20:159))/R(1)); + %plot(R/R(1),R_label); + %grid + + figure(2); + + % interactive menu + + printf("\rframe: %d menu: n-next b-back p-png q-quit ", f); + fflush(stdout); + k = kbhit(); + if (k == 'n') + f = f + 1; + endif + if (k == 'b') + f = f - 1; + endif + + % optional print to PNG + + if (k == 'p') + pngname = sprintf("%s_%d",samname,f); + png(pngname); + endif + + until (k == 'q') + printf("\n"); + +endfunction diff --git a/codec2/branches/0.3/octave/plpitch.m b/codec2/branches/0.3/octave/plpitch.m new file mode 100644 index 00000000..69ad5338 --- /dev/null +++ b/codec2/branches/0.3/octave/plpitch.m @@ -0,0 +1,36 @@ +% Copyright David Rowe 2009 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% plpitch.m +% Plots two pitch tracks on top of each other, used for comparing pitch +% estimators + +function plpitch(pitch1_name, pitch2_name, start_fr, end_fr) + + pitch1 = load(pitch1_name); + pitch2 = load(pitch2_name); + + st = 1; + en = length(pitch1); + if (nargin >= 3) + st = start_fr; + endif + if (nargin >= 4) + en = end_fr; + endif + + figure(1); + clf; + l1 = strcat("r;",pitch1_name,";") + l1 + st + en + plot(pitch1(st:en), l1); + axis([1 en-st 20 160]); + l2 = strcat("g;",pitch2_name,";"); + hold on; + plot(pitch2(st:en),l2); + hold off; +endfunction + diff --git a/codec2/branches/0.3/octave/plppe.m b/codec2/branches/0.3/octave/plppe.m new file mode 100644 index 00000000..cbc5b562 --- /dev/null +++ b/codec2/branches/0.3/octave/plppe.m @@ -0,0 +1,65 @@ +% Copyright David Rowe 2009 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% Plot two sparse phase prediction error text files. +% Generate data from print_pred_error, print_pred_error_sparse_wo_correction1 etc + +function plppe(ppe1_file, ppe2_file, f) + + ppe1 = load(ppe1_file); + ppe2 = load(ppe2_file); + + std1 = std(nonzeros(ppe1(:,40:80))); + std2 = std(nonzeros(ppe2(:,40:80))); + + printf("std dev for %s is %4.3f\n", ppe1_file, std1); + printf("std dev for %s is %4.3f\n", ppe2_file, std2); + + figure(1); + clf; + subplot(211) + hist(nonzeros(ppe1(:,40:80)),20); + subplot(212) + hist(nonzeros(ppe2(:,40:80)),20); + + k = ' '; + do + figure(2); + clf; + subplot(211) + L = length(nonzeros(ppe1(f,:))); + x = (1:L)*4000/L; + std1 = std(nonzeros(ppe1(f,:))); + legend = sprintf(";std dev %4.3f;", std1); + plot(x, nonzeros(ppe1(f,:)),legend); + axis([0 4000 -pi pi]); + subplot(212) + std2 = std(nonzeros(ppe2(f,:))); + legend = sprintf(";std dev %4.3f;", std2); + plot(x, nonzeros(ppe2(f,:)),legend); + axis([0 4000 -pi pi]); + + % interactive menu + + printf("\rframe: %d menu: n-next b-back p-png q-quit ", f); + fflush(stdout); + k = kbhit(); + if (k == 'n') + f = f + 1; + endif + if (k == 'b') + f = f - 1; + endif + + % optional print to PNG + + if (k == 'p') + pngname = sprintf("%s_%d",samname,f); + png(pngname); + endif + + until (k == 'q') + printf("\n"); + +endfunction diff --git a/codec2/branches/0.3/octave/plsub.m b/codec2/branches/0.3/octave/plsub.m new file mode 100644 index 00000000..6e2bc1ea --- /dev/null +++ b/codec2/branches/0.3/octave/plsub.m @@ -0,0 +1,35 @@ +% Copyright David Rowe 2010 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% plots the difference of two files + +function plsub(samname1, samname2, start_sam, end_sam, pngname) + + fs1=fopen(samname1,"rb"); + s1=fread(fs1,Inf,"short"); + fs2=fopen(samname2,"rb"); + s2=fread(fs2,Inf,"short"); + + st = 1; + en = length(s1); + if (nargin >= 3) + st = start_sam; + endif + if (nargin >= 4) + en = end_sam; + endif + + figure(1); + clf; + l1 = strcat("r;",samname1,";"); + plot(s1(st:en) - s2(st:en), l1); + %axis([1 en-st min(s1(st:en)) max(s1(st:en))]); + + if (nargin == 5) + pngname = sprintf("%s.png",pngname); + print(pngname, '-dpng', "-S500,500") + pngname = sprintf("%s_large.png",pngname); + print(pngname, '-dpng', "-S800,600") + endif + +endfunction diff --git a/codec2/branches/0.3/octave/plvoicing.m b/codec2/branches/0.3/octave/plvoicing.m new file mode 100644 index 00000000..a5317476 --- /dev/null +++ b/codec2/branches/0.3/octave/plvoicing.m @@ -0,0 +1,89 @@ +% Copyright David Rowe 2009 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% Plot voicing information from sample and dump files. +% +% samfilename is the raw source file, e.g. "../raw/hts1a.raw" +% samname is the dumpfile prefix, e.g. "../src/hts1a" +% +% There is a 160 sample (two frame delay) from the when a sample +% enters the input buffer until it is at the centre of the analysis window + +function plvoicing(samfilename, samname, start_f, end_f, pngname) + + fs=fopen(samfilename,"rb"); + s=fread(fs,Inf,"short"); + + snr_name = strcat(samname,"_snr.txt"); + snr = load(snr_name); + model_name = strcat(samname,"_model.txt"); + model = load(model_name); + + Wo = model((start_f+1):end_f,1); + F0 = Wo*4000/pi; + dF0 = F0(1:length(Wo)-1) - F0(2:length(Wo)); + + % work out LP and HP energy + + for f=(start_f+1):end_f + L = model(f,2); + Am = model(f,3:(L+2)); + L2 = floor(L/2); + elow = Am(1:L2) * Am(1:L2)'; + ehigh = Am(L2:L) * Am(L2:L)'; + erat(f-(start_f+1)+1) = 10*log10(elow/ehigh); + endfor + + figure(1); + clf; + sp = s((start_f-2)*80:(end_f-2)*80); + plot(sp); + hold on; + vhigh = snr((start_f+1):end_f) > 7; + vlow = snr((start_f+1):end_f) > 4; + + % test correction based on erat + + vlowadj = vlow; + + for f=1:length(erat)-1 + if (vlow(f) == 0) + if (erat(f) > 10) + vlowadj(f) = 1; + endif + endif + if (vlow(f) == 1) + if (erat(f) < -10) + vlowadj(f) = 0; + endif + if (abs(dF0(f)) > 15) + vlowadj(f) = 0; + endif + endif + endfor + + x = 1:(end_f-start_f); + plot(x*80,snr((start_f+1):end_f)*1000,';SNRdB x 1000;g+'); + plot(x*80,-8000 + vhigh*2000,';7dB thresh;g'); + plot(x*80,-11000 + vlowadj*2000,';vlow with corr;g'); + plot(x*80,erat*1000,';elow/ehigh in dB;r'); + plot(x*80,-14000 + vlow*2000,';4dB thresh;r'); + hold off; + grid + if (nargin == 5) + print(pngname, "-dpng", "-S500,500") + endif + + figure(2) + Wo = model((start_f+1):end_f,1); + F0 = Wo*4000/pi; + dF0 = F0(1:length(Wo)-1) - F0(2:length(Wo)); + %plot(dF0,'+--') + %hold on; + %plot([ 1 length(dF0) ], [10 10] ,'r') + %plot([ 1 length(dF0) ], [-10 -10] ,'r') + %axis([1 length(dF0) -50 50]) + %hold off; + plot(F0,'+--') +endfunction diff --git a/codec2/branches/0.3/octave/png.m b/codec2/branches/0.3/octave/png.m new file mode 100644 index 00000000..09a79968 --- /dev/null +++ b/codec2/branches/0.3/octave/png.m @@ -0,0 +1,25 @@ +% Copyright David Rowe 2009 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% Replot current plot as a png, generates small and large versions + +function png(pngname) + % small image + + __gnuplot_set__ terminal png size 420,300 + ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname); + eval(ss) + replot; + + % larger image + + __gnuplot_set__ terminal png size 800,600 + ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname); + eval(ss) + replot; + + % for some reason I need this to stop large plot getting wiped + __gnuplot_set__ output "/dev/null" + +endfunction diff --git a/codec2/branches/0.3/octave/postfilter.m b/codec2/branches/0.3/octave/postfilter.m new file mode 100644 index 00000000..84f7dfc7 --- /dev/null +++ b/codec2/branches/0.3/octave/postfilter.m @@ -0,0 +1,24 @@ +% Copyright David Rowe 2009 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% +% Plot postfilter doing its thing + +function postfilter(samname) + p = load(samname); + figure(1); + plot(p(:,1),";energy;"); + hold on; + plot(p(:,2),";bg_est;"); + hold off; + grid; + pngname=sprintf("%s_postfilter_1", samname); + png(pngname); + + figure(2); + plot(p(:,3),";% unvoiced;"); + grid; + pngname=sprintf("%s_postfilter_2", samname); + png(pngname); +endfunction + diff --git a/codec2/branches/0.3/octave/pulse.m b/codec2/branches/0.3/octave/pulse.m new file mode 100644 index 00000000..223389e7 --- /dev/null +++ b/codec2/branches/0.3/octave/pulse.m @@ -0,0 +1,37 @@ +% pulse.m +% David Rowe August 2009 +% +% Experiments with human pulse perception for sinusoidal codecs + +function pulse(samname) + + A = 1000; + K = 16000; + N = 80; + frames = K/N; + s = zeros(1,K); + + for f=1:frames + % lets try placing np random pulses in every frame + + P = 20 + (160-20)*rand(1,1); + Wo = 2*pi/P; + L = floor(pi/Wo); + sf = zeros(1,N); + for m=1:L/2:L + pos = floor(rand(1,1)*N)+1; + %pos = 50; + for l=m:m+L/2-1 + sf = sf + A*cos(l*Wo*((f-1)*N+1:f*N) - pos*l*Wo); + endfor + endfor + s((f-1)*N+1:f*N) = sf; + endfor + + plot(s(1:250)); + + fs=fopen(samname,"wb"); + fwrite(fs,s,"short"); + fclose(fs); +endfunction + diff --git a/codec2/branches/0.3/octave/sd.m b/codec2/branches/0.3/octave/sd.m new file mode 100644 index 00000000..efff9061 --- /dev/null +++ b/codec2/branches/0.3/octave/sd.m @@ -0,0 +1,99 @@ +% sd.m +% David Rowe Aug 2012 +% Plots the spectal distorion between twofiles of LPCs. Used for LSP +% quantisation tuning. + +function sd(raw_filename, dump_file_prefix, f) + + ak1_filename = sprintf("%s_ak.txt", dump_file_prefix); + ak2_filename = sprintf("%s_ak_.txt", dump_file_prefix); + ak1 = load(ak1_filename); + ak2 = load(ak2_filename); + + [ak1_r, ak1_c] = size(ak1); + [ak2_r, ak2_c] = size(ak1); + + frames = max([ak1_r ak2_r]); + sd = zeros(1,frames); + Ndft = 512; + A1 = zeros(frames, Ndft); + A2 = zeros(frames, Ndft); + + % initial helicopter view of all frames + + for i = 1:frames + A1(i,:) = -20*log10(abs(fft(ak1(i,:),Ndft))); + A2(i,:) = -20*log10(abs(fft(ak2(i,:),Ndft))); + sd(i) = sum((A1(i,:) - A2(i,:)).^2)/Ndft; + end + printf("sd av %3.2f dB*dB\n", sum(sd)/frames); + + figure(1); + clf; + subplot(211) + fs=fopen(raw_filename,"rb"); + s = fread(fs,Inf,"short"); + plot(s); + subplot(212) + plot(sd); + + lsp1_filename = sprintf("%s_lsp.txt", dump_file_prefix); + lsp2_filename = sprintf("%s_lsp_.txt", dump_file_prefix); + lsp1 = load(lsp1_filename); + lsp2 = load(lsp2_filename); + + weights_filename = sprintf("%s_weights.txt", dump_file_prefix); + if file_in_path(".",weights_filename) + weights = load(weights_filename); + end + + % now enter single step mode so we can analyse each frame + k = ' '; + do + figure(2); + clf; + plot((4000/pi)*lsp1((f-2:f+2),:)); + hold on; + plot((4000/pi)*lsp2((f-2:f+2),:),'+-'); + hold off; + + figure(3); + clf; + + plot((1:Ndft/2)*4000/(Ndft/2), A1(f,1:(Ndft/2)),";A1;r"); + axis([1 4000 -20 40]); + hold on; + plot((1:Ndft/2)*4000/(Ndft/2), A2(f,1:(Ndft/2)),";A2;"); + if file_in_path(".",weights_filename) + plot(lsp1(f,:)*4000/pi, weights(f,:),";weights;g+"); + end + + for l=1:10 + plot([lsp1(f,l)*4000/pi lsp1(f,l)*4000/pi], [0 -10], 'r'); + plot([lsp2(f,l)*4000/pi lsp2(f,l)*4000/pi], [-10 -20], 'b'); + endfor + + plot(0,0,';lsp1;r'); + plot(0,0,';lsp2;b'); + sd_str = sprintf(";sd %3.2f dB*dB;", sd(f)); + plot(0,0,sd_str); + + hold off; + + % interactive menu + + printf("\rframe: %d menu: n-next b-back q-quit", f); + fflush(stdout); + k = kbhit(); + if (k == 'n') + f = f + 1; + endif + if (k == 'b') + f = f - 1; + endif + + until (k == 'q') + printf("\n"); + +endfunction + diff --git a/codec2/branches/0.3/octave/spec.m b/codec2/branches/0.3/octave/spec.m new file mode 100644 index 00000000..d556b906 --- /dev/null +++ b/codec2/branches/0.3/octave/spec.m @@ -0,0 +1,86 @@ +% spec.m +% Jean Marc Valin +% +% Spectrogram function for Octave +% +% Copyright (c) John-Marc Valin 2012 +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions +% are met: +% +% - Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% +% - Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% +% - Neither the name of Jean Marc Valin nor the names of its +% contributors may be used to endorse or promote products derived from +% this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +% ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +% A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR +% CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +% PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +function X = spec(x, Fs, framesize, start, stop) + + +gr=[zeros(1024,1),[0:1023]'/1023,.68*[0:1023]'/1023]; + +%gr=[.4*[0:1023]'/1023,[0:1023]'/1023,.68*[0:1023]'/1023]; + +%t=[0:1023]'/1023; +%t=(1+.25*t-cos(pi*t))/2.25; +%gr = [zeros(1024,1),t,.68*t]; + + +%colormap(gr); + +if nargin < 2 || isempty(Fs) + Fs = 44100; +end + +if nargin < 3 || isempty(framesize) + framesize = 2048; +endif + +offset = framesize/8; + +X = 20*log10(abs(specgram(x, framesize, 48000, blackmanharris(framesize)', framesize-offset))); + +XM=max(max(X)); +X = max(XM-30,X); +%size(X) +F = -[framesize/2-1:-1:0]/framesize*Fs; +%F = [0:127]/128*24000; +T=[1:size(X,2)]/Fs*offset; +%imagesc(X(end:-1:1,:)); + +if nargin < 4 || isempty(start) + istart=1; +else + istart = round(start*Fs/offset); +end + +if nargin < 5 || isempty(stop) + istop = size(X,2); +else + istop = round(stop*Fs/offset); +endif + +istart = max(1,istart); +istop = min(istop, size(X,2)); + +imagesc(T(1+istart:istop), F, X(end:-1:1,1+istart:istop)); + +X = X(:,1+istart:istop); diff --git a/codec2/branches/0.3/octave/test_dqpsk.m b/codec2/branches/0.3/octave/test_dqpsk.m new file mode 100644 index 00000000..76beaf9c --- /dev/null +++ b/codec2/branches/0.3/octave/test_dqpsk.m @@ -0,0 +1,394 @@ +% test_dqpsk.m +% David Rowe March 2014 +% +% Single sample/symbol DQPSK modem simulation to test modulating modem +% tx power based on speech energy. + +1; + +% main test function + +function sim_out = ber_test(sim_in) + Fs = 8000; + + verbose = sim_in.verbose; + framesize = sim_in.framesize; + Ntrials = sim_in.Ntrials; + Esvec = sim_in.Esvec; + phase_offset = sim_in.phase_offset; + w_offset = sim_in.w_offset; + plot_scatter = sim_in.plot_scatter; + Rs = sim_in.Rs; + hf_sim = sim_in.hf_sim; + nhfdelay = sim_in.hf_delay_ms*Rs/1000; + hf_phase_only = sim_in.hf_phase_only; + hf_mag_only = sim_in.hf_mag_only; + Nc = sim_in.Nc; + symbol_amp = sim_in.symbol_amp; + + bps = 2; + Nsymb = framesize/bps; + for k=1:Nc + prev_sym_tx(k) = qpsk_mod([0 0]); + prev_sym_rx(k) = qpsk_mod([0 0]); + end + + rate = 1; + + % Init HF channel model from stored sample files of spreading signal ---------------------------------- + + % convert "spreading" samples from 1kHz carrier at Fs to complex + % baseband, generated by passing a 1kHz sine wave through PathSim + % with the ccir-poor model, enabling one path at a time. + + Fc = 1000; M = Fs/Rs; + fspread = fopen("../raw/sine1k_2Hz_spread.raw","rb"); + spread1k = fread(fspread, "int16")/10000; + fclose(fspread); + fspread = fopen("../raw/sine1k_2ms_delay_2Hz_spread.raw","rb"); + spread1k_2ms = fread(fspread, "int16")/10000; + fclose(fspread); + + % down convert to complex baseband + spreadbb = spread1k.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k))'); + spreadbb_2ms = spread1k_2ms.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k_2ms))'); + + % remove -2000 Hz image + b = fir1(50, 5/Fs); + spread = filter(b,1,spreadbb); + spread_2ms = filter(b,1,spreadbb_2ms); + + % discard first 1000 samples as these were near 0, probably as + % PathSim states were ramping up + + spread = spread(1000:length(spread)); + spread_2ms = spread_2ms(1000:length(spread_2ms)); + + % decimate down to Rs + + spread = spread(1:M:length(spread)); + spread_2ms = spread_2ms(1:M:length(spread_2ms)); + + % Determine "gain" of HF channel model, so we can normalise + % carrier power during HF channel sim to calibrate SNR. I imagine + % different implementations of ccir-poor would do this in + % different ways, leading to different BER results. Oh Well! + + hf_gain = 1.0/sqrt(var(spread)+var(spread_2ms)); + + % Start Simulation ---------------------------------------------------------------- + + for ne = 1:length(Esvec) + EsNodB = Esvec(ne); + EsNo = 10^(EsNodB/10); + + variance = 1/EsNo; + if verbose > 1 + printf("EsNo (dB): %f EsNo: %f variance: %f\n", EsNodB, EsNo, variance); + end + + Terrs = 0; Tbits = 0; + + tx_symb_log = []; + rx_symb_log = []; + noise_log = []; + sim_out.errors_log = []; + + % init HF channel + + hf_n = 1; + hf_angle_log = []; + hf_fading = ones(1,Nsymb); % default input for ldpc dec + hf_model = ones(Ntrials*Nsymb/Nc, Nc); % defaults for plotting surface + + sim_out.errors_log = []; + sim_out.Nerrs = []; + sim_out.snr_log = []; + sim_out.hf_model_pwr = []; + + symbol_amp_index = 1; + + for nn = 1: Ntrials + + tx_bits = round( rand( 1, framesize*rate ) ); + + % modulate -------------------------------------------- + + s = zeros(1, Nsymb); + for i=1:Nc:Nsymb + for k=1:Nc + tx_symb = qpsk_mod(tx_bits(2*(i-1+k-1)+1:2*(i+k-1))); + tx_symb *= prev_sym_tx(k); + prev_sym_tx(k) = tx_symb; + s(i+k-1) = symbol_amp(symbol_amp_index)*tx_symb; + end + end + s_ch = s; + symbol_amp_index++; + + % HF channel simulation ------------------------------------ + + if hf_sim + + % separation between carriers. Note this is + % effectively under samples at Rs, I dont think this + % matters. Equivalent to doing freq shift at Fs, then + % decimating to Rs. + + wsep = 2*pi*(1+0.5); % e.g. 75Hz spacing at Rs=50Hz, alpha=0.5 filters + + if Nsymb/Nc != floor(Nsymb/Nc) + printf("Error: Nsymb/Nc must be an integrer\n") + return; + end + + % arrange symbols in Nsymb/Nc by Nc matrix + + for i=1:Nc:Nsymb + + % Determine HF channel at each carrier for this symbol + + for k=1:Nc + hf_model(hf_n, k) = hf_gain*(spread(hf_n) + exp(-j*k*wsep*nhfdelay)*spread_2ms(hf_n)); + hf_fading(i+k-1) = abs(hf_model(hf_n, k)); + if hf_mag_only + s_ch(i+k-1) *= abs(hf_model(hf_n, k)); + else + s_ch(i+k-1) *= hf_model(hf_n, k); + end + end + hf_n++; + end + end + + tx_symb_log = [tx_symb_log s_ch]; + + % "genie" SNR estimate + + snr = (s_ch*s_ch')/(Nsymb*variance); + sim_out.snr_log = [sim_out.snr_log snr]; + sim_out.hf_model_pwr = [sim_out.hf_model_pwr mean(hf_fading.^2)]; + + % AWGN noise and phase/freq offset channel simulation + % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im + + noise = sqrt(variance*0.5)*(randn(1,Nsymb) + j*randn(1,Nsymb)); + noise_log = [noise_log noise]; + + % organise into carriers to apply frequency and phase offset + + for i=1:Nc:Nsymb + for k=1:Nc + s_ch(i+k-1) = s_ch(i+k-1)*exp(j*phase_offset) + noise(i+k-1); + end + phase_offset += w_offset; + end + + % de-modulate + + rx_bits = zeros(1, framesize); + for i=1:Nc:Nsymb + for k=1:Nc + rx_symb = s_ch(i+k-1); + tmp = rx_symb; + rx_symb *= conj(prev_sym_rx(k)/abs(prev_sym_rx(k))); + prev_sym_rx(k) = tmp; + rx_bits((2*(i-1+k-1)+1):(2*(i+k-1))) = qpsk_demod(rx_symb); + rx_symb_log = [rx_symb_log rx_symb]; + end + end + + error_positions = xor(rx_bits, tx_bits); + Nerrs = sum(error_positions); + sim_out.Nerrs = [sim_out.Nerrs Nerrs]; + Terrs += Nerrs; + Tbits += length(tx_bits); + + sim_out.errors_log = [sim_out.errors_log error_positions]; + end + + TERvec(ne) = Terrs; + BERvec(ne) = Terrs/Tbits; + + if verbose + printf("EsNo (dB): %f Terrs: %d BER %f ", EsNodB, Terrs, Terrs/Tbits); + printf("\n"); + end + if verbose > 1 + printf("Terrs: %d BER %f C %f N %f Es %f No %f Es/No %f\n\n", Terrs, + Terrs/Tbits, var(tx_symb_log), var(noise_log), + var(tx_symb_log), var(noise_log), var(tx_symb_log)/var(noise_log)); + end + end + + Ebvec = Esvec - 10*log10(bps); + + sim_out.BERvec = BERvec; + sim_out.Ebvec = Ebvec; + sim_out.TERvec = TERvec; + + if plot_scatter + figure(2); + clf; + scat = rx_symb_log .* exp(j*pi/4); + plot(real(scat), imag(scat),'+'); + title('Scatter plot'); + + figure(3); + clf; + y = 1:Rs*2; + x = 1:Nc; + EsNodBSurface = 20*log10(abs(hf_model(y,:))) - 10*log10(variance); + mesh(x,y,EsNodBSurface); + grid + title('HF Channel Es/No'); + + if 0 + figure(4); + clf; + subplot(211) + plot(y,abs(hf_model(y,1))) + title('HF Channel Carrier 1 Mag'); + subplot(212) + plot(y,angle(hf_model(y,1))) + title('HF Channel Carrier 1 Phase'); + end + end + +endfunction + +% Gray coded QPSK modulation function + +function symbol = qpsk_mod(two_bits) + two_bits_decimal = sum(two_bits .* [2 1]); + switch(two_bits_decimal) + case (0) symbol = 1; + case (1) symbol = j; + case (2) symbol = -j; + case (3) symbol = -1; + endswitch +endfunction + +% Gray coded QPSK demodulation function + +function two_bits = qpsk_demod(symbol) + if isscalar(symbol) == 0 + printf("only works with scalars\n"); + return; + end + bit0 = real(symbol*exp(j*pi/4)) < 0; + bit1 = imag(symbol*exp(j*pi/4)) < 0; + two_bits = [bit1 bit0]; +endfunction + +function sim_in = standard_init + sim_in.verbose = 1; + sim_in.plot_scatter = 0; + + sim_in.Esvec = 5:15; + sim_in.Ntrials = 100; + sim_in.framesize = 64; + sim_in.Rs = 100; + sim_in.Nc = 8; + + sim_in.phase_offset = 0; + sim_in.w_offset = 0; + sim_in.phase_noise_amp = 0; + + sim_in.hf_delay_ms = 2; + sim_in.hf_sim = 0; + sim_in.hf_phase_only = 0; + sim_in.hf_mag_only = 0; +endfunction + +function awgn_hf_ber_curves() + sim_in = standard_init(); + + Ebvec = sim_in.Esvec - 10*log10(2); + BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10))); + + dpsk_awgn = ber_test(sim_in); + sim_in.hf_sim = 1; + dpsk_hf = ber_test(sim_in); + + figure(1); + clf; + semilogy(Ebvec, BER_theory,'r;QPSK theory;') + hold on; + semilogy(dpsk_awgn.Ebvec, dpsk_awgn.BERvec,'g;DQPSK;') + semilogy(dpsk_hf.Ebvec, dpsk_hf.BERvec,'g;DQPSK HF;') + hold off; + xlabel('Eb/N0') + ylabel('BER') + grid("minor") + axis([min(Ebvec) max(Ebvec) 1E-3 1]) +end + +sim_in = standard_init(); + +% energy file sampled every 10ms + +load ../src/ve9qrp.txt +pdB=10*log10(ve9qrp); +for i=1:length(pdB) + if pdB(i) < 0 + pdB(i) = 0; + end +end + +% Down sample to 40ms rate used for 1300 bit/s codec, every 4th sample is transmitted + +pdB = pdB(4:4:length(pdB)); + +% Use linear mapping function in dB domain to map to symbol power + +power_map_x = [ 0 20 24 40 50 ]; +power_map_y = [-6 -6 0 6 6]; +mapped_pdB = interp1(power_map_x, power_map_y, pdB); + +%sim_in.symbol_amp = 10 .^ (mapped_pdB/20); +sim_in.symbol_amp = ones(1,length(pdB)); +sim_in.plot_scatter = 1; +sim_in.verbose = 2; +sim_in.hf_sim = 1; +sim_in.Esvec = 10; +sim_in.Ntrials = 400; + +dqpsk_pwr_hf = ber_test(sim_in); + +% note: need way to test that power is aligned with speech + +figure(4) +clf; +plot((1:sim_in.Ntrials)*80*4, pdB(1:sim_in.Ntrials)); +hold on; +plot((1:sim_in.Ntrials)*80*4, mapped_pdB(1:sim_in.Ntrials),'r'); +hold off; + +figure(5) +clf; + +s = load_raw("../raw/ve9qrp.raw"); +M=320; M_on_2 = M/2; % processing delay between input speech and centre of analysis window +plot(M_on_2:(M_on_2-1+sim_in.Ntrials*M),s(1:sim_in.Ntrials*M)) +hold on; +plot((1:sim_in.Ntrials)*M, 5000*sim_in.symbol_amp(1:sim_in.Ntrials),'r'); +hold off; +axis([1 sim_in.Ntrials*M -3E4 3E4]); + +figure(6) +clf; +plot((1:sim_in.Ntrials)*M, 20*log10(sim_in.symbol_amp(1:sim_in.Ntrials)),'b;Es (dB);'); +hold on; +plot((1:sim_in.Ntrials)*M, 10*log10(dqpsk_pwr_hf.hf_model_pwr),'g;Fading (dB);'); +plot((1:sim_in.Ntrials)*M, 10*log10(dqpsk_pwr_hf.snr_log),'r;Es/No (dB);'); + +ber = dqpsk_pwr_hf.Nerrs/sim_in.framesize; +ber_clip = ber; +ber_clip(find(ber > 0.2)) = 0.2; +plot((1:sim_in.Ntrials)*M, -20+100*ber_clip,'k;BER (0-20%);'); +hold off; +axis([1 sim_in.Ntrials*M -20 20]) + +fep=fopen("dqpsk_errors_pwr.bin","wb"); fwrite(fep, dqpsk_pwr_hf.errors_log, "short"); fclose(fep); +fber=fopen("ber.bin","wb"); fwrite(fber, ber, "float"); fclose(fber); diff --git a/codec2/branches/0.3/octave/test_dqpsk2.m b/codec2/branches/0.3/octave/test_dqpsk2.m new file mode 100644 index 00000000..01f45677 --- /dev/null +++ b/codec2/branches/0.3/octave/test_dqpsk2.m @@ -0,0 +1,463 @@ +% test_dqpsk2.m +% David Rowe April 2014 +% +% DQPSK modem simulation inclduing filtering to test modulating modem +% tx power based on speech energy. Unlike test_dpsk runs at sample +% rate Fs. + +1; + +% main test function + +function sim_out = ber_test(sim_in) + Fs = 8000; + + verbose = sim_in.verbose; + framesize = sim_in.framesize; + Ntrials = sim_in.Ntrials; + Esvec = sim_in.Esvec; + phase_offset = sim_in.phase_offset; + w_offset = sim_in.w_offset; + plot_scatter = sim_in.plot_scatter; + Rs = sim_in.Rs; + hf_sim = sim_in.hf_sim; + Nhfdelay = floor(sim_in.hf_delay_ms*Fs/1000); + Nc = sim_in.Nc; + symbol_amp = sim_in.symbol_amp; + + bps = 2; + Nsymb = framesize/bps; + for k=1:Nc + prev_sym_tx(k) = qpsk_mod([0 0]); + prev_sym_rx(k) = qpsk_mod([0 0]); + end + + % design root nyquist (root raised cosine) filter and init tx and rx filter states + + alpha = 0.5; T=1/Fs; Nfiltsym=7; M=Fs/Rs; + if floor(Fs/Rs) != Fs/Rs + printf("oversampling ratio must be an integer\n"); + return; + end + hrn = gen_rn_coeffs(alpha, T, Rs, Nfiltsym, M); + Nfilter = length(hrn); + + % convert "spreading" samples from 1kHz carrier at Fs to complex + % baseband, generated by passing a 1kHz sine wave through PathSim + % with the ccir-poor model, enabling one path at a time. + + Fc = 1000; + fspread = fopen("../raw/sine1k_2Hz_spread.raw","rb"); + spread1k = fread(fspread, "int16")/10000; + fclose(fspread); + fspread = fopen("../raw/sine1k_2ms_delay_2Hz_spread.raw","rb"); + spread1k_2ms = fread(fspread, "int16")/10000; + fclose(fspread); + + % down convert to complex baseband + spreadbb = spread1k.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k))'); + spreadbb_2ms = spread1k_2ms.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k_2ms))'); + + % remove -2000 Hz image + b = fir1(50, 5/Fs); + spread = filter(b,1,spreadbb); + spread_2ms = filter(b,1,spreadbb_2ms); + + % discard first 1000 samples as these were near 0, probably as + % PathSim states were ramping up. Transpose for convenience + + spread = transpose(spread(1000:length(spread))); + spread_2ms = transpose(spread_2ms(1000:length(spread_2ms))); + + % Determine "gain" of HF channel model, so we can normalise + % carrier power during HF channel sim to calibrate SNR. I imagine + % different implementations of ccir-poor would do this in + % different ways, leading to different BER results. Oh Well! + + hf_gain = 1.0/sqrt(var(spread)+var(spread_2ms)); + + % Start Simulation ---------------------------------------------------------------- + + for ne = 1:length(Esvec) + EsNodB = Esvec(ne); + EsNo = 10^(EsNodB/10); + + variance = Fs/(Rs*EsNo); + if verbose > 1 + printf("EsNo (dB): %f EsNo: %f variance: %f\n", EsNodB, EsNo, variance); + end + + Terrs = 0; Tbits = 0; + + tx_symb_log = []; + rx_symb_log = []; + noise_log = []; + sim_out.errors_log = []; + sim_out.tx_baseband_log = []; + sim_out.rx_filt_log = []; + symbol_amp_index = 1; + + % init filter memories and LOs + + tx_filter_memory = zeros(Nc, Nfilter); + rx_filter_memory = zeros(Nc, Nfilter); + s_delay_line_filt = zeros(Nc, Nfiltsym); + phase_tx = ones(1,Nc); + phase_rx = ones(1,Nc); + Fcentre = 1500; Fsep = (1+alpha)*Rs; + freq = Fcentre + Fsep*((-Nc/2+0.5):(Nc/2-0.5)); + freq = exp(j*freq*2*pi/Fs); + + % init HF channel + + sc = 1; hf_n = 1; + hf_sim_delay_line = zeros(1,M+Nhfdelay); + freq_sample_hz = Fcentre + ((Fsep*(-Nc/2)):50:(Fsep*(Nc/2))); + freq_sample_rads = (2*pi/Fs)*freq_sample_hz; + hf_model = ones(Ntrials*Nsymb/Nc, length(freq_sample_rads)); % defaults for plotting surface + + % bunch of outputs we log for graphing + + sim_out.errors_log = []; + sim_out.Nerrs = []; + sim_out.snr_log = []; + sim_out.hf_model_pwr = []; + sim_out.tx_fdm_log = []; + C_log = []; + + for nn = 1: Ntrials + + tx_bits = round( rand( 1, framesize ) ); + + % modulate -------------------------------------------- + + s = zeros(1, Nsymb); + for i=1:Nc:Nsymb + for k=1:Nc + tx_symb = qpsk_mod(tx_bits(2*(i-1+k-1)+1:2*(i+k-1))); + s_qpsk(i+k-1) = tx_symb; + tx_symb *= prev_sym_tx(k); + prev_sym_tx(k) = tx_symb; + s(i+k-1) = symbol_amp(symbol_amp_index)*tx_symb; + end + end + symbol_amp_index++; + s_ch = s; + + % Now we start processing frame Nc symbols at a time to model parallel carriers + + tx_fdm_sym_log = []; + for i=1:Nc:Nsymb + + % Delay tx symbols to match delay due to filters. qpsk + % (rather than dqpsk) symbols used for convenience as + % it's easy to shift symbols than pairs of bits + + s_delay_line_filt(:,1:Nfiltsym-1) = s_delay_line_filt(:,2:Nfiltsym); + s_delay_line_filt(:,Nfiltsym) = s_qpsk(i:i+Nc-1); + s_qpsk(i:i+Nc-1) = s_delay_line_filt(:,1); + for k=1:Nc + tx_bits(2*(i-1+k-1)+1:2*(i+k-1)) = qpsk_demod(s_qpsk(i+k-1)); + end + + % tx filter + + tx_baseband = zeros(Nc,M); + + % tx filter each symbol, generate M filtered output samples for each symbol. + % Efficient polyphase filter techniques used as tx_filter_memory is sparse + + tx_filter_memory(:,Nfilter) = s(i:i+Nc-1); + + for k=1:M + tx_baseband(:,k) = M*tx_filter_memory(:,M:M:Nfilter) * hrn(M-k+1:M:Nfilter)'; + end + tx_filter_memory(:,1:Nfilter-M) = tx_filter_memory(:,M+1:Nfilter); + tx_filter_memory(:,Nfilter-M+1:Nfilter) = zeros(Nc,M); + + sim_out.tx_baseband_log = [sim_out.tx_baseband_log tx_baseband]; + + % upconvert + + tx_fdm = zeros(1,M); + + for c=1:Nc + for k=1:M + phase_tx(c) = phase_tx(c) * freq(c); + tx_fdm(k) = tx_fdm(k) + tx_baseband(c,k)*phase_tx(c); + end + end + + sim_out.tx_fdm_log = [sim_out.tx_fdm_log tx_fdm]; + + % HF channel + + if hf_sim + hf_sim_delay_line(1:Nhfdelay) = hf_sim_delay_line(M+1:M+Nhfdelay); + hf_sim_delay_line(Nhfdelay+1:M+Nhfdelay) = tx_fdm; + + tx_fdm = tx_fdm.*spread(sc:sc+M-1) + hf_sim_delay_line(1:M).*spread_2ms(sc:sc+M-1); + tx_fdm *= hf_gain; + + % sample HF channel spectrum in middle of this symbol for plotting + + hf_model(hf_n,:) = hf_gain*(spread(sc+M/2) + exp(-j*freq_sample_rads*Nhfdelay)*spread_2ms(sc+M/2)); + + sc += M; + hf_n++; + end + + tx_fdm_sym_log = [tx_fdm_sym_log tx_fdm ]; + + % AWGN noise and phase/freq offset channel simulation + % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im + + noise = sqrt(variance*0.5)*(randn(1,M) + j*randn(1,M)); + noise_log = [noise_log noise]; + + % apply frequency and phase offset and noise + + for k=1:M + rx_fdm(k) = tx_fdm(k)*exp(j*phase_offset) + noise(k); + phase_offset += w_offset; + end + + % downconvert + + rx_baseband = zeros(Nc,M); + for c=1:Nc + for k=1:M + phase_rx(c) = phase_rx(c) * freq(c); + rx_baseband(c,k) = rx_fdm(k)*phase_rx(c)'; + end + end + + % rx filter + + rx_filter_memory(:,Nfilter-M+1:Nfilter) = rx_baseband; + rx_filt = rx_filter_memory * hrn'; + rx_filter_memory(:,1:Nfilter-M) = rx_filter_memory(:,1+M:Nfilter); + sim_out.rx_filt_log = [sim_out.rx_filt_log rx_filt]; + + s_ch(i:i+Nc-1) = rx_filt; + end + + % est HF model power for entire code frame (which could be several symbols) + + if hf_sim + frame_hf_model = reshape(hf_model(hf_n-Nsymb/Nc:hf_n-1,:),1,(Nsymb/Nc)*length(freq_sample_hz)); + sim_out.hf_model_pwr = [sim_out.hf_model_pwr mean(abs(frame_hf_model).^2)]; + else + sim_out.hf_model_pwr = [sim_out.hf_model_pwr 1]; + end + + % "genie" SNR estimate + + snr = (tx_fdm_sym_log*tx_fdm_sym_log')/(M*variance); + sim_out.snr_log = [sim_out.snr_log snr]; + + % de-modulate + + rx_bits = zeros(1, framesize); + for i=1:Nc:Nsymb + for k=1:Nc + rx_symb = s_ch(i+k-1); + tmp = rx_symb; + rx_symb *= conj(prev_sym_rx(k)/abs(prev_sym_rx(k))); + prev_sym_rx(k) = tmp; + rx_bits((2*(i-1+k-1)+1):(2*(i+k-1))) = qpsk_demod(rx_symb); + rx_symb_log = [rx_symb_log rx_symb]; + end + end + + % ignore data until we have enough frames to fill filter memory + % then count errors + + if nn > ceil(Nfiltsym/(Nsymb/Nc)) + error_positions = xor(rx_bits, tx_bits); + sim_out.errors_log = [sim_out.errors_log error_positions]; + Nerrs = sum(error_positions); + sim_out.Nerrs = [sim_out.Nerrs Nerrs]; + Terrs += Nerrs; + Tbits += length(tx_bits); + end + + end + + TERvec(ne) = Terrs; + BERvec(ne) = Terrs/Tbits; + + if verbose + printf("EsNo (dB): %f Terrs: %d BER %f ", EsNodB, Terrs, Terrs/Tbits); + printf("\n"); + end + if verbose > 1 + printf("Terrs: %d BER %f C %f N %f Es %f No %f Es/No %f\n\n", Terrs, + Terrs/Tbits, var(sim_out.tx_fdm_log), var(noise_log), + var(sim_out.tx_fdm_log)/(Nc*Rs), var(noise_log)/Fs, (var(sim_out.tx_fdm_log)/(Nc*Rs))/(var(noise_log)/Fs)); + end + end + + Ebvec = Esvec - 10*log10(bps); + + sim_out.BERvec = BERvec; + sim_out.Ebvec = Ebvec; + sim_out.TERvec = TERvec; + + if plot_scatter + figure(2); + clf; + scat = rx_symb_log(Nfiltsym*Nc:length(rx_symb_log)) .* exp(j*pi/4); + plot(real(scat), imag(scat),'+'); + title('Scatter plot'); + + figure(3); + clf; + y = 1:Rs*2; + EsNodBSurface = 20*log10(abs(hf_model(y,:))) + EsNodB; + mesh(1:length(freq_sample_hz),y,EsNodBSurface); + grid + title('HF Channel Es/No'); + end + +endfunction + +% Gray coded QPSK modulation function + +function symbol = qpsk_mod(two_bits) + two_bits_decimal = sum(two_bits .* [2 1]); + switch(two_bits_decimal) + case (0) symbol = 1; + case (1) symbol = j; + case (2) symbol = -j; + case (3) symbol = -1; + endswitch +endfunction + +% Gray coded QPSK demodulation function + +function two_bits = qpsk_demod(symbol) + if isscalar(symbol) == 0 + printf("only works with scalars\n"); + return; + end + bit0 = real(symbol*exp(j*pi/4)) < 0; + bit1 = imag(symbol*exp(j*pi/4)) < 0; + two_bits = [bit1 bit0]; +endfunction + +function sim_in = standard_init + sim_in.verbose = 1; + sim_in.plot_scatter = 0; + + sim_in.Esvec = 5:15; + sim_in.Ntrials = 100; + sim_in.framesize = 64; + sim_in.Rs = 100; + sim_in.Nc = 8; + + sim_in.phase_offset = 0; + sim_in.w_offset = 0; + sim_in.phase_noise_amp = 0; + + sim_in.hf_delay_ms = 2; + sim_in.hf_sim = 0; + sim_in.hf_phase_only = 0; + sim_in.hf_mag_only = 0; +endfunction + +function awgn_hf_ber_curves() + sim_in = standard_init(); + + Ebvec = sim_in.Esvec - 10*log10(2); + BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10))); + + dpsk_awgn = ber_test(sim_in); + sim_in.hf_sim = 1; + dpsk_hf = ber_test(sim_in); + + figure(1); + clf; + semilogy(Ebvec, BER_theory,'r;QPSK theory;') + hold on; + semilogy(dpsk_awgn.Ebvec, dpsk_awgn.BERvec,'g;DQPSK;') + semilogy(dpsk_hf.Ebvec, dpsk_hf.BERvec,'g;DQPSK HF;') + hold off; + xlabel('Eb/N0') + ylabel('BER') + grid("minor") + axis([min(Ebvec) max(Ebvec) 1E-3 1]) +end + +sim_in = standard_init(); + +% energy file sampled every 10ms + +load ../src/ve9qrp.txt +pdB=10*log10(ve9qrp); +for i=1:length(pdB) + if pdB(i) < 0 + pdB(i) = 0; + end +end + +% Down sample to 40ms rate used for 1300 bit/s codec, every 4th sample is transmitted + +pdB = pdB(4:4:length(pdB)); + +% Use linear mapping function in dB domain to map to symbol power + +power_map_x = [ 0 20 24 40 50 ]; +power_map_y = [-6 -6 0 6 6]; +mapped_pdB = interp1(power_map_x, power_map_y, pdB); + +sim_in.symbol_amp = 10 .^ (mapped_pdB/20); +%sim_in.symbol_amp = ones(1,length(pdB)); +sim_in.plot_scatter = 1; +sim_in.verbose = 2; +sim_in.hf_delay_ms = 2; +sim_in.hf_sim = 1; +sim_in.Esvec = 10; +sim_in.Ntrials = 400; + +dqpsk_pwr_hf = ber_test(sim_in); + +% note: need way to test that power is aligned with speech + +figure(4) +clf; +plot((1:sim_in.Ntrials)*80*4, pdB(1:sim_in.Ntrials)); +hold on; +plot((1:sim_in.Ntrials)*80*4, mapped_pdB(1:sim_in.Ntrials),'r'); +hold off; + +figure(5) +clf; +s = load_raw("../raw/ve9qrp.raw"); +M=320; M_on_2 = M/2; % processing delay between input speech and centre of analysis window +subplot(211) +plot(M_on_2:(M_on_2-1+sim_in.Ntrials*M),s(1:sim_in.Ntrials*M)) +hold on; +plot((1:sim_in.Ntrials)*M, 5000*sim_in.symbol_amp(1:sim_in.Ntrials),'r'); +hold off; +axis([1 sim_in.Ntrials*M -3E4 3E4]); +subplot(212) +plot(real(dqpsk_pwr_hf.tx_fdm_log)); + + +figure(6) +clf; +plot((1:sim_in.Ntrials)*M, 20*log10(sim_in.symbol_amp(1:sim_in.Ntrials)),'b;Es (dB);'); +hold on; +plot((1:sim_in.Ntrials)*M, 10*log10(dqpsk_pwr_hf.hf_model_pwr),'g;Fading (dB);'); +plot((1:sim_in.Ntrials)*M, 10*log10(dqpsk_pwr_hf.snr_log),'r;Es/No (dB);'); + +ber = dqpsk_pwr_hf.Nerrs/sim_in.framesize; +ber_clip = ber; +ber_clip(find(ber > 0.2)) = 0.2; +plot((1:length(ber_clip))*M, -20+100*ber_clip,'k;BER (0-20%);'); +hold off; +axis([1 sim_in.Ntrials*M -20 20]) + +fep=fopen("dqpsk_errors_pwr.bin","wb"); fwrite(fep, dqpsk_pwr_hf.errors_log, "short"); fclose(fep); +fber=fopen("ber.bin","wb"); fwrite(fber, ber, "float"); fclose(fber); diff --git a/codec2/branches/0.3/octave/test_qpsk.m b/codec2/branches/0.3/octave/test_qpsk.m new file mode 100644 index 00000000..987841cf --- /dev/null +++ b/codec2/branches/0.3/octave/test_qpsk.m @@ -0,0 +1,516 @@ +% test_qpsk.m +% David Rowe Feb 2014 +% +% QPSK modem simulation, initially based on code by Bill Cowley +% Generates curves BER versus E/No curves for different modems. +% Design to test coherent demodulation ideas on HF channels without +% building a full blown modem. Uses 'genie provided' estimates for +% timing estimation, frame sync. + +1; + +% main test function + +function sim_out = ber_test(sim_in, modulation) + Fs = 8000; + + verbose = sim_in.verbose; + framesize = sim_in.framesize; + Ntrials = sim_in.Ntrials; + Esvec = sim_in.Esvec; + phase_offset = sim_in.phase_offset; + phase_est = sim_in.phase_est; + w_offset = sim_in.w_offset; + plot_scatter = sim_in.plot_scatter; + Rs = sim_in.Rs; + hf_sim = sim_in.hf_sim; + Nhfdelay = floor(sim_in.hf_delay_ms*1000/Fs); + hf_phase_only = sim_in.hf_phase_only; + hf_mag_only = sim_in.hf_mag_only; + + bps = 2; + Nsymb = framesize/bps; + prev_sym_tx = qpsk_mod([0 0]); + prev_sym_rx = qpsk_mod([0 0]); + rx_symb_log = []; + + Np = sim_in.Np; % number of pilot symbols to use in phase est + Ns = sim_in.Ns; % spacing of pilot symbols, so (Nps-1) data symbols between every pilot + Nps = Np*Ns; + r_delay_line = zeros(1,Nps+1); + s_delay_line = zeros(1,Nps+1); + spread_main_phi = 0; + spread_delay_phi = 0; + spread_main_phi_log = []; + + ldpc_code = sim_in.ldpc_code; + + if ldpc_code + % Start CML library + + currentdir = pwd; + addpath '/home/david/tmp/cml/mat' % assume the source files stored here + cd /home/david/tmp/cml + CmlStartup % note that this is not in the cml path! + cd(currentdir) + + % Our LDPC library + + ldpc; + + rate = 3/4; + mod_order = 4; + modulation = 'QPSK'; + mapping = 'gray'; + + demod_type = 0; + decoder_type = 0; + max_iterations = 100; + + code_param = ldpc_init(rate, framesize, modulation, mod_order, mapping); + code_param.code_bits_per_frame = framesize; + code_param.symbols_per_frame = framesize/bps; + else + rate = 1; + end + + % convert "spreading" samples from 1kHz carrier at Fs to complex + % baseband, generated by passing a 1kHz sine wave through PathSim + % with the ccir-poor model, enabling one path at a time. + + Fc = 1000; + fspread = fopen("../raw/sine1k_2Hz_spread.raw","rb"); + spread1k = fread(fspread, "int16")/10000; + fclose(fspread); + fspread = fopen("../raw/sine1k_2ms_delay_2Hz_spread.raw","rb"); + spread1k_2ms = fread(fspread, "int16")/10000; + fclose(fspread); + + % down convert to complex baseband + spreadbb = spread1k.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k))'); + spreadbb_2ms = spread1k_2ms.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k_2ms))'); + + % remove -2000 Hz image + b = fir1(50, 5/Fs); + spread = filter(b,1,spreadbb); + spread_2ms = filter(b,1,spreadbb_2ms); + + % discard first 1000 samples as these were near 0, probably as + % PathSim states were ramping up + + spread = spread(1000:length(spread)); + spread_2ms = spread_2ms(1000:length(spread_2ms)); + + % Determine "gain" of HF channel model, so we can normalise + % carrier power during HF channel sim to calibrate SNR. I imagine + % different implementations of ccir-poor would do this in + % different ways, leading to different BER results. Oh Well! + + hf_gain = 1.0/sqrt(var(spread)+var(spread_2ms)); + + % design root nyquist (root raised cosine) filter and init tx and rx filter states + + alpha = 0.5; T=1/Fs; Nfiltsym=7; M=Fs/Rs; + if floor(Fs/Rs) != Fs/Rs + printf("oversampling ratio must be an integer\n"); + return; + end + hrn = gen_rn_coeffs(alpha, T, Rs, Nfiltsym, M); + Nfilter = length(hrn); + tx_filter_memory = zeros(1, Nfilter); + rx_filter_memory = zeros(1, Nfilter); + s_delay_line_filt = zeros(1,Nfiltsym); + tx_bits_delay_line_filt = zeros(1,Nfiltsym*bps); + hf_sim_delay_line = zeros(1,M+Nhfdelay); + + for ne = 1:length(Esvec) + Es = Esvec(ne); + EsNo = 10^(Es/10); + + % Given Es/No, determine the variance of a normal noise source: + % + % Es = C/Rs where C is carrier power (energy per unit time) and Rs is the symbole rate + % N = NoB where N is the total noise power, No is the Noise spectral density is W/Hz + % and B is the bandwidth of the noise which is Fs + % No = N/Fs + % + % equating Es/No we get: + % + % Es/No = (C/Rs)/(No/Fs) + % No = CFs/(Rs(Es/No)) + + variance = Fs/(Rs*EsNo); + Terrs = 0; Tbits = 0; Terrsldpc = 0; Tbitsldpc = 0; Ferrsldpc = 0; + if verbose > 1 + printf("EsNo (dB): %f EsNo: %f variance: %f\n", Es, EsNo, variance); + end + + % init HF channel + sc = 1; + + tx_filt_log = []; + rx_filt_log = []; + rx_baseband_log = []; + tx_baseband_log = []; + noise_log = []; + hf_angle_log = []; + tx_phase = rx_phase = 0; + tx_data_buffer = zeros(1,2*framesize); + s_data_buffer = zeros(1,2*Nsymb); + C_log = []; + + for nn = 1: Ntrials + + tx_bits = round( rand( 1, framesize*rate ) ); + %tx_bits = [1 0 zeros(1,framesize*rate-2)]; + + % modulate + + if ldpc_code + [tx_bits, s] = ldpc_enc(tx_bits, code_param); + t2 = tx_bits; + s2 = s; + else + s = zeros(1, Nsymb); + for i=1:Nsymb + tx_symb = qpsk_mod(tx_bits(2*(i-1)+1:2*i)); + %printf("shift: %f prev_sym: %f ", tx_symb, prev_sym_tx); + if strcmp(modulation,'dqpsk') + tx_symb *= prev_sym_tx; + %printf("tx_symb: %f\n", tx_symb); + prev_sym_tx = tx_symb; + end + s(i) = tx_symb; + end + end + s_ch = s; + + % root nyquist filter symbols + + for k=1:Nsymb + + % tx filter symbols + + tx_filt = zeros(1,M); + + % tx filter each symbol, generate M filtered output samples for each symbol. + % Efficient polyphase filter techniques used as tx_filter_memory is sparse + + tx_filter_memory(Nfilter) = s_ch(k); + + for i=1:M + tx_filt(i) = M*tx_filter_memory(M:M:Nfilter) * hrn(M-i+1:M:Nfilter)'; + end + tx_filter_memory(1:Nfilter-M) = tx_filter_memory(M+1:Nfilter); + tx_filter_memory(Nfilter-M+1:Nfilter) = zeros(1,M); + + % HF channel simulation + + if hf_sim + + hf_sim_delay_line(1:Nhfdelay) = hf_sim_delay_line(M+1:M+Nhfdelay); + hf_sim_delay_line(Nhfdelay+1:M+Nhfdelay) = tx_filt; + + % disable as a wrap around will cause a nasty phase jump. Best to generate + % longer files + %if ((sc+M) > length(spread)) || ((sc+M) > length(spread_2ms)) + % sc =1 ; + %end + comb = conj(spread(sc:sc+M-1))' + conj(spread_2ms(sc:sc+M-1))'; + if hf_phase_only + tx_filt = tx_filt.*exp(j*angle(comb)); + hf_angle_log = [hf_angle_log angle(comb)]; + else + if hf_mag_only + comb = conj(spread(sc:sc+M-1))' + conj(spread_2ms(sc:sc+M-1))'; + tx_filt = tx_filt.*abs(comb); + else + % regular HF channel sim + tx_filt = tx_filt.*conj(spread(sc:sc+M-1))' + hf_sim_delay_line(1:M).*conj(spread_2ms(sc:sc+M-1))'; + end + end + sc += M; + + % normalise so average HF power C=1 + + if hf_phase_only == 0 % C already 1 if we are just tweaking phase + tx_filt *= hf_gain; + end + C_log = [C_log abs(comb)*hf_gain]; + end + tx_filt_log = [tx_filt_log tx_filt]; + + % AWGN noise and phase/freq offset channel simulation + % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im + + noise = sqrt(variance*0.5)*( randn(1,M) + j*randn(1,M) ); + noise_log = [noise_log noise]; + rx_baseband = tx_filt.*exp(j*phase_offset) + noise; + phase_offset += w_offset; + + % rx filter symbol + + rx_filter_memory(Nfilter-M+1:Nfilter) = rx_baseband; + rx_filt = rx_filter_memory * hrn'; + rx_filter_memory(1:Nfilter-M) = rx_filter_memory(1+M:Nfilter); + rx_filt_log = [rx_filt_log rx_filt]; + + % delay in tx symbols to compensate for filtering + % delay, as tx symbols are used as pilot symbols input + % to phase est + + s_delay_line_filt(1:Nfiltsym-1) = s_delay_line_filt(2:Nfiltsym); + s_delay_line_filt(Nfiltsym) = s(k); + s(k) = s_delay_line_filt(1); + + % delay in tx bits to compensate for filtering delay + + tx_bits_delay_line_filt(1:(Nfiltsym-1)*bps) = tx_bits_delay_line_filt(bps+1:Nfiltsym*bps); + tx_bits_delay_line_filt((Nfiltsym-1)*bps+1:Nfiltsym*bps) = tx_bits((k-1)*bps+1:k*bps); + tx_bits((k-1)*bps+1:k*bps) = tx_bits_delay_line_filt(1:bps); + + s_ch(k) = rx_filt; + end + + % coherent demod phase estimation and correction using pilot symbols + % cheating a bit here, we use fact that all tx-ed symbols are known + + if phase_est + for i=1:Nsymb + + % delay line for phase est window + + r_delay_line(1:Nps-1) = r_delay_line(2:Nps); + r_delay_line(Nps) = s_ch(i); + + % delay in tx data to compensate data for phase est window + + s_delay_line(1:Nps-1) = s_delay_line(2:Nps); + s_delay_line(Nps) = s(i); + tx_bits(2*(i-1)+1:2*i) = qpsk_demod(s_delay_line(floor(Nps/2)+1)); + + % estimate phase from surrounding known pilot symbols and correct + + corr = 0; centre = floor(Nps/2)+1; + for k=1:Ns:(Nps+1) + if (k != centre) + corr += s_delay_line(k) * r_delay_line(k)'; + end + end + s_ch(i) = r_delay_line(centre).*exp(j*angle(corr)); + end + %printf("corr: %f angle: %f\n", corr, angle(corr)); + end + + % de-modulate + + rx_bits = zeros(1, framesize); + for i=1:Nsymb + rx_symb = s_ch(i); + if strcmp(modulation,'dqpsk') + tmp = rx_symb; + rx_symb *= conj(prev_sym_rx/abs(prev_sym_rx)); + prev_sym_rx = tmp; + end + rx_bits((2*(i-1)+1):(2*i)) = qpsk_demod(rx_symb); + rx_symb_log = [rx_symb_log rx_symb]; + end + + % Measure BER + + % discard bits from first 2*Nfiltsym+Nps+1 symbols as tx + % and rx filter and phase est memories not full + + skip = bps*(2*Nfiltsym+1+Nps+1); + if nn == 1 + tx_bits_tmp = tx_bits(skip:length(tx_bits)); + rx_bits_tmp = rx_bits(skip:length(rx_bits)); + else + tx_bits_tmp = tx_bits; + rx_bits_tmp = rx_bits; + end + + error_positions = xor( rx_bits_tmp, tx_bits_tmp ); + Nerrs = sum(error_positions); + Terrs += Nerrs; + Tbits += length(tx_bits_tmp); + + % Optionally LDPC decode + + if ldpc_code + % filter memories etc screw up frame alignment so we need to buffer a frame + + tx_data_buffer(1:framesize) = tx_data_buffer(framesize+1:2*framesize); + s_data_buffer(1:Nsymb) = s_data_buffer(Nsymb+1:2*Nsymb); + tx_data_buffer(framesize+1:2*framesize) = tx_bits; + s_data_buffer(Nsymb+1:2*Nsymb) = s_ch; + + offset = Nfiltsym-1; + if (phase_est) + offset += floor(Nps/2); + end + st_tx = offset*bps+1; + st_s = offset; + + detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, ... + s_data_buffer(st_s+1:st_s+Nsymb), min(100,EsNo)); + + % ignore first frame as filter, phase est memories filling up + if nn != 1 + error_positions = xor( detected_data(1:framesize*rate), ... + tx_data_buffer(st_tx:st_tx+framesize*rate-1) ); + Nerrs = sum(error_positions); + if Nerrs + Ferrsldpc++; + end + Terrsldpc += Nerrs; + Tbitsldpc += framesize*rate; + end + end + + end + + TERvec(ne) = Terrs; + BERvec(ne) = Terrs/Tbits; + if ldpc_code + TERldpcvec(ne) = Terrsldpc; + FERldpcvec(ne) = Ferrsldpc; + BERldpcvec(ne) = Terrsldpc/Tbitsldpc; + end + + if verbose + printf("EsNo (dB): %f Terrs: %d BER %f BER theory %f", Es, Terrs, + Terrs/Tbits, 0.5*erfc(sqrt(EsNo/2))); + if ldpc_code + printf(" LDPC: Terrs: %d BER: %f Ferrs: %d FER: %f", + Terrsldpc, Terrsldpc/Tbitsldpc, Ferrsldpc, Ferrsldpc/(Ntrials-1)); + end + printf("\n"); + end + if verbose > 1 + printf("Terrs: %d BER %f BER theory %f C %f N %f Es %f No %f Es/No %f\n\n", Terrs, + Terrs/Tbits, 0.5*erfc(sqrt(EsNo/2)), var(tx_filt_log), var(noise_log), + var(tx_filt_log)/Rs, var(noise_log)/Fs, (var(tx_filt_log)/Rs)/(var(noise_log)/Fs)); + end + end + + Ebvec = Esvec - 10*log10(bps); + sim_out.BERvec = BERvec; + sim_out.Ebvec = Ebvec; + sim_out.TERvec = TERvec; + if ldpc_code + sim_out.BERldpcvec = BERldpcvec; + sim_out.TERldpcvec = TERldpcvec; + sim_out.FERldpcvec = FERldpcvec; + end + + if plot_scatter + figure(2); + clf; + scat = rx_symb_log(2*Nfiltsym:length(rx_symb_log)) .* exp(j*pi/4); + plot(real(scat), imag(scat),'+'); + + figure(3); + clf; + + if hf_phase_only + plot(hf_angle_log); + axis([1 10000 min(hf_angle_log) max(hf_angle_log)]) + else + plot(C_log); + end + end +endfunction + +% Gray coded QPSK modulation function + +function symbol = qpsk_mod(two_bits) + two_bits_decimal = sum(two_bits .* [2 1]); + switch(two_bits_decimal) + case (0) symbol = 1; + case (1) symbol = j; + case (2) symbol = -j; + case (3) symbol = -1; + endswitch +endfunction + +% Gray coded QPSK demodulation function + +function two_bits = qpsk_demod(symbol) + if isscalar(symbol) == 0 + printf("only works with scalars\n"); + return; + end + bit0 = real(symbol*exp(j*pi/4)) < 0; + bit1 = imag(symbol*exp(j*pi/4)) < 0; + two_bits = [bit1 bit0]; +endfunction + +% Start simulations --------------------------------------- + +more off; +sim_in.verbose = 2; + +sim_in.Esvec = 5; +sim_in.Ntrials = 100; +sim_in.framesize = 100; +sim_in.Rs = 400; +sim_in.phase_offset = 0; +sim_in.phase_est = 0; +sim_in.w_offset = 0; +sim_in.plot_scatter = 1; +sim_in.hf_delay_ms = 2; +sim_in.hf_sim = 1; +sim_in.Np = 6; +sim_in.Ns = 5; +sim_in.hf_phase_only = 0; +sim_in.hf_mag_only = 1; +sim_in.ldpc_code = 0; + +Ebvec = sim_in.Esvec - 10*log10(2); +BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10))); + +sim_qpsk = ber_test(sim_in, 'qpsk'); + +figure(1); +clf; +semilogy(Ebvec, BER_theory,'r;QPSK theory;') +hold on; +semilogy(sim_qpsk.Ebvec, sim_qpsk.BERvec,'g;QPSK;') +hold off; +xlabel('Eb/N0') +ylabel('BER') +grid("minor") + + +if 0 +sim_in.hf_mag_only = 1; +sim_qpsk_mag = ber_test(sim_in, 'qpsk'); + +sim_in.hf_mag_only = 0; +sim_in.hf_phase_only = 1; +sim_in.phase_est = 1; +sim_qpsk_phase = ber_test(sim_in, 'qpsk'); + +sim_in.hf_phase_only = 0; +sim_qpsk_coh_6_5 = ber_test(sim_in, 'qpsk'); + +sim_in.phase_est = 0; +sim_dqpsk = ber_test(sim_in, 'dqpsk'); + +figure(1); +clf; +semilogy(Ebvec, BER_theory,'r;QPSK theory;') +hold on; +semilogy(sim_qpsk_mag.Ebvec, sim_qpsk_mag.BERvec,'g;QPSK CCIR poor mag;') +semilogy(sim_qpsk_phase.Ebvec, sim_qpsk_phase.BERvec,'k;QPSK CCIR poor phase;') +semilogy(sim_qpsk_coh_6_5.Ebvec, sim_qpsk_coh_6_5.BERvec,'c;QPSK CCIR poor Np=6 Ns=5;') +semilogy(sim_dqpsk.Ebvec, sim_dqpsk.BERvec,'b;DQPSK CCIR poor;') +%semilogy(sim_qpsk_coh_5_24.Ebvec, sim_qpsk_coh_5_24.BERvec,'k;QPSK Ns=5 Np=24;') +%semilogy(sim_qpsk_coh_2_12.Ebvec, sim_qpsk_coh_2_12.BERvec,'c;QPSK Ns=2 Np=12;') +hold off; +xlabel('Eb/N0') +ylabel('BER') +grid("minor") +axis([min(Ebvec)-1 max(Ebvec)+1 1E-2 1]) +end diff --git a/codec2/branches/0.3/octave/test_qpsk2.m b/codec2/branches/0.3/octave/test_qpsk2.m new file mode 100644 index 00000000..a17e1ee4 --- /dev/null +++ b/codec2/branches/0.3/octave/test_qpsk2.m @@ -0,0 +1,639 @@ +% test_qps2k.m +% David Rowe Feb 2014 +% +% QPSK modem simulation, version 2. Simplifed version of +% test_qpsk. initially based on code by Bill Cowley Generates curves +% BER versus E/No curves for different modems. Design to test +% coherent demodulation ideas on HF channels without building a full +% blown modem. Uses 'genie provided' estimates for timing estimation, +% frame sync. + +1; + +% main test function + +function sim_out = ber_test(sim_in, modulation) + Fs = 8000; + + verbose = sim_in.verbose; + framesize = sim_in.framesize; + Ntrials = sim_in.Ntrials; + Esvec = sim_in.Esvec; + phase_offset = sim_in.phase_offset; + phase_est = sim_in.phase_est; + w_offset = sim_in.w_offset; + plot_scatter = sim_in.plot_scatter; + Rs = sim_in.Rs; + hf_sim = sim_in.hf_sim; + nhfdelay = sim_in.hf_delay_ms*Rs/1000; + hf_phase_only = sim_in.hf_phase_only; + hf_mag_only = sim_in.hf_mag_only; + Nc = sim_in.Nc; + + bps = 2; + Nsymb = framesize/bps; + prev_sym_tx = qpsk_mod([0 0]); + prev_sym_rx = qpsk_mod([0 0]); + + phase_est_method = sim_in.phase_est_method; + if phase_est_method == 1 + Nps = sim_in.Np; + else + Np = sim_in.Np; + Ns = sim_in.Ns; + if Np/2 == floor(Np/2) + printf("Np must be odd\n"); + return; + end + Nps = (Np-1)*Ns+1; + end + r_delay_line = zeros(Nc, Nps); + s_delay_line = zeros(Nc, Nps); + ph_est_log = []; + + phase_noise_amp = sim_in.phase_noise_amp; + + ldpc_code = sim_in.ldpc_code; + + tx_bits_buf = zeros(1,2*framesize); + rx_bits_buf = zeros(1,2*framesize); + rx_symb_buf = zeros(1,2*Nsymb); + + % Init LDPC -------------------------------------------------------------------- + + if ldpc_code + % Start CML library + + currentdir = pwd; + addpath '/home/david/tmp/cml/mat' % assume the source files stored here + cd /home/david/tmp/cml + CmlStartup % note that this is not in the cml path! + cd(currentdir) + + % Our LDPC library + + ldpc; + + rate = sim_in.ldpc_code_rate; + mod_order = 4; + modulation = 'QPSK'; + mapping = 'gray'; + + demod_type = 0; + decoder_type = 0; + max_iterations = 100; + + code_param = ldpc_init(rate, framesize, modulation, mod_order, mapping); + code_param.code_bits_per_frame = framesize; + code_param.symbols_per_frame = framesize/bps; + else + rate = 1; + end + + % Init HF channel model from stored sample files of spreading signal ---------------------------------- + + % convert "spreading" samples from 1kHz carrier at Fs to complex + % baseband, generated by passing a 1kHz sine wave through PathSim + % with the ccir-poor model, enabling one path at a time. + + Fc = 1000; M = Fs/Rs; + fspread = fopen("../raw/sine1k_2Hz_spread.raw","rb"); + spread1k = fread(fspread, "int16")/10000; + fclose(fspread); + fspread = fopen("../raw/sine1k_2ms_delay_2Hz_spread.raw","rb"); + spread1k_2ms = fread(fspread, "int16")/10000; + fclose(fspread); + + % down convert to complex baseband + spreadbb = spread1k.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k))'); + spreadbb_2ms = spread1k_2ms.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k_2ms))'); + + % remove -2000 Hz image + b = fir1(50, 5/Fs); + spread = filter(b,1,spreadbb); + spread_2ms = filter(b,1,spreadbb_2ms); + + % discard first 1000 samples as these were near 0, probably as + % PathSim states were ramping up + + spread = spread(1000:length(spread)); + spread_2ms = spread_2ms(1000:length(spread_2ms)); + + % decimate down to Rs + + spread = spread(1:M:length(spread)); + spread_2ms = spread_2ms(1:M:length(spread_2ms)); + + % Determine "gain" of HF channel model, so we can normalise + % carrier power during HF channel sim to calibrate SNR. I imagine + % different implementations of ccir-poor would do this in + % different ways, leading to different BER results. Oh Well! + + hf_gain = 1.0/sqrt(var(spread)+var(spread_2ms)); + + % Start Simulation ---------------------------------------------------------------- + + for ne = 1:length(Esvec) + EsNodB = Esvec(ne); + EsNo = 10^(EsNodB/10); + + variance = 1/EsNo; + if verbose > 1 + printf("EsNo (dB): %f EsNo: %f variance: %f\n", EsNodB, EsNo, variance); + end + + Terrs = 0; Tbits = 0; Terrsldpc = 0; Tbitsldpc = 0; Ferrsldpc = 0; + + tx_symb_log = []; + rx_symb_log = []; + noise_log = []; + mod_strip_log = []; + + % init HF channel + + hf_n = 1; + hf_angle_log = []; + hf_fading = ones(1,Nsymb); % default input for ldpc dec + hf_model = ones(Ntrials*Nsymb/Nc, Nc); % defaults for plotting surface + + for nn = 1: Ntrials + + tx_bits = round( rand( 1, framesize*rate ) ); + + % modulate -------------------------------------------- + + if ldpc_code + [tx_bits, s] = ldpc_enc(tx_bits, code_param); + else + s = zeros(1, Nsymb); + for i=1:Nsymb + tx_symb = qpsk_mod(tx_bits(2*(i-1)+1:2*i)); + if strcmp(modulation,'dqpsk') + tx_symb *= prev_sym_tx; + prev_sym_tx = tx_symb; + end + s(i) = tx_symb; + end + end + tx_bits_buf(1:framesize) = tx_bits_buf(framesize+1:2*framesize); + tx_bits_buf(framesize+1:2*framesize) = tx_bits; + s_ch = s; + + % HF channel simulation ------------------------------------ + + if hf_sim + + % separation between carriers. Note this is + % effectively under samples at Rs, I dont think this + % matters. Equivalent to doing freq shift at Fs, then + % decimating to Rs. + + wsep = 2*pi*(1+0.5); % e.g. 75Hz spacing at Rs=50Hz, alpha=0.5 filters + + if Nsymb/Nc != floor(Nsymb/Nc) + printf("Error: Nsymb/Nc must be an integrer\n") + return; + end + + % arrange symbols in Nsymb/Nc by Nc matrix + + for i=1:Nc:Nsymb + + % Determine HF channel at each carrier for this symbol + + for k=1:Nc + hf_model(hf_n, k) = hf_gain*(spread(hf_n) + exp(-j*k*wsep*nhfdelay)*spread_2ms(hf_n)); + hf_fading(i+k-1) = abs(hf_model(hf_n, k)); + if hf_mag_only + s_ch(i+k-1) *= abs(hf_model(hf_n, k)); + else + s_ch(i+k-1) *= hf_model(hf_n, k); + end + end + hf_n++; + end + end + + tx_symb_log = [tx_symb_log s_ch]; + + % AWGN noise and phase/freq offset channel simulation + % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im + + noise = sqrt(variance*0.5)*(randn(1,Nsymb) + j*randn(1,Nsymb)); + noise_log = [noise_log noise]; + phase_noise = phase_noise_amp*(2.0*rand(1,Nsymb)-1.0); + + % organise into carriers to apply frequency and phase offset + + for i=1:Nc:Nsymb + for k=1:Nc + s_ch(i+k-1) = s_ch(i+k-1)*exp(j*(phase_offset+phase_noise(i+k-1))) + noise(i+k-1); + end + phase_offset += w_offset; + end + + % phase estimation + + ph_est = zeros(Nc,1); + + if phase_est + + % organise into carriers + + for i=1:Nc:Nsymb + + for k=1:Nc + centre = floor(Nps/2)+1; + + % delay line for phase est window + + r_delay_line(k,1:Nps-1) = r_delay_line(k,2:Nps); + r_delay_line(k,Nps) = s_ch(i+k-1); + + % delay in tx data to compensate data for phase est window + + s_delay_line(k,1:Nps-1) = s_delay_line(k,2:Nps); + s_delay_line(k,Nps) = s(i+k-1); + %tx_bits(2*(i+k-1-1)+1:2*(i+k-1)) = qpsk_demod(s_delay_line(k,centre)); + + if phase_est_method == 1 + % QPSK modulation strip and phase est + + mod_strip_pol = angle(r_delay_line(k,:)) * 4; + mod_strip_rect = exp(j*mod_strip_pol); + + ph_est_pol = atan2(sum(imag(mod_strip_rect)),sum(real(mod_strip_rect)))/4; + ph_est(k) = exp(j*ph_est_pol); + + s_ch(i+k-1) = r_delay_line(k,centre).*exp(-j*ph_est_pol); + else + + % estimate phase from surrounding known pilot symbols and correct + + corr = 0; + for m=1:Ns:Nps + if (m != centre) + corr += s_delay_line(k,m) * r_delay_line(k,m)'; + end + end + ph_est(k) = conj(corr/(1E-6+abs(corr))); + s_ch(i+k-1) = r_delay_line(k,centre).*exp(j*angle(corr)); + end + + end + + ph_est_log = [ph_est_log ph_est]; + end + %printf("corr: %f angle: %f\n", corr, angle(corr)); + end + + % de-modulate + + rx_bits = zeros(1, framesize); + for i=1:Nsymb + rx_symb = s_ch(i); + if strcmp(modulation,'dqpsk') + tmp = rx_symb; + rx_symb *= conj(prev_sym_rx/abs(prev_sym_rx)); + prev_sym_rx = tmp; + end + rx_bits((2*(i-1)+1):(2*i)) = qpsk_demod(rx_symb); + rx_symb_log = [rx_symb_log rx_symb]; + end + + rx_bits_buf(1:framesize) = rx_bits_buf(framesize+1:2*framesize); + rx_bits_buf(framesize+1:2*framesize) = rx_bits; + rx_symb_buf(1:Nsymb) = rx_symb_buf(Nsymb+1:2*Nsymb); + rx_symb_buf(Nsymb+1:2*Nsymb) = s_ch; + + % determine location of start and end of frame depending on processing delays + + if phase_est + st_rx_bits = 1+(floor(Nps/2)+1-1)*Nc*2; + st_rx_symb = 1+(floor(Nps/2)+1-1)*Nc; + else + st_rx_bits = 1; + st_rx_symb = 1; + end + en_rx_bits = st_rx_bits+framesize-1; + en_rx_symb = st_rx_symb+Nsymb-1; + + if nn > 1 + % Measure BER + + %printf("nn: %d centre: %d\n", nn, floor(Nps/2)+1); + %tx_bits_buf(1:20) + %rx_bits_buf(st_rx_bits:st_rx_bits+20-1) + error_positions = xor(rx_bits_buf(st_rx_bits:en_rx_bits), tx_bits_buf(1:framesize)); + Nerrs = sum(error_positions); + Terrs += Nerrs; + Tbits += length(tx_bits); + + % Optionally LDPC decode + + if ldpc_code + detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, rx_symb_buf(st_rx_symb:en_rx_symb), min(100,EsNo), hf_fading); + %for m=1:20 + % printf("%f ", qpsk_demod(rx_symb_buf(m))); + %end + %detected_data(1:19) + error_positions = xor( detected_data(1:framesize*rate), tx_bits_buf(1:framesize*rate) ); + Nerrs = sum(error_positions); + if Nerrs + Ferrsldpc++; + end + Terrsldpc += Nerrs; + Tbitsldpc += framesize*rate; + end + end + end + + TERvec(ne) = Terrs; + BERvec(ne) = Terrs/Tbits; + if ldpc_code + TERldpcvec(ne) = Terrsldpc; + FERldpcvec(ne) = Ferrsldpc; + BERldpcvec(ne) = Terrsldpc/Tbitsldpc; + end + + if verbose + printf("EsNo (dB): %f Terrs: %d BER %f BER theory %f", EsNodB, Terrs, + Terrs/Tbits, 0.5*erfc(sqrt(EsNo/2))); + if ldpc_code + printf(" LDPC: Terrs: %d BER: %f Ferrs: %d FER: %f", + Terrsldpc, Terrsldpc/Tbitsldpc, Ferrsldpc, Ferrsldpc/(Ntrials-1)); + end + printf("\n"); + end + if verbose > 1 + printf("Terrs: %d BER %f BER theory %f C %f N %f Es %f No %f Es/No %f\n\n", Terrs, + Terrs/Tbits, 0.5*erfc(sqrt(EsNo/2)), var(tx_symb_log), var(noise_log), + var(tx_symb_log), var(noise_log), var(tx_symb_log)/var(noise_log)); + end + end + + Ebvec = Esvec - 10*log10(bps); + sim_out.BERvec = BERvec; + sim_out.Ebvec = Ebvec; + sim_out.TERvec = TERvec; + if ldpc_code + sim_out.BERldpcvec = BERldpcvec; + sim_out.TERldpcvec = TERldpcvec; + sim_out.FERldpcvec = FERldpcvec; + end + + if plot_scatter + figure(2); + clf; + scat = rx_symb_log .* exp(j*pi/4); + plot(real(scat(Nps*Nc:length(scat))), imag(scat(Nps*Nc:length(scat))),'+'); + title('Scatter plot'); + + figure(3); + clf; + + y = 1:Rs*2; + x = 1:Nc; + EsNodBSurface = 20*log10(abs(hf_model(y,:))) - 10*log10(variance); + mesh(x,y,EsNodBSurface); + grid + %axis([1 Nc 1 Rs*2 -10 10]) + title('HF Channel Es/No'); + + figure(4); + clf; + %mesh(x,y,unwrap(angle(hf_model(y,:)))); + subplot(211) + plot(y,abs(hf_model(y,1))) + title('HF Channel Carrier 1 Mag'); + subplot(212) + plot(y,angle(hf_model(y,1))) + title('HF Channel Carrier 1 Phase'); + + if phase_est + scat = ph_est_log(1,floor(Nps/2):Rs*2+floor(Nps/2)-1); + hold on; + plot(angle(scat),'r'); + hold off; + + figure(5) + clf; + scat = ph_est_log(1,y); + plot(real(scat), imag(scat),'+'); + title('Carrier 1 Phase Est'); + axis([-1 1 -1 1]) + end +if 0 + figure(5); + clf; + subplot(211) + plot(real(spread)); + hold on; + plot(imag(spread),'g'); + hold off; + subplot(212) + plot(real(spread_2ms)); + hold on; + plot(imag(spread_2ms),'g'); + hold off; + + figure(6) + tmp = []; + for i = 1:hf_n-1 + tmp = [tmp abs(hf_model(i,:))]; + end + hist(tmp); +end + end + +endfunction + +% Gray coded QPSK modulation function + +function symbol = qpsk_mod(two_bits) + two_bits_decimal = sum(two_bits .* [2 1]); + switch(two_bits_decimal) + case (0) symbol = 1; + case (1) symbol = j; + case (2) symbol = -j; + case (3) symbol = -1; + endswitch +endfunction + +% Gray coded QPSK demodulation function + +function two_bits = qpsk_demod(symbol) + if isscalar(symbol) == 0 + printf("only works with scalars\n"); + return; + end + bit0 = real(symbol*exp(j*pi/4)) < 0; + bit1 = imag(symbol*exp(j*pi/4)) < 0; + two_bits = [bit1 bit0]; +endfunction + +function sim_in = standard_init + sim_in.verbose = 1; + sim_in.plot_scatter = 0; + + sim_in.Esvec = 5; + sim_in.Ntrials = 30; + sim_in.framesize = 576; + sim_in.Rs = 100; + sim_in.Nc = 8; + + sim_in.phase_offset = 0; + sim_in.w_offset = 0; + sim_in.phase_noise_amp = 0; + + sim_in.hf_delay_ms = 2; + sim_in.hf_sim = 0; + sim_in.hf_phase_only = 0; + sim_in.hf_mag_only = 1; + + sim_in.phase_est = 0; + sim_in.phase_est_method = 1; + sim_in.Np = 5; + sim_in.Ns = 5; + + sim_in.ldpc_code_rate = 1/2; + sim_in.ldpc_code = 1; +endfunction + +function ideal + + sim_in = standard_init(); + + sim_in.verbose = 1; + sim_in.plot_scatter = 1; + + sim_in.Esvec = 5; + sim_in.hf_sim = 1; + sim_in.Ntrials = 30; + + sim_qpsk_hf = ber_test(sim_in, 'qpsk'); + + sim_in.hf_sim = 0; + sim_in.plot_scatter = 0; + sim_in.Esvec = 2:15; + sim_in.ldpc_code = 0; + Ebvec = sim_in.Esvec - 10*log10(2); + BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10))); + sim_qpsk = ber_test(sim_in, 'qpsk'); + sim_dqpsk = ber_test(sim_in, 'dqpsk'); + + sim_in.hf_sim = 1; + sim_in.Esvec = 2:15; + sim_qpsk_hf = ber_test(sim_in, 'qpsk'); + sim_dqpsk_hf = ber_test(sim_in, 'dqpsk'); + sim_in.ldpc_code = 1; + sim_qpsk_hf_ldpc1 = ber_test(sim_in, 'qpsk'); + sim_in.ldpc_code_rate = 1/2; + sim_qpsk_hf_ldpc2 = ber_test(sim_in, 'qpsk'); + sim_in.ldpc_code_rate = 3/4; + sim_in.hf_sim = 0; + sim_qpsk_awgn_ldpc = ber_test(sim_in, 'qpsk'); + + figure(1); + clf; + semilogy(Ebvec, BER_theory,'r;QPSK theory;') + hold on; + semilogy(sim_qpsk.Ebvec, sim_qpsk.BERvec,'g;QPSK AWGN;') + semilogy(sim_qpsk_hf.Ebvec, sim_qpsk_hf.BERvec,'r;QPSK HF;') + semilogy(sim_dqpsk.Ebvec, sim_dqpsk.BERvec,'c;DQPSK AWGN;') + semilogy(sim_dqpsk_hf.Ebvec, sim_dqpsk_hf.BERvec,'m;DQPSK HF;') + semilogy(sim_qpsk_hf_ldpc1.Ebvec, sim_qpsk_hf_ldpc1.BERldpcvec,'k;QPSK HF LDPC 3/4;') + semilogy(sim_qpsk_hf_ldpc2.Ebvec, sim_qpsk_hf_ldpc2.BERldpcvec,'b;QPSK HF LDPC 1/2;') + semilogy(sim_qpsk_awgn_ldpc.Ebvec, sim_qpsk_awgn_ldpc.BERldpcvec,'k;QPSK AWGN LDPC 3/4;') + + hold off; + xlabel('Eb/N0') + ylabel('BER') + grid("minor") + axis([min(Ebvec) max(Ebvec) 1E-3 1]) +endfunction + +function phase_noise + sim_in = standard_init(); + + sim_in.verbose = 1; + sim_in.plot_scatter = 1; + + sim_in.Esvec = 100; + sim_in.Ntrials = 30; + + sim_in.ldpc_code_rate = 1/2; + sim_in.ldpc_code = 1; + + sim_in.phase_noise_amp = pi/16; + tmp = ber_test(sim_in, 'qpsk'); + + sim_in.plot_scatter = 0; + sim_in.Esvec = 2:8; + sim_qpsk_hf = ber_test(sim_in, 'qpsk'); + + Ebvec = sim_in.Esvec - 10*log10(2); + BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10))); + + sim_in.phase_noise_amp = 0; + sim_qpsk = ber_test(sim_in, 'qpsk'); + sim_in.phase_noise_amp = pi/8; + sim_qpsk_pn8 = ber_test(sim_in, 'qpsk'); + sim_in.phase_noise_amp = pi/16; + sim_qpsk_pn16 = ber_test(sim_in, 'qpsk'); + sim_in.phase_noise_amp = pi/32; + sim_qpsk_pn32 = ber_test(sim_in, 'qpsk'); + + figure(1); + clf; + semilogy(sim_qpsk.Ebvec, sim_qpsk.BERvec,'g;QPSK phase noise 0;') + hold on; + semilogy(sim_qpsk_pn8.Ebvec, sim_qpsk_pn8.BERvec,'c;QPSK phase noise +/- pi/8;') + semilogy(sim_qpsk_pn16.Ebvec, sim_qpsk_pn16.BERvec,'b;QPSK phase noise +/- pi/16;') + semilogy(sim_qpsk_pn32.Ebvec, sim_qpsk_pn32.BERvec,'k;QPSK phase noise +/- pi/32;') + + semilogy(sim_qpsk.Ebvec, sim_qpsk.BERldpcvec,'g;QPSK phase noise 0 ldpc;') + semilogy(sim_qpsk_pn8.Ebvec, sim_qpsk_pn8.BERldpcvec,'c;QPSK phase noise +/- pi/8 ldpc;') + semilogy(sim_qpsk_pn16.Ebvec, sim_qpsk_pn16.BERldpcvec,'b;QPSK phase noise +/- pi/16 ldpc;') + semilogy(sim_qpsk_pn32.Ebvec, sim_qpsk_pn32.BERldpcvec,'k;QPSK phase noise +/- pi/32 ldpc;') + + hold off; + xlabel('Eb/N0') + ylabel('BER') + grid("minor") + axis([min(Ebvec) max(Ebvec) 1E-2 1]) +endfunction + +function test_phase_est + sim_in = standard_init(); + + sim_in.Rs = 100; + sim_in.Nc = 8; + + sim_in.verbose = 1; + sim_in.plot_scatter = 1; + + sim_in.Esvec = 5; + sim_in.Ntrials = 30; + + sim_in.ldpc_code_rate = 1/2; + sim_in.ldpc_code = 1; + + sim_in.phase_est = 1; + sim_in.phase_est_method = 2; + sim_in.Np = 3; + sim_in.phase_offset = 0; + sim_in.w_offset = 0; + + sim_in.hf_sim = 1; + sim_in.hf_mag_only = 0; + + tmp = ber_test(sim_in, 'qpsk'); + +endfunction + +% Start simulations --------------------------------------- + +more off; + +test_phase_est(); diff --git a/codec2/branches/0.3/octave/test_qpsk3.m b/codec2/branches/0.3/octave/test_qpsk3.m new file mode 100644 index 00000000..37efad87 --- /dev/null +++ b/codec2/branches/0.3/octave/test_qpsk3.m @@ -0,0 +1,955 @@ +% test_qps3k.m +% David Rowe March 2014 +% +% QPSK modem simulation, version 2. Simplifed version of +% test_qpsk. Initially based on code by Bill Cowley Generates curves +% BER versus E/No curves for different modems. Design to test +% coherent demodulation ideas on HF channels without building a full +% blown modem. Uses 'genie provided' estimates for timing estimation, +% frame sync. +% +% Compared to test_qsk2.m this version supports phase estimation +% (coherent demod) + +1; + +% main test function + +function sim_out = ber_test(sim_in, modulation) + Fs = 8000; + + newldpc = sim_in.newldpc; + verbose = sim_in.verbose; + framesize = sim_in.framesize; + Ntrials = sim_in.Ntrials; + Esvec = sim_in.Esvec; + phase_offset = sim_in.phase_offset; + phase_est = sim_in.phase_est; + w_offset = sim_in.w_offset; + plot_scatter = sim_in.plot_scatter; + Rs = sim_in.Rs; + hf_sim = sim_in.hf_sim; + nhfdelay = sim_in.hf_delay_ms*Rs/1000; + hf_phase_only = sim_in.hf_phase_only; + hf_mag_only = sim_in.hf_mag_only; + Nc = sim_in.Nc; + sim_coh_dpsk = sim_in.sim_coh_dpsk; + + bps = 2; + Nsymb = framesize/bps; + for k=1:Nc + prev_sym_tx(k) = qpsk_mod([0 0]); + prev_sym_rx(k) = qpsk_mod([0 0]); + end + + phase_est_method = sim_in.phase_est_method; + if phase_est_method == 2 + Np = sim_in.Np; + Ns = sim_in.Ns; + if Np/2 == floor(Np/2) + printf("Np must be odd\n"); + return; + end + Nps = (Np-1)*Ns+1; + else + Nps = sim_in.Np; + end + r_delay_line = zeros(Nc, Nps); + s_delay_line = zeros(Nc, Nps); + ph_est_log = []; + + phase_noise_amp = sim_in.phase_noise_amp; + + ldpc_code = sim_in.ldpc_code; + + tx_bits_buf = zeros(1,2*framesize); + rx_bits_buf = zeros(1,2*framesize); + rx_symb_buf = zeros(1,2*Nsymb); + hf_fading_buf = zeros(1,2*Nsymb); + + % Init LDPC -------------------------------------------------------------------- + + if ldpc_code + % Start CML library + + currentdir = pwd; + addpath '/home/david/tmp/cml/mat' % assume the source files stored here + cd /home/david/tmp/cml + CmlStartup % note that this is not in the cml path! + cd(currentdir) + + % Our LDPC library + + ldpc; + + rate = sim_in.ldpc_code_rate; + mod_order = 4; + modulation2 = 'QPSK'; + mapping = 'gray'; + + demod_type = 0; + decoder_type = 0; + max_iterations = 100; + + code_param = ldpc_init(rate, framesize, modulation2, mod_order, mapping); + code_param.code_bits_per_frame = framesize; + code_param.symbols_per_frame = framesize/bps; + else + rate = 1; + end + + % Init HF channel model from stored sample files of spreading signal ---------------------------------- + + % convert "spreading" samples from 1kHz carrier at Fs to complex + % baseband, generated by passing a 1kHz sine wave through PathSim + % with the ccir-poor model, enabling one path at a time. + + Fc = 1000; M = Fs/Rs; + fspread = fopen("../raw/sine1k_2Hz_spread.raw","rb"); + spread1k = fread(fspread, "int16")/10000; + fclose(fspread); + fspread = fopen("../raw/sine1k_2ms_delay_2Hz_spread.raw","rb"); + spread1k_2ms = fread(fspread, "int16")/10000; + fclose(fspread); + + % down convert to complex baseband + spreadbb = spread1k.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k))'); + spreadbb_2ms = spread1k_2ms.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k_2ms))'); + + % remove -2000 Hz image + b = fir1(50, 5/Fs); + spread = filter(b,1,spreadbb); + spread_2ms = filter(b,1,spreadbb_2ms); + + % discard first 1000 samples as these were near 0, probably as + % PathSim states were ramping up + + spread = spread(1000:length(spread)); + spread_2ms = spread_2ms(1000:length(spread_2ms)); + + % decimate down to Rs + + spread = spread(1:M:length(spread)); + spread_2ms = spread_2ms(1:M:length(spread_2ms)); + + % Determine "gain" of HF channel model, so we can normalise + % carrier power during HF channel sim to calibrate SNR. I imagine + % different implementations of ccir-poor would do this in + % different ways, leading to different BER results. Oh Well! + + hf_gain = 1.0/sqrt(var(spread)+var(spread_2ms)); + + % Start Simulation ---------------------------------------------------------------- + + for ne = 1:length(Esvec) + EsNodB = Esvec(ne); + EsNo = 10^(EsNodB/10); + + variance = 1/EsNo; + if verbose > 1 + printf("EsNo (dB): %f EsNo: %f variance: %f\n", EsNodB, EsNo, variance); + end + + Terrs = 0; Tbits = 0; Terrsldpc = 0; Tbitsldpc = 0; Ferrsldpc = 0; + + tx_symb_log = []; + rx_symb_log = []; + noise_log = []; + mod_strip_log = []; + + % init HF channel + + hf_n = 1; + hf_angle_log = []; + hf_fading = ones(1,Nsymb); % default input for ldpc dec + hf_model = ones(Ntrials*Nsymb/Nc, Nc); % defaults for plotting surface + + sim_out.errors_log = []; + sim_out.ldpc_errors_log = []; + + for nn = 1: Ntrials + + tx_bits = round( rand( 1, framesize*rate ) ); + + % modulate -------------------------------------------- + + if ldpc_code + [tx_bits, s] = ldpc_enc(tx_bits, code_param); + end + s = zeros(1, Nsymb); + for i=1:Nc:Nsymb + for k=1:Nc + tx_symb = qpsk_mod(tx_bits(2*(i-1+k-1)+1:2*(i+k-1))); + if strcmp(modulation,'dqpsk') + tx_symb *= prev_sym_tx(k); + prev_sym_tx(k) = tx_symb; + end + s(i+k-1) = tx_symb; + end + end + tx_bits_buf(1:framesize) = tx_bits_buf(framesize+1:2*framesize); + tx_bits_buf(framesize+1:2*framesize) = tx_bits; + s_ch = s; + + % HF channel simulation ------------------------------------ + + if hf_sim + + % separation between carriers. Note this is + % effectively under samples at Rs, I dont think this + % matters. Equivalent to doing freq shift at Fs, then + % decimating to Rs. + + wsep = 2*pi*(1+0.5); % e.g. 75Hz spacing at Rs=50Hz, alpha=0.5 filters + + if Nsymb/Nc != floor(Nsymb/Nc) + printf("Error: Nsymb/Nc must be an integrer\n") + return; + end + + % arrange symbols in Nsymb/Nc by Nc matrix + + for i=1:Nc:Nsymb + + % Determine HF channel at each carrier for this symbol + + for k=1:Nc + hf_model(hf_n, k) = hf_gain*(spread(hf_n) + exp(-j*k*wsep*nhfdelay)*spread_2ms(hf_n)); + hf_fading(i+k-1) = abs(hf_model(hf_n, k)); + if hf_mag_only + s_ch(i+k-1) *= abs(hf_model(hf_n, k)); + else + s_ch(i+k-1) *= hf_model(hf_n, k); + end + end + hf_n++; + end + end + + tx_symb_log = [tx_symb_log s_ch]; + + % AWGN noise and phase/freq offset channel simulation + % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im + + noise = sqrt(variance*0.5)*(randn(1,Nsymb) + j*randn(1,Nsymb)); + noise_log = [noise_log noise]; + phase_noise = phase_noise_amp*(2.0*rand(1,Nsymb)-1.0); + + % organise into carriers to apply frequency and phase offset + + for i=1:Nc:Nsymb + for k=1:Nc + s_ch(i+k-1) = s_ch(i+k-1)*exp(j*(phase_offset+phase_noise(i+k-1))) + noise(i+k-1); + end + phase_offset += w_offset; + end + + % phase estimation + + ph_est = zeros(Nc,1); + + if phase_est + + % organise into carriers + + for i=1:Nc:Nsymb + + for k=1:Nc + centre = floor(Nps/2)+1; + + % delay line for phase est window + + r_delay_line(k,1:Nps-1) = r_delay_line(k,2:Nps); + r_delay_line(k,Nps) = s_ch(i+k-1); + + % delay in tx data to compensate data for phase est window + + s_delay_line(k,1:Nps-1) = s_delay_line(k,2:Nps); + s_delay_line(k,Nps) = s(i+k-1); + + if phase_est_method == 1 + % QPSK modulation strip and phase est + + mod_strip_pol = angle(r_delay_line(k,:)) * 4; + mod_strip_rect = exp(j*mod_strip_pol); + + ph_est_pol = atan2(sum(imag(mod_strip_rect)),sum(real(mod_strip_rect)))/4; + ph_est(k) = exp(j*ph_est_pol); + + s_ch(i+k-1) = r_delay_line(k,centre).*exp(-j*ph_est_pol); + % s_ch(i+k-1) = r_delay_line(k,centre); + end + + if phase_est_method == 3 + % QPSK modulation strip and phase est with original symbol mags + + mod_strip_pol = angle(r_delay_line(k,:)) * 4; + mod_strip_rect = abs(r_delay_line(k,:)) .* exp(j*mod_strip_pol); + + ph_est_pol = atan2(sum(imag(mod_strip_rect)),sum(real(mod_strip_rect)))/4; + ph_est(k) = exp(j*ph_est_pol); + + s_ch(i+k-1) = r_delay_line(k,centre).*exp(-j*ph_est_pol); + % s_ch(i+k-1) = r_delay_line(k,centre); + end + + if phase_est_method == 2 + + % estimate phase from surrounding known pilot symbols and correct + + corr = 0; + for m=1:Ns:Nps + if (m != centre) + corr += s_delay_line(k,m) * r_delay_line(k,m)'; + end + end + ph_est(k) = conj(corr/(1E-6+abs(corr))); + s_ch(i+k-1) = r_delay_line(k,centre).*exp(j*angle(corr)); + %s_ch(i+k-1) = r_delay_line(k,centre); + end + + end + + ph_est_log = [ph_est_log ph_est]; + end + %printf("corr: %f angle: %f\n", corr, angle(corr)); + end + + % de-modulate + + rx_bits = zeros(1, framesize); + for i=1:Nc:Nsymb + for k=1:Nc + rx_symb = s_ch(i+k-1); + if strcmp(modulation,'dqpsk') + tmp = rx_symb; + rx_symb *= conj(prev_sym_rx(k)/abs(prev_sym_rx(k))); + if sim_coh_dpsk + prev_sym_rx(k) = qpsk_mod(qpsk_demod(tmp)); + else + prev_sym_rx(k) = tmp; + end + s_ch(i+k-1) = rx_symb; + end + rx_bits((2*(i-1+k-1)+1):(2*(i+k-1))) = qpsk_demod(rx_symb); + rx_symb_log = [rx_symb_log rx_symb]; + end + end + +if newldpc + rx_bits_buf(1:framesize) = rx_bits_buf(framesize+1:2*framesize); + rx_bits_buf(framesize+1:2*framesize) = rx_bits; + rx_symb_buf(1:Nsymb) = rx_symb_buf(Nsymb+1:2*Nsymb); + rx_symb_buf(Nsymb+1:2*Nsymb) = s_ch; + hf_fading_buf(1:Nsymb) = hf_fading_buf(Nsymb+1:2*Nsymb); + hf_fading_buf(Nsymb+1:2*Nsymb) = hf_fading; + + % determine location of start and end of frame depending on processing delays + + if phase_est + st_rx_bits = 1+(floor(Nps/2)+1-1)*Nc*2; + st_rx_symb = 1+(floor(Nps/2)+1-1)*Nc; + else + st_rx_bits = 1; + st_rx_symb = 1; + end + en_rx_bits = st_rx_bits+framesize-1; + en_rx_symb = st_rx_symb+Nsymb-1; + + if nn > 1 + % Measure BER + + %printf("nn: %d centre: %d\n", nn, floor(Nps/2)+1); + %tx_bits_buf(1:20) + %rx_bits_buf(st_rx_bits:st_rx_bits+20-1) + error_positions = xor(rx_bits_buf(st_rx_bits:en_rx_bits), tx_bits_buf(1:framesize)); + Nerrs = sum(error_positions); + sim_out.errors_log = [sim_out.errors_log error_positions]; + Terrs += Nerrs; + Tbits += length(tx_bits); + + % Optionally LDPC decode + + if ldpc_code + detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, ... + rx_symb_buf(st_rx_symb:en_rx_symb), min(100,EsNo), hf_fading_buf(1:Nsymb)); + error_positions = xor( detected_data(1:framesize*rate), tx_bits_buf(1:framesize*rate) ); + %detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, s_ch, min(100,EsNo), hf_fading); + %error_positions = xor( detected_data(1:framesize*rate), tx_bits(1:framesize*rate) ); + Nerrs = sum(error_positions); + sim_out.ldpc_errors_log = [sim_out.ldpc_errors_log error_positions]; + if Nerrs + Ferrsldpc++; + end + Terrsldpc += Nerrs; + Tbitsldpc += framesize*rate; + end + end + +else + error_positions = xor(rx_bits, tx_bits); + Nerrs = sum(error_positions); + Terrs += Nerrs; + Tbits += length(tx_bits); + + % Optionally LDPC decode + + if ldpc_code + detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, s_ch, min(100,EsNo), hf_fading); + error_positions = xor( detected_data(1:framesize*rate), tx_bits(1:framesize*rate) ); + Nerrs = sum(error_positions); + if Nerrs + Ferrsldpc++; + end + Terrsldpc += Nerrs; + Tbitsldpc += framesize*rate; + + end + end +end + + TERvec(ne) = Terrs; + BERvec(ne) = Terrs/Tbits; + if ldpc_code + TERldpcvec(ne) = Terrsldpc; + FERldpcvec(ne) = Ferrsldpc; + BERldpcvec(ne) = Terrsldpc/Tbitsldpc; + end + + if verbose + printf("EsNo (dB): %f Terrs: %d BER %f BER theory %f", EsNodB, Terrs, + Terrs/Tbits, 0.5*erfc(sqrt(EsNo/2))); + if ldpc_code + printf(" LDPC: Terrs: %d BER: %f Ferrs: %d FER: %f", + Terrsldpc, Terrsldpc/Tbitsldpc, Ferrsldpc, Ferrsldpc/(Ntrials-1)); + end + printf("\n"); + end + if verbose > 1 + printf("Terrs: %d BER %f BER theory %f C %f N %f Es %f No %f Es/No %f\n\n", Terrs, + Terrs/Tbits, 0.5*erfc(sqrt(EsNo/2)), var(tx_symb_log), var(noise_log), + var(tx_symb_log), var(noise_log), var(tx_symb_log)/var(noise_log)); + end + end + + Ebvec = Esvec - 10*log10(bps); + + % account for extra power rqd for pilot symbols + + if (phase_est_method == 2) && (phase_est) + Ebvec += 10*log10(Ns/(Ns-1)); + end + + sim_out.BERvec = BERvec; + sim_out.Ebvec = Ebvec; + sim_out.TERvec = TERvec; + if ldpc_code + sim_out.BERldpcvec = BERldpcvec; + sim_out.TERldpcvec = TERldpcvec; + sim_out.FERldpcvec = FERldpcvec; + end + + if plot_scatter + figure(2); + clf; + scat = rx_symb_log .* exp(j*pi/4); + plot(real(scat(Nps*Nc:length(scat))), imag(scat(Nps*Nc:length(scat))),'+'); + title('Scatter plot'); + + figure(3); + clf; + + y = 1:Rs*2; + x = 1:Nc; + EsNodBSurface = 20*log10(abs(hf_model(y,:))) - 10*log10(variance); + mesh(x,y,EsNodBSurface); + grid + %axis([1 Nc 1 Rs*2 -10 10]) + title('HF Channel Es/No'); + + figure(4); + clf; + %mesh(x,y,unwrap(angle(hf_model(y,:)))); + subplot(211) + plot(y,abs(hf_model(y,1))) + title('HF Channel Carrier 1 Mag'); + subplot(212) + plot(y,angle(hf_model(y,1))) + title('HF Channel Carrier 1 Phase'); + + if phase_est + scat = ph_est_log(1,floor(Nps/2):Rs*2+floor(Nps/2)-1); + hold on; + plot(angle(scat),'r'); + hold off; + + figure(5) + clf; + scat = ph_est_log(1,y); + plot(real(scat), imag(scat),'+'); + title('Carrier 1 Phase Est'); + axis([-1 1 -1 1]) + end +if 0 + figure(5); + clf; + subplot(211) + plot(real(spread)); + hold on; + plot(imag(spread),'g'); + hold off; + subplot(212) + plot(real(spread_2ms)); + hold on; + plot(imag(spread_2ms),'g'); + hold off; + + figure(6) + tmp = []; + for i = 1:hf_n-1 + tmp = [tmp abs(hf_model(i,:))]; + end + hist(tmp); +end + end + +size(sim_out.errors_log) + +endfunction + +% Gray coded QPSK modulation function + +function symbol = qpsk_mod(two_bits) + two_bits_decimal = sum(two_bits .* [2 1]); + switch(two_bits_decimal) + case (0) symbol = 1; + case (1) symbol = j; + case (2) symbol = -j; + case (3) symbol = -1; + endswitch +endfunction + +% Gray coded QPSK demodulation function + +function two_bits = qpsk_demod(symbol) + if isscalar(symbol) == 0 + printf("only works with scalars\n"); + return; + end + bit0 = real(symbol*exp(j*pi/4)) < 0; + bit1 = imag(symbol*exp(j*pi/4)) < 0; + two_bits = [bit1 bit0]; +endfunction + +function sim_in = standard_init + sim_in.verbose = 1; + sim_in.plot_scatter = 0; + + sim_in.Esvec = 5; + sim_in.Ntrials = 30; + sim_in.framesize = 576; + sim_in.Rs = 100; + sim_in.Nc = 8; + + sim_in.phase_offset = 0; + sim_in.w_offset = 0; + sim_in.phase_noise_amp = 0; + + sim_in.hf_delay_ms = 2; + sim_in.hf_sim = 0; + sim_in.hf_phase_only = 0; + sim_in.hf_mag_only = 1; + + sim_in.phase_est = 0; + sim_in.phase_est_method = 1; + sim_in.Np = 5; + sim_in.Ns = 5; + + sim_in.ldpc_code_rate = 1/2; + sim_in.ldpc_code = 1; +endfunction + +function ideal + + sim_in = standard_init(); + + sim_in.verbose = 1; + sim_in.plot_scatter = 1; + + sim_in.Esvec = 5; + sim_in.hf_sim = 1; + sim_in.Ntrials = 100; + + sim_qpsk_hf = ber_test(sim_in, 'qpsk'); + + sim_in.hf_sim = 0; + sim_in.plot_scatter = 0; + sim_in.Esvec = 2:15; + sim_in.ldpc_code = 0; + Ebvec = sim_in.Esvec - 10*log10(2); + BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10))); + sim_qpsk = ber_test(sim_in, 'qpsk'); + sim_dqpsk = ber_test(sim_in, 'dqpsk'); + + sim_in.hf_sim = 1; + sim_in.Esvec = 2:15; + sim_qpsk_hf = ber_test(sim_in, 'qpsk'); + sim_dqpsk_hf = ber_test(sim_in, 'dqpsk'); + sim_in.ldpc_code = 1; + sim_in.ldpc_code_rate = 3/4; + sim_qpsk_hf_ldpc1 = ber_test(sim_in, 'qpsk'); + sim_in.ldpc_code_rate = 1/2; + sim_qpsk_hf_ldpc2 = ber_test(sim_in, 'qpsk'); + sim_in.ldpc_code_rate = 3/4; + sim_in.hf_sim = 0; + sim_qpsk_awgn_ldpc = ber_test(sim_in, 'qpsk'); + + figure(1); + clf; + semilogy(Ebvec, BER_theory,'r;QPSK theory;') + hold on; + semilogy(sim_qpsk.Ebvec, sim_qpsk.BERvec,'g;QPSK AWGN;') + semilogy(sim_qpsk_hf.Ebvec, sim_qpsk_hf.BERvec,'r;QPSK HF;') + semilogy(sim_dqpsk.Ebvec, sim_dqpsk.BERvec,'c;DQPSK AWGN;') + semilogy(sim_dqpsk_hf.Ebvec, sim_dqpsk_hf.BERvec,'m;DQPSK HF;') + semilogy(sim_qpsk_hf_ldpc1.Ebvec, sim_qpsk_hf_ldpc1.BERldpcvec,'k;QPSK HF LDPC 3/4;') + semilogy(sim_qpsk_hf_ldpc2.Ebvec, sim_qpsk_hf_ldpc2.BERldpcvec,'b;QPSK HF LDPC 1/2;') + semilogy(sim_qpsk_awgn_ldpc.Ebvec, sim_qpsk_awgn_ldpc.BERldpcvec,'k;QPSK AWGN LDPC 3/4;') + + hold off; + xlabel('Eb/N0') + ylabel('BER') + grid("minor") + axis([min(Ebvec) max(Ebvec) 1E-3 1]) +endfunction + +function phase_noise + sim_in = standard_init(); + + sim_in.verbose = 1; + sim_in.plot_scatter = 1; + + sim_in.Esvec = 100; + sim_in.Ntrials = 100; + + sim_in.ldpc_code_rate = 1/2; + sim_in.ldpc_code = 1; + + sim_in.phase_noise_amp = pi/16; + tmp = ber_test(sim_in, 'qpsk'); + + sim_in.plot_scatter = 0; + sim_in.Esvec = 2:8; + sim_qpsk_hf = ber_test(sim_in, 'qpsk'); + + Ebvec = sim_in.Esvec - 10*log10(2); + BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10))); + + sim_in.phase_noise_amp = 0; + sim_qpsk = ber_test(sim_in, 'qpsk'); + sim_in.phase_noise_amp = pi/8; + sim_qpsk_pn8 = ber_test(sim_in, 'qpsk'); + sim_in.phase_noise_amp = pi/16; + sim_qpsk_pn16 = ber_test(sim_in, 'qpsk'); + sim_in.phase_noise_amp = pi/32; + sim_qpsk_pn32 = ber_test(sim_in, 'qpsk'); + + figure(1); + clf; + semilogy(sim_qpsk.Ebvec, sim_qpsk.BERvec,'g;QPSK phase noise 0;') + hold on; + semilogy(sim_qpsk_pn8.Ebvec, sim_qpsk_pn8.BERvec,'c;QPSK phase noise +/- pi/8;') + semilogy(sim_qpsk_pn16.Ebvec, sim_qpsk_pn16.BERvec,'b;QPSK phase noise +/- pi/16;') + semilogy(sim_qpsk_pn32.Ebvec, sim_qpsk_pn32.BERvec,'k;QPSK phase noise +/- pi/32;') + + semilogy(sim_qpsk.Ebvec, sim_qpsk.BERldpcvec,'g;QPSK phase noise 0 ldpc;') + semilogy(sim_qpsk_pn8.Ebvec, sim_qpsk_pn8.BERldpcvec,'c;QPSK phase noise +/- pi/8 ldpc;') + semilogy(sim_qpsk_pn16.Ebvec, sim_qpsk_pn16.BERldpcvec,'b;QPSK phase noise +/- pi/16 ldpc;') + semilogy(sim_qpsk_pn32.Ebvec, sim_qpsk_pn32.BERldpcvec,'k;QPSK phase noise +/- pi/32 ldpc;') + + hold off; + xlabel('Eb/N0') + ylabel('BER') + grid("minor") + axis([min(Ebvec) max(Ebvec) 1E-2 1]) +endfunction + +function phase_est_hf + sim_in = standard_init(); + + sim_in.Rs = 100; + sim_in.Nc = 8; + + sim_in.verbose = 1; + sim_in.plot_scatter = 0; + + sim_in.Esvec = 5:15; + sim_in.Ntrials = 100; + + sim_in.newldpc = 1; + sim_in.ldpc_code_rate = 1/2; + sim_in.ldpc_code = 1; + + sim_in.phase_est = 0; + sim_in.sim_coh_dpsk = 0; + sim_in.phase_est_method = 2; + sim_in.Np = 3; + sim_in.phase_offset = 0; + sim_in.w_offset = 0; + + sim_in.hf_sim = 1; + sim_in.hf_mag_only = 1; + + Ebvec = sim_in.Esvec - 10*log10(2); + + baseline = ber_test(sim_in, 'qpsk'); + + sim_in.hf_mag_only = 0; + sim_in.phase_est_method = 2; + sim_in.phase_est = 1; + sim_in.Np = 3; + pilot_3 = ber_test(sim_in, 'qpsk'); + sim_in.Np = 5; + pilot_5 = ber_test(sim_in, 'qpsk'); + sim_in.Np = 7; + pilot_7 = ber_test(sim_in, 'qpsk'); + +if 1 + sim_in.phase_est = 0; + dqpsk = ber_test(sim_in, 'dqpsk'); + + figure(1); + clf; + semilogy(baseline.Ebvec, baseline.BERvec,'r;QPSK CCIR poor;') + hold on; + semilogy(baseline.Ebvec, baseline.BERldpcvec,'r;QPSK CCIR poor ldpc;') + semilogy(pilot_3.Ebvec, pilot_3.BERvec,'b;QPSK CCIR poor ldpc pilot 3;') + semilogy(pilot_3.Ebvec, pilot_3.BERldpcvec,'b;QPSK CCIR poor ldpc pilot 3;') + semilogy(pilot_5.Ebvec, pilot_5.BERvec,'g;QPSK CCIR poor ldpc pilot 5;') + semilogy(pilot_5.Ebvec, pilot_5.BERldpcvec,'g;QPSK CCIR poor ldpc pilot 5;') + semilogy(pilot_7.Ebvec, pilot_7.BERvec,'m;QPSK CCIR poor ldpc pilot 7;') + semilogy(pilot_7.Ebvec, pilot_7.BERldpcvec,'m;QPSK CCIR poor ldpc pilot 7;') + semilogy(dqpsk.Ebvec, dqpsk.BERvec,'k;DQPSK CCIR poor ldpc;') + semilogy(dqpsk.Ebvec, dqpsk.BERldpcvec,'k;DQPSK CCIR poor ldpc;') + + hold off; + xlabel('Eb/N0') + ylabel('BER') + grid("minor") + axis([min(Ebvec) max(Ebvec) 1E-2 1]) +end +endfunction + +function phase_est_awgn + sim_in = standard_init(); + + sim_in.Rs = 100; + sim_in.Nc = 8; + + sim_in.verbose = 1; + sim_in.plot_scatter = 0; + + sim_in.Esvec = 0:0.5:3; + sim_in.Ntrials = 30; + + sim_in.newldpc = 1; + sim_in.ldpc_code_rate = 1/2; + sim_in.ldpc_code = 1; + + sim_in.phase_est = 0; + sim_in.phase_est_method = 1; + sim_in.Np = 3; + sim_in.phase_offset = 0; + sim_in.w_offset = 0; + + sim_in.hf_sim = 0; + sim_in.hf_mag_only = 1; + + ideal = ber_test(sim_in, 'qpsk'); + + sim_in.phase_est = 1; + sim_in.Np = 21; + sim_in.phase_est_method = 3; + strip_21_mag = ber_test(sim_in, 'qpsk'); + + sim_in.Np = 41; + strip_41_mag = ber_test(sim_in, 'qpsk'); + + sim_in.phase_est_method = 1; + sim_in.Np = 21; + strip_21 = ber_test(sim_in, 'qpsk'); + + sim_in.Np = 41; + strip_41 = ber_test(sim_in, 'qpsk'); + + sim_in.Np = 7; + sim_in.phase_est_method = 2; + pilot_7 = ber_test(sim_in, 'qpsk'); + + Ebvec = sim_in.Esvec - 10*log10(2); + + figure(1); + clf; + semilogy(ideal.Ebvec, ideal.BERvec,'r;QPSK;') + hold on; + semilogy(ideal.Ebvec, ideal.BERldpcvec,'r;QPSK LDPC;') + semilogy(strip_21.Ebvec, strip_21.BERvec,'g;QPSK strip 21;') + semilogy(strip_21.Ebvec, strip_21.BERldpcvec,'g;QPSK LDPC strip 21;') + semilogy(strip_41.Ebvec, strip_41.BERvec,'b;QPSK strip 41;') + semilogy(strip_41.Ebvec, strip_41.BERldpcvec,'b;QPSK LDPC strip 41;') + semilogy(strip_21_mag.Ebvec, strip_21_mag.BERvec,'m;QPSK strip 21 mag;') + semilogy(strip_21_mag.Ebvec, strip_21_mag.BERldpcvec,'m;QPSK LDPC strip 21 mag;') + semilogy(strip_41_mag.Ebvec, strip_41_mag.BERvec,'c;QPSK strip 41 mag;') + semilogy(strip_41_mag.Ebvec, strip_41_mag.BERldpcvec,'c;QPSK LDPC strip 41 mag;') + semilogy(pilot_7.Ebvec, pilot_7.BERvec,'k;QPSK pilot 7;') + semilogy(pilot_7.Ebvec, pilot_7.BERldpcvec,'k;QPSK LDPC pilot 7;') + + hold off; + xlabel('Eb/N0') + ylabel('BER') + grid("minor") + axis([min(Ebvec) max(Ebvec) 1E-2 1]) +endfunction + +function test_dpsk + sim_in = standard_init(); + + sim_in.Rs = 100; + sim_in.Nc = 8; + + sim_in.verbose = 1; + sim_in.plot_scatter = 0; + + sim_in.Esvec = 5; + sim_in.Ntrials = 30; + + sim_in.newldpc = 1; + sim_in.ldpc_code_rate = 1/2; + sim_in.ldpc_code = 1; + + sim_in.phase_est = 0; + sim_in.phase_est_method = 3; + sim_in.Np = 41; + sim_in.phase_offset = 0; + sim_in.w_offset = 0; + sim_in.sim_coh_dpsk = 0; + + sim_in.hf_sim = 0; + sim_in.hf_mag_only = 1; + + Ebvec = sim_in.Esvec - 10*log10(2); + + baseline = ber_test(sim_in, 'qpsk'); + sim_in.phase_est = 0; + dqpsk = ber_test(sim_in, 'dqpsk'); + + sim_in.phase_est = 1; + sim_in.phase_est_method = 3; + sim_in.sim_coh_dpsk = 1; + sim_in.Np = 41; + dqpsk_strip_41 = ber_test(sim_in, 'dqpsk'); + + figure(1); + clf; + semilogy(baseline.Ebvec, baseline.BERvec,'r;QPSK CCIR poor;') + hold on; + semilogy(baseline.Ebvec, baseline.BERldpcvec,'r;QPSK CCIR poor ldpc;') + semilogy(dqpsk.Ebvec, dqpsk.BERvec,'c;DQPSK CCIR poor ldpc;') + semilogy(dqpsk.Ebvec, dqpsk.BERldpcvec,'c;DQPSK CCIR poor ldpc;') + semilogy(dqpsk_strip_41.Ebvec, dqpsk_strip_41.BERvec,'m;DQPSK CCIR poor ldpc strip 41;') + semilogy(dqpsk_strip_41.Ebvec, dqpsk_strip_41.BERldpcvec,'m;DQPSK CCIR poor ldpc strip 41;') + + hold off; + xlabel('Eb/N0') + ylabel('BER') + grid("minor") + axis([min(Ebvec) max(Ebvec) 1E-2 1]) + +endfunction + +function gen_error_pattern_qpsk() + sim_in = standard_init(); + + % model codec and uncoded streams as 1000 bit/s each + + sim_in.Rs = 100; + sim_in.Nc = 4; + + sim_in.verbose = 1; + sim_in.plot_scatter = 0; + + sim_in.Esvec = 10; % Eb/No=2dB + sim_in.Ntrials = 30; + + sim_in.newldpc = 1; + sim_in.ldpc_code_rate = 1/2; + sim_in.ldpc_code = 1; + + sim_in.phase_est = 1; + sim_in.phase_est_method = 2; + sim_in.Np = 5; + sim_in.phase_offset = 0; + sim_in.w_offset = 0; + sim_in.sim_coh_dpsk = 0; + + sim_in.hf_sim = 1; + sim_in.hf_mag_only = 0; + + qpsk = ber_test(sim_in, 'qpsk'); + + length(qpsk.errors_log) + length(qpsk.ldpc_errors_log) + % multiplex errors into prot and unprot halves of 52 bit codec frames + + error_pattern = []; + for i=1:26:length(qpsk.ldpc_errors_log)-52 + error_pattern = [error_pattern qpsk.ldpc_errors_log(i:i+25) qpsk.errors_log(i:i+25) zeros(1,4)]; + %error_pattern = [error_pattern qpsk.ldpc_errors_log(i:i+25) zeros(1,26) zeros(1,4)]; + %error_pattern = [error_pattern zeros(1,26) qpsk.errors_log(i:i+25) zeros(1,4)]; + end + + fep=fopen("qpsk_errors_2dB.bin","wb"); fwrite(fep, error_pattern, "short"); fclose(fep); + +endfunction + +function gen_error_pattern_dpsk() + sim_in = standard_init(); + + sim_in.Rs = 50; + sim_in.Nc = 16; + + sim_in.verbose = 1; + sim_in.plot_scatter = 1; + + sim_in.Esvec = 10; % Eb/No=Es/No-3 + sim_in.Ntrials = 30; + + sim_in.newldpc = 1; + sim_in.ldpc_code_rate = 1/2; + sim_in.ldpc_code = 0; + + sim_in.phase_est = 0; + sim_in.phase_est_method = 3; + sim_in.Np = 41; + sim_in.phase_offset = 0; + sim_in.w_offset = 0; + sim_in.sim_coh_dpsk = 0; + + sim_in.hf_sim = 1; + sim_in.hf_mag_only = 1; + + dqpsk = ber_test(sim_in, 'dqpsk'); + + fep=fopen("dqpsk_errors_12dB.bin","wb"); fwrite(fep, dqpsk.errors_log, "short"); fclose(fep); + +endfunction + +% Start simulations --------------------------------------- + +more off; + +%ideal(); +%phase_est_hf(); +%phase_est_awgn(); +%test_dpsk(); +gen_error_pattern_qpsk diff --git a/codec2/branches/0.3/octave/tfdmdv.m b/codec2/branches/0.3/octave/tfdmdv.m new file mode 100644 index 00000000..41e68c88 --- /dev/null +++ b/codec2/branches/0.3/octave/tfdmdv.m @@ -0,0 +1,306 @@ +% tfdmdv.m +% +% Octave script that tests the C port of the FDMDV modem. This script loads +% the output of unittest/tfdmdv.c and compares it to the output of the +% reference versions of the same functions written in Octave. +% +% Copyright David Rowe 2012 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% + +fdmdv; % load modem code + +% Generate reference vectors using Octave implementation of FDMDV modem + +global passes; +global fails; +passes = fails = 0; +frames = 25; +prev_tx_symbols = ones(Nc+1,1); +prev_rx_symbols = ones(Nc+1,1); +foff_phase_rect = 1; +coarse_fine = 0; +fest_state = 0; +channel = []; +channel_count = 0; +next_nin = M; +sig_est = zeros(Nc+1,1); +noise_est = zeros(Nc+1,1); + +% Octave outputs we want to collect for comparison to C version + +tx_bits_log = []; +tx_symbols_log = []; +tx_baseband_log = []; +tx_fdm_log = []; +pilot_baseband1_log = []; +pilot_baseband2_log = []; +pilot_lpf1_log = []; +pilot_lpf2_log = []; +S1_log = []; +S2_log = []; +foff_coarse_log = []; +foff_fine_log = []; +foff_log = []; +rx_baseband_log = []; +rx_filt_log = []; +env_log = []; +rx_timing_log = []; +rx_symbols_log = []; +rx_bits_log = []; +sync_bit_log = []; +coarse_fine_log = []; +nin_log = []; +sig_est_log = []; +noise_est_log = []; + +for f=1:frames + + % modulator + + tx_bits = get_test_bits(Nc*Nb); + tx_bits_log = [tx_bits_log tx_bits]; + tx_symbols = bits_to_qpsk(prev_tx_symbols, tx_bits, 'dqpsk'); + prev_tx_symbols = tx_symbols; + tx_symbols_log = [tx_symbols_log tx_symbols]; + tx_baseband = tx_filter(tx_symbols); + tx_baseband_log = [tx_baseband_log tx_baseband]; + tx_fdm = fdm_upconvert(tx_baseband); + tx_fdm_log = [tx_fdm_log tx_fdm]; + + % channel + + nin = next_nin; + %nin = 120; + %nin = M; + %if (f == 3) + % nin = 120; + %elseif (f == 4) + % nin = 200; + %else + % nin = M; + %end + channel = [channel real(tx_fdm)]; + channel_count += M; + rx_fdm = channel(1:nin); + channel = channel(nin+1:channel_count); + channel_count -= nin; + + % demodulator + + [pilot prev_pilot pilot_lut_index prev_pilot_lut_index] = get_pilot(pilot_lut_index, prev_pilot_lut_index, nin); + + [foff_coarse S1 S2] = rx_est_freq_offset(rx_fdm, pilot, prev_pilot, nin); + if coarse_fine == 0 + foff = foff_coarse; + end + foff_coarse_log = [foff_coarse_log foff_coarse]; + + pilot_baseband1_log = [pilot_baseband1_log pilot_baseband1]; + pilot_baseband2_log = [pilot_baseband2_log pilot_baseband2]; + pilot_lpf1_log = [pilot_lpf1_log pilot_lpf1]; + pilot_lpf2_log = [pilot_lpf2_log pilot_lpf2]; + S1_log = [S1_log S1]; + S2_log = [S2_log S2]; + + foff_rect = exp(j*2*pi*foff/Fs); + + for i=1:nin + foff_phase_rect *= foff_rect'; + rx_fdm_fcorr(i) = rx_fdm(i)*foff_phase_rect; + end + + rx_baseband = fdm_downconvert(rx_fdm_fcorr, nin); + rx_baseband_log = [rx_baseband_log rx_baseband]; + + rx_filt = rx_filter(rx_baseband, nin); + rx_filt_log = [rx_filt_log rx_filt]; + + [rx_symbols rx_timing env] = rx_est_timing(rx_filt, rx_baseband, nin); + env_log = [env_log env]; + + rx_timing_log = [rx_timing_log rx_timing]; + rx_symbols_log = [rx_symbols_log rx_symbols]; + + next_nin = M; + if rx_timing > 2*M/P + next_nin += M/P; + end + if rx_timing < 0; + next_nin -= M/P; + end + nin_log = [nin_log nin]; + + [rx_bits sync_bit foff_fine pd] = qpsk_to_bits(prev_rx_symbols, rx_symbols, 'dqpsk'); + + [sig_est noise_est] = snr_update(sig_est, noise_est, pd); + sig_est_log = [sig_est_log sig_est]; + noise_est_log = [noise_est_log noise_est]; + + prev_rx_symbols = rx_symbols; + rx_bits_log = [rx_bits_log rx_bits]; + foff_fine_log = [foff_fine_log foff_fine]; + sync_bit_log = [sync_bit_log sync_bit]; + foff -= 0.5*foff_fine; + foff_log = [foff_log foff]; + + % freq est state machine + + [coarse_fine fest_state] = freq_state(sync_bit, fest_state); + coarse_fine_log = [coarse_fine_log coarse_fine]; +end + +% Compare to the output from the C version + +load ../unittest/tfdmdv_out.txt + +% Helper functions to plot output of C verson and difference between Octave and C versions + +function stem_sig_and_error(plotnum, subplotnum, sig, error, titlestr, axisvec) + figure(plotnum) + subplot(subplotnum) + stem(sig); + hold on; + stem(error,'g'); + hold off; + if nargin == 6 + axis(axisvec); + end + title(titlestr); +endfunction + +function plot_sig_and_error(plotnum, subplotnum, sig, error, titlestr, axisvec) + figure(plotnum) + subplot(subplotnum) + plot(sig); + hold on; + plot(error,'g'); + hold off; + if nargin == 6 + axis(axisvec); + end + title(titlestr); +endfunction + +% --------------------------------------------------------------------------------------- +% Plot output and test each C function +% --------------------------------------------------------------------------------------- + +% fdmdv_get_test_bits() & bits_to_dqpsk_symbols() + +n = 28; +stem_sig_and_error(1, 211, tx_bits_log_c(1:n), tx_bits_log(1:n) - tx_bits_log_c(1:n), 'tx bits', [1 n -1.5 1.5]) +stem_sig_and_error(1, 212, real(tx_symbols_log_c(1:n/2)), real(tx_symbols_log(1:n/2) - tx_symbols_log_c(1:n/2)), 'tx symbols real', [1 n/2 -1.5 1.5]) + +% tx_filter() + +diff = tx_baseband_log - tx_baseband_log_c; +c=15; +plot_sig_and_error(2, 211, real(tx_baseband_log_c(c,:)), real(sum(diff)), 'tx baseband real') +plot_sig_and_error(2, 212, imag(tx_baseband_log_c(c,:)), imag(sum(diff)), 'tx baseband imag') + +% fdm_upconvert() + +plot_sig_and_error(3, 211, real(tx_fdm_log_c), real(tx_fdm_log - tx_fdm_log_c), 'tx fdm real') +plot_sig_and_error(3, 212, imag(tx_fdm_log_c), imag(tx_fdm_log - tx_fdm_log_c), 'tx fdm imag') + +% generate_pilot_lut() + +plot_sig_and_error(4, 211, real(pilot_lut_c), real(pilot_lut - pilot_lut_c), 'pilot lut real') +plot_sig_and_error(4, 212, imag(pilot_lut_c), imag(pilot_lut - pilot_lut_c), 'pilot lut imag') + +% rx_est_freq_offset() + +st=1; en = 3*Npilotbaseband; +plot_sig_and_error(5, 211, real(pilot_baseband1_log(st:en)), real(pilot_baseband1_log(st:en) - pilot_baseband1_log_c(st:en)), 'pilot baseband1 real' ) +plot_sig_and_error(5, 212, real(pilot_baseband2_log(st:en)), real(pilot_baseband2_log(st:en) - pilot_baseband2_log_c(st:en)), 'pilot baseband2 real' ) + +st=1; en = 3*Npilotlpf; +plot_sig_and_error(6, 211, real(pilot_lpf1_log(st:en)), real(pilot_lpf1_log(st:en) - pilot_lpf1_log_c(st:en)), 'pilot lpf1 real' ) +plot_sig_and_error(6, 212, real(pilot_lpf2_log(st:en)), real(pilot_lpf2_log(st:en) - pilot_lpf2_log_c(st:en)), 'pilot lpf2 real' ) + +plot_sig_and_error(7, 211, real(S1_log), real(S1_log - S1_log_c), 'S1 real' ) +plot_sig_and_error(7, 212, imag(S1_log), imag(S1_log - S1_log_c), 'S1 imag' ) + +plot_sig_and_error(8, 211, real(S2_log), real(S2_log - S2_log_c), 'S2 real' ) +plot_sig_and_error(8, 212, imag(S2_log), imag(S2_log - S2_log_c), 'S2 imag' ) + +plot_sig_and_error(9, 211, foff_coarse_log, foff_coarse_log - foff_coarse_log_c, 'Coarse Freq Offset' ) +plot_sig_and_error(9, 212, foff_fine_log, foff_fine_log - foff_fine_log_c, 'Fine Freq Offset' ) + +plot_sig_and_error(10, 211, foff_log, foff_log - foff_log_c, 'Freq Offset' ) +plot_sig_and_error(10, 212, coarse_fine_log, coarse_fine_log - coarse_fine_log_c, 'Freq Est Coarse(0) Fine(1)', [1 frames -0.5 1.5] ) + +c=15; +plot_sig_and_error(11, 211, real(rx_baseband_log(c,:)), real(rx_baseband_log(c,:) - rx_baseband_log_c(c,:)), 'Rx baseband real' ) +plot_sig_and_error(11, 212, imag(rx_baseband_log(c,:)), imag(rx_baseband_log(c,:) - rx_baseband_log_c(c,:)), 'Rx baseband imag' ) + +plot_sig_and_error(12, 211, real(rx_filt_log(c,:)), real(rx_filt_log(c,:) - rx_filt_log_c(c,:)), 'Rx filt real' ) +plot_sig_and_error(12, 212, imag(rx_filt_log(c,:)), imag(rx_filt_log(c,:) - rx_filt_log_c(c,:)), 'Rx filt imag' ) + +st=1; en=3*Nt*P; +plot_sig_and_error(13, 211, env_log(st:en), env_log(st:en) - env_log_c(st:en), 'env' ) +stem_sig_and_error(13, 212, real(rx_symbols_log(c,:)), real(rx_symbols_log(c,:) - rx_symbols_log_c(c,:)), 'rx symbols' ) + +st=10*28; +en = 12*28; +plot_sig_and_error(14, 211, rx_timing_log, rx_timing_log - rx_timing_log_c, 'Rx Timing' ) +stem_sig_and_error(14, 212, sync_bit_log_c, sync_bit_log - sync_bit_log_c, 'Sync bit', [1 n -1.5 1.5]) + +stem_sig_and_error(15, 211, rx_bits_log_c(st:en), rx_bits_log(st:en) - rx_bits_log_c(st:en), 'RX bits', [1 en-st -1.5 1.5]) +stem_sig_and_error(15, 212, nin_log_c, nin_log - nin_log_c, 'nin') + +c = 1; +plot_sig_and_error(16, 211, sig_est_log(c,:), sig_est_log(c,:) - sig_est_log_c(c,:), 'sig est for SNR' ) +plot_sig_and_error(16, 212, noise_est_log(c,:), noise_est_log(c,:) - noise_est_log_c(c,:), 'noise est for SNR' ) + +% --------------------------------------------------------------------------------------- +% AUTOMATED CHECKS ------------------------------------------ +% --------------------------------------------------------------------------------------- + +function check(a, b, test_name) + global passes; + global fails; + + [m n] = size(a); + printf("%s", test_name); + for i=1:(25-length(test_name)) + printf("."); + end + printf(": "); + + if sum(abs(a - b))/n < 1E-3 + printf("OK\n"); + passes++; + else + printf("FAIL\n"); + fails++; + end +endfunction + +check(tx_bits_log, tx_bits_log_c, 'tx_bits'); +check(tx_symbols_log, tx_symbols_log_c, 'tx_symbols'); +check(tx_baseband_log, tx_baseband_log_c, 'tx_baseband'); +check(tx_fdm_log, tx_fdm_log_c, 'tx_fdm'); +check(pilot_lut, pilot_lut_c, 'pilot_lut'); +check(pilot_baseband1_log, pilot_baseband1_log_c, 'pilot lpf1'); +check(pilot_baseband2_log, pilot_baseband2_log_c, 'pilot lpf2'); +check(S1_log, S1_log_c, 'S1'); +check(S2_log, S2_log_c, 'S2'); +check(foff_coarse_log, foff_coarse_log_c, 'foff_coarse'); +check(foff_fine_log, foff_fine_log_c, 'foff_fine'); +check(foff_log, foff_log_c, 'foff'); +check(rx_baseband_log, rx_baseband_log_c, 'rx baseband'); +check(rx_filt_log, rx_filt_log_c, 'rx filt'); +check(env_log, env_log_c, 'env'); +check(rx_timing_log, rx_timing_log_c, 'rx_timing'); +check(rx_symbols_log, rx_symbols_log_c, 'rx_symbols'); +check(rx_bits_log, rx_bits_log_c, 'rx bits'); +check(sync_bit_log, sync_bit_log_c, 'sync bit'); +check(coarse_fine_log, coarse_fine_log_c, 'coarse_fine'); +check(nin_log, nin_log_c, 'nin'); +check(sig_est_log, sig_est_log_c, 'sig_est'); +check(noise_est_log, noise_est_log_c, 'noise_est'); + +printf("\npasses: %d fails: %d\n", passes, fails); diff --git a/codec2/branches/0.3/octave/tget_spec.m b/codec2/branches/0.3/octave/tget_spec.m new file mode 100644 index 00000000..593f2af2 --- /dev/null +++ b/codec2/branches/0.3/octave/tget_spec.m @@ -0,0 +1,49 @@ +% tget-spec.m +% +% Used in conjunction with src/fdmdv_demod to test the +% fdmdv_get_rx_spectrum() function. +% +% codec2/src$ ./fdmdv_demod fdmdv_mod.raw tmp.c2 dump.txt +% octave:3> tget_spec("../src/dump.txt") +% +% Copyright David Rowe 2012 +% This program is distributed under the terms of the GNU General Public License +% Version 2 +% + +function tfft_log(dumpfilename) + + load(dumpfilename); + + [rows cols] = size(rx_spec_log_c); + Fs = 8000; low_freq = 0; high_freq = 2500; + res = (Fs/2)/cols; + st_bin = low_freq/res + 1; + en_bin = high_freq/res; + xaxis = (st_bin:en_bin)*res; + + f_start = 2; f_end = 100; + beta = 0.1; + + av = zeros(f_end, en_bin-st_bin+1); + for r=f_start:f_end + x = (1-beta)*av(r-1,:) + beta*rx_spec_log_c(r,st_bin:en_bin); + av(r,:) = x; + end + + % spectrogram (waterfall) + + figure(1) + clf; + imagesc(av,[-40 0]); + + % animated spectrum display + + figure(2) + clf; + for r=f_start:f_end + plot(xaxis, av(r,:)) + axis([ low_freq high_freq -40 0]) + sleep(0.1) + end +endfunction diff --git a/codec2/branches/0.3/octave/twotone.m b/codec2/branches/0.3/octave/twotone.m new file mode 100644 index 00000000..a20c5c5a --- /dev/null +++ b/codec2/branches/0.3/octave/twotone.m @@ -0,0 +1,52 @@ +% twotone.m +% David Rowe Aug 2012 +% Used to experiment with combining phase of two tones + +function cbphase + + Wo = 100.0*pi/4000; + L = floor(pi/Wo); + phi = zeros(1,L); + + % two harmonics + + a = 20; b = 21; + + % set up phases to whatever + + phi(a) = -pi; + phi(b) = -pi/2; + + % synthesis the two-tone signal + + N = 16000; + Nplot = 250; + s = zeros(1,N); + + for m=a:b + s_m = cos(m*Wo*(0:(N-1)) + phi(m)); + s = s + s_m; + endfor + + % now our theory says that this signal should be the same perceptually + + phi_(a) = (phi(a) - phi(b))/2; + phi_(b) = (phi(b) - phi(a))/2; + + s_ = zeros(1,N); + for m=a:b + s_m = cos(m*Wo*(0:(N-1)) + phi_(m)); + s_ = s_ + s_m; + endfor + + % plot them and see if envelope has the same phase, but "carriers" + % have different phase + + figure(1); + clf; + subplot(211); + plot(s(1:Nplot)); + subplot(212); + plot(s_(1:Nplot),'r'); +endfunction + diff --git a/codec2/branches/0.3/octave/twotone1.m b/codec2/branches/0.3/octave/twotone1.m new file mode 100644 index 00000000..9f36c68d --- /dev/null +++ b/codec2/branches/0.3/octave/twotone1.m @@ -0,0 +1,76 @@ +% twotone1.m +% David Rowe Aug 17 2012 +% +% Used to experiment with combining phase of two tones. This version +% sets up a complete synthetic speech signal then tries to combine the +% phase of high frequency tones. Lets see if we can do this and keep perceptual +% nature of signal the same. + +function twotone1 + + % hts1a frame 47 + + Wo = 0.093168; + L = 33; + %A = [69.626907 460.218536 839.677429 2577.498047 972.647888 712.755066 489.048553 364.830536 409.230652 371.767487 489.112854 893.127014 2447.596680 752.878113 475.720520 234.452271 248.161606 232.171051 202.669891 323.914490 678.749451 362.958038 211.652512 170.764435 148.631790 169.261673 272.254150 176.872375 67.344391 99.022301 60.812035 34.319073 14.864757]; + A = zeros(1,L)*100; + phi = [1.560274 1.508063 -1.565184 1.289117 -2.547365 1.412528 -1.303992 3.121130 1.087573 -1.158161 -2.928007 0.995093 -2.614023 0.246136 -2.267406 2.143802 -0.273431 -2.266897 1.685171 -0.668712 2.699722 -1.151891 2.406379 -0.046192 -2.718611 0.761067 -2.305014 0.133172 -1.428978 1.492630 -1.668385 1.539734 -1.336615]; + %phi = zeros(1,L); + st = floor(L/2); + %st = 1; + + A(st:st+5) = 1000; + + % now set up phase of signal with phase of upper frequency harmonic + % pairs combined + + phi_ = phi; + for m=floor(L/2):2:L + phi_(m) = (phi(m) - phi(m+1))/2; + phi_(m+1) = (phi(m+1) - phi(m))/2; + %phi_(m+1) = 0; + end + + % synthesise the signals + + N = 16000; + Nplot = 250; + + s = zeros(1,N); + for m=st:L + s_m = A(m)*cos(m*Wo*(0:(N-1)) + phi(m)); + s = s + s_m; + endfor + + s_ = zeros(1,N); + for m=st:L + s_m = A(m)*cos(m*Wo*(0:(N-1)) + phi_(m)); + s_ = s_ + s_m; + endfor + + % plot them, expect to see similar time domain waveforms + + figure(1); + clf; + subplot(211); + plot(s(1:Nplot)); + subplot(212); + plot(s_(1:Nplot),'r'); + + figure(2); + clf; + subplot(211); + plot(s(1:Nplot)-s_(1:Nplot)); + + % save to disk + + gain = 1; + fs=fopen("twotone1_orig.raw","wb"); + fwrite(fs,gain*s,"short"); + fclose(fs); + fs=fopen("twotone1_comb.raw","wb"); + fwrite(fs,gain*s_,"short"); + fclose(fs); + +endfunction + diff --git a/codec2/branches/0.3/octave/undersample.m b/codec2/branches/0.3/octave/undersample.m new file mode 100644 index 00000000..1bfbf38b --- /dev/null +++ b/codec2/branches/0.3/octave/undersample.m @@ -0,0 +1,26 @@ +% undersample.m +% David Rowe 5 Nov 2012 +% Testing algorithms for plotting undersampled data for fdmdv2 waveform displays + +fs=fopen("../raw/hts1a.raw","rb"); +s = fread(fs,Inf,"short"); + +Fs1=8000; +Fs2=200; + +M=Fs1/Fs2; + +samples=length(s)/M; +s1=zeros(1,2*samples); +for b=1:samples + st = (b-1)*M + 1; + en = b*M; + s1(2*b-1) = max(s(st:en)); + s1(2*b) = min(s(st:en)); +end + +subplot(211) +plot(s) +subplot(212) +plot(s1); + diff --git a/codec2/branches/0.3/portaudio/Makefile b/codec2/branches/0.3/portaudio/Makefile new file mode 100644 index 00000000..39255b6c --- /dev/null +++ b/codec2/branches/0.3/portaudio/Makefile @@ -0,0 +1,23 @@ +# Makefile for Portaudio test programs +# Requires Portaudio V19 + +CFLAGS = -g -Wall -I../src +LIBS = -lm -lportaudio -pthread +SRC = ../src/fdmdv.c ../src/kiss_fft.c ../src/fifo.c + +all: pa_rec pa_play pa_recplay pa_impresp + +pa_rec: Makefile pa_rec.c $(SRC) + gcc $(CFLAGS) pa_rec.c $(SRC) -o pa_rec $(LIBS) + +pa_play: Makefile pa_play.c $(SRC) + gcc $(CFLAGS) pa_play.c $(SRC) -o pa_play $(LIBS) + +pa_recplay: Makefile pa_recplay.c $(SRC) + gcc $(CFLAGS) pa_recplay.c $(SRC) -o pa_recplay $(LIBS) + +pa_impresp: Makefile pa_impresp.c $(SRC) + gcc $(CFLAGS) pa_impresp.c $(SRC) -o pa_impresp $(LIBS) + +clean: + rm -f pa_rec pa_play pa_recplay diff --git a/codec2/branches/0.3/portaudio/pa_impresp.c b/codec2/branches/0.3/portaudio/pa_impresp.c new file mode 100644 index 00000000..7317e07e --- /dev/null +++ b/codec2/branches/0.3/portaudio/pa_impresp.c @@ -0,0 +1,254 @@ +/* + pa_impresp.c + David Rowe + August 29 2012 + + Measures the impulse reponse of the path between the speaker and + microphone. Used to explore why Codec audio quality is + different through a speaker and headphones. + + Modified from pa_playrec.c +*/ + +/* + * $Id: paex_record.c 1752 2011-09-08 03:21:55Z philburk $ + * + * This program uses the PortAudio Portable Audio Library. + * For more information see: http://www.portaudio.com + * Copyright (c) 1999-2000 Ross Bencina and Phil Burk + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include "portaudio.h" +#include "fdmdv.h" + +#define SAMPLE_RATE 48000 /* 48 kHz sampling rate rec. as we + can trust accuracy of sound + card */ +#define N8 160 /* processing buffer size at 8 kHz */ +#define N48 (N8*FDMDV_OS) /* processing buffer size at 48 kHz */ +#define MEM8 (FDMDV_OS_TAPS/FDMDV_OS) +#define NUM_CHANNELS 2 /* I think most sound cards prefer + stereo, we will convert to mono + as we sample */ + +#define IMPULSE_AMP 16384 /* amplitide of impulse */ +#define IMPULSE_PERIOD 0.1 /* period (dly between impulses) in secs */ + +/* state information passed to call back */ + +typedef struct { + float in48k[FDMDV_OS_TAPS + N48]; + float in8k[MEM8 + N8]; + FILE *fimp; + float *impulse_buf; + int impulse_buf_length; + int impulse_sample_count; + int framesLeft; +} paTestData; + + +/* + This routine will be called by the PortAudio engine when audio is + required. It may be called at interrupt level on some machines so + don't do anything that could mess up the system like calling + malloc() or free(). +*/ + +static int callback( const void *inputBuffer, void *outputBuffer, + unsigned long framesPerBuffer, + const PaStreamCallbackTimeInfo* timeInfo, + PaStreamCallbackFlags statusFlags, + void *userData ) +{ + paTestData *data = (paTestData*)userData; + int i; + short *rptr = (short*)inputBuffer; + short *wptr = (short*)outputBuffer; + float *in8k = data->in8k; + float *in48k = data->in48k; + float out8k[N8]; + float out48k[N48]; + short out48k_short[N48]; + short out8k_short[N8]; + + (void) timeInfo; + (void) statusFlags; + + assert(inputBuffer != NULL); + + /* just use left channel */ + + for(i=0; iin48k[i+FDMDV_OS_TAPS] = *rptr; + + /* downsample and update filter memory */ + + fdmdv_48_to_8(out8k, &in48k[FDMDV_OS_TAPS], N8); + for(i=0; ifimp); + + /* play side, read from impulse buffer */ + + for(i=0; iimpulse_buf[data->impulse_sample_count]; + data->impulse_sample_count++; + if (data->impulse_sample_count == data->impulse_buf_length) + data->impulse_sample_count = 0; + } + + /* upsample and update filter memory */ + + fdmdv_8_to_48(out48k, &in8k[MEM8], N8); + for(i=0; iframesLeft -= framesPerBuffer; + if (data->framesLeft > 0) + return paContinue; + else + return paComplete; +} + +int main(int argc, char *argv[]) +{ + PaStreamParameters inputParameters, outputParameters; + PaStream* stream; + PaError err = paNoError; + paTestData data; + int i, numSecs; + + if (argc != 3) { + printf("usage: %s impulseRawFile time(s)\n", argv[0]); + exit(0); + } + + data.fimp = fopen(argv[1], "wb"); + if (data.fimp == NULL) { + printf("Error opening impulse output file %s\n", argv[1]); + exit(1); + } + + numSecs = atoi(argv[2]); + data.framesLeft = numSecs * SAMPLE_RATE; + + /* init filter states */ + + for(i=0; idefaultLowInputLatency; + inputParameters.hostApiSpecificStreamInfo = NULL; + + outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */ + if (outputParameters.device == paNoDevice) { + fprintf(stderr,"Error: No default output device.\n"); + goto done; + } + outputParameters.channelCount = NUM_CHANNELS; /* stereo output */ + outputParameters.sampleFormat = paInt16; + outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; + outputParameters.hostApiSpecificStreamInfo = NULL; + + /* Play some audio --------------------------------------------- */ + + err = Pa_OpenStream( + &stream, + &inputParameters, + &outputParameters, + SAMPLE_RATE, + N48, + paClipOff, + callback, + &data ); + if( err != paNoError ) goto done; + + err = Pa_StartStream( stream ); + if( err != paNoError ) goto done; + + while( ( err = Pa_IsStreamActive( stream ) ) == 1 ) + { + Pa_Sleep(100); + } + if( err < 0 ) goto done; + + err = Pa_CloseStream( stream ); + if( err != paNoError ) goto done; + + +done: + Pa_Terminate(); + if( err != paNoError ) + { + fprintf( stderr, "An error occured while using the portaudio stream\n" ); + fprintf( stderr, "Error number: %d\n", err ); + fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + err = 1; /* Always return 0 or 1, but no other return codes. */ + } + + fclose(data.fimp); + + return err; +} + diff --git a/codec2/branches/0.3/portaudio/pa_play.c b/codec2/branches/0.3/portaudio/pa_play.c new file mode 100644 index 00000000..00ea0868 --- /dev/null +++ b/codec2/branches/0.3/portaudio/pa_play.c @@ -0,0 +1,199 @@ +/* + pa_play.c + David Rowe + July 8 2012 + + Converts samples from a 16 bit short 8000 Hz rawfile to 480000Hz + sample rate and plays them using the default sound device. Used as + an intermediate step in Portaudio integration. + + Modified from paex_record.c Portaudio example. Original author + author Phil Burk http://www.softsynth.com +*/ + +/* + * $Id: paex_record.c 1752 2011-09-08 03:21:55Z philburk $ + * + * This program uses the PortAudio Portable Audio Library. + * For more information see: http://www.portaudio.com + * Copyright (c) 1999-2000 Ross Bencina and Phil Burk + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include "portaudio.h" +#include "fdmdv.h" + +#define SAMPLE_RATE 48000 /* 48 kHz sampling rate rec. as we + can trust accuracy of sound + card */ +#define N8 160 /* processing buffer size at 8 kHz */ +#define N48 (N8*FDMDV_OS) /* processing buffer size at 48 kHz */ +#define MEM8 (FDMDV_OS_TAPS/FDMDV_OS) +#define NUM_CHANNELS 2 /* I think most sound cards prefer + stereo, we will convert to mono + as we sample */ + +/* state information passed to call back */ + +typedef struct { + FILE *fin; + float in8k[MEM8 + N8]; +} paTestData; + + +/* + This routine will be called by the PortAudio engine when audio is + required. It may be called at interrupt level on some machines so + don't do anything that could mess up the system like calling + malloc() or free(). +*/ + +static int playCallback( const void *inputBuffer, void *outputBuffer, + unsigned long framesPerBuffer, + const PaStreamCallbackTimeInfo* timeInfo, + PaStreamCallbackFlags statusFlags, + void *userData ) +{ + paTestData *data = (paTestData*)userData; + FILE *fin = data->fin; + int i, nread; + int finished; + short *wptr = (short*)outputBuffer; + float *in8k = data->in8k; + float out48k[N48]; + short out48k_short[N48]; + short in8k_short[N8]; + + (void) outputBuffer; /* Prevent unused variable warnings. */ + (void) timeInfo; + (void) statusFlags; + (void) userData; + + /* note Portaudio docs recs. against making systems calls like + fwrite() in this callback but seems to work OK */ + + nread = fread(in8k_short, sizeof(short), N8, fin); + if (nread == N8) + finished = paContinue; + else + finished = paComplete; + + for(i=0; idefaultLowOutputLatency; + outputParameters.hostApiSpecificStreamInfo = NULL; + + /* Play some audio --------------------------------------------- */ + + err = Pa_OpenStream( + &stream, + NULL, + &outputParameters, + SAMPLE_RATE, + N48, + paClipOff, + playCallback, + &data ); + if( err != paNoError ) goto done; + + err = Pa_StartStream( stream ); + if( err != paNoError ) goto done; + + while( ( err = Pa_IsStreamActive( stream ) ) == 1 ) + { + Pa_Sleep(100); + } + if( err < 0 ) goto done; + + err = Pa_CloseStream( stream ); + if( err != paNoError ) goto done; + + fclose(data.fin); + + +done: + Pa_Terminate(); + if( err != paNoError ) + { + fprintf( stderr, "An error occured while using the portaudio stream\n" ); + fprintf( stderr, "Error number: %d\n", err ); + fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + err = 1; /* Always return 0 or 1, but no other return codes. */ + } + return err; +} + diff --git a/codec2/branches/0.3/portaudio/pa_rec.c b/codec2/branches/0.3/portaudio/pa_rec.c new file mode 100644 index 00000000..00023b02 --- /dev/null +++ b/codec2/branches/0.3/portaudio/pa_rec.c @@ -0,0 +1,212 @@ +/* + pa_rec.c + David Rowe + July 6 2012 + + Records at 48000 Hz from default sound device, convertes to 8 kHz, + and saves to raw file. Used to get experience with Portaudio. + + Modified from paex_record.c Portaudio example. Original author + author Phil Burk http://www.softsynth.com + + To Build: + + gcc paex_rec.c -o paex_rec -lm -lrt -lportaudio -pthread +*/ + +/* + * $Id: paex_record.c 1752 2011-09-08 03:21:55Z philburk $ + * + * This program uses the PortAudio Portable Audio Library. + * For more information see: http://www.portaudio.com + * Copyright (c) 1999-2000 Ross Bencina and Phil Burk + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include "portaudio.h" +#include "fdmdv.h" + +#define SAMPLE_RATE 48000 /* 48 kHz sampling rate rec. as we + can trust accuracy of sound + card */ +#define N8 160 /* processing buffer size at 8 kHz */ +#define N48 (N8*FDMDV_OS) /* processing buffer size at 48 kHz */ +#define NUM_CHANNELS 2 /* I think most sound cards prefer + stereo, we will convert to mono + as we sample */ + +/* state information passed to call back */ + +typedef struct { + FILE *fout; + int framesLeft; + float in48k[FDMDV_OS_TAPS + N48]; +} paTestData; + + +/* + This routine will be called by the PortAudio engine when audio is + available. It may be called at interrupt level on some machines so + don't do anything that could mess up the system like calling + malloc() or free(). +*/ + +static int recordCallback( const void *inputBuffer, void *outputBuffer, + unsigned long framesPerBuffer, + const PaStreamCallbackTimeInfo* timeInfo, + PaStreamCallbackFlags statusFlags, + void *userData ) +{ + paTestData *data = (paTestData*)userData; + FILE *fout = data->fout; + int framesToCopy; + int i; + int finished; + short *rptr = (short*)inputBuffer; + float out8k[N8]; + short out8k_short[N8]; + + (void) outputBuffer; /* Prevent unused variable warnings. */ + (void) timeInfo; + (void) statusFlags; + (void) userData; + + if (data->framesLeft < framesPerBuffer) { + framesToCopy = data->framesLeft; + finished = paComplete; + } + else { + framesToCopy = framesPerBuffer; + finished = paContinue; + } + data->framesLeft -= framesToCopy; + + assert(inputBuffer != NULL); + + /* just use left channel */ + + for(i=0; iin48k[i+FDMDV_OS_TAPS] = *rptr; + + /* downsample and update filter memory */ + + fdmdv_48_to_8(out8k, &data->in48k[FDMDV_OS_TAPS], N8); + for(i=0; iin48k[i] = data->in48k[i+framesToCopy]; + + /* save 8k to disk */ + + for(i=0; idefaultLowInputLatency; + inputParameters.hostApiSpecificStreamInfo = NULL; + + /* Record some audio --------------------------------------------- */ + + err = Pa_OpenStream( + &stream, + &inputParameters, + NULL, /* &outputParameters, */ + SAMPLE_RATE, + N48, + paClipOff, /* we won't output out of range samples so don't bother clipping them */ + recordCallback, + &data ); + if( err != paNoError ) goto done; + + err = Pa_StartStream( stream ); + if( err != paNoError ) goto done; + + while( ( err = Pa_IsStreamActive( stream ) ) == 1 ) + { + Pa_Sleep(100); + } + if( err < 0 ) goto done; + + err = Pa_CloseStream( stream ); + if( err != paNoError ) goto done; + + fclose(data.fout); + + +done: + Pa_Terminate(); + if( err != paNoError ) + { + fprintf( stderr, "An error occured while using the portaudio stream\n" ); + fprintf( stderr, "Error number: %d\n", err ); + fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + err = 1; /* Always return 0 or 1, but no other return codes. */ + } + return err; +} + diff --git a/codec2/branches/0.3/portaudio/pa_recplay.c b/codec2/branches/0.3/portaudio/pa_recplay.c new file mode 100644 index 00000000..6bfcd08b --- /dev/null +++ b/codec2/branches/0.3/portaudio/pa_recplay.c @@ -0,0 +1,270 @@ +/* + pa_recplay.c + David Rowe + July 8 2012 + + Echos audio from sound card input to sound card output. Samples at + 48 kHz, converts to 8 kHz, converts back to 48kHz, and plays using + the default sound device. Used as an intermediate step in + Portaudio integration. + + Modified from paex_record.c Portaudio example. Original author + author Phil Burk http://www.softsynth.com +*/ + +/* + * $Id: paex_record.c 1752 2011-09-08 03:21:55Z philburk $ + * + * This program uses the PortAudio Portable Audio Library. + * For more information see: http://www.portaudio.com + * Copyright (c) 1999-2000 Ross Bencina and Phil Burk + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include "portaudio.h" +#include "fdmdv.h" +#include "fifo.h" + +#define SAMPLE_RATE 48000 /* 48 kHz sampling rate rec. as we + can trust accuracy of sound + card */ +#define N8 160 /* processing buffer size at 8 kHz */ +#define N48 (N8*FDMDV_OS) /* processing buffer size at 48 kHz */ +#define MEM8 (FDMDV_OS_TAPS/FDMDV_OS) +#define NUM_CHANNELS 2 /* I think most sound cards prefer + stereo, we will convert to mono + as we sample */ +#define MAX_FPB 2048 /* maximum value of framesPerBuffer */ + +/* state information passed to call back */ + +typedef struct { + float in48k[FDMDV_OS_TAPS + N48]; + float in8k[MEM8 + N8]; + struct FIFO *infifo; + struct FIFO *outfifo; +} paTestData; + + +/* + This routine will be called by the PortAudio engine when audio is + required. It may be called at interrupt level on some machines so + don't do anything that could mess up the system like calling + malloc() or free(). +*/ + +static int callback( const void *inputBuffer, void *outputBuffer, + unsigned long framesPerBuffer, + const PaStreamCallbackTimeInfo* timeInfo, + PaStreamCallbackFlags statusFlags, + void *userData ) +{ + paTestData *data = (paTestData*)userData; + int i; + short *rptr = (short*)inputBuffer; + short *wptr = (short*)outputBuffer; + float *in8k = data->in8k; + float *in48k = data->in48k; + float out8k[N8]; + float out48k[N48]; + short out48k_short[N48]; + short in48k_short[N48]; + short indata[MAX_FPB]; + short outdata[MAX_FPB]; + + (void) timeInfo; + (void) statusFlags; + + assert(inputBuffer != NULL); + assert(outputBuffer != NULL); + + /* + framesPerBuffer is portaudio-speak for number of samples we + actually get from the record side and need to provide to the + play side. On Linux (at least) it was found that + framesPerBuffer may not always be what we ask for in the + framesPerBuffer field of Pa_OpenStream. For example a request + for 960 sample buffers lead to framesPerBuffer = 1024. + + To perform the 48 to 8 kHz conversion we need an integer + multiple of FDMDV_OS samples to support the interpolation and + decimation. As we can't guarantee the size of framesPerBuffer + we do a little FIFO buffering. + */ + + //printf("framesPerBuffer: %d N48 %d\n", framesPerBuffer, N48); + + /* assemble a mono buffer (just use left channel) and write to FIFO */ + + assert(framesPerBuffer < MAX_FPB); + for(i=0; iinfifo, indata, framesPerBuffer); + + /* while we have enough samples available ... */ + + //printf("infifo before: %d\n", fifo_n(data->infifo)); + while (fifo_read(data->infifo, in48k_short, N48) == 0) { + + /* convert to float */ + + for(i=0; ioutfifo, out48k_short, N48); + } + //printf("infifo after: %d\n", fifo_n(data->infifo)); + //printf("outfifo : %d\n", fifo_n(data->outfifo)); + + + /* OK now set up output samples */ + + if (fifo_read(data->outfifo, outdata, framesPerBuffer) == 0) { + + /* write signal to both channels */ + + for(i=0; idefaultLowInputLatency; + inputParameters.hostApiSpecificStreamInfo = NULL; + + outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */ + if (outputParameters.device == paNoDevice) { + fprintf(stderr,"Error: No default output device.\n"); + goto done; + } + outputParameters.channelCount = NUM_CHANNELS; /* stereo output */ + outputParameters.sampleFormat = paInt16; + outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; + outputParameters.hostApiSpecificStreamInfo = NULL; + + /* Play some audio --------------------------------------------- */ + + err = Pa_OpenStream( + &stream, + &inputParameters, + &outputParameters, + SAMPLE_RATE, + 512, + paClipOff, + callback, + &data ); + if( err != paNoError ) goto done; + + err = Pa_StartStream( stream ); + if( err != paNoError ) goto done; + + while( ( err = Pa_IsStreamActive( stream ) ) == 1 ) + { + Pa_Sleep(100); + } + if( err < 0 ) goto done; + + err = Pa_CloseStream( stream ); + if( err != paNoError ) goto done; + + +done: + Pa_Terminate(); + if( err != paNoError ) + { + fprintf( stderr, "An error occured while using the portaudio stream\n" ); + fprintf( stderr, "Error number: %d\n", err ); + fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); + err = 1; /* Always return 0 or 1, but no other return codes. */ + } + + fifo_destroy(data.infifo); + fifo_destroy(data.outfifo); + + return err; +} + diff --git a/codec2/branches/0.3/raw/b0067.raw b/codec2/branches/0.3/raw/b0067.raw new file mode 100644 index 00000000..3aea9cda Binary files /dev/null and b/codec2/branches/0.3/raw/b0067.raw differ diff --git a/codec2/branches/0.3/raw/cq_ref.raw b/codec2/branches/0.3/raw/cq_ref.raw new file mode 100644 index 00000000..485703d9 Binary files /dev/null and b/codec2/branches/0.3/raw/cq_ref.raw differ diff --git a/codec2/branches/0.3/raw/cross.raw b/codec2/branches/0.3/raw/cross.raw new file mode 100644 index 00000000..1b2af6a9 Binary files /dev/null and b/codec2/branches/0.3/raw/cross.raw differ diff --git a/codec2/branches/0.3/raw/cross_melp2400.raw b/codec2/branches/0.3/raw/cross_melp2400.raw new file mode 100644 index 00000000..439012ca Binary files /dev/null and b/codec2/branches/0.3/raw/cross_melp2400.raw differ diff --git a/codec2/branches/0.3/raw/f2400.raw b/codec2/branches/0.3/raw/f2400.raw new file mode 100644 index 00000000..5f4427f2 Binary files /dev/null and b/codec2/branches/0.3/raw/f2400.raw differ diff --git a/codec2/branches/0.3/raw/forig.raw b/codec2/branches/0.3/raw/forig.raw new file mode 100644 index 00000000..4ba294d7 Binary files /dev/null and b/codec2/branches/0.3/raw/forig.raw differ diff --git a/codec2/branches/0.3/raw/forig_ambe2000.raw b/codec2/branches/0.3/raw/forig_ambe2000.raw new file mode 100644 index 00000000..91143579 Binary files /dev/null and b/codec2/branches/0.3/raw/forig_ambe2000.raw differ diff --git a/codec2/branches/0.3/raw/forig_g729a.raw b/codec2/branches/0.3/raw/forig_g729a.raw new file mode 100644 index 00000000..fbca567b Binary files /dev/null and b/codec2/branches/0.3/raw/forig_g729a.raw differ diff --git a/codec2/branches/0.3/raw/forig_gsm13k.raw b/codec2/branches/0.3/raw/forig_gsm13k.raw new file mode 100644 index 00000000..71cbe6f6 Binary files /dev/null and b/codec2/branches/0.3/raw/forig_gsm13k.raw differ diff --git a/codec2/branches/0.3/raw/forig_speex_8k.raw b/codec2/branches/0.3/raw/forig_speex_8k.raw new file mode 100644 index 00000000..e95302ef Binary files /dev/null and b/codec2/branches/0.3/raw/forig_speex_8k.raw differ diff --git a/codec2/branches/0.3/raw/g3plx.raw b/codec2/branches/0.3/raw/g3plx.raw new file mode 100644 index 00000000..9970c3fb Binary files /dev/null and b/codec2/branches/0.3/raw/g3plx.raw differ diff --git a/codec2/branches/0.3/raw/hts.raw b/codec2/branches/0.3/raw/hts.raw new file mode 100644 index 00000000..79f869ad Binary files /dev/null and b/codec2/branches/0.3/raw/hts.raw differ diff --git a/codec2/branches/0.3/raw/hts1.raw b/codec2/branches/0.3/raw/hts1.raw new file mode 100644 index 00000000..3369387e Binary files /dev/null and b/codec2/branches/0.3/raw/hts1.raw differ diff --git a/codec2/branches/0.3/raw/hts1a.raw b/codec2/branches/0.3/raw/hts1a.raw new file mode 100644 index 00000000..7332f936 Binary files /dev/null and b/codec2/branches/0.3/raw/hts1a.raw differ diff --git a/codec2/branches/0.3/raw/hts1a_ambe2000.raw b/codec2/branches/0.3/raw/hts1a_ambe2000.raw new file mode 100644 index 00000000..ab72ba2f Binary files /dev/null and b/codec2/branches/0.3/raw/hts1a_ambe2000.raw differ diff --git a/codec2/branches/0.3/raw/hts1a_g729a.raw b/codec2/branches/0.3/raw/hts1a_g729a.raw new file mode 100644 index 00000000..130f1ddc Binary files /dev/null and b/codec2/branches/0.3/raw/hts1a_g729a.raw differ diff --git a/codec2/branches/0.3/raw/hts1a_gsm13k.raw b/codec2/branches/0.3/raw/hts1a_gsm13k.raw new file mode 100644 index 00000000..dd102f59 Binary files /dev/null and b/codec2/branches/0.3/raw/hts1a_gsm13k.raw differ diff --git a/codec2/branches/0.3/raw/hts1a_melp.raw b/codec2/branches/0.3/raw/hts1a_melp.raw new file mode 100644 index 00000000..a4040d29 Binary files /dev/null and b/codec2/branches/0.3/raw/hts1a_melp.raw differ diff --git a/codec2/branches/0.3/raw/hts1a_speex_8k.raw b/codec2/branches/0.3/raw/hts1a_speex_8k.raw new file mode 100644 index 00000000..9289e1c9 Binary files /dev/null and b/codec2/branches/0.3/raw/hts1a_speex_8k.raw differ diff --git a/codec2/branches/0.3/raw/hts2.raw b/codec2/branches/0.3/raw/hts2.raw new file mode 100644 index 00000000..0bb9df10 Binary files /dev/null and b/codec2/branches/0.3/raw/hts2.raw differ diff --git a/codec2/branches/0.3/raw/hts2a.raw b/codec2/branches/0.3/raw/hts2a.raw new file mode 100644 index 00000000..6d9cf17b Binary files /dev/null and b/codec2/branches/0.3/raw/hts2a.raw differ diff --git a/codec2/branches/0.3/raw/hts2a_ambe2000.raw b/codec2/branches/0.3/raw/hts2a_ambe2000.raw new file mode 100644 index 00000000..7225f60a Binary files /dev/null and b/codec2/branches/0.3/raw/hts2a_ambe2000.raw differ diff --git a/codec2/branches/0.3/raw/hts2a_g729a.raw b/codec2/branches/0.3/raw/hts2a_g729a.raw new file mode 100644 index 00000000..9199b0ad Binary files /dev/null and b/codec2/branches/0.3/raw/hts2a_g729a.raw differ diff --git a/codec2/branches/0.3/raw/hts2a_gsm13k.raw b/codec2/branches/0.3/raw/hts2a_gsm13k.raw new file mode 100644 index 00000000..f0a58505 Binary files /dev/null and b/codec2/branches/0.3/raw/hts2a_gsm13k.raw differ diff --git a/codec2/branches/0.3/raw/hts2a_melp.raw b/codec2/branches/0.3/raw/hts2a_melp.raw new file mode 100644 index 00000000..5138e494 Binary files /dev/null and b/codec2/branches/0.3/raw/hts2a_melp.raw differ diff --git a/codec2/branches/0.3/raw/hts2a_speex_8k.raw b/codec2/branches/0.3/raw/hts2a_speex_8k.raw new file mode 100644 index 00000000..c421bb4e Binary files /dev/null and b/codec2/branches/0.3/raw/hts2a_speex_8k.raw differ diff --git a/codec2/branches/0.3/raw/k6hx.raw b/codec2/branches/0.3/raw/k6hx.raw new file mode 100644 index 00000000..35e6df71 Binary files /dev/null and b/codec2/branches/0.3/raw/k6hx.raw differ diff --git a/codec2/branches/0.3/raw/kristoff.raw b/codec2/branches/0.3/raw/kristoff.raw new file mode 100644 index 00000000..9b0b4655 Binary files /dev/null and b/codec2/branches/0.3/raw/kristoff.raw differ diff --git a/codec2/branches/0.3/raw/m2400.raw b/codec2/branches/0.3/raw/m2400.raw new file mode 100644 index 00000000..1c0956da Binary files /dev/null and b/codec2/branches/0.3/raw/m2400.raw differ diff --git a/codec2/branches/0.3/raw/mmt1.raw b/codec2/branches/0.3/raw/mmt1.raw new file mode 100644 index 00000000..40638a5a Binary files /dev/null and b/codec2/branches/0.3/raw/mmt1.raw differ diff --git a/codec2/branches/0.3/raw/mmt1_ambe2000.raw b/codec2/branches/0.3/raw/mmt1_ambe2000.raw new file mode 100644 index 00000000..e38955c3 Binary files /dev/null and b/codec2/branches/0.3/raw/mmt1_ambe2000.raw differ diff --git a/codec2/branches/0.3/raw/mmt1_g729a.raw b/codec2/branches/0.3/raw/mmt1_g729a.raw new file mode 100644 index 00000000..196716e0 Binary files /dev/null and b/codec2/branches/0.3/raw/mmt1_g729a.raw differ diff --git a/codec2/branches/0.3/raw/mmt1_gsm13k.raw b/codec2/branches/0.3/raw/mmt1_gsm13k.raw new file mode 100644 index 00000000..a9965af3 Binary files /dev/null and b/codec2/branches/0.3/raw/mmt1_gsm13k.raw differ diff --git a/codec2/branches/0.3/raw/mmt1_speex_8k.raw b/codec2/branches/0.3/raw/mmt1_speex_8k.raw new file mode 100644 index 00000000..769a49cd Binary files /dev/null and b/codec2/branches/0.3/raw/mmt1_speex_8k.raw differ diff --git a/codec2/branches/0.3/raw/morig.raw b/codec2/branches/0.3/raw/morig.raw new file mode 100644 index 00000000..4af0e8f9 Binary files /dev/null and b/codec2/branches/0.3/raw/morig.raw differ diff --git a/codec2/branches/0.3/raw/morig_ambe2000.raw b/codec2/branches/0.3/raw/morig_ambe2000.raw new file mode 100644 index 00000000..99642756 Binary files /dev/null and b/codec2/branches/0.3/raw/morig_ambe2000.raw differ diff --git a/codec2/branches/0.3/raw/morig_g729a.raw b/codec2/branches/0.3/raw/morig_g729a.raw new file mode 100644 index 00000000..636ecfdc Binary files /dev/null and b/codec2/branches/0.3/raw/morig_g729a.raw differ diff --git a/codec2/branches/0.3/raw/morig_gsm13k.raw b/codec2/branches/0.3/raw/morig_gsm13k.raw new file mode 100644 index 00000000..660368fe Binary files /dev/null and b/codec2/branches/0.3/raw/morig_gsm13k.raw differ diff --git a/codec2/branches/0.3/raw/morig_speex_8k.raw b/codec2/branches/0.3/raw/morig_speex_8k.raw new file mode 100644 index 00000000..ab667a1b Binary files /dev/null and b/codec2/branches/0.3/raw/morig_speex_8k.raw differ diff --git a/codec2/branches/0.3/raw/sine1k_2Hz_spread.raw b/codec2/branches/0.3/raw/sine1k_2Hz_spread.raw new file mode 100644 index 00000000..2ab521fc Binary files /dev/null and b/codec2/branches/0.3/raw/sine1k_2Hz_spread.raw differ diff --git a/codec2/branches/0.3/raw/sine1k_2ms_delay_2Hz_spread.raw b/codec2/branches/0.3/raw/sine1k_2ms_delay_2Hz_spread.raw new file mode 100644 index 00000000..d694d23f Binary files /dev/null and b/codec2/branches/0.3/raw/sine1k_2ms_delay_2Hz_spread.raw differ diff --git a/codec2/branches/0.3/script/menu.sh b/codec2/branches/0.3/script/menu.sh new file mode 100755 index 00000000..c0335d27 --- /dev/null +++ b/codec2/branches/0.3/script/menu.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# ./menu.sh +# +# David Rowe +# Created August 2009 +# +# Presents a menu of sound files, press 1 to play file1, 2 to play file2 etc +# +# The aim is to make comparing files with different processing easier than +# using up-arrow on the command line. Based on cdialog. +# +# usage: +# menu.sh file1.raw file2.raw ........ [-d playbackdevice] +# +# for example: +# +# ../script/menu.sh hts1a.raw hts1a_uq.raw +# +# or: +# +# ../script/menu.sh hts1a.raw hts1a_uq.raw -d /dev/dsp1 +# + +# Copyright (C) 2007 David Rowe +# +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2, as +# published by the Free Software Foundation. +# +# 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 . + +files=0 +items="Q-Quit\n" +while [ ! -z "$1" ] +do + case "$1" in + -d) dsp="${1} ${2}"; shift;; + *) files=`expr 1 + $files`; + new_file=$1; + file[$files]=$new_file; + items="${items} ${files}-${new_file}\n";; + esac + shift +done + +echo -n -e "\r" $items"- " +while true ; do + echo -n -e "\r -" + stty cbreak # or stty raw. Stty uses file descriptor 0, not /dev/tty. + readchar=`dd bs=1 count=1 2>/dev/null` + stty -cbreak + if [ -n "$readchar" ] ; then + if [ x$readchar == 'xq' -o x$readchar == 'xQ' ] ; then + echo + exit 0 + fi + if [ -z ${file[$readchar]} ] ; then + echo -n -e "\nUnknown input\n" $items"- " + continue + fi + if ( play --version ) >/dev/null 2>&1; then + play -r 8000 -s -2 ${file[$readchar]} $dsp 2> /dev/null + elif ( aplay --version ) > /dev/null 2>&1; then + aplay -r 8000 -f S16_LE ${file[$readchar]} 2> /dev/null + elif ( ossplay -f? ) > /dev/null 2>&1; then + ossplay -s8000 -fS16_LE ${file[$readchar]} 2> /dev/null + else + echo "could not find play, aplay or ossplay program" + fi + fi +done +echo diff --git a/codec2/branches/0.3/script/playraw.sh b/codec2/branches/0.3/script/playraw.sh new file mode 100755 index 00000000..683cbaa1 --- /dev/null +++ b/codec2/branches/0.3/script/playraw.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Plays a raw file +# usage: +# playraw file.raw +# playraw file.raw -d /dev/dsp1 (e.g. for USB headphones) +play -r 8000 -s -2 $1 $2 $3 diff --git a/codec2/branches/0.3/script/raw2wav.sh b/codec2/branches/0.3/script/raw2wav.sh new file mode 100755 index 00000000..a05efb72 --- /dev/null +++ b/codec2/branches/0.3/script/raw2wav.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# Converts 16 bit signed short 8 kHz raw (headerless) files to wave +sox -r 8000 -s -2 $1 $2 diff --git a/codec2/branches/0.3/script/wav2raw.sh b/codec2/branches/0.3/script/wav2raw.sh new file mode 100755 index 00000000..39c0f1ae --- /dev/null +++ b/codec2/branches/0.3/script/wav2raw.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# Converts wave files to raw (headerless) files +sox $1 -t raw $2 diff --git a/codec2/branches/0.3/src/CMakeLists.txt b/codec2/branches/0.3/src/CMakeLists.txt new file mode 100644 index 00000000..36ffc926 --- /dev/null +++ b/codec2/branches/0.3/src/CMakeLists.txt @@ -0,0 +1,267 @@ +# +# Generated sources +# + +set(D ${CMAKE_CURRENT_SOURCE_DIR}/codebook) + +# lsp quantisers + +set(CODEBOOKS + ${D}/lsp1.txt + ${D}/lsp2.txt + ${D}/lsp3.txt + ${D}/lsp4.txt + ${D}/lsp5.txt + ${D}/lsp6.txt + ${D}/lsp7.txt + ${D}/lsp8.txt + ${D}/lsp9.txt + ${D}/lsp10.txt +) + +# lspd quantisers + +set(CODEBOOKSD + ${D}/dlsp1.txt + ${D}/dlsp2.txt + ${D}/dlsp3.txt + ${D}/dlsp4.txt + ${D}/dlsp5.txt + ${D}/dlsp6.txt + ${D}/dlsp7.txt + ${D}/dlsp8.txt + ${D}/dlsp9.txt + ${D}/dlsp10.txt +) + +# lspd VQ quantisers + +set(CODEBOOKSVQ + ${D}/lsp1.txt + ${D}/lsp2.txt + ${D}/lsp3.txt + ${D}/lsp4.txt + ${CMAKE_SOURCE_DIR}/unittest/lsp45678910.txt +) + +set(CODEBOOKSJND + ${D}/lsp1.txt + ${D}/lsp2.txt + ${D}/lsp3.txt + ${D}/lsp4.txt + ${CMAKE_SOURCE_DIR}/unittest/lspjnd5-10.txt +) + +set(CODEBOOKSDT + ${D}/lspdt1.txt + ${D}/lspdt2.txt + ${D}/lspdt3.txt + ${D}/lspdt4.txt + ${D}/lspdt5.txt + ${D}/lspdt6.txt + ${D}/lspdt7.txt + ${D}/lspdt8.txt + ${D}/lspdt9.txt + ${D}/lspdt10.txt +) + +set(CODEBOOKSJVM + ${D}/lspjvm1.txt + ${D}/lspjvm2.txt + ${D}/lspjvm3.txt +) + +set(CODEBOOKSVQANSSI + ${D}/lspvqanssi1.txt + ${D}/lspvqanssi2.txt + ${D}/lspvqanssi3.txt + ${D}/lspvqanssi4.txt +) + +set(CODEBOOKSGE ${D}/gecb.txt) + +# when crosscompiling import the executable targets from a file +if(CMAKE_CROSSCOMPILING) + set(IMPORT_EXECUTABLES "IMPORTFILE-NOTFOUND" CACHE FILEPATH "Point to the export file from a native build") + include(${IMPORT_EXECUTABLES}) +else(CMAKE_CROSSCOMPILING) +# Build code generator binaries. These do not get installed. + # generate_codebook + add_executable(generate_codebook generate_codebook.c) + target_link_libraries(generate_codebook ${CMAKE_REQUIRED_LIBRARIES}) + # genlspdtcb + add_executable(genlspdtcb genlspdtcb.c) + target_link_libraries(genlspdtcb ${CMAKE_REQUIRED_LIBRARIES}) + # Make native builds available for cross-compiling. + export(TARGETS generate_codebook genlspdtcb + FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake) +endif(CMAKE_CROSSCOMPILING) + + +# codebook.c +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebook.c + COMMAND generate_codebook lsp_cb ${CODEBOOKS} > ${CMAKE_CURRENT_BINARY_DIR}/codebook.c + DEPENDS generate_codebook ${CODEBOOKS} +) + +# codebookd.c +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebookd.c + COMMAND generate_codebook lsp_cbd ${CODEBOOKSD} > ${CMAKE_CURRENT_BINARY_DIR}/codebookd.c + DEPENDS generate_codebook ${CODEBOOKSD} +) + +# codebookdt.c +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebookdt.c + COMMAND generate_codebook lsp_cbdt ${CODEBOOKSDT} > ${CMAKE_CURRENT_BINARY_DIR}/codebookdt.c + DEPENDS generate_codebook ${CODEBOOKSDT} +) + +# codebookvq.c +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebookvq.c + COMMAND generate_codebook lsp_cbvq ${CODEBOOKSVQ} > ${CMAKE_CURRENT_BINARY_DIR}/codebookvq.c + DEPENDS generate_codebook ${CODEBOOKSVQ} +) + +# codebookjnd.c +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebookjnd.c + COMMAND generate_codebook lsp_cbjnd ${CODEBOOKSJND} > ${CMAKE_CURRENT_BINARY_DIR}/codebookjnd.c + DEPENDS generate_codebook ${CODEBOOKSJND} +) + +# codebookjvm.c +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebookjvm.c + COMMAND generate_codebook lsp_cbjvm ${CODEBOOKSJVM} > ${CMAKE_CURRENT_BINARY_DIR}/codebookjvm.c + DEPENDS generate_codebook ${CODEBOOKSJVM} +) + +# codebookvqanssi.c +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebookvqanssi.c + COMMAND generate_codebook lsp_cbvqanssi ${CODEBOOKSVQANSSI} > ${CMAKE_CURRENT_BINARY_DIR}/codebookvqanssi.c + DEPENDS generate_codebook ${CODEBOOKSVQANSSI} +) + +# codebookge.c +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebookge.c + COMMAND generate_codebook ge_cb ${CODEBOOKSGE} > ${CMAKE_CURRENT_BINARY_DIR}/codebookge.c + DEPENDS generate_codebook ${CODEBOOKSGE} +) + +# +# codec2 library sources +# + +set(CODEC2_SRCS + dump.c + lpc.c + nlp.c + postfilter.c + sine.c + codec2.c + fifo.c + fdmdv.c + kiss_fft.c + interp.c + lsp.c + phase.c + quantise.c + pack.c + codebook.c + codebookd.c + codebookvq.c + codebookjnd.c + codebookjvm.c + codebookvqanssi.c + codebookdt.c + codebookge.c + golay23.c +) + +set(CODEC2_PUBLIC_HEADERS + golay23.h + codec2.h + codec2_fdmdv.h + codec2_fifo.h + comp.h +) + +# +# Setup the codec2 library +# +add_library(codec2 ${CODEC2_SRCS}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(codec2 ${CMAKE_REQUIRED_LIBRARIES}) +set_target_properties(codec2 PROPERTIES + SOVERSION ${SOVERSION} + PUBLIC_HEADER "${CODEC2_PUBLIC_HEADERS}" +) + +add_executable(c2demo c2demo.c) +target_link_libraries(c2demo ${CMAKE_REQUIRED_LIBRARIES} codec2) + +add_executable(c2enc c2enc.c) +target_link_libraries(c2enc ${CMAKE_REQUIRED_LIBRARIES} codec2) + +add_executable(c2dec c2dec.c) +target_link_libraries(c2dec ${CMAKE_REQUIRED_LIBRARIES} codec2) + +add_executable(c2sim c2sim.c ampexp.c phaseexp.c) +target_link_libraries(c2sim ${CMAKE_REQUIRED_LIBRARIES} codec2) + +add_executable(fdmdv_get_test_bits fdmdv_get_test_bits.c fdmdv.c kiss_fft.c) +target_link_libraries(fdmdv_get_test_bits ${CMAKE_REQUIRED_LIBRARIES}) + +add_executable(fdmdv_mod fdmdv_mod.c fdmdv.c kiss_fft.c) +target_link_libraries(fdmdv_mod ${CMAKE_REQUIRED_LIBRARIES}) + +add_executable(fdmdv_demod fdmdv_demod.c fdmdv.c kiss_fft.c octave.c) +target_link_libraries(fdmdv_demod ${CMAKE_REQUIRED_LIBRARIES}) + +add_executable(fdmdv_put_test_bits fdmdv_put_test_bits.c fdmdv.c kiss_fft.c) +target_link_libraries(fdmdv_put_test_bits ${CMAKE_REQUIRED_LIBRARIES}) + +add_executable(fdmdv_interleave fdmdv_interleave.c) +target_link_libraries(fdmdv_interleave ${CMAKE_REQUIRED_LIBRARIES}) + +add_executable(insert_errors insert_errors.c) +target_link_libraries(insert_errors ${CMAKE_REQUIRED_LIBRARIES}) + +add_executable(fec_enc fec_enc.c golay23.c) +target_link_libraries(fec_enc ${CMAKE_REQUIRED_LIBRARIES} codec2) + +add_executable(fec_dec fec_dec.c golay23.c) +target_link_libraries(fec_dec ${CMAKE_REQUIRED_LIBRARIES} codec2) + +install(TARGETS codec2 EXPORT codec2-config + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/codec2 +) + +#install(EXPORT codec2-config +# DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/codec2 +#) + +install(TARGETS + c2demo + c2demo + c2enc + c2dec + c2sim + fdmdv_get_test_bits + fdmdv_mod fdmdv_demod + fdmdv_put_test_bits + fdmdv_interleave + insert_errors + fec_enc + fec_dec + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/codec2/branches/0.3/src/_kiss_fft_guts.h b/codec2/branches/0.3/src/_kiss_fft_guts.h new file mode 100644 index 00000000..ba661444 --- /dev/null +++ b/codec2/branches/0.3/src/_kiss_fft_guts.h @@ -0,0 +1,164 @@ +/* +Copyright (c) 2003-2010, Mark Borgerding + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* kiss_fft.h + defines kiss_fft_scalar as either short or a float type + and defines + typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */ +#include "kiss_fft.h" +#include + +#define MAXFACTORS 32 +/* e.g. an fft of length 128 has 4 factors + as far as kissfft is concerned + 4*4*4*2 + */ + +struct kiss_fft_state{ + int nfft; + int inverse; + int factors[2*MAXFACTORS]; + kiss_fft_cpx twiddles[1]; +}; + +/* + Explanation of macros dealing with complex math: + + C_MUL(m,a,b) : m = a*b + C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise + C_SUB( res, a,b) : res = a - b + C_SUBFROM( res , a) : res -= a + C_ADDTO( res , a) : res += a + * */ +#ifdef FIXED_POINT +#if (FIXED_POINT==32) +# define FRACBITS 31 +# define SAMPPROD int64_t +#define SAMP_MAX 2147483647 +#else +# define FRACBITS 15 +# define SAMPPROD int32_t +#define SAMP_MAX 32767 +#endif + +#define SAMP_MIN -SAMP_MAX + +#if defined(CHECK_OVERFLOW) +# define CHECK_OVERFLOW_OP(a,op,b) \ + if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \ + fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); } +#endif + + +# define smul(a,b) ( (SAMPPROD)(a)*(b) ) +# define sround( x ) (kiss_fft_scalar)( ( (x) + (1<<(FRACBITS-1)) ) >> FRACBITS ) + +# define S_MUL(a,b) sround( smul(a,b) ) + +# define C_MUL(m,a,b) \ + do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \ + (m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0) + +# define DIVSCALAR(x,k) \ + (x) = sround( smul( x, SAMP_MAX/k ) ) + +# define C_FIXDIV(c,div) \ + do { DIVSCALAR( (c).r , div); \ + DIVSCALAR( (c).i , div); }while (0) + +# define C_MULBYSCALAR( c, s ) \ + do{ (c).r = sround( smul( (c).r , s ) ) ;\ + (c).i = sround( smul( (c).i , s ) ) ; }while(0) + +#else /* not FIXED_POINT*/ + +# define S_MUL(a,b) ( (a)*(b) ) +#define C_MUL(m,a,b) \ + do{ (m).r = (a).r*(b).r - (a).i*(b).i;\ + (m).i = (a).r*(b).i + (a).i*(b).r; }while(0) +# define C_FIXDIV(c,div) /* NOOP */ +# define C_MULBYSCALAR( c, s ) \ + do{ (c).r *= (s);\ + (c).i *= (s); }while(0) +#endif + +#ifndef CHECK_OVERFLOW_OP +# define CHECK_OVERFLOW_OP(a,op,b) /* noop */ +#endif + +#define C_ADD( res, a,b)\ + do { \ + CHECK_OVERFLOW_OP((a).r,+,(b).r)\ + CHECK_OVERFLOW_OP((a).i,+,(b).i)\ + (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \ + }while(0) +#define C_SUB( res, a,b)\ + do { \ + CHECK_OVERFLOW_OP((a).r,-,(b).r)\ + CHECK_OVERFLOW_OP((a).i,-,(b).i)\ + (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \ + }while(0) +#define C_ADDTO( res , a)\ + do { \ + CHECK_OVERFLOW_OP((res).r,+,(a).r)\ + CHECK_OVERFLOW_OP((res).i,+,(a).i)\ + (res).r += (a).r; (res).i += (a).i;\ + }while(0) + +#define C_SUBFROM( res , a)\ + do {\ + CHECK_OVERFLOW_OP((res).r,-,(a).r)\ + CHECK_OVERFLOW_OP((res).i,-,(a).i)\ + (res).r -= (a).r; (res).i -= (a).i; \ + }while(0) + + +#ifdef FIXED_POINT +# define KISS_FFT_COS(phase) floor(.5+SAMP_MAX * cos (phase)) +# define KISS_FFT_SIN(phase) floor(.5+SAMP_MAX * sin (phase)) +# define HALF_OF(x) ((x)>>1) +#elif defined(USE_SIMD) +# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) ) +# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) ) +# define HALF_OF(x) ((x)*_mm_set1_ps(.5)) +#else +# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase) +# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase) +# define HALF_OF(x) ((x)*.5) +#endif + +#define kf_cexp(x,phase) \ + do{ \ + (x)->r = KISS_FFT_COS(phase);\ + (x)->i = KISS_FFT_SIN(phase);\ + }while(0) + + +/* a debugging function */ +#define pcpx(c)\ + fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) ) + + +#ifdef KISS_FFT_USE_ALLOCA +// define this to allow use of alloca instead of malloc for temporary buffers +// Temporary buffers are used in two case: +// 1. FFT sizes that have "bad" factors. i.e. not 2,3 and 5 +// 2. "in-place" FFTs. Notice the quotes, since kissfft does not really do an in-place transform. +#include +#define KISS_FFT_TMP_ALLOC(nbytes) alloca(nbytes) +#define KISS_FFT_TMP_FREE(ptr) +#else +#define KISS_FFT_TMP_ALLOC(nbytes) KISS_FFT_MALLOC(nbytes) +#define KISS_FFT_TMP_FREE(ptr) KISS_FFT_FREE(ptr) +#endif diff --git a/codec2/branches/0.3/src/ampexp.c b/codec2/branches/0.3/src/ampexp.c new file mode 100644 index 00000000..94e2184c --- /dev/null +++ b/codec2/branches/0.3/src/ampexp.c @@ -0,0 +1,1093 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: ampexp.c + AUTHOR......: David Rowe + DATE CREATED: 7 August 2012 + + Functions for experimenting with amplitude quantisation. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2012 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not,see . +*/ + + +#include +#include +#include +#include +#include +#include + +#include "ampexp.h" + + +#define PRED_COEFF 0.9 + +/* states for amplitude experiments */ + +struct codebook { + unsigned int k; + unsigned int log2m; + unsigned int m; + float *cb; + unsigned int offset; +}; + +struct AEXP { + float A_prev[MAX_AMP]; + int frames; + float snr; + int snr_n; + float var; + int var_n; + float vq_var; + int vq_var_n; + struct codebook *vq1,*vq2,*vq3,*vq4,*vq5; + + int indexes[5][3]; + MODEL model[3]; + float mag[3]; + MODEL model_uq[3]; +}; + + +/*---------------------------------------------------------------------------*\ + + Bruce Perens' funcs to load codebook files + +\*---------------------------------------------------------------------------*/ + + +static const char format[] = +"The table format must be:\n" +"\tTwo integers describing the dimensions of the codebook.\n" +"\tThen, enough numbers to fill the specified dimensions.\n"; + +static float get_float(FILE * in, const char * name, char * * cursor, char * buffer, int size) +{ + for ( ; ; ) { + char * s = *cursor; + char c; + + while ( (c = *s) != '\0' && !isdigit(c) && c != '-' && c != '.' ) + s++; + + /* Comments start with "#" and continue to the end of the line. */ + if ( c != '\0' && c != '#' ) { + char * end = 0; + float f = 0; + + f = strtod(s, &end); + + if ( end != s ) + *cursor = end; + return f; + } + + if ( fgets(buffer, size, in) == NULL ) { + fprintf(stderr, "%s: Format error. %s\n", name, format); + exit(1); + } + *cursor = buffer; + } +} + +static struct codebook *load(const char * name) +{ + FILE *file; + char line[2048]; + char *cursor = line; + struct codebook *b = malloc(sizeof(struct codebook)); + int i; + int size; + + file = fopen(name, "rt"); + assert(file != NULL); + + *cursor = '\0'; + + b->k = (int)get_float(file, name, &cursor, line, sizeof(line)); + b->m = (int)get_float(file, name ,&cursor, line, sizeof(line)); + size = b->k * b->m; + + b->cb = (float *)malloc(size * sizeof(float)); + + for ( i = 0; i < size; i++ ) { + b->cb[i] = get_float(file, name, &cursor, line, sizeof(line)); + } + + fclose(file); + + return b; +} + + +/*---------------------------------------------------------------------------* \ + + amp_experiment_create() + + Inits states for amplitude quantisation experiments. + +\*---------------------------------------------------------------------------*/ + +struct AEXP *amp_experiment_create() { + struct AEXP *aexp; + int i,j,m; + + aexp = (struct AEXP *)malloc(sizeof(struct AEXP)); + assert (aexp != NULL); + + for(i=0; iA_prev[i] = 1.0; + aexp->frames = 0; + aexp->snr = 0.0; + aexp->snr_n = 0; + aexp->var = 0.0; + aexp->var_n = 0; + aexp->vq_var = 0.0; + aexp->vq_var_n = 0; + + //aexp->vq1 = load("amp_1_80_1024a.txt"); + //aexp->vq1 = load("../unittest/st1_10_1024.txt"); + //aexp->vq1 = load("../unittest/amp41_80_1024.txt"); + //aexp->vq1->offset = 40; + aexp->vq1 = load("../unittest/amp1_10_1024.txt"); + aexp->vq1->offset = 0; + aexp->vq2 = load("../unittest/amp11_20_1024.txt"); + aexp->vq2->offset = 10; + + aexp->vq3 = load("../unittest/amp21_40_1024.txt"); + aexp->vq3->offset = 20; + aexp->vq4 = load("../unittest/amp41_60_1024.txt"); + aexp->vq4->offset = 40; + aexp->vq5 = load("../unittest/amp61_80_256.txt"); + aexp->vq5->offset = 60; + + #ifdef CAND2_GS + //aexp->vq1 = load("../unittest/t1_amp1_20_1024.txt"); + //aexp->vq1 = load("../unittest/t2_amp1_20_1024.txt"); + aexp->vq1 = load("../unittest/amp1_20_1024.txt"); + aexp->vq1->offset = 0; + aexp->vq2 = load("../unittest/amp21_40_1024.txt"); + aexp->vq2->offset = 20; + aexp->vq3 = load("../unittest/amp41_60_1024.txt"); + aexp->vq3->offset = 40; + aexp->vq4 = load("../unittest/amp61_80_32.txt"); + aexp->vq4->offset = 60; + #endif + + //#define CAND2_GS + #ifdef CAND2_GS + aexp->vq1 = load("../unittest/amp1_20_1024.txt"); + aexp->vq2 = load("../unittest/amp21_40_1024.txt"); + aexp->vq3 = load("../unittest/amp41_80_1024.txt"); + aexp->vq4 = load("../unittest/amp61_80_32.txt"); + aexp->vq1->offset = 0; + aexp->vq2->offset = 20; + aexp->vq3->offset = 40; + aexp->vq4->offset = 60; + #endif + + //#define CAND1 + #ifdef CAND1 + aexp->vq1 = load("../unittest/amp1_10_128.txt"); + aexp->vq2 = load("../unittest/amp11_20_512.txt"); + aexp->vq3 = load("../unittest/amp21_40_1024.txt"); + aexp->vq4 = load("../unittest/amp41_60_1024.txt"); + aexp->vq5 = load("../unittest/amp61_80_32.txt"); + aexp->vq1->offset = 0; + aexp->vq2->offset = 10; + aexp->vq3->offset = 20; + aexp->vq4->offset = 40; + aexp->vq5->offset = 60; + #endif + + for(i=0; i<3; i++) { + for(j=0; j<5; j++) + aexp->indexes[j][i] = 0; + aexp->mag[i] = 1.0; + aexp->model[i].Wo = TWO_PI*100.0/8000.0; + aexp->model[i].L = floor(PI/aexp->model[i].Wo); + for(m=1; m<=MAX_AMP; m++) + aexp->model[i].A[m] = 10.0; + aexp->model_uq[i] = aexp->model[i]; + } + + return aexp; +} + + +/*---------------------------------------------------------------------------* \ + + amp_experiment_destroy() + +\*---------------------------------------------------------------------------*/ + +void amp_experiment_destroy(struct AEXP *aexp) { + assert(aexp != NULL); + if (aexp->snr != 0.0) + printf("snr: %4.2f dB\n", aexp->snr/aexp->snr_n); + if (aexp->var != 0.0) + printf("var...: %4.3f std dev...: %4.3f (%d amplitude samples)\n", + aexp->var/aexp->var_n, sqrt(aexp->var/aexp->var_n), aexp->var_n); + if (aexp->vq_var != 0.0) + printf("vq var: %4.3f std dev...: %4.3f (%d amplitude samples)\n", + aexp->vq_var/aexp->vq_var_n, sqrt(aexp->vq_var/aexp->vq_var_n), aexp->vq_var_n); + free(aexp); +} + + +/*---------------------------------------------------------------------------*\ + + Various test and experimental functions ................ + +\*---------------------------------------------------------------------------*/ + +/* + Quantisation noise simulation. Assume noise on amplitudes is a uniform + distribution, of +/- x dB. This means x = sqrt(3)*sigma. + + Note: for uniform distribution var = = sigma * sigma = (b-a)*(b-a)/12. +*/ + +static void add_quant_noise(struct AEXP *aexp, MODEL *model, int start, int end, float sigma_dB) +{ + int m; + float x_dB; + float noise_sam_dB; + float noise_sam_lin; + + x_dB = sqrt(3.0) * sigma_dB; + + for(m=start; m<=end; m++) { + noise_sam_dB = x_dB*(1.0 - 2.0*rand()/RAND_MAX); + //printf("%f\n", noise_sam_dB); + noise_sam_lin = pow(10.0, noise_sam_dB/20.0); + model->A[m] *= noise_sam_lin; + aexp->var += noise_sam_dB*noise_sam_dB; + aexp->var_n++; + } + +} + +/* + void print_sparse_pred_error() + + use to check pred error stats (e.g. of first 1kHz) in Octave: + + $ ./c2sim ../raw/hts1a.raw --ampexp > amppe.txt + + octave> load ../src/amppe.txt + octave> std(nonzeros(amppe(:,1:20))) + octave> hist(nonzeros(amppe(:,1:20)),20); + + */ + + +static void print_sparse_pred_error(struct AEXP *aexp, MODEL *model, float mag_thresh) +{ + int m, index; + float mag, error; + float sparse_pe[MAX_AMP]; + + mag = 0.0; + for(m=1; m<=model->L; m++) + mag += model->A[m]*model->A[m]; + mag = 10*log10(mag/model->L); + + if (mag > mag_thresh) { + for(m=0; mL; m++) { + assert(model->A[m] > 0.0); + error = PRED_COEFF*20.0*log10(aexp->A_prev[m]) - 20.0*log10(model->A[m]); + //error = 20.0*log10(model->A[m]) - mag; + + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + sparse_pe[index] = error; + } + + /* dump sparse amp vector */ + + for(m=0; mL; m++) + e += model->A[m]*model->A[m]; + edB = 10*log10(e); + + #define VER_E0 + + #ifdef VER_E0 + *enormdB = 10*log10(e/model->L); /* make high and low pitches have similar amps */ + #endif + + #ifdef VER_E1 + e = 0.0; + for(m=1; m<=model->L; m++) + e += 10*log10(model->A[m]*model->A[m]); + *enormdB = e; + #endif + + #ifdef VER_E2 + e = 0.0; + for(m=1; m<=model->L; m++) + e += 10*log10(model->A[m]*model->A[m]); + *enormdB = e/model->L; + #endif + //printf("%f\n", enormdB); + + return edB; +} + +static void print_sparse_amp_error(struct AEXP *aexp, MODEL *model, float edB_thresh) +{ + int m, index; + float edB, enormdB, error, dWo; + float sparse_pe[MAX_AMP]; + + edB = frame_energy(model, &enormdB); + //printf("%f\n", enormdB); + dWo = fabs((aexp->model_uq[2].Wo - aexp->model_uq[1].Wo)/aexp->model_uq[2].Wo); + + if ((edB > edB_thresh) && (dWo < 0.1)) { + for(m=0; mL; m++) { + assert(model->A[m] > 0.0); + error = 20.0*log10(model->A[m]) - enormdB; + + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + sparse_pe[index] = error; + } + + /* dump sparse amp vector */ + + for(m=0; mcb, &sparse_pe_in[vq->offset], &weights[vq->offset], vq->k, vq->m, &se); + printf("\n offset %d k %d m %d vq_ind %d j: ", vq->offset, vq->k, vq->m, vq_ind); + + non_zero = 0; + for(i=0, j=vq->offset; ik; i++,j++) { + if (sparse_pe_in[j] != 0.0) { + printf("%d ", j); + sparse_pe_in[j] -= vq->cb[vq->k * vq_ind + i]; + sparse_pe_out[j] += vq->cb[vq->k * vq_ind + i]; + non_zero++; + } + } + aexp->vq_var_n += non_zero; + return vq_ind; +} + + +static void sparse_vq_pred_error(struct AEXP *aexp, + MODEL *model +) +{ + int m, index; + float error, amp_dB, edB, enormdB; + float sparse_pe_in[MAX_AMP]; + float sparse_pe_out[MAX_AMP]; + float weights[MAX_AMP]; + + edB = frame_energy(model, &enormdB); + + for(m=0; mL; m++) { + assert(model->A[m] > 0.0); + error = PRED_COEFF*20.0*log10(aexp->A_prev[m]) - 20.0*log10(model->A[m]); + + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + sparse_pe_in[index] = error; + weights[index] = model->A[m]; + } + + /* vector quantise */ + + for(m=0; mvq1, weights, sparse_pe_in); + #else + for(m=aexp->vq->offset; mvq->offset+aexp->vq->k; m++) { + if (sparse_pe_in[m] != 0.0) { + float error = 8*(1.0 - 2.0*rand()/RAND_MAX); + aexp->vq_var += error*error; + aexp->vq_var_n++; + sparse_pe_out[m] = sparse_pe_in[m] + error; + } + } + #endif + + if (edB > -100.0) + for(m=0; mvq_var += pow(sparse_pe_out[m] - sparse_pe_in[m], 2.0); + } + + /* transform quantised amps back */ + + for(m=1; m<=model->L; m++) { + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + amp_dB = PRED_COEFF*20.0*log10(aexp->A_prev[m]) - sparse_pe_out[index]; + //printf("in: %f out: %f\n", sparse_pe_in[index], sparse_pe_out[index]); + //printf("amp_dB: %f A[m] (dB) %f\n", amp_dB, 20.0*log10(model->A[m])); + model->A[m] = pow(10.0, amp_dB/20.0); + } + //exit(0); +} + + +static void split_error(struct AEXP *aexp, struct codebook *vq, float sparse_pe_in[], int ind) +{ + int i, j; + + for(i=0, j=vq->offset; ik; i++,j++) { + if (sparse_pe_in[j] != 0.0) { + sparse_pe_in[j] -= vq->cb[vq->k * ind + i]; + } + } +} + + +static void sparse_vq_amp(struct AEXP *aexp, MODEL *model) +{ + int m, index; + float error, amp_dB, enormdB; + float sparse_pe_in[MAX_AMP]; + float sparse_pe_out[MAX_AMP]; + float weights[MAX_AMP]; + + frame_energy(model, &enormdB); + + aexp->mag[2] = enormdB; + + for(m=0; mL; m++) { + assert(model->A[m] > 0.0); + error = 20.0*log10(model->A[m]) - enormdB; + + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + sparse_pe_in[index] = error; + weights[index] = pow(model->A[m],0.8); + } + + /* vector quantise */ + + for(m=0; mindexes[0][2] = split_vq(sparse_pe_out, aexp, aexp->vq1, weights, sparse_pe_in); + + aexp->indexes[1][2] = split_vq(sparse_pe_out, aexp, aexp->vq2, weights, sparse_pe_in); + aexp->indexes[2][2] = split_vq(sparse_pe_out, aexp, aexp->vq3, weights, sparse_pe_in); + aexp->indexes[3][2] = split_vq(sparse_pe_out, aexp, aexp->vq4, weights, sparse_pe_in); + aexp->indexes[4][2] = split_vq(sparse_pe_out, aexp, aexp->vq5, weights, sparse_pe_in); + #endif + //#define MULTISTAGE + #ifdef MULTISTAGE + aexp->indexes[0][2] = split_vq(sparse_pe_out, aexp, aexp->vq1, weights, sparse_pe_in); + aexp->indexes[1][2] = split_vq(sparse_pe_out, aexp, aexp->vq2, weights, sparse_pe_in); + aexp->indexes[2][2] = split_vq(sparse_pe_out, aexp, aexp->vq3, weights, sparse_pe_in); + //aexp->indexes[3][2] = split_vq(sparse_pe_out, aexp, aexp->vq4, weights, sparse_pe_in); + #endif + + for(m=0; mvq_var += pow(sparse_pe_out[m] - sparse_pe_in[m], 2.0); + } + + /* transform quantised amps back */ + + for(m=1; m<=model->L; m++) { + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + amp_dB = sparse_pe_out[index] + enormdB; + model->A[m] = pow(10.0, amp_dB/20.0); + } + //exit(0); +} + + +static void update_snr_calc(struct AEXP *aexp, MODEL *m1, MODEL *m2) +{ + int m; + float signal, noise, signal_dB; + + assert(m1->L == m2->L); + + signal = 0.0; noise = 1E-32; + for(m=1; m<=m1->L; m++) { + signal += m1->A[m]*m1->A[m]; + noise += pow(m1->A[m] - m2->A[m], 2.0); + //printf("%f %f\n", before[m], model->phi[m]); + } + signal_dB = 10*log10(signal); + if (signal_dB > -100.0) { + aexp->snr += 10.0*log10(signal/noise); + aexp->snr_n++; + } +} + + +/* gain/shape vq search. Returns index of best gain. Gain is additive (as we use log quantisers) */ + +int gain_shape_vq_amp(float cb[], float vec[], float weights[], int d, int e, float *se, float *best_gain) +{ + float error; /* current error */ + int besti; /* best index so far */ + float best_error; /* best error so far */ + int i,j,m; + float diff, metric, best_metric, gain, sumAm, sumCb; + + besti = 0; + best_metric = best_error = 1E32; + for(j=0; jcb, &sparse_pe_in[vq->offset], &weights[vq->offset], vq->k, vq->m, &se, best_gain); + //printf("\n offset %d k %d m %d vq_ind %d gain: %4.2f j: ", vq->offset, vq->k, vq->m, vq_ind, *best_gain); + + non_zero = 0; + for(i=0, j=vq->offset; ik; i++,j++) { + if (sparse_pe_in[j] != 0.0) { + //printf("%d ", j); + sparse_pe_out[j] = vq->cb[vq->k * vq_ind + i] + *best_gain; + non_zero++; + } + } + aexp->vq_var_n += non_zero; +} + + +static void gain_shape_sparse_vq_amp(struct AEXP *aexp, MODEL *model) +{ + int m, index; + float amp_dB, best_gain; + float sparse_pe_in[MAX_AMP]; + float sparse_pe_out[MAX_AMP]; + float weights[MAX_AMP]; + + for(m=0; mL; m++) { + assert(model->A[m] > 0.0); + + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + sparse_pe_in[index] = 20.0*log10(model->A[m]); + weights[index] = model->A[m]; + } + + /* vector quantise */ + + for(m=0; mvq1, weights, sparse_pe_in, &best_gain); + gain_shape_split_vq(sparse_pe_out, aexp, aexp->vq2, weights, sparse_pe_in, &best_gain); + gain_shape_split_vq(sparse_pe_out, aexp, aexp->vq3, weights, sparse_pe_in, &best_gain); + gain_shape_split_vq(sparse_pe_out, aexp, aexp->vq4, weights, sparse_pe_in, &best_gain); + + for(m=0; mvq_var += pow(sparse_pe_out[m] - sparse_pe_in[m], 2.0); + } + + /* transform quantised amps back */ + + for(m=1; m<=model->L; m++) { + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + amp_dB = sparse_pe_out[index]; + model->A[m] = pow(10.0, amp_dB/20.0); + } + //exit(0); +} + + +static void interp_split_vq(float sparse_pe_out[], struct AEXP *aexp, struct codebook *vq, float sparse_pe_in[], int ind) +{ + int i, j; + float amp_dB; + + for(i=0, j=vq->offset; ik; i++,j++) { + if (sparse_pe_in[j] != 0.0) { + amp_dB = 0.5*(aexp->mag[0] + vq->cb[vq->k * aexp->indexes[ind][0] + i]); + amp_dB += 0.5*(aexp->mag[2] + vq->cb[vq->k * aexp->indexes[ind][2] + i]); + sparse_pe_out[j] = amp_dB; + } + } +} + + +static void vq_interp(struct AEXP *aexp, MODEL *model, int on) +{ + int i, j, m, index; + float amp_dB; + //struct codebook *vq = aexp->vq1; + float sparse_pe_in[MAX_AMP]; + float sparse_pe_out[MAX_AMP]; + + /* replace odd frames with interp */ + /* once we get an even input frame we can interpolate and output odd */ + /* using VQ to interpolate. This assumes some correlation in + adjacent VQ samples */ + + memcpy(&aexp->model[2], model, sizeof(MODEL)); + + /* once we get an even input frame we have enough information to + replace prev odd frame with interpolated version */ + + if (on && ((aexp->frames % 2) == 0)) { + + /* copy Wo, L, and phases */ + + memcpy(model, &aexp->model[1], sizeof(MODEL)); + //printf("mags: %4.2f %4.2f %4.2f Am: \n", aexp->mag[0], aexp->mag[1], aexp->mag[2]); + + /* now replace Am by interpolation, use similar design to VQ + to handle different bands */ + + for(m=1; m<=model->L; m++) { + assert(model->A[m] > 0.0); + + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + sparse_pe_in[index] = 20.0*log10(model->A[m]); + } + + /* this can be used for when just testing partial interpolation */ + + for(m=0; mvq1, sparse_pe_in, 0); + interp_split_vq(sparse_pe_out, aexp, aexp->vq2, sparse_pe_in, 1); + interp_split_vq(sparse_pe_out, aexp, aexp->vq3, sparse_pe_in, 2); + interp_split_vq(sparse_pe_out, aexp, aexp->vq4, sparse_pe_in, 3); + interp_split_vq(sparse_pe_out, aexp, aexp->vq5, sparse_pe_in, 4); + + for(m=1; m<=model->L; m++) { + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + amp_dB = sparse_pe_out[index]; + //printf(" %4.2f", 10.0*log10(model->A[m])); + model->A[m] = pow(10.0, amp_dB/20.0); + //printf(" %4.2f\n", 10.0*log10(model->A[m])); + } + + #ifdef INITIAL_VER + + for(m=1; m<=model->L; m++) { + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + + if (index < vq->k) { + amp_dB = 0.5*(aexp->mag[0] + vq->cb[vq->k * aexp->indexes[0] + index]); + amp_dB += 0.5*(aexp->mag[2] + vq->cb[vq->k * aexp->indexes[2] + index]); + //printf(" %4.2f", 10.0*log10(model->A[m])); + //amp_dB = 10; + model->A[m] = pow(10.0, amp_dB/20.0); + printf(" %4.2f\n", 10.0*log10(model->A[m])); + } + } + + #endif + } + else + memcpy(model, &aexp->model[1], sizeof(MODEL)); + + /* update memories */ + + for(i=0; i<2; i++) { + memcpy(&aexp->model[i], &aexp->model[i+1], sizeof(MODEL)); + for(j=0; j<5; j++) + aexp->indexes[j][i] = aexp->indexes[j][i+1]; + aexp->mag[i] = aexp->mag[i+1]; + } + +} + + +/* + This functions tests theory that some bands can be combined together + due to less frequency resolution at higher frequencies. This will + reduce the amount of information we need to encode. +*/ + +void smooth_samples(struct AEXP *aexp, MODEL *model, int mode) +{ + int m, i, j, index, step, nav, v, en; + float sparse_pe_in[MAX_AMP], av, amp_dB; + float sparse_pe_out[MAX_AMP]; + float smoothed[MAX_AMP], smoothed_out[MAX_AMP]; + float weights[MAX_AMP]; + float enormdB; + + frame_energy(model, &enormdB); + + for(m=0; mL; m++) { + assert(model->A[m] > 0.0); + + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + sparse_pe_out[index] = sparse_pe_in[index] = 20.0*log10(model->A[m]) - enormdB; + } + + /* now combine samples at high frequencies to reduce dimension */ + + step=4; + for(i=MAX_AMP/2,v=0; i (MAX_AMP-1)) + en = MAX_AMP-1; + for(j=i; jvq1, weights, smoothed); + for(i=0; i (MAX_AMP-1)) + en = MAX_AMP-1; + for(j=i; jL; m++) { + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + amp_dB = sparse_pe_out[index] + enormdB; + //printf("%d %4.2f %4.2f\n", m, 10.0*log10(model->A[m]), amp_dB); + model->A[m] = pow(10.0, amp_dB/20.0); + } + +} + +#define MAX_BINS 40 +static float bins[] = { + /*1000.0, 1200.0, 1400.0, 1600.0, 1800,*/ + 2000.0, 2400.0, 2800.0, + 3000.0, 3400.0, 3600.0, 4000.0}; + +void smooth_amp(struct AEXP *aexp, MODEL *model) { + int m, i; + int nbins; + int b; + float f; + float av[MAX_BINS]; + int nav[MAX_BINS]; + + nbins = sizeof(bins)/sizeof(float); + + /* clear all bins */ + + for(i=0; iL; m++) { + f = m*model->Wo*FS/TWO_PI; + if (f > bins[0]) { + + /* find bin */ + + for(i=0; i bins[i]) && (f <= bins[i+1])) + b = i; + assert(b < MAX_BINS); + + av[b] += model->A[m]*model->A[m]; + nav[b]++; + } + + } + + /* use averages to est amps */ + + for(m=1; m<=model->L; m++) { + f = m*model->Wo*FS/TWO_PI; + if (f > bins[0]) { + + /* find bin */ + + for(i=0; i bins[i]) && (f <= bins[i+1])) + b = i; + assert(b < MAX_BINS); + + /* add predicted phase error to this bin */ + + printf("L %d m %d f %4.f b %d\n", model->L, m, f, b); + + printf(" %d: %4.3f -> ", m, 20*log10(model->A[m])); + model->A[m] = sqrt(av[b]/nav[b]); + printf("%4.3f\n", 20*log10(model->A[m])); + } + } + printf("\n"); +} + +/*---------------------------------------------------------------------------* \ + + amp_experiment() + + Amplitude quantisation experiments. + +\*---------------------------------------------------------------------------*/ + +void amp_experiment(struct AEXP *aexp, MODEL *model, char *arg) { + int m,i; + + memcpy(&aexp->model_uq[2], model, sizeof(MODEL)); + + if (strcmp(arg, "qn") == 0) { + add_quant_noise(aexp, model, 1, model->L, 1); + update_snr_calc(aexp, &aexp->model_uq[2], model); + } + + /* print training samples that can be > train.txt for training VQ */ + + if (strcmp(arg, "train") == 0) + print_sparse_amp_error(aexp, model, 00.0); + + /* VQ of amplitudes, no interpolation (ie 10ms rate) */ + + if (strcmp(arg, "vq") == 0) { + sparse_vq_amp(aexp, model); + vq_interp(aexp, model, 0); + update_snr_calc(aexp, &aexp->model_uq[1], model); + } + + /* VQ of amplitudes, interpolation (ie 20ms rate) */ + + if (strcmp(arg, "vqi") == 0) { + sparse_vq_amp(aexp, model); + vq_interp(aexp, model, 1); + update_snr_calc(aexp, &aexp->model_uq[1], model); + } + + /* gain/shape VQ of amplitudes, 10ms rate (doesn't work that well) */ + + if (strcmp(arg, "gsvq") == 0) { + gain_shape_sparse_vq_amp(aexp, model); + vq_interp(aexp, model, 0); + update_snr_calc(aexp, &aexp->model_uq[1], model); + } + + if (strcmp(arg, "smooth") == 0) { + smooth_samples(aexp, model, 0); + update_snr_calc(aexp, &aexp->model_uq[2], model); + } + + if (strcmp(arg, "smoothtrain") == 0) { + smooth_samples(aexp, model, 1); + //update_snr_calc(aexp, &aexp->model_uq[2], model); + } + + if (strcmp(arg, "smoothvq") == 0) { + smooth_samples(aexp, model, 2); + update_snr_calc(aexp, &aexp->model_uq[2], model); + } + + if (strcmp(arg, "smoothamp") == 0) { + smooth_amp(aexp, model); + update_snr_calc(aexp, &aexp->model_uq[2], model); + } + + /* update states */ + + for(m=1; m<=model->L; m++) + aexp->A_prev[m] = model->A[m]; + aexp->frames++; + for(i=0; i<3; i++) + aexp->model_uq[i] = aexp->model_uq[i+1]; +} + diff --git a/codec2/branches/0.3/src/ampexp.h b/codec2/branches/0.3/src/ampexp.h new file mode 100644 index 00000000..313abb15 --- /dev/null +++ b/codec2/branches/0.3/src/ampexp.h @@ -0,0 +1,39 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: ampexp.h + AUTHOR......: David Rowe + DATE CREATED: & August 2012 + + Functions for experimenting with amplitude quantisation. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2012 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not,see . +*/ + +#ifndef __AMPEX__ +#define __AMPEXP__ + +#include "defines.h" + +struct AEXP; + +struct AEXP *amp_experiment_create(); +void amp_experiment_destroy(struct AEXP *aexp); +void amp_experiment(struct AEXP *aexp, MODEL *model, char *arg); + +#endif diff --git a/codec2/branches/0.3/src/c2dec.c b/codec2/branches/0.3/src/c2dec.c new file mode 100644 index 00000000..641e4019 --- /dev/null +++ b/codec2/branches/0.3/src/c2dec.c @@ -0,0 +1,291 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: c2dec.c + AUTHOR......: David Rowe + DATE CREATED: 23/8/2010 + + Decodes a file of bits to a file of raw speech samples using codec2. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2010 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include "codec2.h" +#include "dump.h" + +#include +#include +#include +#include +#include +#include + +#define NONE 0 /* no bit errors */ +#define UNIFORM 1 /* random bit errors */ +#define TWO_STATE 2 /* Two state error model */ +#define UNIFORM_RANGE 3 /* random bit errors over a certain range */ + +void print_help(const struct option *long_options, int num_opts, char* argv[]); + +int main(int argc, char *argv[]) +{ + int mode; + void *codec2; + FILE *fin; + FILE *fout; + FILE *fber = NULL; + short *buf; + unsigned char *bits, *prev_bits; + int nsam, nbit, nbyte, i, byte, frames, bits_proc, bit_errors, error_mode; + int nstart_bit, nend_bit, bit_rate; + int state, next_state; + float ber, r, burst_length, burst_period, burst_timer, ber_est; + unsigned char mask; + int natural, dump; + + char* opt_string = "h:"; + struct option long_options[] = { + { "ber", required_argument, NULL, 0 }, + { "startbit", required_argument, NULL, 0 }, + { "endbit", required_argument, NULL, 0 }, + { "berfile", required_argument, NULL, 0 }, + { "natural", no_argument, &natural, 1 }, + #ifdef DUMP + { "dump", required_argument, &dump, 1 }, + #endif + { "help", no_argument, NULL, 'h' }, + { NULL, no_argument, NULL, 0 } + }; + int num_opts=sizeof(long_options)/sizeof(struct option); + + if (argc < 4) + print_help(long_options, num_opts, argv); + + if (strcmp(argv[1],"3200") == 0) + mode = CODEC2_MODE_3200; + else if (strcmp(argv[1],"2400") == 0) + mode = CODEC2_MODE_2400; + else if (strcmp(argv[1],"1600") == 0) + mode = CODEC2_MODE_1600; + else if (strcmp(argv[1],"1400") == 0) + mode = CODEC2_MODE_1400; + else if (strcmp(argv[1],"1300") == 0) + mode = CODEC2_MODE_1300; + else if (strcmp(argv[1],"1200") == 0) + mode = CODEC2_MODE_1200; + else { + fprintf(stderr, "Error in mode: %s. Must be 3200, 2400, 1600, 1400, 1300 or 1200\n", argv[1]); + exit(1); + } + bit_rate = atoi(argv[1]); + + if (strcmp(argv[2], "-") == 0) fin = stdin; + else if ( (fin = fopen(argv[2],"rb")) == NULL ) { + fprintf(stderr, "Error opening input bit file: %s: %s.\n", + argv[2], strerror(errno)); + exit(1); + } + + if (strcmp(argv[3], "-") == 0) fout = stdout; + else if ( (fout = fopen(argv[3],"wb")) == NULL ) { + fprintf(stderr, "Error opening output speech file: %s: %s.\n", + argv[3], strerror(errno)); + exit(1); + } + + error_mode = NONE; + ber = 0.0; + burst_length = burst_period = 0.0; + burst_timer = 0.0; + dump = natural = 0; + + codec2 = codec2_create(mode); + nsam = codec2_samples_per_frame(codec2); + nbit = codec2_bits_per_frame(codec2); + buf = (short*)malloc(nsam*sizeof(short)); + nbyte = (nbit + 7) / 8; + bits = (unsigned char*)malloc(nbyte*sizeof(char)); + prev_bits = (unsigned char*)malloc(nbyte*sizeof(char)); + frames = bit_errors = bits_proc = 0; + nstart_bit = 0; + nend_bit = nbit-1; + + while(1) { + int option_index = 0; + int opt = getopt_long(argc, argv, opt_string, + long_options, &option_index); + if (opt == -1) + break; + + switch (opt) { + case 0: + if(strcmp(long_options[option_index].name, "ber") == 0) { + ber = atof(optarg); + error_mode = UNIFORM; + } else if(strcmp(long_options[option_index].name, "startbit") == 0) { + nstart_bit = atoi(optarg); + } else if(strcmp(long_options[option_index].name, "endbit") == 0) { + nend_bit = atoi(optarg); + } else if(strcmp(long_options[option_index].name, "berfile") == 0) { + if ((fber = fopen(optarg,"wt")) == NULL) { + fprintf(stderr, "Error opening BER file: %s %s.\n", + optarg, strerror(errno)); + exit(1); + } + + } + #ifdef DUMP + else if(strcmp(long_options[option_index].name, "dump") == 0) { + if (dump) + dump_on(optarg); + } + #endif + break; + + case 'h': + print_help(long_options, num_opts, argv); + break; + + default: + /* This will never be reached */ + break; + } + } + assert(nend_bit <= nbit); + codec2_set_natural_or_gray(codec2, !natural); + //printf("%d %d\n", nstart_bit, nend_bit); + + while(fread(bits, sizeof(char), nbyte, fin) == (size_t)nbyte) { + frames++; + + // apply bit errors, MSB of byte 0 is bit 0 in frame */ + + if ((error_mode == UNIFORM) || (error_mode == UNIFORM_RANGE)) { + for(i=nstart_bit; i (burst_period - burst_length)) + next_state = 1; + break; + + case 1: + + /* burst error state - 50% bit error rate */ + + for(i=nstart_bit; i burst_period) { + burst_timer = 0.0; + next_state = 0; + } + break; + + } + + state = next_state; + } + + if (fber != NULL) { + if (fread(&ber_est, sizeof(float), 1, fber) != 1) { + fprintf(stderr, "ran out of BER estimates!\n"); + exit(1); + } + //fprintf(stderr, "ber_est: %f\n", ber_est); + } + else + ber_est = 0.0; + + codec2_decode_ber(codec2, buf, bits, ber_est); + fwrite(buf, sizeof(short), nsam, fout); + //if this is in a pipeline, we probably don't want the usual + //buffering to occur + if (fout == stdout) fflush(stdout); + if (fin == stdin) fflush(stdin); + + memcpy(prev_bits, bits, nbyte); + } + + if (error_mode) + fprintf(stderr, "actual BER: %1.3f\n", (float)bit_errors/bits_proc); + + codec2_destroy(codec2); + + free(buf); + free(bits); + fclose(fin); + fclose(fout); + + return 0; +} + +void print_help(const struct option* long_options, int num_opts, char* argv[]) +{ + int i; + char *option_parameters; + fprintf(stderr, "\nc2dec - Codec 2 decoder and bit error simulation program\n" + "usage: %s 3200|2400|1400}1300|1200 InputFile OutputRawFile [OPTIONS]\n\n" + "Options:\n", argv[0]); + for(i=0; i. +*/ + +#include "codec2.h" +#include "sine.h" +#include "dump.h" + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + struct CODEC2 *codec2; + FILE *fin; + FILE *fout; + short *buf; + unsigned char *bits; + int nsam, nbit, i, r; + + for(i=0; i<10; i++) { + r = codec2_rand(); + printf("[%d] r = %d\n", i, r); + } + + if (argc != 3) { + printf("usage: %s InputRawSpeechFile OutputRawSpeechFile\n", argv[0]); + exit(1); + } + + if ( (fin = fopen(argv[1],"rb")) == NULL ) { + fprintf(stderr, "Error opening input speech file: %s: %s.\n", + argv[1], strerror(errno)); + exit(1); + } + + if ( (fout = fopen(argv[2],"wb")) == NULL ) { + fprintf(stderr, "Error opening output speech file: %s: %s.\n", + argv[2], strerror(errno)); + exit(1); + } + + #ifdef DUMP + dump_on("c2demo"); + #endif + + /* Note only one set of Codec 2 states is required for an encoder + and decoder pair. */ + + codec2 = codec2_create(CODEC2_MODE_1300); + nsam = codec2_samples_per_frame(codec2); + buf = (short*)malloc(nsam*sizeof(short)); + nbit = codec2_bits_per_frame(codec2); + bits = (unsigned char*)malloc(nbit*sizeof(char)); + + while(fread(buf, sizeof(short), nsam, fin) == (size_t)nsam) { + codec2_encode(codec2, bits, buf); + codec2_decode(codec2, buf, bits); + fwrite(buf, sizeof(short), nsam, fout); + } + + free(buf); + free(bits); + codec2_destroy(codec2); + + fclose(fin); + fclose(fout); + + return 0; +} diff --git a/codec2/branches/0.3/src/c2enc.c b/codec2/branches/0.3/src/c2enc.c new file mode 100644 index 00000000..f0d9bca1 --- /dev/null +++ b/codec2/branches/0.3/src/c2enc.c @@ -0,0 +1,117 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: c2enc.c + AUTHOR......: David Rowe + DATE CREATED: 23/8/2010 + + Encodes a file of raw speech samples using codec2 and outputs a file + of bits. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2010 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include "codec2.h" + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + int mode; + void *codec2; + FILE *fin; + FILE *fout; + short *buf; + unsigned char *bits; + int nsam, nbit, nbyte, gray; + + if (argc < 4) { + printf("usage: c2enc 3200|2400|1600|1400|1300|1200 InputRawspeechFile OutputBitFile [--natural]\n"); + printf("e.g c2enc 1400 ../raw/hts1a.raw hts1a.c2\n"); + printf("e.g c2enc 1300 ../raw/hts1a.raw hts1a.c2 --natural\n"); + exit(1); + } + + if (strcmp(argv[1],"3200") == 0) + mode = CODEC2_MODE_3200; + else if (strcmp(argv[1],"2400") == 0) + mode = CODEC2_MODE_2400; + else if (strcmp(argv[1],"1600") == 0) + mode = CODEC2_MODE_1600; + else if (strcmp(argv[1],"1400") == 0) + mode = CODEC2_MODE_1400; + else if (strcmp(argv[1],"1300") == 0) + mode = CODEC2_MODE_1300; + else if (strcmp(argv[1],"1200") == 0) + mode = CODEC2_MODE_1200; + else { + fprintf(stderr, "Error in mode: %s. Must be 3200, 2400, 1600, 1400, 1300 or 1200\n", argv[1]); + exit(1); + } + + if (strcmp(argv[2], "-") == 0) fin = stdin; + else if ( (fin = fopen(argv[2],"rb")) == NULL ) { + fprintf(stderr, "Error opening input speech file: %s: %s.\n", + argv[2], strerror(errno)); + exit(1); + } + + if (strcmp(argv[3], "-") == 0) fout = stdout; + else if ( (fout = fopen(argv[3],"wb")) == NULL ) { + fprintf(stderr, "Error opening output compressed bit file: %s: %s.\n", + argv[3], strerror(errno)); + exit(1); + } + + codec2 = codec2_create(mode); + nsam = codec2_samples_per_frame(codec2); + nbit = codec2_bits_per_frame(codec2); + buf = (short*)malloc(nsam*sizeof(short)); + nbyte = (nbit + 7) / 8; + + bits = (unsigned char*)malloc(nbyte*sizeof(char)); + + if (argc == 5) { + if (strcmp(argv[4], "--natural") == 0) + gray = 0; + else + gray = 1; + codec2_set_natural_or_gray(codec2, gray); + } + + while(fread(buf, sizeof(short), nsam, fin) == (size_t)nsam) { + codec2_encode(codec2, bits, buf); + fwrite(bits, sizeof(char), nbyte, fout); + // if this is in a pipeline, we probably don't want the usual + // buffering to occur + if (fout == stdout) fflush(stdout); + if (fin == stdin) fflush(stdin); + } + + codec2_destroy(codec2); + + free(buf); + free(bits); + fclose(fin); + fclose(fout); + + return 0; +} diff --git a/codec2/branches/0.3/src/c2sim.c b/codec2/branches/0.3/src/c2sim.c new file mode 100644 index 00000000..9b3b8208 --- /dev/null +++ b/codec2/branches/0.3/src/c2sim.c @@ -0,0 +1,934 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: c2sim.c + AUTHOR......: David Rowe + DATE CREATED: 20/8/2010 + + Codec2 simulation. Combines encoder and decoder and allows + switching in and out various algorithms and quantisation steps. Used + for algorithm development. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2009 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "defines.h" +#include "sine.h" +#include "nlp.h" +#include "dump.h" +#include "lpc.h" +#include "lsp.h" +#include "quantise.h" +#include "phase.h" +#include "postfilter.h" +#include "interp.h" +#include "ampexp.h" +#include "phaseexp.h" + +void synth_one_frame(kiss_fft_cfg fft_inv_cfg, short buf[], MODEL *model, float Sn_[], float Pn[], int prede, float *de_mem, float gain); +void print_help(const struct option *long_options, int num_opts, char* argv[]); + + +/*---------------------------------------------------------------------------*\ + + MAIN + +\*---------------------------------------------------------------------------*/ + +int main(int argc, char *argv[]) +{ + FILE *fout = NULL; /* output speech file */ + FILE *fin; /* input speech file */ + short buf[N]; /* input/output buffer */ + float Sn[M]; /* float input speech samples */ + float Sn_pre[M]; /* pre-emphasised input speech samples */ + COMP Sw[FFT_ENC]; /* DFT of Sn[] */ + kiss_fft_cfg fft_fwd_cfg; + kiss_fft_cfg fft_inv_cfg; + float w[M]; /* time domain hamming window */ + COMP W[FFT_ENC]; /* DFT of w[] */ + MODEL model; + float Pn[2*N]; /* trapezoidal synthesis window */ + float Sn_[2*N]; /* synthesised speech */ + int i; /* loop variable */ + int frames; + float prev_Wo, prev__Wo, uq_Wo, prev_uq_Wo; + float pitch; + int voiced1 = 0; + char out_file[MAX_STR]; + char ampexp_arg[MAX_STR]; + char phaseexp_arg[MAX_STR]; + float snr; + float sum_snr; + + int lpc_model = 0, order = LPC_ORD; + int lsp = 0, lspd = 0, lspvq = 0; + int lspres = 0; + int lspdt = 0, lspdt_mode = LSPDT_ALL; + int dt = 0, lspjvm = 0, lspanssi = 0, lspjnd = 0, lspmel = 0; + int prede = 0; + float pre_mem = 0.0, de_mem = 0.0; + float ak[LPC_MAX]; + COMP Sw_[FFT_ENC]; + COMP Ew[FFT_ENC]; + + int phase0 = 0; + float ex_phase[MAX_AMP+1]; + + int postfilt; + float bg_est; + + int hand_voicing = 0, phaseexp = 0, ampexp = 0, hi = 0, simlpcpf = 0; + int lpcpf = 0; + FILE *fvoicing = 0; + + MODEL prev_model, interp_model; + int decimate = 0; + float lsps[LPC_MAX]; + float prev_lsps[LPC_MAX], prev_lsps_[LPC_MAX]; + float lsps__prev[LPC_MAX]; + float lsps__prev2[LPC_MAX]; + float e, prev_e; + float ak_interp[LPC_MAX]; + int lsp_indexes[LPC_MAX]; + float lsps_[LPC_MAX]; + float Woe_[2]; + + void *nlp_states; + float hpf_states[2]; + int scalar_quant_Wo_e = 0; + int vector_quant_Wo_e = 0; + int dump_pitch_e = 0; + FILE *fjvm = NULL; + #ifdef DUMP + int dump; + #endif + struct PEXP *pexp = NULL; + struct AEXP *aexp = NULL; + float gain = 1.0; + + char* opt_string = "ho:"; + struct option long_options[] = { + { "lpc", required_argument, &lpc_model, 1 }, + { "lspjnd", no_argument, &lspjnd, 1 }, + { "lspmel", no_argument, &lspmel, 1 }, + { "lsp", no_argument, &lsp, 1 }, + { "lspd", no_argument, &lspd, 1 }, + { "lspvq", no_argument, &lspvq, 1 }, + { "lspres", no_argument, &lspres, 1 }, + #ifdef __EXPERIMENTAL__ + { "lspdt", no_argument, &lspdt, 1 }, + { "lspdt_mode", required_argument, NULL, 0 }, + #endif + { "lspjvm", no_argument, &lspjvm, 1 }, + #ifdef __EXPERIMENTAL__ + { "lspanssi", no_argument, &lspanssi, 1 }, + #endif + { "phase0", no_argument, &phase0, 1 }, + { "phaseexp", required_argument, &phaseexp, 1 }, + { "ampexp", required_argument, &exp, 1 }, + { "postfilter", no_argument, &postfilt, 1 }, + { "hand_voicing", required_argument, &hand_voicing, 1 }, + { "dec", no_argument, &decimate, 1 }, + { "dt", no_argument, &dt, 1 }, + { "hi", no_argument, &hi, 1 }, + { "simlpcpf", no_argument, &simlpcpf, 1 }, + { "lpcpf", no_argument, &lpcpf, 1 }, + { "prede", no_argument, &prede, 1 }, + { "dump_pitch_e", required_argument, &dump_pitch_e, 1 }, + { "sq_pitch_e", no_argument, &scalar_quant_Wo_e, 1 }, + { "vq_pitch_e", no_argument, &vector_quant_Wo_e, 1 }, + { "rate", required_argument, NULL, 0 }, + { "gain", required_argument, NULL, 0 }, + #ifdef DUMP + { "dump", required_argument, &dump, 1 }, + #endif + { "help", no_argument, NULL, 'h' }, + { NULL, no_argument, NULL, 0 } + }; + int num_opts=sizeof(long_options)/sizeof(struct option); + + for(i=0; i 20)) { + fprintf(stderr, "Error in LPC order: %s\n", optarg); + exit(1); + } + #ifdef DUMP + } else if(strcmp(long_options[option_index].name, "dump") == 0) { + if (dump) + dump_on(optarg); + #endif + } else if(strcmp(long_options[option_index].name, "lsp") == 0 + || strcmp(long_options[option_index].name, "lspd") == 0 + || strcmp(long_options[option_index].name, "lspvq") == 0) { + assert(order == LPC_ORD); + } else if(strcmp(long_options[option_index].name, "lspdt_mode") == 0) { + if (strcmp(optarg,"all") == 0) + lspdt_mode = LSPDT_ALL; + else if (strcmp(optarg,"low") == 0) + lspdt_mode = LSPDT_LOW; + else if (strcmp(optarg,"high") == 0) + lspdt_mode = LSPDT_HIGH; + else { + fprintf(stderr, "Error in lspdt_mode: %s\n", optarg); + exit(1); + } + } else if(strcmp(long_options[option_index].name, "hand_voicing") == 0) { + if ((fvoicing = fopen(optarg,"rt")) == NULL) { + fprintf(stderr, "Error opening voicing file: %s: %s.\n", + optarg, strerror(errno)); + exit(1); + } + } else if(strcmp(long_options[option_index].name, "dump_pitch_e") == 0) { + if ((fjvm = fopen(optarg,"wt")) == NULL) { + fprintf(stderr, "Error opening pitch & energy dump file: %s: %s.\n", + optarg, strerror(errno)); + exit(1); + } + } else if(strcmp(long_options[option_index].name, "phaseexp") == 0) { + strcpy(phaseexp_arg, optarg); + } else if(strcmp(long_options[option_index].name, "ampexp") == 0) { + strcpy(ampexp_arg, optarg); + } else if(strcmp(long_options[option_index].name, "gain") == 0) { + gain = atof(optarg); + } else if(strcmp(long_options[option_index].name, "rate") == 0) { + if(strcmp(optarg,"3200") == 0) { + lpc_model = 1; order = 10; + scalar_quant_Wo_e = 1; + lspd = 1; + phase0 = 1; + postfilt = 1; + decimate = 1; + lpcpf = 1; + } else if(strcmp(optarg,"2400") == 0) { + lpc_model = 1; order = 10; + vector_quant_Wo_e = 1; + lsp = 1; + phase0 = 1; + postfilt = 1; + decimate = 1; + lpcpf = 1; + } else if(strcmp(optarg,"1400") == 0) { + lpc_model = 1; order = 10; + vector_quant_Wo_e = 1; + lsp = 1; lspdt = 1; + phase0 = 1; + postfilt = 1; + decimate = 1; + dt = 1; + lpcpf = 1; + } else if(strcmp(optarg,"1200") == 0) { + lpc_model = 1; order = 10; + scalar_quant_Wo_e = 1; + lspjvm = 1; lspdt = 1; + phase0 = 1; + postfilt = 1; + decimate = 1; + dt = 1; + lpcpf = 1; + } else { + fprintf(stderr, "Error: invalid output rate %s\n", optarg); + exit(1); + } + } + break; + + case 'h': + print_help(long_options, num_opts, argv); + break; + + case 'o': + if (strcmp(optarg, "-") == 0) fout = stdout; + else if ((fout = fopen(optarg,"wb")) == NULL) { + fprintf(stderr, "Error opening output speech file: %s: %s.\n", + optarg, strerror(errno)); + exit(1); + } + strcpy(out_file,optarg); + break; + + default: + /* This will never be reached */ + break; + } + } + + /* Input file */ + + if ((fin = fopen(argv[optind],"rb")) == NULL) { + fprintf(stderr, "Error opening input speech file: %s: %s.\n", + argv[optind], strerror(errno)); + exit(1); + } + + ex_phase[0] = 0; + bg_est = 0.0; + Woe_[0] = Woe_[1] = 1.0; + + /* + printf("lspd: %d lspdt: %d lspdt_mode: %d phase0: %d postfilt: %d " + "decimate: %d dt: %d\n",lspd,lspdt,lspdt_mode,phase0,postfilt, + decimate,dt); + */ + + /* Initialise ------------------------------------------------------------*/ + + fft_fwd_cfg = kiss_fft_alloc(FFT_ENC, 0, NULL, NULL); /* fwd FFT,used in several places */ + fft_inv_cfg = kiss_fft_alloc(FFT_DEC, 1, NULL, NULL); /* inverse FFT, used just for synth */ + make_analysis_window(fft_fwd_cfg, w, W); + make_synthesis_window(Pn); + quantise_init(); + if (phaseexp) + pexp = phase_experiment_create(); + if (ampexp) + aexp = amp_experiment_create(); + + /*----------------------------------------------------------------*\ + + Main Loop + + \*----------------------------------------------------------------*/ + + frames = 0; + sum_snr = 0; + while(fread(buf,sizeof(short),N,fin)) { + frames++; + //printf("frame: %d ", frames); + + /* Read input speech */ + + for(i=0; i 32767.0) + buf[i] = 32767; + else if (Sn_[i] < -32767.0) + buf[i] = -32767; + else + buf[i] = Sn_[i]; + } + +} + +void print_help(const struct option* long_options, int num_opts, char* argv[]) +{ + int i; + char *option_parameters; + + fprintf(stderr, "\nCodec2 - low bit rate speech codec - Simulation Program\n" + "\thttp://rowetel.com/codec2.html\n\n" + "usage: %s [OPTIONS] \n\n" + "Options:\n" + "\t-o \n", argv[0]); + for(i=0; i. +*/ + +#include +#include +#include +#include +#include + +#include "defines.h" +#include "sine.h" +#include "nlp.h" +#include "dump.h" +#include "lpc.h" +#include "quantise.h" +#include "phase.h" +#include "interp.h" +#include "postfilter.h" +#include "codec2.h" +#include "lsp.h" +#include "codec2_internal.h" +#include "machdep.h" + +/*---------------------------------------------------------------------------*\ + + FUNCTION HEADERS + +\*---------------------------------------------------------------------------*/ + +void analyse_one_frame(struct CODEC2 *c2, MODEL *model, short speech[]); +void synthesise_one_frame(struct CODEC2 *c2, short speech[], MODEL *model, + float ak[]); +void codec2_encode_3200(struct CODEC2 *c2, unsigned char * bits, short speech[]); +void codec2_decode_3200(struct CODEC2 *c2, short speech[], const unsigned char * bits); +void codec2_encode_2400(struct CODEC2 *c2, unsigned char * bits, short speech[]); +void codec2_decode_2400(struct CODEC2 *c2, short speech[], const unsigned char * bits); +void codec2_encode_1600(struct CODEC2 *c2, unsigned char * bits, short speech[]); +void codec2_decode_1600(struct CODEC2 *c2, short speech[], const unsigned char * bits); +void codec2_encode_1400(struct CODEC2 *c2, unsigned char * bits, short speech[]); +void codec2_decode_1400(struct CODEC2 *c2, short speech[], const unsigned char * bits); +void codec2_encode_1300(struct CODEC2 *c2, unsigned char * bits, short speech[]); +void codec2_decode_1300(struct CODEC2 *c2, short speech[], const unsigned char * bits, float ber_est); +void codec2_encode_1200(struct CODEC2 *c2, unsigned char * bits, short speech[]); +void codec2_decode_1200(struct CODEC2 *c2, short speech[], const unsigned char * bits); +static void ear_protection(float in_out[], int n); + +/*---------------------------------------------------------------------------*\ + + FUNCTIONS + +\*---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: codec2_create + AUTHOR......: David Rowe + DATE CREATED: 21/8/2010 + + Create and initialise an instance of the codec. Returns a pointer + to the codec states or NULL on failure. One set of states is + sufficient for a full duuplex codec (i.e. an encoder and decoder). + You don't need separate states for encoders and decoders. See + c2enc.c and c2dec.c for examples. + +\*---------------------------------------------------------------------------*/ + +struct CODEC2 * CODEC2_WIN32SUPPORT codec2_create(int mode) +{ + struct CODEC2 *c2; + int i,l; + + c2 = (struct CODEC2*)malloc(sizeof(struct CODEC2)); + if (c2 == NULL) + return NULL; + + assert( + (mode == CODEC2_MODE_3200) || + (mode == CODEC2_MODE_2400) || + (mode == CODEC2_MODE_1600) || + (mode == CODEC2_MODE_1400) || + (mode == CODEC2_MODE_1300) || + (mode == CODEC2_MODE_1200) + ); + c2->mode = mode; + for(i=0; iSn[i] = 1.0; + c2->hpf_states[0] = c2->hpf_states[1] = 0.0; + for(i=0; i<2*N; i++) + c2->Sn_[i] = 0; + c2->fft_fwd_cfg = kiss_fft_alloc(FFT_ENC, 0, NULL, NULL); + make_analysis_window(c2->fft_fwd_cfg, c2->w,c2->W); + make_synthesis_window(c2->Pn); + c2->fft_inv_cfg = kiss_fft_alloc(FFT_DEC, 1, NULL, NULL); + quantise_init(); + c2->prev_Wo_enc = 0.0; + c2->bg_est = 0.0; + c2->ex_phase = 0.0; + + for(l=1; l<=MAX_AMP; l++) + c2->prev_model_dec.A[l] = 0.0; + c2->prev_model_dec.Wo = TWO_PI/P_MAX; + c2->prev_model_dec.L = PI/c2->prev_model_dec.Wo; + c2->prev_model_dec.voiced = 0; + + for(i=0; iprev_lsps_dec[i] = i*PI/(LPC_ORD+1); + } + c2->prev_e_dec = 1; + + c2->nlp = nlp_create(M); + if (c2->nlp == NULL) { + free (c2); + return NULL; + } + + c2->gray = 1; + + c2->lpc_pf = 1; c2->bass_boost = 1; c2->beta = LPCPF_BETA; c2->gamma = LPCPF_GAMMA; + + c2->xq_enc[0] = c2->xq_enc[1] = 0.0; + c2->xq_dec[0] = c2->xq_dec[1] = 0.0; + + c2->smoothing = 0; + + return c2; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: codec2_destroy + AUTHOR......: David Rowe + DATE CREATED: 21/8/2010 + + Destroy an instance of the codec. + +\*---------------------------------------------------------------------------*/ + +void CODEC2_WIN32SUPPORT codec2_destroy(struct CODEC2 *c2) +{ + assert(c2 != NULL); + nlp_destroy(c2->nlp); + KISS_FFT_FREE(c2->fft_fwd_cfg); + KISS_FFT_FREE(c2->fft_inv_cfg); + free(c2); +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: codec2_bits_per_frame + AUTHOR......: David Rowe + DATE CREATED: Nov 14 2011 + + Returns the number of bits per frame. + +\*---------------------------------------------------------------------------*/ + +int CODEC2_WIN32SUPPORT codec2_bits_per_frame(struct CODEC2 *c2) { + if (c2->mode == CODEC2_MODE_3200) + return 64; + if (c2->mode == CODEC2_MODE_2400) + return 48; + if (c2->mode == CODEC2_MODE_1600) + return 64; + if (c2->mode == CODEC2_MODE_1400) + return 56; + if (c2->mode == CODEC2_MODE_1300) + return 52; + if (c2->mode == CODEC2_MODE_1200) + return 48; + + return 0; /* shouldn't get here */ +} + + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: codec2_samples_per_frame + AUTHOR......: David Rowe + DATE CREATED: Nov 14 2011 + + Returns the number of bits per frame. + +\*---------------------------------------------------------------------------*/ + +int CODEC2_WIN32SUPPORT codec2_samples_per_frame(struct CODEC2 *c2) { + if (c2->mode == CODEC2_MODE_3200) + return 160; + if (c2->mode == CODEC2_MODE_2400) + return 160; + if (c2->mode == CODEC2_MODE_1600) + return 320; + if (c2->mode == CODEC2_MODE_1400) + return 320; + if (c2->mode == CODEC2_MODE_1300) + return 320; + if (c2->mode == CODEC2_MODE_1200) + return 320; + + return 0; /* shouldnt get here */ +} + +void CODEC2_WIN32SUPPORT codec2_encode(struct CODEC2 *c2, unsigned char *bits, short speech[]) +{ + assert(c2 != NULL); + assert( + (c2->mode == CODEC2_MODE_3200) || + (c2->mode == CODEC2_MODE_2400) || + (c2->mode == CODEC2_MODE_1600) || + (c2->mode == CODEC2_MODE_1400) || + (c2->mode == CODEC2_MODE_1300) || + (c2->mode == CODEC2_MODE_1200) + ); + + if (c2->mode == CODEC2_MODE_3200) + codec2_encode_3200(c2, bits, speech); + if (c2->mode == CODEC2_MODE_2400) + codec2_encode_2400(c2, bits, speech); + if (c2->mode == CODEC2_MODE_1600) + codec2_encode_1600(c2, bits, speech); + if (c2->mode == CODEC2_MODE_1400) + codec2_encode_1400(c2, bits, speech); + if (c2->mode == CODEC2_MODE_1300) + codec2_encode_1300(c2, bits, speech); + if (c2->mode == CODEC2_MODE_1200) + codec2_encode_1200(c2, bits, speech); +} + +void CODEC2_WIN32SUPPORT codec2_decode(struct CODEC2 *c2, short speech[], const unsigned char *bits) +{ + codec2_decode_ber(c2, speech, bits, 0.0); +} + +void CODEC2_WIN32SUPPORT codec2_decode_ber(struct CODEC2 *c2, short speech[], const unsigned char *bits, float ber_est) +{ + assert(c2 != NULL); + assert( + (c2->mode == CODEC2_MODE_3200) || + (c2->mode == CODEC2_MODE_2400) || + (c2->mode == CODEC2_MODE_1600) || + (c2->mode == CODEC2_MODE_1400) || + (c2->mode == CODEC2_MODE_1300) || + (c2->mode == CODEC2_MODE_1200) + ); + + if (c2->mode == CODEC2_MODE_3200) + codec2_decode_3200(c2, speech, bits); + if (c2->mode == CODEC2_MODE_2400) + codec2_decode_2400(c2, speech, bits); + if (c2->mode == CODEC2_MODE_1600) + codec2_decode_1600(c2, speech, bits); + if (c2->mode == CODEC2_MODE_1400) + codec2_decode_1400(c2, speech, bits); + if (c2->mode == CODEC2_MODE_1300) + codec2_decode_1300(c2, speech, bits, ber_est); + if (c2->mode == CODEC2_MODE_1200) + codec2_decode_1200(c2, speech, bits); +} + + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: codec2_encode_3200 + AUTHOR......: David Rowe + DATE CREATED: 13 Sep 2012 + + Encodes 160 speech samples (20ms of speech) into 64 bits. + + The codec2 algorithm actually operates internally on 10ms (80 + sample) frames, so we run the encoding algorithm twice. On the + first frame we just send the voicing bits. On the second frame we + send all model parameters. Compared to 2400 we use a larger number + of bits for the LSPs and non-VQ pitch and energy. + + The bit allocation is: + + Parameter bits/frame + -------------------------------------- + Harmonic magnitudes (LSPs) 50 + Pitch (Wo) 7 + Energy 5 + Voicing (10ms update) 2 + TOTAL 64 + +\*---------------------------------------------------------------------------*/ + +void codec2_encode_3200(struct CODEC2 *c2, unsigned char * bits, short speech[]) +{ + MODEL model; + float ak[LPC_ORD+1]; + float lsps[LPC_ORD]; + float e; + int Wo_index, e_index; + int lspd_indexes[LPC_ORD]; + int i; + unsigned int nbit = 0; + + assert(c2 != NULL); + + memset(bits, '\0', ((codec2_bits_per_frame(c2) + 7) / 8)); + + /* first 10ms analysis frame - we just want voicing */ + + analyse_one_frame(c2, &model, speech); + pack(bits, &nbit, model.voiced, 1); + + /* second 10ms analysis frame */ + + analyse_one_frame(c2, &model, &speech[N]); + pack(bits, &nbit, model.voiced, 1); + Wo_index = encode_Wo(model.Wo); + pack(bits, &nbit, Wo_index, WO_BITS); + + e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); + e_index = encode_energy(e); + pack(bits, &nbit, e_index, E_BITS); + + encode_lspds_scalar(lspd_indexes, lsps, LPC_ORD); + for(i=0; iprev_model_dec, &model[1]); + e[0] = interp_energy(c2->prev_e_dec, e[1]); + + /* LSPs are sampled every 20ms so we interpolate the frame in + between, then recover spectral amplitudes */ + + interpolate_lsp_ver2(&lsps[0][0], c2->prev_lsps_dec, &lsps[1][0], 0.5); + for(i=0; i<2; i++) { + lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD); + aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 0, 0, + c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma); + apply_lpc_correction(&model[i]); + } + + /* synthesise ------------------------------------------------*/ + + for(i=0; i<2; i++) + synthesise_one_frame(c2, &speech[N*i], &model[i], &ak[i][0]); + + /* update memories for next frame ----------------------------*/ + + c2->prev_model_dec = model[1]; + c2->prev_e_dec = e[1]; + for(i=0; iprev_lsps_dec[i] = lsps[1][i]; +} + + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: codec2_encode_2400 + AUTHOR......: David Rowe + DATE CREATED: 21/8/2010 + + Encodes 160 speech samples (20ms of speech) into 48 bits. + + The codec2 algorithm actually operates internally on 10ms (80 + sample) frames, so we run the encoding algorithm twice. On the + first frame we just send the voicing bit. On the second frame we + send all model parameters. + + The bit allocation is: + + Parameter bits/frame + -------------------------------------- + Harmonic magnitudes (LSPs) 36 + Joint VQ of Energy and Wo 8 + Voicing (10ms update) 2 + Spare 2 + TOTAL 48 + +\*---------------------------------------------------------------------------*/ + +void codec2_encode_2400(struct CODEC2 *c2, unsigned char * bits, short speech[]) +{ + MODEL model; + float ak[LPC_ORD+1]; + float lsps[LPC_ORD]; + float e; + int WoE_index; + int lsp_indexes[LPC_ORD]; + int i; + int spare = 0; + unsigned int nbit = 0; + + assert(c2 != NULL); + + memset(bits, '\0', ((codec2_bits_per_frame(c2) + 7) / 8)); + + /* first 10ms analysis frame - we just want voicing */ + + analyse_one_frame(c2, &model, speech); + pack(bits, &nbit, model.voiced, 1); + + /* second 10ms analysis frame */ + + analyse_one_frame(c2, &model, &speech[N]); + pack(bits, &nbit, model.voiced, 1); + + e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); + WoE_index = encode_WoE(&model, e, c2->xq_enc); + pack(bits, &nbit, WoE_index, WO_E_BITS); + + encode_lsps_scalar(lsp_indexes, lsps, LPC_ORD); + for(i=0; ixq_dec, WoE_index); + + for(i=0; iprev_model_dec, &model[1]); + e[0] = interp_energy(c2->prev_e_dec, e[1]); + + /* LSPs are sampled every 20ms so we interpolate the frame in + between, then recover spectral amplitudes */ + + interpolate_lsp_ver2(&lsps[0][0], c2->prev_lsps_dec, &lsps[1][0], 0.5); + for(i=0; i<2; i++) { + lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD); + aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 0, 0, + c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma); + apply_lpc_correction(&model[i]); + } + + /* synthesise ------------------------------------------------*/ + + for(i=0; i<2; i++) + synthesise_one_frame(c2, &speech[N*i], &model[i], &ak[i][0]); + + /* update memories for next frame ----------------------------*/ + + c2->prev_model_dec = model[1]; + c2->prev_e_dec = e[1]; + for(i=0; iprev_lsps_dec[i] = lsps[1][i]; +} + + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: codec2_encode_1600 + AUTHOR......: David Rowe + DATE CREATED: Feb 28 2013 + + Encodes 320 speech samples (40ms of speech) into 64 bits. + + The codec2 algorithm actually operates internally on 10ms (80 + sample) frames, so we run the encoding algorithm 4 times: + + frame 0: voicing bit + frame 1: voicing bit, Wo and E + frame 2: voicing bit + frame 3: voicing bit, Wo and E, scalar LSPs + + The bit allocation is: + + Parameter frame 2 frame 4 Total + ------------------------------------------------------- + Harmonic magnitudes (LSPs) 0 36 36 + Pitch (Wo) 7 7 14 + Energy 5 5 10 + Voicing (10ms update) 2 2 4 + TOTAL 14 50 64 + +\*---------------------------------------------------------------------------*/ + +void codec2_encode_1600(struct CODEC2 *c2, unsigned char * bits, short speech[]) +{ + MODEL model; + float lsps[LPC_ORD]; + float ak[LPC_ORD+1]; + float e; + int lsp_indexes[LPC_ORD]; + int Wo_index, e_index; + int i; + unsigned int nbit = 0; + + assert(c2 != NULL); + + memset(bits, '\0', ((codec2_bits_per_frame(c2) + 7) / 8)); + + /* frame 1: - voicing ---------------------------------------------*/ + + analyse_one_frame(c2, &model, speech); + pack(bits, &nbit, model.voiced, 1); + + /* frame 2: - voicing, scalar Wo & E -------------------------------*/ + + analyse_one_frame(c2, &model, &speech[N]); + pack(bits, &nbit, model.voiced, 1); + + Wo_index = encode_Wo(model.Wo); + pack(bits, &nbit, Wo_index, WO_BITS); + + /* need to run this just to get LPC energy */ + e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); + e_index = encode_energy(e); + pack(bits, &nbit, e_index, E_BITS); + + /* frame 3: - voicing ---------------------------------------------*/ + + analyse_one_frame(c2, &model, &speech[2*N]); + pack(bits, &nbit, model.voiced, 1); + + /* frame 4: - voicing, scalar Wo & E, scalar LSPs ------------------*/ + + analyse_one_frame(c2, &model, &speech[3*N]); + pack(bits, &nbit, model.voiced, 1); + + Wo_index = encode_Wo(model.Wo); + pack(bits, &nbit, Wo_index, WO_BITS); + + e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); + e_index = encode_energy(e); + pack(bits, &nbit, e_index, E_BITS); + + encode_lsps_scalar(lsp_indexes, lsps, LPC_ORD); + for(i=0; iprev_model_dec, &model[1]); + e[0] = interp_energy(c2->prev_e_dec, e[1]); + interp_Wo(&model[2], &model[1], &model[3]); + e[2] = interp_energy(e[1], e[3]); + + /* LSPs are sampled every 40ms so we interpolate the 3 frames in + between, then recover spectral amplitudes */ + + for(i=0, weight=0.25; i<3; i++, weight += 0.25) { + interpolate_lsp_ver2(&lsps[i][0], c2->prev_lsps_dec, &lsps[3][0], weight); + } + for(i=0; i<4; i++) { + lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD); + aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 0, 0, + c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma); + apply_lpc_correction(&model[i]); + } + + /* synthesise ------------------------------------------------*/ + + for(i=0; i<4; i++) + synthesise_one_frame(c2, &speech[N*i], &model[i], &ak[i][0]); + + /* update memories for next frame ----------------------------*/ + + c2->prev_model_dec = model[3]; + c2->prev_e_dec = e[3]; + for(i=0; iprev_lsps_dec[i] = lsps[3][i]; + +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: codec2_encode_1400 + AUTHOR......: David Rowe + DATE CREATED: May 11 2012 + + Encodes 320 speech samples (40ms of speech) into 56 bits. + + The codec2 algorithm actually operates internally on 10ms (80 + sample) frames, so we run the encoding algorithm 4 times: + + frame 0: voicing bit + frame 1: voicing bit, joint VQ of Wo and E + frame 2: voicing bit + frame 3: voicing bit, joint VQ of Wo and E, scalar LSPs + + The bit allocation is: + + Parameter frame 2 frame 4 Total + ------------------------------------------------------- + Harmonic magnitudes (LSPs) 0 36 36 + Energy+Wo 8 8 16 + Voicing (10ms update) 2 2 4 + TOTAL 10 46 56 + +\*---------------------------------------------------------------------------*/ + +void codec2_encode_1400(struct CODEC2 *c2, unsigned char * bits, short speech[]) +{ + MODEL model; + float lsps[LPC_ORD]; + float ak[LPC_ORD+1]; + float e; + int lsp_indexes[LPC_ORD]; + int WoE_index; + int i; + unsigned int nbit = 0; + + assert(c2 != NULL); + + memset(bits, '\0', ((codec2_bits_per_frame(c2) + 7) / 8)); + + /* frame 1: - voicing ---------------------------------------------*/ + + analyse_one_frame(c2, &model, speech); + pack(bits, &nbit, model.voiced, 1); + + /* frame 2: - voicing, joint Wo & E -------------------------------*/ + + analyse_one_frame(c2, &model, &speech[N]); + pack(bits, &nbit, model.voiced, 1); + + /* need to run this just to get LPC energy */ + e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); + + WoE_index = encode_WoE(&model, e, c2->xq_enc); + pack(bits, &nbit, WoE_index, WO_E_BITS); + + /* frame 3: - voicing ---------------------------------------------*/ + + analyse_one_frame(c2, &model, &speech[2*N]); + pack(bits, &nbit, model.voiced, 1); + + /* frame 4: - voicing, joint Wo & E, scalar LSPs ------------------*/ + + analyse_one_frame(c2, &model, &speech[3*N]); + pack(bits, &nbit, model.voiced, 1); + + e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); + WoE_index = encode_WoE(&model, e, c2->xq_enc); + pack(bits, &nbit, WoE_index, WO_E_BITS); + + encode_lsps_scalar(lsp_indexes, lsps, LPC_ORD); + for(i=0; ixq_dec, WoE_index); + + model[2].voiced = unpack(bits, &nbit, 1); + + model[3].voiced = unpack(bits, &nbit, 1); + WoE_index = unpack(bits, &nbit, WO_E_BITS); + decode_WoE(&model[3], &e[3], c2->xq_dec, WoE_index); + + for(i=0; iprev_model_dec, &model[1]); + e[0] = interp_energy(c2->prev_e_dec, e[1]); + interp_Wo(&model[2], &model[1], &model[3]); + e[2] = interp_energy(e[1], e[3]); + + /* LSPs are sampled every 40ms so we interpolate the 3 frames in + between, then recover spectral amplitudes */ + + for(i=0, weight=0.25; i<3; i++, weight += 0.25) { + interpolate_lsp_ver2(&lsps[i][0], c2->prev_lsps_dec, &lsps[3][0], weight); + } + for(i=0; i<4; i++) { + lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD); + aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 0, 0, + c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma); + apply_lpc_correction(&model[i]); + } + + /* synthesise ------------------------------------------------*/ + + for(i=0; i<4; i++) + synthesise_one_frame(c2, &speech[N*i], &model[i], &ak[i][0]); + + /* update memories for next frame ----------------------------*/ + + c2->prev_model_dec = model[3]; + c2->prev_e_dec = e[3]; + for(i=0; iprev_lsps_dec[i] = lsps[3][i]; + +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: codec2_encode_1300 + AUTHOR......: David Rowe + DATE CREATED: March 14 2013 + + Encodes 320 speech samples (40ms of speech) into 52 bits. + + The codec2 algorithm actually operates internally on 10ms (80 + sample) frames, so we run the encoding algorithm 4 times: + + frame 0: voicing bit + frame 1: voicing bit, + frame 2: voicing bit + frame 3: voicing bit, Wo and E, scalar LSPs + + The bit allocation is: + + Parameter frame 2 frame 4 Total + ------------------------------------------------------- + Harmonic magnitudes (LSPs) 0 36 36 + Pitch (Wo) 0 7 7 + Energy 0 5 5 + Voicing (10ms update) 2 2 4 + TOTAL 2 50 52 + +\*---------------------------------------------------------------------------*/ + +void codec2_encode_1300(struct CODEC2 *c2, unsigned char * bits, short speech[]) +{ + MODEL model; + float lsps[LPC_ORD]; + float ak[LPC_ORD+1]; + float e; + int lsp_indexes[LPC_ORD]; + int Wo_index, e_index; + int i; + unsigned int nbit = 0; + #ifdef TIMER + unsigned int quant_start; + #endif + + assert(c2 != NULL); + + memset(bits, '\0', ((codec2_bits_per_frame(c2) + 7) / 8)); + + /* frame 1: - voicing ---------------------------------------------*/ + + analyse_one_frame(c2, &model, speech); + pack_natural_or_gray(bits, &nbit, model.voiced, 1, c2->gray); + + /* frame 2: - voicing ---------------------------------------------*/ + + analyse_one_frame(c2, &model, &speech[N]); + pack_natural_or_gray(bits, &nbit, model.voiced, 1, c2->gray); + + /* frame 3: - voicing ---------------------------------------------*/ + + analyse_one_frame(c2, &model, &speech[2*N]); + pack_natural_or_gray(bits, &nbit, model.voiced, 1, c2->gray); + + /* frame 4: - voicing, scalar Wo & E, scalar LSPs ------------------*/ + + analyse_one_frame(c2, &model, &speech[3*N]); + pack_natural_or_gray(bits, &nbit, model.voiced, 1, c2->gray); + + Wo_index = encode_Wo(model.Wo); + pack_natural_or_gray(bits, &nbit, Wo_index, WO_BITS, c2->gray); + + #ifdef TIMER + quant_start = machdep_timer_sample(); + #endif + e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); + e_index = encode_energy(e); + pack_natural_or_gray(bits, &nbit, e_index, E_BITS, c2->gray); + + encode_lsps_scalar(lsp_indexes, lsps, LPC_ORD); + for(i=0; igray); + } + #ifdef TIMER + machdep_timer_sample_and_log(quant_start, " quant/packing"); + #endif + + assert(nbit == (unsigned)codec2_bits_per_frame(c2)); +} + + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: codec2_decode_1300 + AUTHOR......: David Rowe + DATE CREATED: 11 May 2012 + + Decodes frames of 52 bits into 320 samples (40ms) of speech. + +\*---------------------------------------------------------------------------*/ + +void codec2_decode_1300(struct CODEC2 *c2, short speech[], const unsigned char * bits, float ber_est) +{ + MODEL model[4]; + int lsp_indexes[LPC_ORD]; + float lsps[4][LPC_ORD]; + int Wo_index, e_index; + float e[4]; + float snr; + float ak[4][LPC_ORD+1]; + int i,j; + unsigned int nbit = 0; + float weight; + TIMER_VAR(recover_start); + + assert(c2 != NULL); + + /* only need to zero these out due to (unused) snr calculation */ + + for(i=0; i<4; i++) + for(j=1; j<=MAX_AMP; j++) + model[i].A[j] = 0.0; + + /* unpack bits from channel ------------------------------------*/ + + /* this will partially fill the model params for the 4 x 10ms + frames */ + + model[0].voiced = unpack_natural_or_gray(bits, &nbit, 1, c2->gray); + model[1].voiced = unpack_natural_or_gray(bits, &nbit, 1, c2->gray); + model[2].voiced = unpack_natural_or_gray(bits, &nbit, 1, c2->gray); + model[3].voiced = unpack_natural_or_gray(bits, &nbit, 1, c2->gray); + + Wo_index = unpack_natural_or_gray(bits, &nbit, WO_BITS, c2->gray); + model[3].Wo = decode_Wo(Wo_index); + model[3].L = PI/model[3].Wo; + + e_index = unpack_natural_or_gray(bits, &nbit, E_BITS, c2->gray); + e[3] = decode_energy(e_index); + + for(i=0; igray); + } + decode_lsps_scalar(&lsps[3][0], lsp_indexes, LPC_ORD); + check_lsp_order(&lsps[3][0], LPC_ORD); + bw_expand_lsps(&lsps[3][0], LPC_ORD, 50.0, 100.0); + + if (ber_est > 0.15) { + model[0].voiced = model[1].voiced = model[2].voiced = model[3].voiced = 0; + e[3] = decode_energy(10); + bw_expand_lsps(&lsps[3][0], LPC_ORD, 200.0, 200.0); + fprintf(stderr, "soft mute\n"); + } + + /* interpolate ------------------------------------------------*/ + + /* Wo, energy, and LSPs are sampled every 40ms so we interpolate + the 3 frames in between */ + + TIMER_SAMPLE(recover_start); + for(i=0, weight=0.25; i<3; i++, weight += 0.25) { + interpolate_lsp_ver2(&lsps[i][0], c2->prev_lsps_dec, &lsps[3][0], weight); + interp_Wo2(&model[i], &c2->prev_model_dec, &model[3], weight); + e[i] = interp_energy2(c2->prev_e_dec, e[3],weight); + } + + /* then recover spectral amplitudes */ + + for(i=0; i<4; i++) { + lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD); + aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 0, 0, + c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma); + apply_lpc_correction(&model[i]); + } + TIMER_SAMPLE_AND_LOG2(recover_start, " recover"); + #ifdef DUMP + dump_lsp_(&lsps[3][0]); + dump_ak_(&ak[3][0], LPC_ORD); + #endif + + /* synthesise ------------------------------------------------*/ + + for(i=0; i<4; i++) + synthesise_one_frame(c2, &speech[N*i], &model[i], &ak[i][0]); + + /* update memories for next frame ----------------------------*/ + + c2->prev_model_dec = model[3]; + c2->prev_e_dec = e[3]; + for(i=0; iprev_lsps_dec[i] = lsps[3][i]; + +} + + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: codec2_encode_1200 + AUTHOR......: David Rowe + DATE CREATED: Nov 14 2011 + + Encodes 320 speech samples (40ms of speech) into 48 bits. + + The codec2 algorithm actually operates internally on 10ms (80 + sample) frames, so we run the encoding algorithm four times: + + frame 0: voicing bit + frame 1: voicing bit, joint VQ of Wo and E + frame 2: voicing bit + frame 3: voicing bit, joint VQ of Wo and E, VQ LSPs + + The bit allocation is: + + Parameter frame 2 frame 4 Total + ------------------------------------------------------- + Harmonic magnitudes (LSPs) 0 27 27 + Energy+Wo 8 8 16 + Voicing (10ms update) 2 2 4 + Spare 0 1 1 + TOTAL 10 38 48 + +\*---------------------------------------------------------------------------*/ + +void codec2_encode_1200(struct CODEC2 *c2, unsigned char * bits, short speech[]) +{ + MODEL model; + float lsps[LPC_ORD]; + float lsps_[LPC_ORD]; + float ak[LPC_ORD+1]; + float e; + int lsp_indexes[LPC_ORD]; + int WoE_index; + int i; + int spare = 0; + unsigned int nbit = 0; + + assert(c2 != NULL); + + memset(bits, '\0', ((codec2_bits_per_frame(c2) + 7) / 8)); + + /* frame 1: - voicing ---------------------------------------------*/ + + analyse_one_frame(c2, &model, speech); + pack(bits, &nbit, model.voiced, 1); + + /* frame 2: - voicing, joint Wo & E -------------------------------*/ + + analyse_one_frame(c2, &model, &speech[N]); + pack(bits, &nbit, model.voiced, 1); + + /* need to run this just to get LPC energy */ + e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); + + WoE_index = encode_WoE(&model, e, c2->xq_enc); + pack(bits, &nbit, WoE_index, WO_E_BITS); + + /* frame 3: - voicing ---------------------------------------------*/ + + analyse_one_frame(c2, &model, &speech[2*N]); + pack(bits, &nbit, model.voiced, 1); + + /* frame 4: - voicing, joint Wo & E, scalar LSPs ------------------*/ + + analyse_one_frame(c2, &model, &speech[3*N]); + pack(bits, &nbit, model.voiced, 1); + + e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); + WoE_index = encode_WoE(&model, e, c2->xq_enc); + pack(bits, &nbit, WoE_index, WO_E_BITS); + + encode_lsps_vq(lsp_indexes, lsps, lsps_, LPC_ORD); + for(i=0; ixq_dec, WoE_index); + + model[2].voiced = unpack(bits, &nbit, 1); + + model[3].voiced = unpack(bits, &nbit, 1); + WoE_index = unpack(bits, &nbit, WO_E_BITS); + decode_WoE(&model[3], &e[3], c2->xq_dec, WoE_index); + + for(i=0; iprev_model_dec, &model[1]); + e[0] = interp_energy(c2->prev_e_dec, e[1]); + interp_Wo(&model[2], &model[1], &model[3]); + e[2] = interp_energy(e[1], e[3]); + + /* LSPs are sampled every 40ms so we interpolate the 3 frames in + between, then recover spectral amplitudes */ + + for(i=0, weight=0.25; i<3; i++, weight += 0.25) { + interpolate_lsp_ver2(&lsps[i][0], c2->prev_lsps_dec, &lsps[3][0], weight); + } + for(i=0; i<4; i++) { + lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD); + aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 0, 0, + c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma); + apply_lpc_correction(&model[i]); + } + + /* synthesise ------------------------------------------------*/ + + for(i=0; i<4; i++) + synthesise_one_frame(c2, &speech[N*i], &model[i], &ak[i][0]); + + /* update memories for next frame ----------------------------*/ + + c2->prev_model_dec = model[3]; + c2->prev_e_dec = e[3]; + for(i=0; iprev_lsps_dec[i] = lsps[3][i]; +} + + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: synthesise_one_frame() + AUTHOR......: David Rowe + DATE CREATED: 23/8/2010 + + Synthesise 80 speech samples (10ms) from model parameters. + +\*---------------------------------------------------------------------------*/ + +void synthesise_one_frame(struct CODEC2 *c2, short speech[], MODEL *model, float ak[]) +{ + int i; + TIMER_VAR(phase_start, pf_start, synth_start); + + #ifdef DUMP + dump_quantised_model(model); + #endif + + TIMER_SAMPLE(phase_start); + + phase_synth_zero_order(c2->fft_fwd_cfg, model, ak, &c2->ex_phase, LPC_ORD); + + TIMER_SAMPLE_AND_LOG(pf_start,phase_start, " phase_synth"); + + postfilter(model, &c2->bg_est); + + TIMER_SAMPLE_AND_LOG(synth_start, pf_start, " postfilter"); + + synthesise(c2->fft_inv_cfg, c2->Sn_, model, c2->Pn, 1); + + TIMER_SAMPLE_AND_LOG2(synth_start, " synth"); + + ear_protection(c2->Sn_, N); + + for(i=0; iSn_[i] > 32767.0) + speech[i] = 32767; + else if (c2->Sn_[i] < -32767.0) + speech[i] = -32767; + else + speech[i] = c2->Sn_[i]; + } + +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: analyse_one_frame() + AUTHOR......: David Rowe + DATE CREATED: 23/8/2010 + + Extract sinusoidal model parameters from 80 speech samples (10ms of + speech). + +\*---------------------------------------------------------------------------*/ + +void analyse_one_frame(struct CODEC2 *c2, MODEL *model, short speech[]) +{ + COMP Sw[FFT_ENC]; + COMP Sw_[FFT_ENC]; + COMP Ew[FFT_ENC]; + float pitch; + int i; + TIMER_VAR(dft_start, nlp_start, model_start, two_stage, estamps); + + /* Read input speech */ + + for(i=0; iSn[i] = c2->Sn[i+N]; + for(i=0; iSn[i+M-N] = speech[i]; + + TIMER_SAMPLE(dft_start); + dft_speech(c2->fft_fwd_cfg, Sw, c2->Sn, c2->w); + TIMER_SAMPLE_AND_LOG(nlp_start, dft_start, " dft_speech"); + + /* Estimate pitch */ + + nlp(c2->nlp,c2->Sn,N,P_MIN,P_MAX,&pitch,Sw, c2->W, &c2->prev_Wo_enc); + TIMER_SAMPLE_AND_LOG(model_start, nlp_start, " nlp"); + + model->Wo = TWO_PI/pitch; + model->L = PI/model->Wo; + + /* estimate model parameters */ + + two_stage_pitch_refinement(model, Sw); + TIMER_SAMPLE_AND_LOG(two_stage, model_start, " two_stage"); + estimate_amplitudes(model, Sw, c2->W, 0); + TIMER_SAMPLE_AND_LOG(estamps, two_stage, " est_amps"); + est_voicing_mbe(model, Sw, c2->W, Sw_, Ew, c2->prev_Wo_enc); + c2->prev_Wo_enc = model->Wo; + TIMER_SAMPLE_AND_LOG2(estamps, " est_voicing"); + #ifdef DUMP + dump_model(model); + #endif +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: ear_protection() + AUTHOR......: David Rowe + DATE CREATED: Nov 7 2012 + + Limits output level to protect ears when there are bit errors or the input + is overdriven. This doesn't correct or mask bit erros, just reduces the + worst of their damage. + +\*---------------------------------------------------------------------------*/ + +static void ear_protection(float in_out[], int n) { + float max_sample, over, gain; + int i; + + /* find maximum sample in frame */ + + max_sample = 0.0; + for(i=0; i max_sample) + max_sample = in_out[i]; + + /* determine how far above set point */ + + over = max_sample/30000.0; + + /* If we are x dB over set point we reduce level by 2x dB, this + attenuates major excursions in amplitude (likely to be caused + by bit errors) more than smaller ones */ + + if (over > 1.0) { + gain = 1.0/(over*over); + //fprintf(stderr, "gain: %f\n", gain); + for(i=0; i= 0.0) && (beta <= 1.0)); + assert((gamma >= 0.0) && (gamma <= 1.0)); + c2->lpc_pf = enable; + c2->bass_boost = bass_boost; + c2->beta = beta; + c2->gamma = gamma; +} + +/* + Allows optional stealing of one of the voicing bits for use as a + spare bit, only 1300 & 1400 & 1600 bit/s supported for now. + Experimental method of sending voice/data frames for FreeDV. +*/ + +int CODEC2_WIN32SUPPORT codec2_get_spare_bit_index(struct CODEC2 *c2) +{ + assert(c2 != NULL); + + switch(c2->mode) { + case CODEC2_MODE_1300: + return 2; // bit 2 (3th bit) is v2 (third voicing bit) + break; + case CODEC2_MODE_1400: + return 10; // bit 10 (11th bit) is v2 (third voicing bit) + break; + case CODEC2_MODE_1600: + return 15; // bit 15 (16th bit) is v2 (third voicing bit) + break; + } + + return -1; +} + +/* + Reconstructs the spare voicing bit. Note works on unpacked bits + for convenience. +*/ + +int CODEC2_WIN32SUPPORT codec2_rebuild_spare_bit(struct CODEC2 *c2, int unpacked_bits[]) +{ + int v1,v3; + + assert(c2 != NULL); + + v1 = unpacked_bits[1]; + + switch(c2->mode) { + case CODEC2_MODE_1300: + + v3 = unpacked_bits[1+1+1]; + + /* if either adjacent frame is voiced, make this one voiced */ + + unpacked_bits[2] = (v1 || v3); + + return 0; + + break; + + case CODEC2_MODE_1400: + + v3 = unpacked_bits[1+1+8+1]; + + /* if either adjacent frame is voiced, make this one voiced */ + + unpacked_bits[10] = (v1 || v3); + + return 0; + + break; + + case CODEC2_MODE_1600: + v3 = unpacked_bits[1+1+8+5+1]; + + /* if either adjacent frame is voiced, make this one voiced */ + + unpacked_bits[15] = (v1 || v3); + + return 0; + + break; + } + + return -1; +} + +void CODEC2_WIN32SUPPORT codec2_set_natural_or_gray(struct CODEC2 *c2, int gray) +{ + assert(c2 != NULL); + c2->gray = gray; +} + diff --git a/codec2/branches/0.3/src/codec2.h b/codec2/branches/0.3/src/codec2.h new file mode 100644 index 00000000..ea007065 --- /dev/null +++ b/codec2/branches/0.3/src/codec2.h @@ -0,0 +1,76 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: codec2.h + AUTHOR......: David Rowe + DATE CREATED: 21 August 2010 + + Codec 2 fully quantised encoder and decoder functions. If you want use + Codec 2, these are the functions you need to call. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2010 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#ifdef __cplusplus + extern "C" { +#endif + +#ifndef __CODEC2__ +#define __CODEC2__ + +/* set up the calling convention for DLL function import/export for + WIN32 cross compiling */ + +#ifdef __CODEC2_WIN32__ +#ifdef __CODEC2_BUILDING_DLL__ +#define CODEC2_WIN32SUPPORT __declspec(dllexport) __stdcall +#else +#define CODEC2_WIN32SUPPORT __declspec(dllimport) __stdcall +#endif +#else +#define CODEC2_WIN32SUPPORT +#endif + +#define CODEC2_MODE_3200 0 +#define CODEC2_MODE_2400 1 +#define CODEC2_MODE_1600 2 +#define CODEC2_MODE_1400 3 +#define CODEC2_MODE_1300 4 +#define CODEC2_MODE_1200 5 + +struct CODEC2; + +struct CODEC2 * CODEC2_WIN32SUPPORT codec2_create(int mode); +void CODEC2_WIN32SUPPORT codec2_destroy(struct CODEC2 *codec2_state); +void CODEC2_WIN32SUPPORT codec2_encode(struct CODEC2 *codec2_state, unsigned char * bits, short speech_in[]); +void CODEC2_WIN32SUPPORT codec2_decode(struct CODEC2 *codec2_state, short speech_out[], const unsigned char *bits); +void CODEC2_WIN32SUPPORT codec2_decode_ber(struct CODEC2 *codec2_state, short speech_out[], const unsigned char *bits, float ber_est); +int CODEC2_WIN32SUPPORT codec2_samples_per_frame(struct CODEC2 *codec2_state); +int CODEC2_WIN32SUPPORT codec2_bits_per_frame(struct CODEC2 *codec2_state); + +void CODEC2_WIN32SUPPORT codec2_set_lpc_post_filter(struct CODEC2 *codec2_state, int enable, int bass_boost, float beta, float gamma); +int CODEC2_WIN32SUPPORT codec2_get_spare_bit_index(struct CODEC2 *codec2_state); +int CODEC2_WIN32SUPPORT codec2_rebuild_spare_bit(struct CODEC2 *codec2_state, int unpacked_bits[]); +void CODEC2_WIN32SUPPORT codec2_set_natural_or_gray(struct CODEC2 *codec2_state, int gray); + +#endif + +#ifdef __cplusplus +} +#endif + diff --git a/codec2/branches/0.3/src/codec2_fdmdv.h b/codec2/branches/0.3/src/codec2_fdmdv.h new file mode 100644 index 00000000..5938c642 --- /dev/null +++ b/codec2/branches/0.3/src/codec2_fdmdv.h @@ -0,0 +1,124 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: codec2_fdmdv.h + AUTHOR......: David Rowe + DATE CREATED: April 14 2012 + + A 1400 bit/s (nominal) Frequency Division Multiplexed Digital Voice + (FDMDV) modem. Used for digital audio over HF SSB. See + README_fdmdv.txt for more information, and fdmdv_mod.c and + fdmdv_demod.c for example usage. + + The name codec2_fdmdv.h is used to make it unique when "make + installed". + + References: + + [1] http://n1su.com/fdmdv/FDMDV_Docs_Rel_1_4b.pdf + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2012 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#ifndef __FDMDV__ +#define __FDMDV__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* set up the calling convention for DLL function import/export for + WIN32 cross compiling */ + +#ifdef __CODEC2_WIN32__ +#ifdef __CODEC2_BUILDING_DLL__ +#define CODEC2_WIN32SUPPORT __declspec(dllexport) __stdcall +#else +#define CODEC2_WIN32SUPPORT __declspec(dllimport) __stdcall +#endif +#else +#define CODEC2_WIN32SUPPORT +#endif + +#include "comp.h" + +#define FDMDV_NC 14 /* default number of data carriers */ +#define FDMDV_NC_MAX 20 /* maximum number of data carriers */ +#define FDMDV_BITS_PER_FRAME 28 /* 20ms frames, for nominal 1400 bit/s */ +#define FDMDV_NOM_SAMPLES_PER_FRAME 160 /* modulator output samples/frame and nominal demod samples/frame */ + /* at 8000 Hz sample rate */ +#define FDMDV_MAX_SAMPLES_PER_FRAME 200 /* max demod samples/frame, use this to allocate storage */ +#define FDMDV_SCALE 1000 /* suggested scaling for 16 bit shorts */ +#define FDMDV_FCENTRE 1500 /* Centre frequency, Nc/2 carriers below this, Nc/2 carriers above (Hz) */ + +/* 8 to 48 kHz sample rate conversion */ + +#define FDMDV_OS 6 /* oversampling rate */ +#define FDMDV_OS_TAPS 48 /* number of OS filter taps */ + +/* FFT points */ + +#define FDMDV_NSPEC 512 +#define FDMDV_MAX_F_HZ 4000 + +/* FDMDV states and stats structures */ + +struct FDMDV; + +struct FDMDV_STATS { + int Nc; + float snr_est; /* estimated SNR of rx signal in dB (3 kHz noise BW) */ + COMP rx_symbols[FDMDV_NC_MAX+1]; /* latest received symbols, for scatter plot */ + int sync; /* demod sync state */ + float foff; /* estimated freq offset in Hz */ + float rx_timing; /* estimated optimum timing offset in samples */ + float clock_offset; /* Estimated tx/rx sample clock offset in ppm */ +}; + +struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(int Nc); +void CODEC2_WIN32SUPPORT fdmdv_destroy(struct FDMDV *fdmdv_state); +void CODEC2_WIN32SUPPORT fdmdv_use_old_qpsk_mapping(struct FDMDV *fdmdv_state); +int CODEC2_WIN32SUPPORT fdmdv_bits_per_frame(struct FDMDV *fdmdv_state); +float CODEC2_WIN32SUPPORT fdmdv_get_fsep(struct FDMDV *fdmdv_state); +void CODEC2_WIN32SUPPORT fdmdv_set_fsep(struct FDMDV *fdmdv_state, float fsep); + +void CODEC2_WIN32SUPPORT fdmdv_mod(struct FDMDV *fdmdv_state, COMP tx_fdm[], int tx_bits[], int *sync_bit); +void CODEC2_WIN32SUPPORT fdmdv_demod(struct FDMDV *fdmdv_state, int rx_bits[], int *reliable_sync_bit, COMP rx_fdm[], int *nin); + +void CODEC2_WIN32SUPPORT fdmdv_get_test_bits(struct FDMDV *fdmdv_state, int tx_bits[]); +int CODEC2_WIN32SUPPORT fdmdv_error_pattern_size(struct FDMDV *fdmdv_state); +void CODEC2_WIN32SUPPORT fdmdv_put_test_bits(struct FDMDV *f, int *sync, short error_pattern[], int *bit_errors, int *ntest_bits, int rx_bits[]); + +void CODEC2_WIN32SUPPORT fdmdv_get_demod_stats(struct FDMDV *fdmdv_state, struct FDMDV_STATS *fdmdv_stats); +void CODEC2_WIN32SUPPORT fdmdv_get_rx_spectrum(struct FDMDV *fdmdv_state, float mag_dB[], COMP rx_fdm[], int nin); + +void CODEC2_WIN32SUPPORT fdmdv_8_to_48(float out48k[], float in8k[], int n); +void CODEC2_WIN32SUPPORT fdmdv_48_to_8(float out8k[], float in48k[], int n); + +void CODEC2_WIN32SUPPORT fdmdv_freq_shift(COMP rx_fdm_fcorr[], COMP rx_fdm[], float foff, COMP *foff_phase_rect, int nin); + +/* debug/development function(s) */ + +void CODEC2_WIN32SUPPORT fdmdv_dump_osc_mags(struct FDMDV *f); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/codec2/branches/0.3/src/codec2_fifo.h b/codec2/branches/0.3/src/codec2_fifo.h new file mode 100644 index 00000000..dc93e157 --- /dev/null +++ b/codec2/branches/0.3/src/codec2_fifo.h @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: codec2_fifo.h + AUTHOR......: David Rowe + DATE CREATED: Oct 15 2012 + + A FIFO design useful in gluing the FDMDV modem and codec together in + integrated applications. + + The name codec2_fifo.h is used to make it unique when "make + installed". + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2012 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#ifndef __FIFO__ +#define __FIFO__ + +#ifdef __cplusplus +extern "C" { +#endif + +struct FIFO; + +struct FIFO *fifo_create(int nshort); +void fifo_destroy(struct FIFO *fifo); +int fifo_write(struct FIFO *fifo, short data[], int n); +int fifo_read(struct FIFO *fifo, short data[], int n); +int fifo_used(struct FIFO *fifo); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/codec2/branches/0.3/src/codec2_internal.h b/codec2/branches/0.3/src/codec2_internal.h new file mode 100644 index 00000000..aaaf0baa --- /dev/null +++ b/codec2/branches/0.3/src/codec2_internal.h @@ -0,0 +1,63 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: codec2_internal.h + AUTHOR......: David Rowe + DATE CREATED: April 16 2012 + + Header file for Codec2 internal states, exposed via this header + file to assist in testing. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2012 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#ifndef __CODEC2_INTERNAL__ +#define __CODEC2_INTERNAL__ + +struct CODEC2 { + int mode; + kiss_fft_cfg fft_fwd_cfg; /* forward FFT config */ + float w[M]; /* time domain hamming window */ + COMP W[FFT_ENC]; /* DFT of w[] */ + float Pn[2*N]; /* trapezoidal synthesis window */ + float Sn[M]; /* input speech */ + float hpf_states[2]; /* high pass filter states */ + void *nlp; /* pitch predictor states */ + int gray; /* non-zero for gray encoding */ + + kiss_fft_cfg fft_inv_cfg; /* inverse FFT config */ + float Sn_[2*N]; /* synthesised output speech */ + float ex_phase; /* excitation model phase track */ + float bg_est; /* background noise estimate for post filter */ + float prev_Wo_enc; /* previous frame's pitch estimate */ + MODEL prev_model_dec; /* previous frame's model parameters */ + float prev_lsps_dec[LPC_ORD]; /* previous frame's LSPs */ + float prev_e_dec; /* previous frame's LPC energy */ + + int lpc_pf; /* LPC post filter on */ + int bass_boost; /* LPC post filter bass boost */ + float beta; /* LPC post filter parameters */ + float gamma; + + float xq_enc[2]; /* joint pitch and energy VQ states */ + float xq_dec[2]; + + int smoothing; /* enable smoothing for channels with errors */ +}; + +#endif diff --git a/codec2/branches/0.3/src/comp.h b/codec2/branches/0.3/src/comp.h new file mode 100644 index 00000000..cedcab37 --- /dev/null +++ b/codec2/branches/0.3/src/comp.h @@ -0,0 +1,38 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: comp.h + AUTHOR......: David Rowe + DATE CREATED: 24/08/09 + + Complex number definition. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2009 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#ifndef __COMP__ +#define __COMP__ + +/* Complex number */ + +typedef struct { + float real; + float imag; +} COMP; + +#endif diff --git a/codec2/branches/0.3/src/defines.h b/codec2/branches/0.3/src/defines.h new file mode 100644 index 00000000..4870770c --- /dev/null +++ b/codec2/branches/0.3/src/defines.h @@ -0,0 +1,94 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: defines.h + AUTHOR......: David Rowe + DATE CREATED: 23/4/93 + + Defines and structures used throughout the codec. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2009 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#ifndef __DEFINES__ +#define __DEFINES__ + +/*---------------------------------------------------------------------------*\ + + DEFINES + +\*---------------------------------------------------------------------------*/ + +/* General defines */ + +#define N 80 /* number of samples per frame */ +#define MAX_AMP 80 /* maximum number of harmonics */ +#define PI 3.141592654 /* mathematical constant */ +#define TWO_PI 6.283185307 /* mathematical constant */ +#define FS 8000 /* sample rate in Hz */ +#define MAX_STR 256 /* maximum string size */ + +#define NW 279 /* analysis window size */ +#define FFT_ENC 512 /* size of FFT used for encoder */ +#define FFT_DEC 512 /* size of FFT used in decoder */ +#define TW 40 /* Trapezoidal synthesis window overlap */ +#define V_THRESH 6.0 /* voicing threshold in dB */ +#define LPC_MAX 20 /* maximum LPC order */ +#define LPC_ORD 10 /* phase modelling LPC order */ + +/* Pitch estimation defines */ + +#define M 320 /* pitch analysis frame size */ +#define P_MIN 20 /* minimum pitch */ +#define P_MAX 160 /* maximum pitch */ + +/*---------------------------------------------------------------------------*\ + + TYPEDEFS + +\*---------------------------------------------------------------------------*/ + +/* Structure to hold model parameters for one frame */ + +typedef struct { + float Wo; /* fundamental frequency estimate in radians */ + int L; /* number of harmonics */ + float A[MAX_AMP+1]; /* amplitiude of each harmonic */ + float phi[MAX_AMP+1]; /* phase of each harmonic */ + int voiced; /* non-zero if this frame is voiced */ +} MODEL; + +/* describes each codebook */ + +struct lsp_codebook { + int k; /* dimension of vector */ + int log2m; /* number of bits in m */ + int m; /* elements in codebook */ + const float * cb; /* The elements */ +}; + +extern const struct lsp_codebook lsp_cb[]; +extern const struct lsp_codebook lsp_cbd[]; +extern const struct lsp_codebook lsp_cbvq[]; +extern const struct lsp_codebook lsp_cbjnd[]; +extern const struct lsp_codebook lsp_cbdt[]; +extern const struct lsp_codebook lsp_cbjvm[]; +extern const struct lsp_codebook lsp_cbvqanssi[]; +extern const struct lsp_codebook ge_cb[]; + +#endif diff --git a/codec2/branches/0.3/src/dump.c b/codec2/branches/0.3/src/dump.c new file mode 100644 index 00000000..00ce8062 --- /dev/null +++ b/codec2/branches/0.3/src/dump.c @@ -0,0 +1,629 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: dump.c + AUTHOR......: David Rowe + DATE CREATED: 25/8/09 + + Routines to dump data to text files for Octave analysis. + +\*---------------------------------------------------------------------------*/ + +/* + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include "defines.h" +#include "comp.h" +#include "dump.h" +#include +#include +#include +#include +#include + +#ifdef __EMBEDDED__ +#include "gdb_stdio.h" +#define fprintf gdb_stdio_fprintf +#define fopen gdb_stdio_fopen +#define fclose gdb_stdio_fclose +#endif + +#ifdef DUMP +static int dumpon = 0; + +static FILE *fsn = NULL; +static FILE *fsw = NULL; +static FILE *few = NULL; +static FILE *fsw_ = NULL; +static FILE *fmodel = NULL; +static FILE *fqmodel = NULL; +static FILE *fpwb = NULL; +static FILE *fpw = NULL; +static FILE *frw = NULL; +static FILE *flsp = NULL; +static FILE *fweights = NULL; +static FILE *flsp_ = NULL; +static FILE *fmel = NULL; +static FILE *fphase = NULL; +static FILE *fphase_ = NULL; +static FILE *ffw = NULL; +static FILE *fe = NULL; +static FILE *fsq = NULL; +static FILE *fdec = NULL; +static FILE *fsnr = NULL; +static FILE *flpcsnr = NULL; +static FILE *fak = NULL; +static FILE *fak_ = NULL; +static FILE *fbg = NULL; +static FILE *fE = NULL; +static FILE *frk = NULL; +static FILE *fhephase = NULL; + +static char prefix[MAX_STR]; + +void dump_on(char p[]) { + dumpon = 1; + strcpy(prefix, p); +} + +void dump_off(){ + if (fsn != NULL) + fclose(fsn); + if (fsw != NULL) + fclose(fsw); + if (fsw_ != NULL) + fclose(fsw_); + if (few != NULL) + fclose(few); + if (fmodel != NULL) + fclose(fmodel); + if (fqmodel != NULL) + fclose(fqmodel); + if (fpwb != NULL) + fclose(fpwb); + if (fpw != NULL) + fclose(fpw); + if (frw != NULL) + fclose(frw); + if (flsp != NULL) + fclose(flsp); + if (fweights != NULL) + fclose(fweights); + if (flsp_ != NULL) + fclose(flsp_); + if (fmel != NULL) + fclose(fmel); + if (fphase != NULL) + fclose(fphase); + if (fphase_ != NULL) + fclose(fphase_); + if (ffw != NULL) + fclose(ffw); + if (fe != NULL) + fclose(fe); + if (fsq != NULL) + fclose(fsq); + if (fdec != NULL) + fclose(fdec); + if (fsnr != NULL) + fclose(fsnr); + if (flpcsnr != NULL) + fclose(flpcsnr); + if (fak != NULL) + fclose(fak); + if (fak_ != NULL) + fclose(fak_); + if (fbg != NULL) + fclose(fbg); + if (fE != NULL) + fclose(fE); + if (frk != NULL) + fclose(frk); + if (fhephase != NULL) + fclose(fhephase); +} + +void dump_Sn(float Sn[]) { + int i; + char s[MAX_STR]; + + if (!dumpon) return; + + if (fsn == NULL) { + sprintf(s,"%s_sn.txt", prefix); + fsn = fopen(s, "wt"); + assert(fsn != NULL); + } + + /* split across two lines to avoid max line length problems */ + /* reconstruct in Octave */ + + for(i=0; iWo, model->L); + for(l=1; l<=model->L; l++) { + sprintf(s,"%12f ",model->A[l]); + strcat(line, s); + } + for(l=model->L+1; l<=MAX_AMP; l++) { + sprintf(s,"%12f ", 0.0); + strcat(line,s); + } + + sprintf(s,"%d\n",model->voiced); + strcat(line,s); + fprintf(fmodel,"%s",line); +} + +void dump_quantised_model(MODEL *model) { + int l; + char s[MAX_STR]; + char line[2048]; + + if (!dumpon) return; + + if (fqmodel == NULL) { + sprintf(s,"%s_qmodel.txt", prefix); + fqmodel = fopen(s, "wt"); + assert(fqmodel != NULL); + } + + sprintf(line,"%12f %12d ", model->Wo, model->L); + for(l=1; l<=model->L; l++) { + sprintf(s,"%12f ",model->A[l]); + strcat(line, s); + } + for(l=model->L+1; l<=MAX_AMP; l++) { + sprintf(s,"%12f ", 0.0); + strcat(line, s); + } + + sprintf(s,"%d\n",model->voiced); + strcat(line, s); + fprintf(fqmodel, "%s", line); +} + +void dump_phase(float phase[], int L) { + int l; + char s[MAX_STR]; + + if (!dumpon) return; + + if (fphase == NULL) { + sprintf(s,"%s_phase.txt", prefix); + fphase = fopen(s, "wt"); + assert(fphase != NULL); + } + + for(l=1; l<=L; l++) + fprintf(fphase,"%f\t",phase[l]); + for(l=L+1; l<=MAX_AMP; l++) + fprintf(fphase,"%f\t",0.0); + fprintf(fphase,"\n"); +} + +void dump_phase_(float phase_[], int L) { + int l; + char s[MAX_STR]; + + if (!dumpon) return; + + if (fphase_ == NULL) { + sprintf(s,"%s_phase_.txt", prefix); + fphase_ = fopen(s, "wt"); + assert(fphase_ != NULL); + } + + for(l=1; l<=L; l++) + fprintf(fphase_,"%f\t",phase_[l]); + for(l=L+1; l. +*/ + +#ifndef __DUMP__ +#define __DUMP__ + +#include "defines.h" +#include "comp.h" +#include "kiss_fft.h" +#include "codec2_internal.h" + +void dump_on(char filename_prefix[]); +void dump_off(); + +void dump_Sn(float Sn[]); +void dump_Sw(COMP Sw[]); +void dump_Sw_(COMP Sw_[]); +void dump_Ew(COMP Ew[]); + +/* amplitude modelling */ + +void dump_model(MODEL *m); +void dump_quantised_model(MODEL *m); +void dump_Pwn(COMP Pw[]); +void dump_Pw(COMP Pw[]); +void dump_Rw(float Rw[]); +void dump_lsp(float lsp[]); +void dump_weights(float w[], int ndim); +void dump_lsp_(float lsp_[]); +void dump_mel(int mel[]); +void dump_ak(float ak[], int order); +void dump_ak_(float ak[], int order); +void dump_E(float E); +void dump_lpc_snr(float snr); + +/* phase modelling */ + +void dump_snr(float snr); +void dump_phase(float phase[], int L); +void dump_phase_(float phase[], int L); +void dump_hephase(int ind[], int dim); + +/* NLP states */ + +void dump_sq(float sq[]); +void dump_dec(COMP Fw[]); +void dump_Fw(COMP Fw[]); +void dump_e(float e_hz[]); +void dump_Rk(float Rk[]); + +/* post filter */ + +void dump_bg(float e, float bg_est, float percent_uv); +void dump_Pwb(COMP Pwb[]); + +#endif diff --git a/codec2/branches/0.3/src/fdmdv.c b/codec2/branches/0.3/src/fdmdv.c new file mode 100644 index 00000000..6c664f79 --- /dev/null +++ b/codec2/branches/0.3/src/fdmdv.c @@ -0,0 +1,1574 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: fdmdv.c + AUTHOR......: David Rowe + DATE CREATED: April 14 2012 + + Functions that implement the FDMDV modem. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2012 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +/*---------------------------------------------------------------------------*\ + + INCLUDES + +\*---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +#include "fdmdv_internal.h" +#include "codec2_fdmdv.h" +#include "rn.h" +#include "test_bits.h" +#include "pilot_coeff.h" +#include "kiss_fft.h" +#include "hanning.h" +#include "os.h" + +static int sync_uw[] = {1,-1,1,-1,1,-1}; + +/*---------------------------------------------------------------------------* \ + + FUNCTIONS + +\*---------------------------------------------------------------------------*/ + +static COMP cneg(COMP a) +{ + COMP res; + + res.real = -a.real; + res.imag = -a.imag; + + return res; +} + +static COMP cconj(COMP a) +{ + COMP res; + + res.real = a.real; + res.imag = -a.imag; + + return res; +} + +static COMP cmult(COMP a, COMP b) +{ + COMP res; + + res.real = a.real*b.real - a.imag*b.imag; + res.imag = a.real*b.imag + a.imag*b.real; + + return res; +} + +static COMP fcmult(float a, COMP b) +{ + COMP res; + + res.real = a*b.real; + res.imag = a*b.imag; + + return res; +} + +static COMP cadd(COMP a, COMP b) +{ + COMP res; + + res.real = a.real + b.real; + res.imag = a.imag + b.imag; + + return res; +} + +static float cabsolute(COMP a) +{ + return sqrt(pow(a.real, 2.0) + pow(a.imag, 2.0)); +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: fdmdv_create + AUTHOR......: David Rowe + DATE CREATED: 16/4/2012 + + Create and initialise an instance of the modem. Returns a pointer + to the modem states or NULL on failure. One set of states is + sufficient for a full duplex modem. + +\*---------------------------------------------------------------------------*/ + +struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(int Nc) +{ + struct FDMDV *f; + int c, i, k; + + assert(NC == FDMDV_NC_MAX); /* check public and private #defines match */ + assert(Nc <= NC); + assert(FDMDV_NOM_SAMPLES_PER_FRAME == M); + assert(FDMDV_MAX_SAMPLES_PER_FRAME == (M+M/P)); + + f = (struct FDMDV*)malloc(sizeof(struct FDMDV)); + if (f == NULL) + return NULL; + + f->Nc = Nc; + + f->ntest_bits = Nc*NB*4; + f->current_test_bit = 0; + f->rx_test_bits_mem = (int*)malloc(sizeof(int)*f->ntest_bits); + assert(f->rx_test_bits_mem != NULL); + for(i=0; intest_bits; i++) + f->rx_test_bits_mem[i] = 0; + assert((sizeof(test_bits)/sizeof(int)) >= f->ntest_bits); + + f->old_qpsk_mapping = 0; + + f->tx_pilot_bit = 0; + + for(c=0; cprev_tx_symbols[c].real = 1.0; + f->prev_tx_symbols[c].imag = 0.0; + f->prev_rx_symbols[c].real = 1.0; + f->prev_rx_symbols[c].imag = 0.0; + + for(k=0; ktx_filter_memory[c][k].real = 0.0; + f->tx_filter_memory[c][k].imag = 0.0; + } + + for(k=0; krx_filter_memory[c][k].real = 0.0; + f->rx_filter_memory[c][k].imag = 0.0; + } + + /* Spread initial FDM carrier phase out as far as possible. + This helped PAPR for a few dB. We don't need to adjust rx + phase as DQPSK takes care of that. */ + + f->phase_tx[c].real = cos(2.0*PI*c/(Nc+1)); + f->phase_tx[c].imag = sin(2.0*PI*c/(Nc+1)); + + f->phase_rx[c].real = 1.0; + f->phase_rx[c].imag = 0.0; + + for(k=0; krx_filter_mem_timing[c][k].real = 0.0; + f->rx_filter_mem_timing[c][k].imag = 0.0; + } + for(k=0; krx_baseband_mem_timing[c][k].real = 0.0; + f->rx_baseband_mem_timing[c][k].imag = 0.0; + } + } + + fdmdv_set_fsep(f, FSEP); + f->freq[Nc].real = cos(2.0*PI*FDMDV_FCENTRE/FS); + f->freq[Nc].imag = sin(2.0*PI*FDMDV_FCENTRE/FS); + + /* Generate DBPSK pilot Look Up Table (LUT) */ + + generate_pilot_lut(f->pilot_lut, &f->freq[Nc]); + + /* freq Offset estimation states */ + + f->fft_pilot_cfg = kiss_fft_alloc (MPILOTFFT, 0, NULL, NULL); + assert(f->fft_pilot_cfg != NULL); + + for(i=0; ipilot_baseband1[i].real = f->pilot_baseband2[i].real = 0.0; + f->pilot_baseband1[i].imag = f->pilot_baseband2[i].imag = 0.0; + } + f->pilot_lut_index = 0; + f->prev_pilot_lut_index = 3*M; + + for(i=0; ipilot_lpf1[i].real = f->pilot_lpf2[i].real = 0.0; + f->pilot_lpf1[i].imag = f->pilot_lpf2[i].imag = 0.0; + } + + f->foff = 0.0; + f->foff_phase_rect.real = 1.0; + f->foff_phase_rect.imag = 0.0; + + f->fest_state = 0; + f->sync = 0; + f->timer = 0; + for(i=0; isync_mem[i] = 0; + + for(c=0; csig_est[c] = 0.0; + f->noise_est[c] = 0.0; + } + + for(i=0; i<2*FDMDV_NSPEC; i++) + f->fft_buf[i] = 0.0; + f->fft_cfg = kiss_fft_alloc (2*FDMDV_NSPEC, 0, NULL, NULL); + assert(f->fft_cfg != NULL); + + + return f; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: fdmdv_destroy + AUTHOR......: David Rowe + DATE CREATED: 16/4/2012 + + Destroy an instance of the modem. + +\*---------------------------------------------------------------------------*/ + +void CODEC2_WIN32SUPPORT fdmdv_destroy(struct FDMDV *fdmdv) +{ + assert(fdmdv != NULL); + KISS_FFT_FREE(fdmdv->fft_pilot_cfg); + KISS_FFT_FREE(fdmdv->fft_cfg); + free(fdmdv->rx_test_bits_mem); + free(fdmdv); +} + + +void CODEC2_WIN32SUPPORT fdmdv_use_old_qpsk_mapping(struct FDMDV *fdmdv) { + fdmdv->old_qpsk_mapping = 1; +} + + +int CODEC2_WIN32SUPPORT fdmdv_bits_per_frame(struct FDMDV *fdmdv) +{ + return (fdmdv->Nc * NB); +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: fdmdv_get_test_bits() + AUTHOR......: David Rowe + DATE CREATED: 16/4/2012 + + Generate a frame of bits from a repeating sequence of random data. OK so + it's not very random if it repeats but it makes syncing at the demod easier + for test purposes. + +\*---------------------------------------------------------------------------*/ + +void CODEC2_WIN32SUPPORT fdmdv_get_test_bits(struct FDMDV *f, int tx_bits[]) +{ + int i; + int bits_per_frame = fdmdv_bits_per_frame(f); + + for(i=0; icurrent_test_bit]; + f->current_test_bit++; + if (f->current_test_bit > (f->ntest_bits-1)) + f->current_test_bit = 0; + } + } + +float CODEC2_WIN32SUPPORT fdmdv_get_fsep(struct FDMDV *f) +{ + return f->fsep; +} + +void CODEC2_WIN32SUPPORT fdmdv_set_fsep(struct FDMDV *f, float fsep) { + int c; + float carrier_freq; + + f->fsep = fsep; + /* Set up frequency of each carrier */ + + for(c=0; cNc/2; c++) { + carrier_freq = (-f->Nc/2 + c)*f->fsep + FDMDV_FCENTRE; + f->freq[c].real = cos(2.0*PI*carrier_freq/FS); + f->freq[c].imag = sin(2.0*PI*carrier_freq/FS); + } + + for(c=f->Nc/2; cNc; c++) { + carrier_freq = (-f->Nc/2 + c + 1)*f->fsep + FDMDV_FCENTRE; + f->freq[c].real = cos(2.0*PI*carrier_freq/FS); + f->freq[c].imag = sin(2.0*PI*carrier_freq/FS); + } +} + + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: bits_to_dqpsk_symbols() + AUTHOR......: David Rowe + DATE CREATED: 16/4/2012 + + Maps bits to parallel DQPSK symbols. Generate Nc+1 QPSK symbols from + vector of (1,Nc*Nb) input tx_bits. The Nc+1 symbol is the +1 -1 +1 + .... BPSK sync carrier. + +\*---------------------------------------------------------------------------*/ + +void bits_to_dqpsk_symbols(COMP tx_symbols[], int Nc, COMP prev_tx_symbols[], int tx_bits[], int *pilot_bit, int old_qpsk_mapping) +{ + int c, msb, lsb; + COMP j = {0.0,1.0}; + + /* Map tx_bits to to Nc DQPSK symbols. Note legacy support for + old (suboptimal) V0.91 FreeDV mapping */ + + for(c=0; cNc, fdmdv->prev_tx_symbols, tx_bits, &fdmdv->tx_pilot_bit, fdmdv->old_qpsk_mapping); + memcpy(fdmdv->prev_tx_symbols, tx_symbols, sizeof(COMP)*(fdmdv->Nc+1)); + tx_filter(tx_baseband, fdmdv->Nc, tx_symbols, fdmdv->tx_filter_memory); + fdm_upconvert(tx_fdm, fdmdv->Nc, tx_baseband, fdmdv->phase_tx, fdmdv->freq); + + *sync_bit = fdmdv->tx_pilot_bit; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: generate_pilot_fdm() + AUTHOR......: David Rowe + DATE CREATED: 19/4/2012 + + Generate M samples of DBPSK pilot signal for Freq offset estimation. + +\*---------------------------------------------------------------------------*/ + +void generate_pilot_fdm(COMP *pilot_fdm, int *bit, float *symbol, + float *filter_mem, COMP *phase, COMP *freq) +{ + int i,j,k; + float tx_baseband[M]; + + /* +1 -1 +1 -1 DBPSK sync carrier, once filtered becomes (roughly) + two spectral lines at +/- RS/2 */ + + if (*bit) + *symbol = -*symbol; + else + *symbol = *symbol; + if (*bit) + *bit = 0; + else + *bit = 1; + + /* filter DPSK symbol to create M baseband samples */ + + filter_mem[NFILTER-1] = (sqrt(2)/2) * *symbol; + for(i=0; ireal; + pilot_fdm[i].imag = sqrt(2)*2*tx_baseband[i] * phase->imag; + } +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: generate_pilot_lut() + AUTHOR......: David Rowe + DATE CREATED: 19/4/2012 + + Generate a 4M sample vector of DBPSK pilot signal. As the pilot signal + is periodic in 4M samples we can then use this vector as a look up table + for pilot signal generation in the demod. + +\*---------------------------------------------------------------------------*/ + +void generate_pilot_lut(COMP pilot_lut[], COMP *pilot_freq) +{ + int pilot_rx_bit = 0; + float pilot_symbol = sqrt(2.0); + COMP pilot_phase = {1.0, 0.0}; + float pilot_filter_mem[NFILTER]; + COMP pilot[M]; + int i,f; + + for(i=0; i= 4) + memcpy(&pilot_lut[M*(f-4)], pilot, M*sizeof(COMP)); + } + +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: lpf_peak_pick() + AUTHOR......: David Rowe + DATE CREATED: 20/4/2012 + + LPF and peak pick part of freq est, put in a function as we call it twice. + +\*---------------------------------------------------------------------------*/ + +void lpf_peak_pick(float *foff, float *max, COMP pilot_baseband[], + COMP pilot_lpf[], kiss_fft_cfg fft_pilot_cfg, COMP S[], int nin) +{ + int i,j,k; + int mpilot; + COMP s[MPILOTFFT]; + float mag, imax; + int ix; + float r; + + /* LPF cutoff 200Hz, so we can handle max +/- 200 Hz freq offset */ + + for(i=0; i imax) { + imax = mag; + ix = i; + } + } + r = 2.0*200.0/MPILOTFFT; /* maps FFT bin to frequency in Hz */ + + if (ix >= MPILOTFFT/2) + *foff = (ix - MPILOTFFT)*r; + else + *foff = (ix)*r; + *max = imax; + +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: rx_est_freq_offset() + AUTHOR......: David Rowe + DATE CREATED: 19/4/2012 + + Estimate frequency offset of FDM signal using BPSK pilot. Note that + this algorithm is quite sensitive to pilot tone level wrt other + carriers, so test variations to the pilot amplitude carefully. + +\*---------------------------------------------------------------------------*/ + +float rx_est_freq_offset(struct FDMDV *f, COMP rx_fdm[], int nin) +{ + int i,j; + COMP pilot[M+M/P]; + COMP prev_pilot[M+M/P]; + float foff, foff1, foff2; + float max1, max2; + + assert(nin <= M+M/P); + + /* get pilot samples used for correlation/down conversion of rx signal */ + + for (i=0; ipilot_lut[f->pilot_lut_index]; + f->pilot_lut_index++; + if (f->pilot_lut_index >= 4*M) + f->pilot_lut_index = 0; + + prev_pilot[i] = f->pilot_lut[f->prev_pilot_lut_index]; + f->prev_pilot_lut_index++; + if (f->prev_pilot_lut_index >= 4*M) + f->prev_pilot_lut_index = 0; + } + + /* + Down convert latest M samples of pilot by multiplying by ideal + BPSK pilot signal we have generated locally. The peak of the + resulting signal is sensitive to the time shift between the + received and local version of the pilot, so we do it twice at + different time shifts and choose the maximum. + */ + + for(i=0; ipilot_baseband1[i] = f->pilot_baseband1[i+nin]; + f->pilot_baseband2[i] = f->pilot_baseband2[i+nin]; + } + + for(i=0,j=NPILOTBASEBAND-nin; ipilot_baseband1[j] = cmult(rx_fdm[i], cconj(pilot[i])); + f->pilot_baseband2[j] = cmult(rx_fdm[i], cconj(prev_pilot[i])); + } + + lpf_peak_pick(&foff1, &max1, f->pilot_baseband1, f->pilot_lpf1, f->fft_pilot_cfg, f->S1, nin); + lpf_peak_pick(&foff2, &max2, f->pilot_baseband2, f->pilot_lpf2, f->fft_pilot_cfg, f->S2, nin); + + if (max1 > max2) + foff = foff1; + else + foff = foff2; + + return foff; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: fdmdv_freq_shift() + AUTHOR......: David Rowe + DATE CREATED: 26/4/2012 + + Frequency shift modem signal. The use of complex input and output allows + single sided frequency shifting (no images). + +\*---------------------------------------------------------------------------*/ + +void CODEC2_WIN32SUPPORT fdmdv_freq_shift(COMP rx_fdm_fcorr[], COMP rx_fdm[], float foff, + COMP *foff_phase_rect, int nin) +{ + COMP foff_rect; + float mag; + int i; + + foff_rect.real = cos(2.0*PI*foff/FS); + foff_rect.imag = sin(2.0*PI*foff/FS); + for(i=0; ireal /= mag; + foff_phase_rect->imag /= mag; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: fdm_downconvert() + AUTHOR......: David Rowe + DATE CREATED: 22/4/2012 + + Frequency shift each modem carrier down to Nc+1 baseband signals. + +\*---------------------------------------------------------------------------*/ + +void fdm_downconvert(COMP rx_baseband[NC+1][M+M/P], int Nc, COMP rx_fdm[], COMP phase_rx[], COMP freq[], int nin) +{ + int i,c; + float mag; + + /* maximum number of input samples to demod */ + + assert(nin <= (M+M/P)); + + /* Nc/2 tones below centre freq */ + + for (c=0; c M) + rx_timing -= M; + if (rx_timing < -M) + rx_timing += M; + + /* rx_filt_mem_timing contains M + Nfilter + M samples of the + baseband signal at rate M this enables us to resample the + filtered rx symbol with M sample precision once we have + rx_timing */ + + for(c=0; c= 0) && (d.imag >= 0)) { + msb = 0; lsb = 0; + } + if ((d.real < 0) && (d.imag >= 0)) { + msb = 0; lsb = 1; + } + if ((d.real < 0) && (d.imag < 0)) { + if (old_qpsk_mapping) { + msb = 1; lsb = 0; + } else { + msb = 1; lsb = 1; + } + } + if ((d.real >= 0) && (d.imag < 0)) { + if (old_qpsk_mapping) { + msb = 1; lsb = 1; + } else { + msb = 1; lsb = 0; + } + } + rx_bits[2*c] = msb; + rx_bits[2*c+1] = lsb; + } + + /* Extract DBPSK encoded Sync bit and fine freq offset estimate */ + + norm = 1.0/(cabsolute(prev_rx_symbols[Nc])+1E-6); + phase_difference[Nc] = cmult(rx_symbols[Nc], fcmult(norm, cconj(prev_rx_symbols[Nc]))); + if (phase_difference[Nc].real < 0) { + *sync_bit = 1; + ferr = phase_difference[Nc].imag; + } + else { + *sync_bit = 0; + ferr = -phase_difference[Nc].imag; + } + + /* pilot carrier gets an extra pi/4 rotation to make it consistent + with other carriers, as we need it for snr_update and scatter + diagram */ + + phase_difference[Nc] = cmult(phase_difference[Nc], pi_on_4); + + return ferr; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: snr_update() + AUTHOR......: David Rowe + DATE CREATED: 17 May 2012 + + Given phase differences update estimates of signal and noise levels. + +\*---------------------------------------------------------------------------*/ + +void snr_update(float sig_est[], float noise_est[], int Nc, COMP phase_difference[]) +{ + float s[NC+1]; + COMP refl_symbols[NC+1]; + float n[NC+1]; + COMP pi_on_4; + int c; + + pi_on_4.real = cos(PI/4.0); + pi_on_4.imag = sin(PI/4.0); + + /* mag of each symbol is distance from origin, this gives us a + vector of mags, one for each carrier. */ + + for(c=0; cntest_bits; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: fdmdv_put_test_bits() + AUTHOR......: David Rowe + DATE CREATED: 24/4/2012 + + Accepts nbits from rx and attempts to sync with test_bits sequence. + If sync OK measures bit errors. + +\*---------------------------------------------------------------------------*/ + +void CODEC2_WIN32SUPPORT fdmdv_put_test_bits(struct FDMDV *f, int *sync, short error_pattern[], + int *bit_errors, int *ntest_bits, + int rx_bits[]) +{ + int i,j; + float ber; + int bits_per_frame = fdmdv_bits_per_frame(f); + + /* Append to our memory */ + + for(i=0,j=bits_per_frame; intest_bits-bits_per_frame; i++,j++) + f->rx_test_bits_mem[i] = f->rx_test_bits_mem[j]; + for(i=f->ntest_bits-bits_per_frame,j=0; intest_bits; i++,j++) + f->rx_test_bits_mem[i] = rx_bits[j]; + + /* see how many bit errors we get when checked against test sequence */ + + *bit_errors = 0; + for(i=0; intest_bits; i++) { + error_pattern[i] = test_bits[i] ^ f->rx_test_bits_mem[i]; + *bit_errors += error_pattern[i]; + //printf("%d %d %d %d\n", i, test_bits[i], f->rx_test_bits_mem[i], test_bits[i] ^ f->rx_test_bits_mem[i]); + } + + /* if less than a thresh we are aligned and in sync with test sequence */ + + ber = (float)*bit_errors/f->ntest_bits; + + *sync = 0; + if (ber < 0.2) + *sync = 1; + + *ntest_bits = f->ntest_bits; + +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: freq_state(() + AUTHOR......: David Rowe + DATE CREATED: 24/4/2012 + + Freq offset state machine. Moves between coarse and fine states + based on BPSK pilot sequence. Freq offset estimator occasionally + makes mistakes when used continuously. So we use it until we have + acquired the BPSK pilot, then switch to a more robust "fine" + tracking algorithm. If we lose sync we switch back to coarse mode + for fast re-acquisition of large frequency offsets. + + The sync state is also useful for higher layers to determine when + there is valid FDMDV data for decoding. We want to reliably and + quickly get into sync, stay in sync even on fading channels, and + fall out of sync quickly if tx stops or it's a false sync. + + In multipath fading channels the BPSK sync carrier may be pushed + down in the noise, despite other carriers being at full strength. + We want to avoid loss of sync in these cases. + +\*---------------------------------------------------------------------------*/ + +int freq_state(int *reliable_sync_bit, int sync_bit, int *state, int *timer, int *sync_mem) +{ + int next_state, sync, unique_word, i, corr; + + /* look for 6 symbols (120ms) 101010 of sync sequence */ + + unique_word = 0; + for(i=0; isync == 0) + fdmdv->foff = foff_coarse; + fdmdv_freq_shift(rx_fdm_fcorr, rx_fdm, -fdmdv->foff, &fdmdv->foff_phase_rect, *nin); + + /* baseband processing */ + + fdm_downconvert(rx_baseband, fdmdv->Nc, rx_fdm_fcorr, fdmdv->phase_rx, fdmdv->freq, *nin); + rx_filter(rx_filt, fdmdv->Nc, rx_baseband, fdmdv->rx_filter_memory, *nin); + fdmdv->rx_timing = rx_est_timing(rx_symbols, fdmdv->Nc, rx_filt, rx_baseband, fdmdv->rx_filter_mem_timing, env, fdmdv->rx_baseband_mem_timing, *nin); + + /* Adjust number of input samples to keep timing within bounds */ + + *nin = M; + + if (fdmdv->rx_timing > 2*M/P) + *nin += M/P; + + if (fdmdv->rx_timing < 0) + *nin -= M/P; + + foff_fine = qpsk_to_bits(rx_bits, &sync_bit, fdmdv->Nc, fdmdv->phase_difference, fdmdv->prev_rx_symbols, rx_symbols, + fdmdv->old_qpsk_mapping); + memcpy(fdmdv->prev_rx_symbols, rx_symbols, sizeof(COMP)*(fdmdv->Nc+1)); + snr_update(fdmdv->sig_est, fdmdv->noise_est, fdmdv->Nc, fdmdv->phase_difference); + + /* freq offset estimation state machine */ + + fdmdv->sync = freq_state(reliable_sync_bit, sync_bit, &fdmdv->fest_state, &fdmdv->timer, fdmdv->sync_mem); + fdmdv->foff -= TRACK_COEFF*foff_fine; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: calc_snr() + AUTHOR......: David Rowe + DATE CREATED: 17 May 2012 + + Calculate current SNR estimate (3000Hz noise BW) + +\*---------------------------------------------------------------------------*/ + +float calc_snr(int Nc, float sig_est[], float noise_est[]) +{ + float S, SdB; + float mean, N50, N50dB, N3000dB; + float snr_dB; + int c; + + S = 0.0; + for(c=0; cNc = fdmdv->Nc; + fdmdv_stats->snr_est = calc_snr(fdmdv->Nc, fdmdv->sig_est, fdmdv->noise_est); + fdmdv_stats->sync = fdmdv->sync; + fdmdv_stats->foff = fdmdv->foff; + fdmdv_stats->rx_timing = fdmdv->rx_timing; + fdmdv_stats->clock_offset = 0.0; /* TODO - implement clock offset estimation */ + + for(c=0; cNc+1; c++) { + fdmdv_stats->rx_symbols[c] = fdmdv->phase_difference[c]; + } +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: fdmdv_8_to_48() + AUTHOR......: David Rowe + DATE CREATED: 9 May 2012 + + Changes the sample rate of a signal from 8 to 48 kHz. Experience + with PC based modems has shown that PC sound cards have a more + accurate sample clock when set for 48 kHz than 8 kHz. + + n is the number of samples at the 8 kHz rate, there are FDMDV_OS*n samples + at the 48 kHz rate. A memory of FDMDV_OS_TAPS/FDMDV_OS samples is reqd for + in8k[] (see t48_8.c unit test as example). + + This is a classic polyphase upsampler. We take the 8 kHz samples + and insert (FDMDV_OS-1) zeroes between each sample, then + FDMDV_OS_TAPS FIR low pass filter the signal at 4kHz. As most of + the input samples are zeroes, we only need to multiply non-zero + input samples by filter coefficients. The zero insertion and + filtering are combined in the code below and I'm too lazy to explain + it further right now.... + +\*---------------------------------------------------------------------------*/ + +void CODEC2_WIN32SUPPORT fdmdv_8_to_48(float out48k[], float in8k[], int n) +{ + int i,j,k,l; + + /* make sure n is an integer multiple of the oversampling rate, ow + this function breaks */ + + assert((n % FDMDV_OS) == 0); + + for(i=0; ifft_buf[i] = f->fft_buf[i+nin]; + for(j=0; jfft_buf[i] = rx_fdm[j].real; + assert(i == 2*FDMDV_NSPEC); + + /* window and FFT */ + + for(i=0; i<2*FDMDV_NSPEC; i++) { + fft_in[i].real = f->fft_buf[i] * (0.5 - 0.5*cos((float)i*2.0*PI/(2*FDMDV_NSPEC))); + fft_in[i].imag = 0.0; + } + + kiss_fft(f->fft_cfg, (kiss_fft_cpx *)fft_in, (kiss_fft_cpx *)fft_out); + + /* FFT scales up a signal of level 1 FDMDV_NSPEC */ + + full_scale_dB = 20*log10(FDMDV_NSPEC); + + /* scale and convert to dB */ + + for(i=0; iNc; i++) + fprintf(stderr," %1.3f", cabsolute(f->phase_tx[i])); + fprintf(stderr,"\nfreq[]:\n"); + for(i=0; i<=f->Nc; i++) + fprintf(stderr," %1.3f", cabsolute(f->freq[i])); + fprintf(stderr,"\nfoff_phase_rect: %1.3f", cabsolute(f->foff_phase_rect)); + fprintf(stderr,"\nphase_rx[]:\n"); + for(i=0; i<=f->Nc; i++) + fprintf(stderr," %1.3f", cabsolute(f->phase_rx[i])); + fprintf(stderr, "\n\n"); +} diff --git a/codec2/branches/0.3/src/fdmdv_demod.c b/codec2/branches/0.3/src/fdmdv_demod.c new file mode 100644 index 00000000..a64e5109 --- /dev/null +++ b/codec2/branches/0.3/src/fdmdv_demod.c @@ -0,0 +1,253 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: fdmdv_demod.c + AUTHOR......: David Rowe + DATE CREATED: April 30 2012 + + Given an input raw file (8kHz, 16 bit shorts) of FDMDV modem samples + outputs a file of bits. The output file is assumed to be arranged + as codec frames of 56 bits (7 bytes) which are received as two 28 + bit modem frames. + + Demod states can be optionally logged to an Octave file for display + using the Octave script fdmdv_demod_c.m. This is useful for + checking demod performance. + +\*---------------------------------------------------------------------------*/ + + +/* + Copyright (C) 2012 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include +#include +#include +#include +#include + +#include "codec2_fdmdv.h" +#include "octave.h" + +/* lof of information we want to dump to Octave */ + +#define MAX_FRAMES 50*60 /* 1 minute at 50 symbols/s */ + +int main(int argc, char *argv[]) +{ + FILE *fin, *fout; + struct FDMDV *fdmdv; + char *packed_bits; + int *rx_bits; + int *codec_bits; + COMP rx_fdm[FDMDV_MAX_SAMPLES_PER_FRAME]; + short rx_fdm_scaled[FDMDV_MAX_SAMPLES_PER_FRAME]; + int i, bit, byte, c; + int nin, nin_prev; + int sync_bit = 0, reliable_sync_bit; + int sync = 0; + int f; + FILE *foct = NULL; + struct FDMDV_STATS stats; + COMP *rx_fdm_log; + int rx_fdm_log_col_index; + COMP *rx_symbols_log; + int sync_log[MAX_FRAMES]; + float rx_timing_log[MAX_FRAMES]; + float foff_log[MAX_FRAMES]; + int sync_bit_log[MAX_FRAMES]; + int rx_bits_log[FDMDV_BITS_PER_FRAME*MAX_FRAMES]; + float snr_est_log[MAX_FRAMES]; + float *rx_spec_log; + int max_frames_reached; + int bits_per_fdmdv_frame; + int bits_per_codec_frame; + int bytes_per_codec_frame; + int Nc; + + if (argc < 3) { + printf("usage: %s InputModemRawFile OutputBitFile [Nc] [OctaveDumpFile]\n", argv[0]); + printf("e.g %s hts1a_fdmdv.raw hts1a.c2\n", argv[0]); + exit(1); + } + + if (strcmp(argv[1], "-") == 0) fin = stdin; + else if ( (fin = fopen(argv[1],"rb")) == NULL ) { + fprintf(stderr, "Error opening input modem sample file: %s: %s.\n", + argv[1], strerror(errno)); + exit(1); + } + + if (strcmp(argv[2], "-") == 0) fout = stdout; + else if ( (fout = fopen(argv[2],"wb")) == NULL ) { + fprintf(stderr, "Error opening output bit file: %s: %s.\n", + argv[2], strerror(errno)); + exit(1); + } + + if (argc >= 4) { + Nc = atoi(argv[3]); + if ((Nc % 2) != 0) { + fprintf(stderr, "Error number of carriers must be a multiple of 2\n"); + exit(1); + } + if ((Nc < 2) || (Nc > FDMDV_NC_MAX) ) { + fprintf(stderr, "Error number of carriers must be btween 2 and %d\n", FDMDV_NC_MAX); + exit(1); + } + } + else + Nc = FDMDV_NC; + + fdmdv = fdmdv_create(Nc); + + bits_per_fdmdv_frame = fdmdv_bits_per_frame(fdmdv); + bits_per_codec_frame = 2*fdmdv_bits_per_frame(fdmdv); + assert((bits_per_codec_frame % 8) == 0); /* make sure integer number of bytes per frame */ + bytes_per_codec_frame = bits_per_codec_frame/8; + + /* malloc some buffers that are dependant on Nc */ + + packed_bits = (char*)malloc(bytes_per_codec_frame); assert(packed_bits != NULL); + rx_bits = (int*)malloc(sizeof(int)*bits_per_codec_frame); assert(rx_bits != NULL); + codec_bits = (int*)malloc(2*sizeof(int)*bits_per_fdmdv_frame); assert(codec_bits != NULL); + + /* malloc some of the larger variables to prevent out of stack problems */ + + rx_fdm_log = (COMP*)malloc(sizeof(COMP)*FDMDV_MAX_SAMPLES_PER_FRAME*MAX_FRAMES); + assert(rx_fdm_log != NULL); + rx_spec_log = (float*)malloc(sizeof(float)*FDMDV_NSPEC*MAX_FRAMES); + assert(rx_spec_log != NULL); + rx_symbols_log = (COMP*)malloc(sizeof(COMP)*(Nc+1)*MAX_FRAMES); + assert(rx_fdm_log != NULL); + + f = 0; + nin = FDMDV_NOM_SAMPLES_PER_FRAME; + rx_fdm_log_col_index = 0; + max_frames_reached = 0; + + while(fread(rx_fdm_scaled, sizeof(short), nin, fin) == nin) + { + for(i=0; i. +*/ + +#include +#include +#include +#include +#include +#include + +#include "codec2_fdmdv.h" + +int main(int argc, char *argv[]) +{ + FILE *fout; + struct FDMDV *fdmdv; + char *packed_bits; + int *tx_bits; + int n, i, bit, byte; + int numBits, nCodecFrames; + int bits_per_fdmdv_frame; + int bits_per_codec_frame; + int bytes_per_codec_frame; + int Nc; + + if (argc < 3) { + printf("usage: %s OutputBitFile numBits [Nc]\n", argv[0]); + printf("e.g %s test.c2 1400\n", argv[0]); + exit(1); + } + + if (strcmp(argv[1], "-") == 0) fout = stdout; + else if ( (fout = fopen(argv[1],"wb")) == NULL ) { + fprintf(stderr, "Error opening output bit file: %s: %s.\n", + argv[1], strerror(errno)); + exit(1); + } + + numBits = atoi(argv[2]); + + if (argc == 4) { + Nc = atoi(argv[3]); + if ((Nc % 2) != 0) { + fprintf(stderr, "Error number of carriers must be a multiple of 2\n"); + exit(1); + } + if ((Nc < 2) || (Nc > FDMDV_NC_MAX) ) { + fprintf(stderr, "Error number of carriers must be btween 2 and %d\n", FDMDV_NC_MAX); + exit(1); + } + } + else + Nc = FDMDV_NC; + + fdmdv = fdmdv_create(Nc); + + bits_per_fdmdv_frame = fdmdv_bits_per_frame(fdmdv); + bits_per_codec_frame = 2*fdmdv_bits_per_frame(fdmdv); + assert((bits_per_codec_frame % 8) == 0); /* make sure integer number of bytes per frame */ + bytes_per_codec_frame = bits_per_codec_frame/8; + fprintf(stderr, "bits_per_fdmdv_frame: %d bits_per_codec_frame: %d bytes_per_codec_frame: %d\n", + bits_per_fdmdv_frame, bits_per_codec_frame, bytes_per_codec_frame); + + packed_bits = (char*)malloc(bytes_per_codec_frame); + assert(packed_bits != NULL); + tx_bits = (int*)malloc(sizeof(int)*bits_per_codec_frame); + assert(tx_bits != NULL); + + nCodecFrames = numBits/bits_per_codec_frame; + + for(n=0; n. +*/ + +#include +#include +#include +#include +#include +#include + +#include "codec2_fdmdv.h" + +#define MAX_INTERLEAVER 10000 + +int main(int argc, char *argv[]) +{ + FILE *fin, *fout, *finter; + int interleaver[MAX_INTERLEAVER]; + char *packed_bits; + int *bits; + int *interleaved_bits; + int i, bit, byte, m, mpacked, frames, interleave, src_bit, dest_bit; + + if (argc < 4) { + printf("usage: %s InputBitFile OutputBitFile InterleaverFile [de]\n", argv[0]); + printf("e.g %s hts1a.c2 hts1a_interleaved.c2 interleaver.txt\n", argv[0]); + exit(1); + } + + if (strcmp(argv[1], "-") == 0) fin = stdin; + else if ( (fin = fopen(argv[1],"rb")) == NULL ) { + fprintf(stderr, "Error opening input bit file: %s: %s.\n", + argv[1], strerror(errno)); + exit(1); + } + + if (strcmp(argv[2], "-") == 0) fout = stdout; + else if ( (fout = fopen(argv[2],"wb")) == NULL ) { + fprintf(stderr, "Error opening output bit file: %s: %s.\n", + argv[2], strerror(errno)); + exit(1); + } + + if ((finter = fopen(argv[3],"rt")) == NULL ) { + fprintf(stderr, "Error opening interleaver file: %s: %s.\n", + argv[3], strerror(errno)); + exit(1); + } + + if (argc == 5) + interleave = 1; + else + interleave = 0; + + /* load interleaver, size determines block size we will process */ + + src_bit = 0; + while(fscanf(finter, "%d\n", &dest_bit) == 1) { + if (interleave) + interleaver[dest_bit] = src_bit; + else + interleaver[src_bit] = dest_bit; + + src_bit++; + if (src_bit == MAX_INTERLEAVER) { + fprintf(stderr, "Error interleaver too big\n"); + exit(1); + } + } + fclose(finter); + + m = src_bit; + fprintf(stderr, "Interleaver size m = %d interleave = %d\n", m, interleave); + assert((m%8) == 0); + mpacked = m/8; + + packed_bits = (char*)malloc(mpacked*sizeof(char)); + assert(packed_bits != NULL); + bits = (int*)malloc(m*sizeof(int)); + assert(bits != NULL); + interleaved_bits = (int*)malloc(m*sizeof(int)); + assert(interleaved_bits != NULL); + + frames = 0; + + while(fread(packed_bits, sizeof(char), mpacked, fin) == mpacked) { + frames++; + + /* unpack bits, MSB first */ + + bit = 7; byte = 0; + for(i=0; i> bit) & 0x1; + bit--; + if (bit < 0) { + bit = 7; + byte++; + } + } + assert(byte == mpacked); + + /* (de) interleave */ + + for(i=0; i. +*/ + +#ifndef __FDMDV_INTERNAL__ +#define __FDMDV_INTERNAL__ + +#include "comp.h" +#include "codec2_fdmdv.h" +#include "kiss_fft.h" + +/*---------------------------------------------------------------------------*\ + + DEFINES + +\*---------------------------------------------------------------------------*/ + +#define PI 3.141592654 +#define FS 8000 /* sample rate in Hz */ +#define T (1.0/FS) /* sample period in seconds */ +#define RS 50 /* symbol rate in Hz */ +#define NC 20 /* max number of data carriers (plus one pilot in the centre) */ +#define NB 2 /* Bits/symbol for QPSK modulation */ +#define RB (NC*RS*NB) /* bit rate */ +#define M (FS/RS) /* oversampling factor */ +#define NSYM 6 /* number of symbols to filter over */ +#define NFILTER (NSYM*M) /* size of tx/rx filters at sample rate M */ + +#define FSEP 75 /* Default separation between carriers (Hz) */ + +#define NT 5 /* number of symbols we estimate timing over */ +#define P 4 /* oversample factor used for initial rx symbol filtering */ +#define NFILTERTIMING (M+NFILTER+M) /* filter memory used for resampling after timing estimation */ + +#define NPILOT_LUT (4*M) /* number of pilot look up table samples */ +#define NPILOTCOEFF 30 /* number of FIR filter coeffs in LP filter */ +#define NPILOTBASEBAND (NPILOTCOEFF+M+M/P) /* number of pilot baseband samples reqd for pilot LPF */ +#define NPILOTLPF (4*M) /* number of samples we DFT pilot over, pilot est window */ +#define MPILOTFFT 256 + +#define NSYNC_MEM 6 + +/* averaging filter coeffs */ + +#define TRACK_COEFF 0.5 +#define SNR_COEFF 0.9 /* SNR est averaging filter coeff */ + +/*---------------------------------------------------------------------------*\ + + STRUCT for States + +\*---------------------------------------------------------------------------*/ + +struct FDMDV { + + int Nc; + float fsep; + + /* test data (test frame) states */ + + int ntest_bits; + int current_test_bit; + int *rx_test_bits_mem; + + /* Modulator */ + + int old_qpsk_mapping; + int tx_pilot_bit; + COMP prev_tx_symbols[NC+1]; + COMP tx_filter_memory[NC+1][NSYM]; + COMP phase_tx[NC+1]; + COMP freq[NC+1]; + + /* Pilot generation at demodulator */ + + COMP pilot_lut[NPILOT_LUT]; + int pilot_lut_index; + int prev_pilot_lut_index; + + /* freq offset estimation states */ + + kiss_fft_cfg fft_pilot_cfg; + COMP pilot_baseband1[NPILOTBASEBAND]; + COMP pilot_baseband2[NPILOTBASEBAND]; + COMP pilot_lpf1[NPILOTLPF]; + COMP pilot_lpf2[NPILOTLPF]; + COMP S1[MPILOTFFT]; + COMP S2[MPILOTFFT]; + + /* freq offset correction states */ + + float foff; + COMP foff_phase_rect; + + /* Demodulator */ + + COMP phase_rx[NC+1]; + COMP rx_filter_memory[NC+1][NFILTER]; + COMP rx_filter_mem_timing[NC+1][NT*P]; + COMP rx_baseband_mem_timing[NC+1][NFILTERTIMING]; + float rx_timing; + COMP phase_difference[NC+1]; + COMP prev_rx_symbols[NC+1]; + + /* sync state machine */ + + int sync_mem[NSYNC_MEM]; + int fest_state; + int sync; + int timer; + + /* SNR estimation states */ + + float sig_est[NC+1]; + float noise_est[NC+1]; + + /* Buf for FFT/waterfall */ + + float fft_buf[2*FDMDV_NSPEC]; + kiss_fft_cfg fft_cfg; + }; + +/*---------------------------------------------------------------------------*\ + + FUNCTION PROTOTYPES + +\*---------------------------------------------------------------------------*/ + +void bits_to_dqpsk_symbols(COMP tx_symbols[], int Nc, COMP prev_tx_symbols[], int tx_bits[], int *pilot_bit, int old_qpsk_mapping); +void tx_filter(COMP tx_baseband[NC+1][M], int Nc, COMP tx_symbols[], COMP tx_filter_memory[NC+1][NSYM]); +void fdm_upconvert(COMP tx_fdm[], int Nc, COMP tx_baseband[NC+1][M], COMP phase_tx[], COMP freq_tx[]); +void generate_pilot_fdm(COMP *pilot_fdm, int *bit, float *symbol, float *filter_mem, COMP *phase, COMP *freq); +void generate_pilot_lut(COMP pilot_lut[], COMP *pilot_freq); +float rx_est_freq_offset(struct FDMDV *f, COMP rx_fdm[], int nin); +void lpf_peak_pick(float *foff, float *max, COMP pilot_baseband[], COMP pilot_lpf[], kiss_fft_cfg fft_pilot_cfg, COMP S[], int nin); +void fdm_downconvert(COMP rx_baseband[NC+1][M+M/P], int Nc, COMP rx_fdm[], COMP phase_rx[], COMP freq[], int nin); +void rx_filter(COMP rx_filt[NC+1][P+1], int Nc, COMP rx_baseband[NC+1][M+M/P], COMP rx_filter_memory[NC+1][NFILTER], int nin); +float rx_est_timing(COMP rx_symbols[], int Nc, + COMP rx_filt[NC+1][P+1], + COMP rx_baseband[NC+1][M+M/P], + COMP rx_filter_mem_timing[NC+1][NT*P], + float env[], + COMP rx_baseband_mem_timing[NC+1][NFILTERTIMING], + int nin); +float qpsk_to_bits(int rx_bits[], int *sync_bit, int Nc, COMP phase_difference[], COMP prev_rx_symbols[], COMP rx_symbols[], int old_qpsk_mapping); +void snr_update(float sig_est[], float noise_est[], int Nc, COMP phase_difference[]); +int freq_state(int *reliable_sync_bit, int sync_bit, int *state, int *timer, int *sync_mem); +float calc_snr(int Nc, float sig_est[], float noise_est[]); + +#endif diff --git a/codec2/branches/0.3/src/fdmdv_mod.c b/codec2/branches/0.3/src/fdmdv_mod.c new file mode 100644 index 00000000..22318db8 --- /dev/null +++ b/codec2/branches/0.3/src/fdmdv_mod.c @@ -0,0 +1,152 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: fdmdv_mod.c + AUTHOR......: David Rowe + DATE CREATED: April 28 2012 + + Given an input file of bits outputs a raw file (8kHz, 16 bit shorts) + of FDMDV modem samples ready to send over a HF radio channel. The + input file is assumed to be arranged as codec frames of 56 bits (7 + bytes) which we send as two 28 bit modem frames. + +\*---------------------------------------------------------------------------*/ + + +/* + Copyright (C) 2012 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include +#include +#include +#include +#include + +#include "codec2_fdmdv.h" + +int main(int argc, char *argv[]) +{ + FILE *fin, *fout; + struct FDMDV *fdmdv; + char *packed_bits; + int *tx_bits; + COMP tx_fdm[2*FDMDV_NOM_SAMPLES_PER_FRAME]; + short tx_fdm_scaled[2*FDMDV_NOM_SAMPLES_PER_FRAME]; + int frames; + int i, bit, byte; + int sync_bit; + int bits_per_fdmdv_frame; + int bits_per_codec_frame; + int bytes_per_codec_frame; + int Nc; + + if (argc < 3) { + printf("usage: %s InputBitFile OutputModemRawFile [Nc]\n", argv[0]); + printf("e.g %s hts1a.c2 hts1a_fdmdv.raw\n", argv[0]); + exit(1); + } + + if (strcmp(argv[1], "-") == 0) fin = stdin; + else if ( (fin = fopen(argv[1],"rb")) == NULL ) { + fprintf(stderr, "Error opening input bit file: %s: %s.\n", + argv[1], strerror(errno)); + exit(1); + } + + if (strcmp(argv[2], "-") == 0) fout = stdout; + else if ( (fout = fopen(argv[2],"wb")) == NULL ) { + fprintf(stderr, "Error opening output modem sample file: %s: %s.\n", + argv[2], strerror(errno)); + exit(1); + } + + if (argc == 4) { + Nc = atoi(argv[3]); + if ((Nc % 2) != 0) { + fprintf(stderr, "Error number of carriers must be a multiple of 2\n"); + exit(1); + } + if ((Nc < 2) || (Nc > FDMDV_NC_MAX) ) { + fprintf(stderr, "Error number of carriers must be btween 2 and %d\n", FDMDV_NC_MAX); + exit(1); + } + } + else + Nc = FDMDV_NC; + + fdmdv = fdmdv_create(Nc); + + bits_per_fdmdv_frame = fdmdv_bits_per_frame(fdmdv); + bits_per_codec_frame = 2*fdmdv_bits_per_frame(fdmdv); + assert((bits_per_codec_frame % 8) == 0); /* make sure integer number of bytes per frame */ + bytes_per_codec_frame = bits_per_codec_frame/8; + + packed_bits = (char*)malloc(bytes_per_codec_frame); + assert(packed_bits != NULL); + tx_bits = (int*)malloc(sizeof(int)*bits_per_codec_frame); + assert(tx_bits != NULL); + + frames = 0; + + while(fread(packed_bits, sizeof(char), bytes_per_codec_frame, fin) == bytes_per_codec_frame) { + frames++; + + /* unpack bits, MSB first */ + + bit = 7; byte = 0; + for(i=0; i> bit) & 0x1; + bit--; + if (bit < 0) { + bit = 7; + byte++; + } + } + assert(byte == bytes_per_codec_frame); + + /* modulate even and odd frames */ + + fdmdv_mod(fdmdv, tx_fdm, tx_bits, &sync_bit); + assert(sync_bit == 1); + + fdmdv_mod(fdmdv, &tx_fdm[FDMDV_NOM_SAMPLES_PER_FRAME], &tx_bits[bits_per_fdmdv_frame], &sync_bit); + assert(sync_bit == 0); + + /* scale and save to disk as shorts */ + + for(i=0; i<2*FDMDV_NOM_SAMPLES_PER_FRAME; i++) + tx_fdm_scaled[i] = FDMDV_SCALE * tx_fdm[i].real; + + fwrite(tx_fdm_scaled, sizeof(short), 2*FDMDV_NOM_SAMPLES_PER_FRAME, fout); + + /* if this is in a pipeline, we probably don't want the usual + buffering to occur */ + + if (fout == stdout) fflush(stdout); + if (fin == stdin) fflush(stdin); + } + + //fdmdv_dump_osc_mags(fdmdv); + + free(tx_bits); + free(packed_bits); + fclose(fin); + fclose(fout); + fdmdv_destroy(fdmdv); + + return 0; +} diff --git a/codec2/branches/0.3/src/fdmdv_put_test_bits.c b/codec2/branches/0.3/src/fdmdv_put_test_bits.c new file mode 100644 index 00000000..c1e62f12 --- /dev/null +++ b/codec2/branches/0.3/src/fdmdv_put_test_bits.c @@ -0,0 +1,175 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: fdmdv_put_test_bits.c + AUTHOR......: David Rowe + DATE CREATED: 1 May 2012 + + Using a file of packed test bits as input, determines bit error + rate. Useful for testing fdmdv_demod. + +\*---------------------------------------------------------------------------*/ + + +/* + Copyright (C) 2012 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include +#include +#include +#include +#include + +#include "codec2_fdmdv.h" + +int main(int argc, char *argv[]) +{ + FILE *fin; + struct FDMDV *fdmdv; + char *packed_bits; + int *rx_bits; + int i, bit, byte; + int test_frame_sync, bit_errors, total_bit_errors, total_bits, ntest_bits; + int test_frame_sync_state, test_frame_count; + int bits_per_fdmdv_frame; + int bits_per_codec_frame; + int bytes_per_codec_frame; + int Nc; + short *error_pattern; + + if (argc < 2) { + printf("usage: %s InputBitFile [Nc]\n", argv[0]); + printf("e.g %s test.c2\n", argv[0]); + exit(1); + } + + if (strcmp(argv[1], "-") == 0) fin = stdin; + else if ( (fin = fopen(argv[1],"rb")) == NULL ) { + fprintf(stderr, "Error opening input bit file: %s: %s.\n", + argv[1], strerror(errno)); + exit(1); + } + + if (argc == 3) { + Nc = atoi(argv[2]); + if ((Nc % 2) != 0) { + fprintf(stderr, "Error number of carriers must be a multiple of 2\n"); + exit(1); + } + if ((Nc < 2) || (Nc > FDMDV_NC_MAX) ) { + fprintf(stderr, "Error number of carriers must be between 2 and %d\n", FDMDV_NC_MAX); + exit(1); + } + } + else + Nc = FDMDV_NC; + + fdmdv = fdmdv_create(Nc); + + bits_per_fdmdv_frame = fdmdv_bits_per_frame(fdmdv); + bits_per_codec_frame = 2*fdmdv_bits_per_frame(fdmdv); + assert((bits_per_codec_frame % 8) == 0); /* make sure integer number of bytes per frame */ + bytes_per_codec_frame = bits_per_codec_frame/8; + fprintf(stderr, "bits_per_fdmdv_frame: %d bits_per_codec_frame: %d bytes_per_codec_frame: %d\n", + bits_per_fdmdv_frame, bits_per_codec_frame, bytes_per_codec_frame); + + packed_bits = (char*)malloc(bytes_per_codec_frame); + assert(packed_bits != NULL); + rx_bits = (int*)malloc(sizeof(int)*bits_per_codec_frame); + assert(rx_bits != NULL); + + error_pattern = (short*)malloc(fdmdv_error_pattern_size(fdmdv)*sizeof(int)); + assert(error_pattern != NULL); + + total_bit_errors = 0; + total_bits = 0; + test_frame_sync_state = 0; + test_frame_count = 0; + + while(fread(packed_bits, sizeof(char), bytes_per_codec_frame, fin) == bytes_per_codec_frame) { + /* unpack bits, MSB first */ + + bit = 7; byte = 0; + for(i=0; i> bit) & 0x1; + //printf("%d 0x%x %d\n", i, packed_bits[byte], rx_bits[i]); + bit--; + if (bit < 0) { + bit = 7; + byte++; + } + } + assert(byte == bytes_per_codec_frame); + + fdmdv_put_test_bits(fdmdv, &test_frame_sync, error_pattern, &bit_errors, &ntest_bits, rx_bits); + + if (test_frame_sync == 1) { + test_frame_sync_state = 1; + test_frame_count = 0; + } + + if (test_frame_sync_state) { + if (test_frame_count == 0) { + total_bit_errors += bit_errors; + total_bits = total_bits + ntest_bits; + printf("+"); + } + else + printf("-"); + test_frame_count++; + if (test_frame_count == 4) + test_frame_count = 0; + } + else + printf("-"); + + fdmdv_put_test_bits(fdmdv, &test_frame_sync, error_pattern, &bit_errors, &ntest_bits, &rx_bits[bits_per_fdmdv_frame]); + + if (test_frame_sync == 1) { + test_frame_sync_state = 1; + test_frame_count = 0; + } + + if (test_frame_sync_state) { + if (test_frame_count == 0) { + total_bit_errors += bit_errors; + total_bits = total_bits + ntest_bits; + printf("+"); + } + else + printf("-"); + test_frame_count++; + if (test_frame_count == 4) + test_frame_count = 0; + } + else + printf("-"); + + /* if this is in a pipeline, we probably don't want the usual + buffering to occur */ + + if (fin == stdin) fflush(stdin); + } + + fclose(fin); + free(error_pattern); + fdmdv_destroy(fdmdv); + + printf("\nbits %d errors %d BER %1.4f\n", total_bits, total_bit_errors, (float)total_bit_errors/(1E-6+total_bits) ); + return 0; +} + diff --git a/codec2/branches/0.3/src/fec_dec.c b/codec2/branches/0.3/src/fec_dec.c new file mode 100644 index 00000000..350b0119 --- /dev/null +++ b/codec2/branches/0.3/src/fec_dec.c @@ -0,0 +1,307 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: fec_dec.c + AUTHOR......: David Rowe + DATE CREATED: 4 march 2013 + + FEC decoder for data from modem containing compressed Codec 2 data + and FEC. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2013 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include "codec2.h" +#include "codec2_fdmdv.h" +#include "golay23.h" + +#include +#include +#include +#include +#include + +#define MODE_1600 0 +#define MODE_1850 1 +#define MODE_2000 2 + +int main(int argc, char *argv[]) +{ + void *codec2, *fdmdv; + FILE *fin; + FILE *fout; + int bits_per_input_frame, bytes_per_input_frame; + unsigned char *packed_input_bits; + int *unpacked_input_bits; + int bits_per_output_frame, bytes_per_output_frame; + unsigned char *packed_output_bits; + int *unpacked_output_bits; + int codec2_mode, mode, Nc, bit, byte; + int i,j; + int recd_codeword, codeword1, codeword2; + + if (argc < 3) { + printf("%s InputFromModemWithFECFile OutputToCodec2File [2000|1600]\n", argv[0]); + exit(1); + } + + if (strcmp(argv[1], "-") == 0) fin = stdin; + else if ( (fin = fopen(argv[1],"rb")) == NULL ) { + fprintf(stderr, "Error opening input file from Demod: %s: %s.\n", + argv[2], strerror(errno)); + exit(1); + } + + if (strcmp(argv[2], "-") == 0) fout = stdout; + else if ( (fout = fopen(argv[2],"wb")) == NULL ) { + fprintf(stderr, "Error opening output file to Codec : %s: %s.\n", + argv[3], strerror(errno)); + exit(1); + } + + /* input parameters and buffers. Note data is split into two 20ms + frames for transmission over modem. */ + + if ((argc != 4) || (strcmp(argv[3],"2000") == 0)) { + /* 2000 bit/s with FEC */ + mode = MODE_2000; + codec2_mode = CODEC2_MODE_1400; + Nc = 20; + } else if ((strcmp(argv[3],"1850") == 0)) { + /* 1850 bit/s with FEC */ + mode = MODE_1850; + codec2_mode = CODEC2_MODE_1300; + Nc = 20; + } + else if (strcmp(argv[3],"1600") == 0) { + /* 1600 bit/s with FEC (actually 1575 with one spare) */ + mode = MODE_1600; + codec2_mode = CODEC2_MODE_1300; + Nc = 16; + } + else { + fprintf(stderr, "Error in mode: %s. Must be 2000 or 1600\n", argv[3]); + exit(1); + } + + fdmdv = fdmdv_create(Nc); + + bits_per_input_frame = 2*fdmdv_bits_per_frame(fdmdv); + bytes_per_input_frame = bits_per_input_frame / 8; + assert((bits_per_input_frame % 8) == 0); /* make sure integer number of bytes per frame */ + + packed_input_bits = (unsigned char*)malloc(bytes_per_input_frame*sizeof(char)); + assert(packed_input_bits != NULL); + unpacked_input_bits = (int*)malloc(bits_per_input_frame*sizeof(int)); + assert(unpacked_input_bits != NULL); + + /* + Output parameters and buffers. + */ + + codec2 = codec2_create(codec2_mode); + + bits_per_output_frame = codec2_bits_per_frame(codec2); + bytes_per_output_frame = (bits_per_output_frame+7)/8; + + packed_output_bits = (unsigned char*)malloc(bytes_per_output_frame*sizeof(char)); + assert(packed_output_bits != NULL); + unpacked_output_bits = (int*)malloc(bits_per_output_frame*sizeof(int)); + assert(unpacked_output_bits != NULL); + + fprintf(stderr, "input bits: %d input_bytes: %d output_bits: %d output_bytes: %d\n", + bits_per_input_frame, bytes_per_input_frame, bits_per_output_frame, bytes_per_output_frame); + + /* main loop */ + + golay23_init(); + + while(fread(packed_input_bits, sizeof(char), bytes_per_input_frame, fin) == (size_t)bytes_per_input_frame) { + + /* unpack bits, MSB first */ + + bit = 7; byte = 0; + for(i=0; i> bit) & 0x1; + bit--; + if (bit < 0) { + bit = 7; + byte++; + } + } + + #ifdef TEST + /* Some test bit errors (not comprehesnive) */ + unpacked_input_bits[0] = (unpacked_input_bits[0] ^ 1) & 0x1; + unpacked_input_bits[23] = (unpacked_input_bits[23] ^ 1) & 0x1; + #endif + + if (mode == MODE_2000) { + /* decode first codeword */ + + recd_codeword = 0; + for(i=0; i<12; i++) { + recd_codeword <<= 1; + recd_codeword |= unpacked_input_bits[i]; + } + for(i=bits_per_output_frame; i> (22-i)) & 0x1; + } + + /* decode second codeword */ + + recd_codeword = 0; + for(i=12; i<24; i++) { + recd_codeword <<= 1; + recd_codeword |= unpacked_input_bits[i]; + } + for(i=bits_per_output_frame+11; i> (22-i)) & 0x1; + } + + /* unprotected bits */ + + for(i=24; i> (22-i)) & 0x1; + } + for(i=8,j=11; i<12; i++,j++) { + unpacked_output_bits[j] = (codeword1 >> (22-i)) & 0x1; + } + } + + if (mode == MODE_1850) { + recd_codeword = 0; + for(i=0; i<8; i++) { + recd_codeword <<= 1; + recd_codeword |= unpacked_input_bits[i]; + } + for(i=11; i<15; i++) { + recd_codeword <<= 1; + recd_codeword |= unpacked_input_bits[i]; + } + for(i=bits_per_output_frame; i> (22-i)) & 0x1; + } + for(i=8,j=11; i<12; i++,j++) { + unpacked_output_bits[j] = (codeword1 >> (22-i)) & 0x1; + } + for(i=0,j=16; i<12; i++,j++) { + unpacked_output_bits[j] = (codeword2 >> (22-i)) & 0x1; + } + + } + + /* pack bits, MSB first */ + + bit = 7; byte = 0; + memset(packed_output_bits, 0, bytes_per_output_frame); + for(i=0; i. +*/ + +#include "codec2.h" +#include "codec2_fdmdv.h" +#include "golay23.h" + +#include +#include +#include +#include +#include + +#define MODE_1600 0 +#define MODE_1850 1 +#define MODE_2000 2 + +int main(int argc, char *argv[]) +{ + void *codec2, *fdmdv; + FILE *fin; + FILE *fout; + int bits_per_input_frame, bytes_per_input_frame; + unsigned char *packed_input_bits; + int *unpacked_input_bits; + int bits_per_output_frame, bytes_per_output_frame; + unsigned char *packed_output_bits; + int *unpacked_output_bits; + int codec2_mode, mode, Nc, bit, byte; + int i,j; + int data, codeword1, codeword2; + + if (argc < 3) { + printf("%s InputFromCodecFile OutputToModemWithFECFile [2000|1850|1600]\n", argv[0]); + exit(1); + } + + if (strcmp(argv[1], "-") == 0) fin = stdin; + else if ( (fin = fopen(argv[1],"rb")) == NULL ) { + fprintf(stderr, "Error opening input file from Codec: %s: %s.\n", + argv[2], strerror(errno)); + exit(1); + } + + if (strcmp(argv[2], "-") == 0) fout = stdout; + else if ( (fout = fopen(argv[2],"wb")) == NULL ) { + fprintf(stderr, "Error opening output file : %s: %s.\n", + argv[3], strerror(errno)); + exit(1); + } + + if ((argc != 4) || (strcmp(argv[3],"2000") == 0)) { + /* 2000 bit/s with FEC */ + mode = MODE_2000; + codec2_mode = CODEC2_MODE_1400; + Nc = 20; + } else if ((strcmp(argv[3],"1850") == 0)) { + /* 1850 bit/s with FEC */ + mode = MODE_1850; + codec2_mode = CODEC2_MODE_1300; + Nc = 20; + } + else if (strcmp(argv[3],"1600") == 0) { + /* 1600 bit/s with FEC (actually 1575 with one spare) */ + mode = MODE_1600; + codec2_mode = CODEC2_MODE_1300; + Nc = 16; + } + else { + fprintf(stderr, "Error in mode: %s. Must be 2000, 1850, or 1600\n", argv[3]); + exit(1); + } + + /* input parameters and buffers */ + + codec2 = codec2_create(codec2_mode); + + bits_per_input_frame = codec2_bits_per_frame(codec2); + bytes_per_input_frame = (bits_per_input_frame + 7)/8; + + packed_input_bits = (unsigned char*)malloc(bytes_per_input_frame*sizeof(char)); + assert(packed_input_bits != NULL); + unpacked_input_bits = (int*)malloc(bits_per_input_frame*sizeof(int)); + assert(unpacked_input_bits != NULL); + + /* + Output parameters and buffers. Data is split into two 20ms + frames for transmission over modem, but this doesn't really + bother us here, as fdmdv_mod takes care of that. + */ + + fdmdv = fdmdv_create(Nc); + + bits_per_output_frame = 2*fdmdv_bits_per_frame(fdmdv); + bytes_per_output_frame = (bits_per_output_frame+7)/8; + + packed_output_bits = (unsigned char*)malloc(bytes_per_output_frame*sizeof(char)); + assert(packed_output_bits != NULL); + unpacked_output_bits = (int*)malloc(bits_per_output_frame*sizeof(int)); + assert(unpacked_output_bits != NULL); + + fprintf(stderr, "mode: %d Nc: %d\n", mode, Nc); + fprintf(stderr, "input bits: %d input_bytes: %d output_bits: %d output_bytes: %d\n", + bits_per_input_frame, bytes_per_input_frame, bits_per_output_frame, bytes_per_output_frame); + + /* main loop */ + + golay23_init(); + + while(fread(packed_input_bits, sizeof(char), bytes_per_input_frame, fin) == (size_t)bytes_per_input_frame) { + + /* unpack bits, MSB first */ + + bit = 7; byte = 0; + for(i=0; i> bit) & 0x1; + bit--; + if (bit < 0) { + bit = 7; + byte++; + } + } + + /* add FEC ---------------------------------------------------------*/ + + if (mode == MODE_2000) { + /* Protect first 24 bits with (23,12) Golay Code. The first + 24 bits are the most sensitive, as they contain the + pitch/energy VQ and voicing bits. This uses 56 + 11 + 11 = + 78 bits, so we have two spare in 80 bit frame sent to + modem. */ + + /* first codeword */ + + data = 0; + for(i=0; i<12; i++) { + data <<= 1; + data |= unpacked_input_bits[i]; + } + codeword1 = golay23_encode(data); + //fprintf(stderr, "data1: 0x%x codeword1: 0x%x\n", data, codeword1); + + /* second codeword */ + + data = 0; + for(i=12; i<24; i++) { + data <<= 1; + data |= unpacked_input_bits[i]; + } + codeword2 = golay23_encode(data); + //fprintf(stderr, "data: 0x%x codeword2: 0x%x\n", data, codeword2); + + /* now pack output frame with parity bits at end to make them + as far apart as possible from the data the protect. Parity + bits are LSB of the Golay codeword */ + + for(i=0; i> (10-j)) & 0x1; + } + for(j=0; i> (10-j)) & 0x1; + } + } + + if (mode == MODE_1850) { + + /* Protect first 12 out of first 16 excitation bits with (23,12) Golay Code: + + 0,1,2,3: v[0]..v[1] + 4,5,6,7: MSB of pitch + 11,12,13,14: MSB of energy + + */ + + data = 0; + for(i=0; i<8; i++) { + data <<= 1; + data |= unpacked_input_bits[i]; + } + for(i=11; i<15; i++) { + data <<= 1; + data |= unpacked_input_bits[i]; + } + codeword1 = golay23_encode(data); + + /* Protect first 12 LSP bits with (23,12) Golay Code */ + + data = 0; + for(i=16; i<28; i++) { + data <<= 1; + data |= unpacked_input_bits[i]; + } + codeword2 = golay23_encode(data); + fprintf(stderr, "codeword2: 0x0%x\n", codeword2); + + /* now pack output frame with parity bits at end to make them + as far apart as possible from the data they protect. Parity + bits are LSB of the Golay codeword */ + + for(i=0; i> (10-j)) & 0x1; + unpacked_output_bits[i+11] = (codeword2 >> (10-j)) & 0x1; + } + for(i=bits_per_input_frame+11+11; i> (10-j)) & 0x1; + } + unpacked_output_bits[i] = 0; /* spare bit */ + } + + /* pack bits, MSB first */ + + bit = 7; byte = 0; + memset(packed_output_bits, 0, bytes_per_output_frame); + for(i=0; i. +*/ + +#include +#include +#include +#include "codec2_fifo.h" + +struct FIFO { + short *buf; + short *pin; + short *pout; + int nshort; +}; + +struct FIFO *fifo_create(int nshort) { + struct FIFO *fifo; + + fifo = (struct FIFO *)malloc(sizeof(struct FIFO)); + assert(fifo != NULL); + + fifo->buf = (short*)malloc(sizeof(short)*nshort); + assert(fifo->buf != NULL); + fifo->pin = fifo->buf; + fifo->pout = fifo->buf; + fifo->nshort = nshort; + + return fifo; +} + +void fifo_destroy(struct FIFO *fifo) { + assert(fifo != NULL); + free(fifo->buf); + free(fifo); +} + +int fifo_write(struct FIFO *fifo, short data[], int n) { + int i; + int fifo_free; + short *pdata; + short *pin = fifo->pin; + + assert(fifo != NULL); + assert(data != NULL); + + // available storage is one less than nshort as prd == pwr + // is reserved for empty rather than full + + fifo_free = fifo->nshort - fifo_used(fifo) - 1; + + if (n > fifo_free) { + return -1; + } + else { + + /* This could be made more efficient with block copies + using memcpy */ + + pdata = data; + for(i=0; ibuf + fifo->nshort)) + pin = fifo->buf; + } + fifo->pin = pin; + } + + return 0; +} + +int fifo_read(struct FIFO *fifo, short data[], int n) +{ + int i; + short *pdata; + short *pout = fifo->pout; + + assert(fifo != NULL); + assert(data != NULL); + + if (n > fifo_used(fifo)) { + return -1; + } + else { + + /* This could be made more efficient with block copies + using memcpy */ + + pdata = data; + for(i=0; ibuf + fifo->nshort)) + pout = fifo->buf; + } + fifo->pout = pout; + } + + return 0; +} + +int fifo_used(struct FIFO *fifo) +{ + short *pin = fifo->pin; + short *pout = fifo->pout; + unsigned int used; + + assert(fifo != NULL); + if (pin >= pout) + used = pin - pout; + else + used = fifo->nshort + (unsigned int)(pin - pout); + + return used; +} + diff --git a/codec2/branches/0.3/src/fq20.sh b/codec2/branches/0.3/src/fq20.sh new file mode 100755 index 00000000..b83784b4 --- /dev/null +++ b/codec2/branches/0.3/src/fq20.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# fq20.shsh +# David Rowe 27 July 2010 +# +# Decode a file with fully quantised codec at 20ms frame rate + +../src/sinedec ../raw/$1.raw $1.mdl -o $1_phase0_lsp_20_EWo2.raw --phase 0 --lpc 10 --lsp --postfilter --dec + diff --git a/codec2/branches/0.3/src/generate_codebook.c b/codec2/branches/0.3/src/generate_codebook.c new file mode 100644 index 00000000..0bea80d8 --- /dev/null +++ b/codec2/branches/0.3/src/generate_codebook.c @@ -0,0 +1,179 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: generate_codebook.c + AUTHOR......: Bruce Perens + DATE CREATED: 29 Sep 2010 + + Generate header files containing LSP quantisers, runs at compile time. + +\*---------------------------------------------------------------------------*/ + +/* + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include +#include +#include + +static const char usage[] = +"Usage: %s filename array_name [filename ...]\n" +"\tCreate C code for codebook tables.\n"; + +static const char format[] = +"The table format must be:\n" +"\tTwo integers describing the dimensions of the codebook.\n" +"\tThen, enough numbers to fill the specified dimensions.\n"; + +static const char header[] = +"/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */\n\n" +"/*\n" +" * This intermediary file and the files that used to create it are under \n" +" * The LGPL. See the file COPYING.\n" +" */\n\n" +"#include \"defines.h\"\n\n"; + +struct codebook { + unsigned int k; + unsigned int log2m; + unsigned int m; + float * cb; +}; + +static void +dump_array(const struct codebook * b, int index) +{ + int limit = b->k * b->m; + int i; + + printf("static const float codes%d[] = {\n", index); + for ( i = 0; i < limit; i++ ) { + printf(" %g", b->cb[i]); + if ( i < limit - 1 ) + printf(","); + + /* organise VQs by rows, looks prettier */ + if ( ((i+1) % b->k) == 0 ) + printf("\n"); + } + printf("};\n"); +} + +static void +dump_structure(const struct codebook * b, int index) +{ + printf(" {\n"); + printf(" %d,\n", b->k); + printf(" %g,\n", log(b->m) / log(2)); + printf(" %d,\n", b->m); + printf(" codes%d\n", index); + printf(" }"); +} + +float +get_float(FILE * in, const char * name, char * * cursor, char * buffer, + int size) +{ + for ( ; ; ) { + char * s = *cursor; + char c; + + while ( (c = *s) != '\0' && !isdigit(c) && c != '-' && c != '.' ) + s++; + + /* Comments start with "#" and continue to the end of the line. */ + if ( c != '\0' && c != '#' ) { + char * end = 0; + float f = 0; + + f = strtod(s, &end); + + if ( end != s ) + *cursor = end; + return f; + } + + if ( fgets(buffer, size, in) == NULL ) { + fprintf(stderr, "%s: Format error. %s\n", name, format); + exit(1); + } + *cursor = buffer; + } +} + +static struct codebook * +load(FILE * file, const char * name) +{ + char line[1024]; + char * cursor = line; + struct codebook * b = malloc(sizeof(struct codebook)); + int i; + int size; + + *cursor = '\0'; + + b->k = (int)get_float(file, name, &cursor, line, sizeof(line)); + b->m = (int)get_float(file, name ,&cursor, line, sizeof(line)); + size = b->k * b->m; + + b->cb = (float *)malloc(size * sizeof(float)); + + for ( i = 0; i < size; i++ ) + b->cb[i] = get_float(file, name, &cursor, line, sizeof(line)); + + return b; +} + +int +main(int argc, char * * argv) +{ + struct codebook * * cb = malloc(argc * sizeof(struct codebook *)); + int i; + + if ( argc < 2 ) { + fprintf(stderr, usage, argv[0]); + fprintf(stderr, format); + exit(1); + } + + for ( i = 0; i < argc - 2; i++ ) { + FILE * in = fopen(argv[i + 2], "r"); + + if ( in == NULL ) { + perror(argv[i + 2]); + exit(1); + } + + cb[i] = load(in, argv[i + 2]); + + fclose(in); + } + + printf(header); + for ( i = 0; i < argc - 2; i++ ) { + printf(" /* %s */\n", argv[i + 2]); + dump_array(cb[i], i); + } + printf("\nconst struct lsp_codebook %s[] = {\n", argv[1]); + for ( i = 0; i < argc - 2; i++ ) { + printf(" /* %s */\n", argv[i + 2]); + dump_structure(cb[i], i); + printf(",\n"); + } + printf(" { 0, 0, 0, 0 }\n"); + printf("};\n"); + + return 0; +} diff --git a/codec2/branches/0.3/src/genlspdtcb.c b/codec2/branches/0.3/src/genlspdtcb.c new file mode 100644 index 00000000..efac19c5 --- /dev/null +++ b/codec2/branches/0.3/src/genlspdtcb.c @@ -0,0 +1,90 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: genlspdtcb.c + AUTHOR......: David Rowe + DATE CREATED: 2 Nov 2011 + + Generates codebooks (quantisation tables) for LSP delta-T VQ. + +\*---------------------------------------------------------------------------*/ + +/* + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . + +*/ + +#define MAX_ROWS 10 + +float lsp1to4[] = { + -25,0,25, + -25,0,25, + -50,0,50, + -50,0,50 +}; + +float lsp5to10[] = { + -50,0,50, + -50,0,50, + -50,0,50, + -50,0,50, + -50,0,50, + -50,0,50 +}; + +#include +#include +#include +#include +#include + +void create_codebook_text_file(char filename[], float lsp[], + int rows, int cols); + +int main(void) { + create_codebook_text_file("codebook/lspdt1-4.txt", lsp1to4, 4, 3); + create_codebook_text_file("codebook/lspdt5-10.txt", lsp5to10, 6, 3); + return 0; +} + +void create_codebook_text_file(char filename[], float lsp[], + int rows, int cols) +{ + FILE *f; + int i, digits[MAX_ROWS]; + + f = fopen(filename, "wt"); + if (f == NULL) { + printf("Can't open codebook text file %s\n", filename); + exit(0); + } + + for(i=0; i +#include +#include +#define X22 0x00400000 /* vector representation of X^{22} */ +#define X11 0x00000800 /* vector representation of X^{11} */ +#define MASK12 0xfffff800 /* auxiliary vector for testing */ +#define GENPOL 0x00000c75 /* generator polinomial, g(x) */ + +/* Global variables: + * + * pattern = error pattern, or information, or received vector + * encoding_table[] = encoding table + * decoding_table[] = decoding table + * data = information bits, i(x) + * codeword = code bits = x^{11}i(x) + (x^{11}i(x) mod g(x)) + * numerr = number of errors = Hamming weight of error polynomial e(x) + * position[] = error positions in the vector representation of e(x) + * recd = representation of corrupted received polynomial r(x) = c(x) + e(x) + * decerror = number of decoding errors + * a[] = auxiliary array to generate correctable error patterns + */ + +static int inited = 0; + +static int encoding_table[4096], decoding_table[2048]; +#ifdef GOLAY23_UNITTEST +static int position[23] = { 0x00000001, 0x00000002, 0x00000004, 0x00000008, + 0x00000010, 0x00000020, 0x00000040, 0x00000080, + 0x00000100, 0x00000200, 0x00000400, 0x00000800, + 0x00001000, 0x00002000, 0x00004000, 0x00008000, + 0x00010000, 0x00020000, 0x00040000, 0x00080000, + 0x00100000, 0x00200000, 0x00400000 }; +#endif +static int arr2int(int a[], int r) +/* + * Convert a binary vector of Hamming weight r, and nonzero positions in + * array a[1]...a[r], to a long integer \sum_{i=1}^r 2^{a[i]-1}. + */ +{ + int i; + long mul, result = 0, temp; + + for (i=1; i<=r; i++) { + mul = 1; + temp = a[i]-1; + while (temp--) + mul = mul << 1; + result += mul; + } + return(result); +} + +void nextcomb(int n, int r, int a[]) +/* + * Calculate next r-combination of an n-set. + */ +{ + int i, j; + + a[r]++; + if (a[r] <= n) + return; + j = r - 1; + while (a[j] == n - r + j) + j--; + for (i = r; i >= j; i--) + a[i] = a[j] + i - j + 1; + return; +} + +int get_syndrome(int pattern) +/* + * Compute the syndrome corresponding to the given pattern, i.e., the + * remainder after dividing the pattern (when considering it as the vector + * representation of a polynomial) by the generator polynomial, GENPOL. + * In the program this pattern has several meanings: (1) pattern = infomation + * bits, when constructing the encoding table; (2) pattern = error pattern, + * when constructing the decoding table; and (3) pattern = received vector, to + * obtain its syndrome in decoding. + */ +{ + int aux = X22; + + if (pattern >= X11) + while (pattern & MASK12) { + while (!(aux & pattern)) + aux = aux >> 1; + pattern ^= (aux/X11) * GENPOL; + } + return(pattern); +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: golay23_init() + AUTHOR......: David Rowe + DATE CREATED: 3 March 2013 + + Call this once when you start your program to init the Golay tables. + +\*---------------------------------------------------------------------------*/ + +void golay23_init(void ) { + int i; + long temp; + int a[4]; + int pattern; + + /* + * --------------------------------------------------------------------- + * Generate ENCODING TABLE + * + * An entry to the table is an information vector, a 32-bit integer, + * whose 12 least significant positions are the information bits. The + * resulting value is a codeword in the (23,12,7) Golay code: A 32-bit + * integer whose 23 least significant bits are coded bits: Of these, the + * 12 most significant bits are information bits and the 11 least + * significant bits are redundant bits (systematic encoding). + * --------------------------------------------------------------------- + */ + for (pattern = 0; pattern < 4096; pattern++) { + temp = pattern << 11; /* multiply information by X^{11} */ + encoding_table[pattern] = temp + get_syndrome(temp);/* add redundancy */ + } + + /* + * --------------------------------------------------------------------- + * Generate DECODING TABLE + * + * An entry to the decoding table is a syndrome and the resulting value + * is the most likely error pattern. First an error pattern is generated. + * Then its syndrome is calculated and used as a pointer to the table + * where the error pattern value is stored. + * --------------------------------------------------------------------- + * + * (1) Error patterns of WEIGHT 1 (SINGLE ERRORS) + */ + decoding_table[0] = 0; + decoding_table[1] = 1; + temp = 1; + for (i=2; i<= 23; i++) { + temp *= 2; + decoding_table[get_syndrome(temp)] = temp; + } + /* + * (2) Error patterns of WEIGHT 2 (DOUBLE ERRORS) + */ + a[1] = 1; a[2] = 2; + temp = arr2int(a,2); + decoding_table[get_syndrome(temp)] = temp; + for (i=1; i<253; i++) { + nextcomb(23,2,a); + temp = arr2int(a,2); + decoding_table[get_syndrome(temp)] = temp; + } + /* + * (3) Error patterns of WEIGHT 3 (TRIPLE ERRORS) + */ + a[1] = 1; a[2] = 2; a[3] = 3; + temp = arr2int(a,3); + decoding_table[get_syndrome(temp)] = temp; + for (i=1; i<1771; i++) { + nextcomb(23,3,a); + temp = arr2int(a,3); + decoding_table[get_syndrome(temp)] = temp; + } + + inited = 1; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: golay23_encode() + AUTHOR......: David Rowe + DATE CREATED: 3 March 2013 + + Given 12 bits of data retiurns a 23 bit codeword for transmission + over the channel. + +\*---------------------------------------------------------------------------*/ + +int golay23_encode(int data) { + assert(inited); + + //printf("data: 0x%x\n", data); + assert(data <= 0xfff); + return encoding_table[data]; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: golay23_decode() + AUTHOR......: David Rowe + DATE CREATED: 3 March 2013 + + Given a 23 bit received codeword, returns the 12 bit corrected data. + +\*---------------------------------------------------------------------------*/ + +int golay23_decode(int received_codeword) { + assert(inited); + + //printf("syndrome: 0x%x\n", get_syndrome(received_codeword)); + return received_codeword ^= decoding_table[get_syndrome(received_codeword)]; +} + +int golay23_count_errors(int recd_codeword, int corrected_codeword) +{ + int errors = 0; + int diff, i; + + diff = recd_codeword ^ corrected_codeword; + for(i=0; i<23; i++) { + if (diff & 0x1) + errors++; + diff >>= 1; + } + + return errors; +} + +#ifdef GOLAY23_UNITTEST + +static int golay23_test(int error_pattern) { + int data; + int codeword; + int recd; + int pattern; + int decerror; + int i, tests; + + decerror = 0; + tests = 0; + + for (data = 0; data<(1<<12); data++) { + + codeword = golay23_encode(data); + recd = codeword ^ error_pattern; + recd = golay23_decode(recd); + pattern = (recd ^ codeword) >> 11; + for (i=0; i<12; i++) + if (pattern & position[i]) + decerror++; + if (decerror) { + printf("data: 0x%x codeword: 0x%x recd: 0x%x\n", data, codeword, recd); + printf("there were %d decoding errors\n", decerror); + exit(1); + } + tests++; + } + + return tests; +} + +int main(void) +{ + int i; + long temp; + long pattern; + int tests; + int a[4]; + int error_pattern; + + /* + * --------------------------------------------------------------------- + * Generate ENCODING TABLE + * + * An entry to the table is an information vector, a 32-bit integer, + * whose 12 least significant positions are the information bits. The + * resulting value is a codeword in the (23,12,7) Golay code: A 32-bit + * integer whose 23 least significant bits are coded bits: Of these, the + * 12 most significant bits are information bits and the 11 least + * significant bits are redundant bits (systematic encoding). + * --------------------------------------------------------------------- + */ + for (pattern = 0; pattern < 4096; pattern++) { + temp = pattern << 11; /* multiply information by X^{11} */ + encoding_table[pattern] = temp + get_syndrome(temp);/* add redundancy */ + } + + /* + * --------------------------------------------------------------------- + * Generate DECODING TABLE + * + * An entry to the decoding table is a syndrome and the resulting value + * is the most likely error pattern. First an error pattern is generated. + * Then its syndrome is calculated and used as a pointer to the table + * where the error pattern value is stored. + * --------------------------------------------------------------------- + * + * (1) Error patterns of WEIGHT 1 (SINGLE ERRORS) + */ + decoding_table[0] = 0; + decoding_table[1] = 1; + temp = 1; + for (i=2; i<= 23; i++) { + temp *= 2; + decoding_table[get_syndrome(temp)] = temp; + } + /* + * (2) Error patterns of WEIGHT 2 (DOUBLE ERRORS) + */ + a[1] = 1; a[2] = 2; + temp = arr2int(a,2); + decoding_table[get_syndrome(temp)] = temp; + for (i=1; i<253; i++) { + nextcomb(23,2,a); + temp = arr2int(a,2); + decoding_table[get_syndrome(temp)] = temp; + } + /* + * (3) Error patterns of WEIGHT 3 (TRIPLE ERRORS) + */ + a[1] = 1; a[2] = 2; a[3] = 3; + temp = arr2int(a,3); + decoding_table[get_syndrome(temp)] = temp; + for (i=1; i<1771; i++) { + nextcomb(23,3,a); + temp = arr2int(a,3); + decoding_table[get_syndrome(temp)] = temp; + } + + /* --------------------------------------------------------------------- + * Generate DATA + * --------------------------------------------------------------------- + */ + + /* Test all combinations of data and 1,2 or 3 errors */ + + tests = 0; + error_pattern = 1; + for (i=0; i< 23; i++) { + //printf("error_pattern: 0x%x\n", error_pattern); + tests += golay23_test(error_pattern); + error_pattern *= 2; + } + printf("%d 1 bit error tests performed OK!\n", tests); + + tests = 0; + a[1] = 1; a[2] = 2; + error_pattern = arr2int(a,2); + tests += golay23_test(error_pattern); + for (i=1; i<253; i++) { + nextcomb(23,2,a); + error_pattern = arr2int(a,2); + //printf("error_pattern: 0x%x\n", error_pattern); + tests += golay23_test(error_pattern); + } + printf("%d 2 bit error tests performed OK!\n", tests); + + tests = 0; + a[1] = 1; a[2] = 2; a[3] = 3; + error_pattern = arr2int(a,3); + tests += golay23_test(error_pattern); + for (i=1; i<1771; i++) { + nextcomb(23,3,a); + error_pattern = arr2int(a,3); + //printf("error_pattern: 0x%x\n", error_pattern); + tests += golay23_test(error_pattern); + } + printf("%d 3 bit error tests performed OK!\n", tests); + + return 0; +} +#endif diff --git a/codec2/branches/0.3/src/golay23.h b/codec2/branches/0.3/src/golay23.h new file mode 100644 index 00000000..a916d29f --- /dev/null +++ b/codec2/branches/0.3/src/golay23.h @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: golay23.h + AUTHOR......: David Rowe + DATE CREATED: 3 March 2013 + + Header file for Golay FEC. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2013 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#ifndef __GOLAY23__ +#define __GOLAY23__ + +#ifdef __cplusplus +extern "C" { +#endif + +void golay23_init(void); +int golay23_encode(int data); +int golay23_decode(int received_codeword); +int golay23_count_errors(int recd_codeword, int corrected_codeword); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/codec2/branches/0.3/src/hanning.h b/codec2/branches/0.3/src/hanning.h new file mode 100644 index 00000000..81d88dcb --- /dev/null +++ b/codec2/branches/0.3/src/hanning.h @@ -0,0 +1,644 @@ +/* Generated by hanning_file() Octave function */ + +const float hanning[]={ + 0, + 2.4171e-05, + 9.66816e-05, + 0.000217525, + 0.000386689, + 0.000604158, + 0.00086991, + 0.00118392, + 0.00154616, + 0.00195659, + 0.00241517, + 0.00292186, + 0.00347661, + 0.00407937, + 0.00473008, + 0.00542867, + 0.00617507, + 0.00696922, + 0.00781104, + 0.00870045, + 0.00963736, + 0.0106217, + 0.0116533, + 0.0127322, + 0.0138581, + 0.0150311, + 0.0162509, + 0.0175175, + 0.0188308, + 0.0201906, + 0.0215968, + 0.0230492, + 0.0245478, + 0.0260923, + 0.0276826, + 0.0293186, + 0.0310001, + 0.032727, + 0.034499, + 0.036316, + 0.0381779, + 0.0400844, + 0.0420354, + 0.0440307, + 0.04607, + 0.0481533, + 0.0502802, + 0.0524506, + 0.0546643, + 0.056921, + 0.0592206, + 0.0615627, + 0.0639473, + 0.0663741, + 0.0688427, + 0.0713531, + 0.0739048, + 0.0764978, + 0.0791318, + 0.0818064, + 0.0845214, + 0.0872767, + 0.0900718, + 0.0929066, + 0.0957807, + 0.0986939, + 0.101646, + 0.104636, + 0.107665, + 0.110732, + 0.113836, + 0.116978, + 0.120156, + 0.123372, + 0.126624, + 0.129912, + 0.133235, + 0.136594, + 0.139989, + 0.143418, + 0.146881, + 0.150379, + 0.153911, + 0.157476, + 0.161074, + 0.164705, + 0.168368, + 0.172063, + 0.17579, + 0.179549, + 0.183338, + 0.187158, + 0.191008, + 0.194888, + 0.198798, + 0.202737, + 0.206704, + 0.2107, + 0.214724, + 0.218775, + 0.222854, + 0.226959, + 0.231091, + 0.235249, + 0.239432, + 0.243641, + 0.247874, + 0.252132, + 0.256414, + 0.260719, + 0.265047, + 0.269398, + 0.273772, + 0.278167, + 0.282584, + 0.287021, + 0.29148, + 0.295958, + 0.300456, + 0.304974, + 0.30951, + 0.314065, + 0.318638, + 0.323228, + 0.327835, + 0.332459, + 0.3371, + 0.341756, + 0.346427, + 0.351113, + 0.355814, + 0.360528, + 0.365256, + 0.369997, + 0.374751, + 0.379516, + 0.384293, + 0.389082, + 0.393881, + 0.398691, + 0.40351, + 0.408338, + 0.413176, + 0.418022, + 0.422876, + 0.427737, + 0.432605, + 0.43748, + 0.44236, + 0.447247, + 0.452138, + 0.457034, + 0.461935, + 0.466839, + 0.471746, + 0.476655, + 0.481568, + 0.486481, + 0.491397, + 0.496313, + 0.501229, + 0.506145, + 0.511061, + 0.515976, + 0.520889, + 0.5258, + 0.530708, + 0.535614, + 0.540516, + 0.545414, + 0.550308, + 0.555197, + 0.560081, + 0.564958, + 0.56983, + 0.574695, + 0.579552, + 0.584402, + 0.589244, + 0.594077, + 0.598901, + 0.603715, + 0.60852, + 0.613314, + 0.618097, + 0.622868, + 0.627628, + 0.632375, + 0.63711, + 0.641831, + 0.646538, + 0.651232, + 0.655911, + 0.660574, + 0.665222, + 0.669855, + 0.67447, + 0.679069, + 0.683651, + 0.688215, + 0.69276, + 0.697287, + 0.701795, + 0.706284, + 0.710752, + 0.7152, + 0.719627, + 0.724033, + 0.728418, + 0.73278, + 0.73712, + 0.741437, + 0.74573, + 0.75, + 0.754246, + 0.758467, + 0.762663, + 0.766833, + 0.770978, + 0.775097, + 0.779189, + 0.783254, + 0.787291, + 0.791301, + 0.795283, + 0.799236, + 0.80316, + 0.807055, + 0.810921, + 0.814756, + 0.81856, + 0.822334, + 0.826077, + 0.829788, + 0.833468, + 0.837115, + 0.840729, + 0.844311, + 0.847859, + 0.851374, + 0.854855, + 0.858301, + 0.861713, + 0.86509, + 0.868431, + 0.871737, + 0.875007, + 0.87824, + 0.881437, + 0.884598, + 0.887721, + 0.890806, + 0.893854, + 0.896864, + 0.899835, + 0.902768, + 0.905661, + 0.908516, + 0.911331, + 0.914106, + 0.916841, + 0.919536, + 0.92219, + 0.924804, + 0.927376, + 0.929907, + 0.932397, + 0.934845, + 0.93725, + 0.939614, + 0.941935, + 0.944213, + 0.946448, + 0.94864, + 0.950789, + 0.952894, + 0.954955, + 0.956972, + 0.958946, + 0.960874, + 0.962759, + 0.964598, + 0.966393, + 0.968142, + 0.969846, + 0.971505, + 0.973118, + 0.974686, + 0.976207, + 0.977683, + 0.979112, + 0.980495, + 0.981832, + 0.983122, + 0.984365, + 0.985561, + 0.986711, + 0.987813, + 0.988868, + 0.989876, + 0.990837, + 0.99175, + 0.992616, + 0.993434, + 0.994204, + 0.994927, + 0.995601, + 0.996228, + 0.996807, + 0.997337, + 0.99782, + 0.998255, + 0.998641, + 0.998979, + 0.999269, + 0.999511, + 0.999704, + 0.999849, + 0.999946, + 0.999994, + 0.999994, + 0.999946, + 0.999849, + 0.999704, + 0.999511, + 0.999269, + 0.998979, + 0.998641, + 0.998255, + 0.99782, + 0.997337, + 0.996807, + 0.996228, + 0.995601, + 0.994927, + 0.994204, + 0.993434, + 0.992616, + 0.99175, + 0.990837, + 0.989876, + 0.988868, + 0.987813, + 0.986711, + 0.985561, + 0.984365, + 0.983122, + 0.981832, + 0.980495, + 0.979112, + 0.977683, + 0.976207, + 0.974686, + 0.973118, + 0.971505, + 0.969846, + 0.968142, + 0.966393, + 0.964598, + 0.962759, + 0.960874, + 0.958946, + 0.956972, + 0.954955, + 0.952894, + 0.950789, + 0.94864, + 0.946448, + 0.944213, + 0.941935, + 0.939614, + 0.93725, + 0.934845, + 0.932397, + 0.929907, + 0.927376, + 0.924804, + 0.92219, + 0.919536, + 0.916841, + 0.914106, + 0.911331, + 0.908516, + 0.905661, + 0.902768, + 0.899835, + 0.896864, + 0.893854, + 0.890806, + 0.887721, + 0.884598, + 0.881437, + 0.87824, + 0.875007, + 0.871737, + 0.868431, + 0.86509, + 0.861713, + 0.858301, + 0.854855, + 0.851374, + 0.847859, + 0.844311, + 0.840729, + 0.837115, + 0.833468, + 0.829788, + 0.826077, + 0.822334, + 0.81856, + 0.814756, + 0.810921, + 0.807055, + 0.80316, + 0.799236, + 0.795283, + 0.791301, + 0.787291, + 0.783254, + 0.779189, + 0.775097, + 0.770978, + 0.766833, + 0.762663, + 0.758467, + 0.754246, + 0.75, + 0.74573, + 0.741437, + 0.73712, + 0.73278, + 0.728418, + 0.724033, + 0.719627, + 0.7152, + 0.710752, + 0.706284, + 0.701795, + 0.697287, + 0.69276, + 0.688215, + 0.683651, + 0.679069, + 0.67447, + 0.669855, + 0.665222, + 0.660574, + 0.655911, + 0.651232, + 0.646538, + 0.641831, + 0.63711, + 0.632375, + 0.627628, + 0.622868, + 0.618097, + 0.613314, + 0.60852, + 0.603715, + 0.598901, + 0.594077, + 0.589244, + 0.584402, + 0.579552, + 0.574695, + 0.56983, + 0.564958, + 0.560081, + 0.555197, + 0.550308, + 0.545414, + 0.540516, + 0.535614, + 0.530708, + 0.5258, + 0.520889, + 0.515976, + 0.511061, + 0.506145, + 0.501229, + 0.496313, + 0.491397, + 0.486481, + 0.481568, + 0.476655, + 0.471746, + 0.466839, + 0.461935, + 0.457034, + 0.452138, + 0.447247, + 0.44236, + 0.43748, + 0.432605, + 0.427737, + 0.422876, + 0.418022, + 0.413176, + 0.408338, + 0.40351, + 0.398691, + 0.393881, + 0.389082, + 0.384293, + 0.379516, + 0.374751, + 0.369997, + 0.365256, + 0.360528, + 0.355814, + 0.351113, + 0.346427, + 0.341756, + 0.3371, + 0.332459, + 0.327835, + 0.323228, + 0.318638, + 0.314065, + 0.30951, + 0.304974, + 0.300456, + 0.295958, + 0.29148, + 0.287021, + 0.282584, + 0.278167, + 0.273772, + 0.269398, + 0.265047, + 0.260719, + 0.256414, + 0.252132, + 0.247874, + 0.243641, + 0.239432, + 0.235249, + 0.231091, + 0.226959, + 0.222854, + 0.218775, + 0.214724, + 0.2107, + 0.206704, + 0.202737, + 0.198798, + 0.194888, + 0.191008, + 0.187158, + 0.183338, + 0.179549, + 0.17579, + 0.172063, + 0.168368, + 0.164705, + 0.161074, + 0.157476, + 0.153911, + 0.150379, + 0.146881, + 0.143418, + 0.139989, + 0.136594, + 0.133235, + 0.129912, + 0.126624, + 0.123372, + 0.120156, + 0.116978, + 0.113836, + 0.110732, + 0.107665, + 0.104636, + 0.101646, + 0.0986939, + 0.0957807, + 0.0929066, + 0.0900718, + 0.0872767, + 0.0845214, + 0.0818064, + 0.0791318, + 0.0764978, + 0.0739048, + 0.0713531, + 0.0688427, + 0.0663741, + 0.0639473, + 0.0615627, + 0.0592206, + 0.056921, + 0.0546643, + 0.0524506, + 0.0502802, + 0.0481533, + 0.04607, + 0.0440307, + 0.0420354, + 0.0400844, + 0.0381779, + 0.036316, + 0.034499, + 0.032727, + 0.0310001, + 0.0293186, + 0.0276826, + 0.0260923, + 0.0245478, + 0.0230492, + 0.0215968, + 0.0201906, + 0.0188308, + 0.0175175, + 0.0162509, + 0.0150311, + 0.0138581, + 0.0127322, + 0.0116533, + 0.0106217, + 0.00963736, + 0.00870045, + 0.00781104, + 0.00696922, + 0.00617507, + 0.00542867, + 0.00473008, + 0.00407937, + 0.00347661, + 0.00292186, + 0.00241517, + 0.00195659, + 0.00154616, + 0.00118392, + 0.00086991, + 0.000604158, + 0.000386689, + 0.000217525, + 9.66816e-05, + 2.4171e-05, + 0 +}; diff --git a/codec2/branches/0.3/src/insert_errors.c b/codec2/branches/0.3/src/insert_errors.c new file mode 100644 index 00000000..87ef2f8b --- /dev/null +++ b/codec2/branches/0.3/src/insert_errors.c @@ -0,0 +1,121 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: insert_errors.c + AUTHOR......: David Rowe + DATE CREATED: 20/2/2013 + + Inserts errors into a Codec 2 bit stream using error files. The + error files have one 16 bit short per bit, the short is set to 1 if + there is an error, or zero otherwise. The Codec 2 bit stream files + are in packed format, i.e. c2enc/c2dec format. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2013 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include "codec2.h" + +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + FILE *fin; + FILE *fout; + FILE *ferror; + int i, start_bit, end_bit, bit; + unsigned char byte; + short error; + int errors, bits; + int bits_per_frame; + + if (argc < 4) { + printf("%s InputBitFile OutputBitFile ErrorFile bitsPerFrame [startBit endBit]\n", argv[0]); + printf("%s InputBitFile OutputBitFile BER\n", argv[0]); + exit(1); + } + + if (strcmp(argv[1], "-") == 0) fin = stdin; + else if ( (fin = fopen(argv[1],"rb")) == NULL ) { + fprintf(stderr, "Error opening input bit file: %s: %s.\n", + argv[1], strerror(errno)); + exit(1); + } + + if (strcmp(argv[2], "-") == 0) fout = stdout; + else if ( (fout = fopen(argv[2],"wb")) == NULL ) { + fprintf(stderr, "Error opening output speech file: %s: %s.\n", + argv[2], strerror(errno)); + exit(1); + } + + if ((ferror = fopen(argv[3],"rb")) == NULL ) { + fprintf(stderr, "Error opening error file: %s: %s.\n", + argv[3], strerror(errno)); + exit(1); + } + + bits_per_frame = atoi(argv[4]); + assert((bits_per_frame % 8) == 0); + + start_bit = 0; end_bit = bits_per_frame; + if (argc == 7) { + start_bit = atoi(argv[5]); + end_bit = atoi(argv[6]); + } + + bit = 0; + bits = errors = 0; + + while(fread(&byte, sizeof(char), 1, fin) == 1) { + + for(i=0; i<8; i++) { + bits++; + //printf("bit: %d start_bit: %d end_bit: %d\n", bit, start_bit, end_bit); + if (fread(&error, sizeof(short), 1, ferror)) { + if ((bit >= start_bit) && (bit <= end_bit)) + byte ^= error << (7-i); + if (error) + errors++; + } + else { + fprintf(stderr,"bits: %d ber: %4.3f\n", bits, (float)errors/bits); + fclose (fin); fclose(fout); fclose(ferror); + exit(0); + } + bit++; + if (bit == bits_per_frame) + bit = 0; + } + fwrite(&byte, sizeof(char), 1, fout); + if (fout == stdout) fflush(stdout); + if (fin == stdin) fflush(stdin); + + } + + fclose(fin); + fclose(fout); + fclose(ferror); + + fprintf(stderr,"bits: %d ber: %4.3f\n", bits, (float)errors/bits); + + return 0; +} diff --git a/codec2/branches/0.3/src/interp.c b/codec2/branches/0.3/src/interp.c new file mode 100644 index 00000000..e712a46e --- /dev/null +++ b/codec2/branches/0.3/src/interp.c @@ -0,0 +1,323 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: interp.c + AUTHOR......: David Rowe + DATE CREATED: 9/10/09 + + Interpolation of 20ms frames to 10ms frames. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2009 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include +#include +#include + +#include "defines.h" +#include "interp.h" +#include "lsp.h" +#include "quantise.h" + +float sample_log_amp(MODEL *model, float w); + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: interp() + AUTHOR......: David Rowe + DATE CREATED: 22/8/10 + + Given two frames decribed by model parameters 20ms apart, determines + the model parameters of the 10ms frame between them. Assumes + voicing is available for middle (interpolated) frame. Outputs are + amplitudes and Wo for the interpolated frame. + + This version can interpolate the amplitudes between two frames of + different Wo and L. + + This version works by log linear interpolation, but listening tests + showed it creates problems in background noise, e.g. hts2a and mmt1. + When this function is used (--dec mode) bg noise appears to be + amplitude modulated, and gets louder. The interp_lsp() function + below seems to do a better job. + +\*---------------------------------------------------------------------------*/ + +void interpolate( + MODEL *interp, /* interpolated model params */ + MODEL *prev, /* previous frames model params */ + MODEL *next /* next frames model params */ +) +{ + int l; + float w,log_amp; + + /* Wo depends on voicing of this and adjacent frames */ + + if (interp->voiced) { + if (prev->voiced && next->voiced) + interp->Wo = (prev->Wo + next->Wo)/2.0; + if (!prev->voiced && next->voiced) + interp->Wo = next->Wo; + if (prev->voiced && !next->voiced) + interp->Wo = prev->Wo; + } + else { + interp->Wo = TWO_PI/P_MAX; + } + interp->L = PI/interp->Wo; + + /* Interpolate amplitudes using linear interpolation in log domain */ + + for(l=1; l<=interp->L; l++) { + w = l*interp->Wo; + log_amp = (sample_log_amp(prev, w) + sample_log_amp(next, w))/2.0; + interp->A[l] = pow(10.0, log_amp); + } +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: sample_log_amp() + AUTHOR......: David Rowe + DATE CREATED: 22/8/10 + + Samples the amplitude envelope at an arbitrary frequency w. Uses + linear interpolation in the log domain to sample between harmonic + amplitudes. + +\*---------------------------------------------------------------------------*/ + +float sample_log_amp(MODEL *model, float w) +{ + int m; + float f, log_amp; + + assert(w > 0.0); assert (w <= PI); + + m = floorf(w/model->Wo + 0.5); + f = (w - m*model->Wo)/w; + assert(f <= 1.0); + + if (m < 1) { + log_amp = f*log10f(model->A[1] + 1E-6); + } + else if ((m+1) > model->L) { + log_amp = (1.0-f)*log10f(model->A[model->L] + 1E-6); + } + else { + log_amp = (1.0-f)*log10f(model->A[m] + 1E-6) + + f*log10f(model->A[m+1] + 1E-6); + } + + return log_amp; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: interp_lsp() + AUTHOR......: David Rowe + DATE CREATED: 10 Nov 2010 + + Given two frames decribed by model parameters 20ms apart, determines + the model parameters of the 10ms frame between them. Assumes + voicing is available for middle (interpolated) frame. Outputs are + amplitudes and Wo for the interpolated frame. + + This version uses interpolation of LSPs, seems to do a better job + with bg noise. + +\*---------------------------------------------------------------------------*/ + +void interpolate_lsp( + kiss_fft_cfg fft_fwd_cfg, + MODEL *interp, /* interpolated model params */ + MODEL *prev, /* previous frames model params */ + MODEL *next, /* next frames model params */ + float *prev_lsps, /* previous frames LSPs */ + float prev_e, /* previous frames LPC energy */ + float *next_lsps, /* next frames LSPs */ + float next_e, /* next frames LPC energy */ + float *ak_interp, /* interpolated aks for this frame */ + float *lsps_interp/* interpolated lsps for this frame */ +) +{ + int i; + float e; + float snr; + + /* trap corner case where V est is probably wrong */ + + if (interp->voiced && !prev->voiced && !next->voiced) { + interp->voiced = 0; + } + + /* Wo depends on voicing of this and adjacent frames */ + + if (interp->voiced) { + if (prev->voiced && next->voiced) + interp->Wo = (prev->Wo + next->Wo)/2.0; + if (!prev->voiced && next->voiced) + interp->Wo = next->Wo; + if (prev->voiced && !next->voiced) + interp->Wo = prev->Wo; + } + else { + interp->Wo = TWO_PI/P_MAX; + } + interp->L = PI/interp->Wo; + + //printf(" interp: prev_v: %d next_v: %d prev_Wo: %f next_Wo: %f\n", + // prev->voiced, next->voiced, prev->Wo, next->Wo); + //printf(" interp: Wo: %1.5f L: %d\n", interp->Wo, interp->L); + + /* interpolate LSPs */ + + for(i=0; iA[1]); +} + + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: interp_Wo() + AUTHOR......: David Rowe + DATE CREATED: 22 May 2012 + + Interpolates centre 10ms sample of Wo and L samples given two + samples 20ms apart. Assumes voicing is available for centre + (interpolated) frame. + +\*---------------------------------------------------------------------------*/ + +void interp_Wo( + MODEL *interp, /* interpolated model params */ + MODEL *prev, /* previous frames model params */ + MODEL *next /* next frames model params */ + ) +{ + interp_Wo2(interp, prev, next, 0.5); +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: interp_Wo2() + AUTHOR......: David Rowe + DATE CREATED: 22 May 2012 + + Weighted interpolation of two Wo samples. + +\*---------------------------------------------------------------------------*/ + +void interp_Wo2( + MODEL *interp, /* interpolated model params */ + MODEL *prev, /* previous frames model params */ + MODEL *next, /* next frames model params */ + float weight +) +{ + /* trap corner case where voicing est is probably wrong */ + + if (interp->voiced && !prev->voiced && !next->voiced) { + interp->voiced = 0; + } + + /* Wo depends on voicing of this and adjacent frames */ + + if (interp->voiced) { + if (prev->voiced && next->voiced) + interp->Wo = (1.0 - weight)*prev->Wo + weight*next->Wo; + if (!prev->voiced && next->voiced) + interp->Wo = next->Wo; + if (prev->voiced && !next->voiced) + interp->Wo = prev->Wo; + } + else { + interp->Wo = TWO_PI/P_MAX; + } + interp->L = PI/interp->Wo; +} + + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: interp_energy() + AUTHOR......: David Rowe + DATE CREATED: 22 May 2012 + + Interpolates centre 10ms sample of energy given two samples 20ms + apart. + +\*---------------------------------------------------------------------------*/ + +float interp_energy(float prev_e, float next_e) +{ + return powf(10.0, (log10f(prev_e) + log10f(next_e))/2.0); + +} + + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: interp_energy2() + AUTHOR......: David Rowe + DATE CREATED: 22 May 2012 + + Interpolates centre 10ms sample of energy given two samples 20ms + apart. + +\*---------------------------------------------------------------------------*/ + +float interp_energy2(float prev_e, float next_e, float weight) +{ + return powf(10.0, (1.0 - weight)*log10f(prev_e) + weight*log10f(next_e)); + +} + + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: interpolate_lsp_ver2() + AUTHOR......: David Rowe + DATE CREATED: 22 May 2012 + + Weighted interpolation of LSPs. + +\*---------------------------------------------------------------------------*/ + +void interpolate_lsp_ver2(float interp[], float prev[], float next[], float weight) +{ + int i; + + for(i=0; i. +*/ + +#ifndef __INTERP__ +#define __INTERP__ + +#include "kiss_fft.h" + +void interpolate(MODEL *interp, MODEL *prev, MODEL *next); +void interpolate_lsp(kiss_fft_cfg fft_dec_cfg, + MODEL *interp, MODEL *prev, MODEL *next, + float *prev_lsps, float prev_e, + float *next_lsps, float next_e, + float *ak_interp, float *lsps_interp); +void interp_Wo(MODEL *interp, MODEL *prev, MODEL *next); +void interp_Wo2(MODEL *interp, MODEL *prev, MODEL *next, float weight); +float interp_energy(float prev, float next); +float interp_energy2(float prev, float next, float weight); +void interpolate_lsp_ver2(float interp[], float prev[], float next[], float weight); + +#endif diff --git a/codec2/branches/0.3/src/kiss_fft.c b/codec2/branches/0.3/src/kiss_fft.c new file mode 100644 index 00000000..465d6c97 --- /dev/null +++ b/codec2/branches/0.3/src/kiss_fft.c @@ -0,0 +1,408 @@ +/* +Copyright (c) 2003-2010, Mark Borgerding + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "_kiss_fft_guts.h" +/* The guts header contains all the multiplication and addition macros that are defined for + fixed or floating point complex numbers. It also delares the kf_ internal functions. + */ + +static void kf_bfly2( + kiss_fft_cpx * Fout, + const size_t fstride, + const kiss_fft_cfg st, + int m + ) +{ + kiss_fft_cpx * Fout2; + kiss_fft_cpx * tw1 = st->twiddles; + kiss_fft_cpx t; + Fout2 = Fout + m; + do{ + C_FIXDIV(*Fout,2); C_FIXDIV(*Fout2,2); + + C_MUL (t, *Fout2 , *tw1); + tw1 += fstride; + C_SUB( *Fout2 , *Fout , t ); + C_ADDTO( *Fout , t ); + ++Fout2; + ++Fout; + }while (--m); +} + +static void kf_bfly4( + kiss_fft_cpx * Fout, + const size_t fstride, + const kiss_fft_cfg st, + const size_t m + ) +{ + kiss_fft_cpx *tw1,*tw2,*tw3; + kiss_fft_cpx scratch[6]; + size_t k=m; + const size_t m2=2*m; + const size_t m3=3*m; + + + tw3 = tw2 = tw1 = st->twiddles; + + do { + C_FIXDIV(*Fout,4); C_FIXDIV(Fout[m],4); C_FIXDIV(Fout[m2],4); C_FIXDIV(Fout[m3],4); + + C_MUL(scratch[0],Fout[m] , *tw1 ); + C_MUL(scratch[1],Fout[m2] , *tw2 ); + C_MUL(scratch[2],Fout[m3] , *tw3 ); + + C_SUB( scratch[5] , *Fout, scratch[1] ); + C_ADDTO(*Fout, scratch[1]); + C_ADD( scratch[3] , scratch[0] , scratch[2] ); + C_SUB( scratch[4] , scratch[0] , scratch[2] ); + C_SUB( Fout[m2], *Fout, scratch[3] ); + tw1 += fstride; + tw2 += fstride*2; + tw3 += fstride*3; + C_ADDTO( *Fout , scratch[3] ); + + if(st->inverse) { + Fout[m].r = scratch[5].r - scratch[4].i; + Fout[m].i = scratch[5].i + scratch[4].r; + Fout[m3].r = scratch[5].r + scratch[4].i; + Fout[m3].i = scratch[5].i - scratch[4].r; + }else{ + Fout[m].r = scratch[5].r + scratch[4].i; + Fout[m].i = scratch[5].i - scratch[4].r; + Fout[m3].r = scratch[5].r - scratch[4].i; + Fout[m3].i = scratch[5].i + scratch[4].r; + } + ++Fout; + }while(--k); +} + +static void kf_bfly3( + kiss_fft_cpx * Fout, + const size_t fstride, + const kiss_fft_cfg st, + size_t m + ) +{ + size_t k=m; + const size_t m2 = 2*m; + kiss_fft_cpx *tw1,*tw2; + kiss_fft_cpx scratch[5]; + kiss_fft_cpx epi3; + epi3 = st->twiddles[fstride*m]; + + tw1=tw2=st->twiddles; + + do{ + C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3); + + C_MUL(scratch[1],Fout[m] , *tw1); + C_MUL(scratch[2],Fout[m2] , *tw2); + + C_ADD(scratch[3],scratch[1],scratch[2]); + C_SUB(scratch[0],scratch[1],scratch[2]); + tw1 += fstride; + tw2 += fstride*2; + + Fout[m].r = Fout->r - HALF_OF(scratch[3].r); + Fout[m].i = Fout->i - HALF_OF(scratch[3].i); + + C_MULBYSCALAR( scratch[0] , epi3.i ); + + C_ADDTO(*Fout,scratch[3]); + + Fout[m2].r = Fout[m].r + scratch[0].i; + Fout[m2].i = Fout[m].i - scratch[0].r; + + Fout[m].r -= scratch[0].i; + Fout[m].i += scratch[0].r; + + ++Fout; + }while(--k); +} + +static void kf_bfly5( + kiss_fft_cpx * Fout, + const size_t fstride, + const kiss_fft_cfg st, + int m + ) +{ + kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4; + int u; + kiss_fft_cpx scratch[13]; + kiss_fft_cpx * twiddles = st->twiddles; + kiss_fft_cpx *tw; + kiss_fft_cpx ya,yb; + ya = twiddles[fstride*m]; + yb = twiddles[fstride*2*m]; + + Fout0=Fout; + Fout1=Fout0+m; + Fout2=Fout0+2*m; + Fout3=Fout0+3*m; + Fout4=Fout0+4*m; + + tw=st->twiddles; + for ( u=0; ur += scratch[7].r + scratch[8].r; + Fout0->i += scratch[7].i + scratch[8].i; + + scratch[5].r = scratch[0].r + S_MUL(scratch[7].r,ya.r) + S_MUL(scratch[8].r,yb.r); + scratch[5].i = scratch[0].i + S_MUL(scratch[7].i,ya.r) + S_MUL(scratch[8].i,yb.r); + + scratch[6].r = S_MUL(scratch[10].i,ya.i) + S_MUL(scratch[9].i,yb.i); + scratch[6].i = -S_MUL(scratch[10].r,ya.i) - S_MUL(scratch[9].r,yb.i); + + C_SUB(*Fout1,scratch[5],scratch[6]); + C_ADD(*Fout4,scratch[5],scratch[6]); + + scratch[11].r = scratch[0].r + S_MUL(scratch[7].r,yb.r) + S_MUL(scratch[8].r,ya.r); + scratch[11].i = scratch[0].i + S_MUL(scratch[7].i,yb.r) + S_MUL(scratch[8].i,ya.r); + scratch[12].r = - S_MUL(scratch[10].i,yb.i) + S_MUL(scratch[9].i,ya.i); + scratch[12].i = S_MUL(scratch[10].r,yb.i) - S_MUL(scratch[9].r,ya.i); + + C_ADD(*Fout2,scratch[11],scratch[12]); + C_SUB(*Fout3,scratch[11],scratch[12]); + + ++Fout0;++Fout1;++Fout2;++Fout3;++Fout4; + } +} + +/* perform the butterfly for one stage of a mixed radix FFT */ +static void kf_bfly_generic( + kiss_fft_cpx * Fout, + const size_t fstride, + const kiss_fft_cfg st, + int m, + int p + ) +{ + int u,k,q1,q; + kiss_fft_cpx * twiddles = st->twiddles; + kiss_fft_cpx t; + int Norig = st->nfft; + + kiss_fft_cpx * scratch = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC(sizeof(kiss_fft_cpx)*p); + + for ( u=0; u=Norig) twidx-=Norig; + C_MUL(t,scratch[q] , twiddles[twidx] ); + C_ADDTO( Fout[ k ] ,t); + } + k += m; + } + } + KISS_FFT_TMP_FREE(scratch); +} + +static +void kf_work( + kiss_fft_cpx * Fout, + const kiss_fft_cpx * f, + const size_t fstride, + int in_stride, + int * factors, + const kiss_fft_cfg st + ) +{ + kiss_fft_cpx * Fout_beg=Fout; + const int p=*factors++; /* the radix */ + const int m=*factors++; /* stage's fft length/p */ + const kiss_fft_cpx * Fout_end = Fout + p*m; + +#ifdef _OPENMP + // use openmp extensions at the + // top-level (not recursive) + if (fstride==1 && p<=5) + { + int k; + + // execute the p different work units in different threads +# pragma omp parallel for + for (k=0;k floor_sqrt) + p = n; /* no more factors, skip to end */ + } + n /= p; + *facbuf++ = p; + *facbuf++ = n; + } while (n > 1); +} + +/* + * + * User-callable function to allocate all necessary storage space for the fft. + * + * The return value is a contiguous block of memory, allocated with malloc. As such, + * It can be freed with free(), rather than a kiss_fft-specific function. + * */ +kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem ) +{ + kiss_fft_cfg st=NULL; + size_t memneeded = sizeof(struct kiss_fft_state) + + sizeof(kiss_fft_cpx)*(nfft-1); /* twiddle factors*/ + + if ( lenmem==NULL ) { + st = ( kiss_fft_cfg)KISS_FFT_MALLOC( memneeded ); + }else{ + if (mem != NULL && *lenmem >= memneeded) + st = (kiss_fft_cfg)mem; + *lenmem = memneeded; + } + if (st) { + int i; + st->nfft=nfft; + st->inverse = inverse_fft; + + for (i=0;iinverse) + phase *= -1; + kf_cexp(st->twiddles+i, phase ); + } + + kf_factor(nfft,st->factors); + } + return st; +} + + +void kiss_fft_stride(kiss_fft_cfg st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int in_stride) +{ + if (fin == fout) { + //NOTE: this is not really an in-place FFT algorithm. + //It just performs an out-of-place FFT into a temp buffer + kiss_fft_cpx * tmpbuf = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC( sizeof(kiss_fft_cpx)*st->nfft); + kf_work(tmpbuf,fin,1,in_stride, st->factors,st); + memcpy(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft); + KISS_FFT_TMP_FREE(tmpbuf); + }else{ + kf_work( fout, fin, 1,in_stride, st->factors,st ); + } +} + +void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) +{ + kiss_fft_stride(cfg,fin,fout,1); +} + + +void kiss_fft_cleanup(void) +{ + // nothing needed any more +} + +int kiss_fft_next_fast_size(int n) +{ + while(1) { + int m=n; + while ( (m%2) == 0 ) m/=2; + while ( (m%3) == 0 ) m/=3; + while ( (m%5) == 0 ) m/=5; + if (m<=1) + break; /* n is completely factorable by twos, threes, and fives */ + n++; + } + return n; +} diff --git a/codec2/branches/0.3/src/kiss_fft.h b/codec2/branches/0.3/src/kiss_fft.h new file mode 100644 index 00000000..64c50f4a --- /dev/null +++ b/codec2/branches/0.3/src/kiss_fft.h @@ -0,0 +1,124 @@ +#ifndef KISS_FFT_H +#define KISS_FFT_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + ATTENTION! + If you would like a : + -- a utility that will handle the caching of fft objects + -- real-only (no imaginary time component ) FFT + -- a multi-dimensional FFT + -- a command-line utility to perform ffts + -- a command-line utility to perform fast-convolution filtering + + Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c + in the tools/ directory. +*/ + +#ifdef USE_SIMD +# include +# define kiss_fft_scalar __m128 +#define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16) +#define KISS_FFT_FREE _mm_free +#else +#define KISS_FFT_MALLOC malloc +#define KISS_FFT_FREE free +#endif + + +#ifdef FIXED_POINT +#include +# if (FIXED_POINT == 32) +# define kiss_fft_scalar int32_t +# else +# define kiss_fft_scalar int16_t +# endif +#else +# ifndef kiss_fft_scalar +/* default is float */ +# define kiss_fft_scalar float +# endif +#endif + +typedef struct { + kiss_fft_scalar r; + kiss_fft_scalar i; +}kiss_fft_cpx; + +typedef struct kiss_fft_state* kiss_fft_cfg; + +/* + * kiss_fft_alloc + * + * Initialize a FFT (or IFFT) algorithm's cfg/state buffer. + * + * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL); + * + * The return value from fft_alloc is a cfg buffer used internally + * by the fft routine or NULL. + * + * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc. + * The returned value should be free()d when done to avoid memory leaks. + * + * The state can be placed in a user supplied buffer 'mem': + * If lenmem is not NULL and mem is not NULL and *lenmem is large enough, + * then the function places the cfg in mem and the size used in *lenmem + * and returns mem. + * + * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough), + * then the function returns NULL and places the minimum cfg + * buffer size in *lenmem. + * */ + +kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); + +/* + * kiss_fft(cfg,in_out_buf) + * + * Perform an FFT on a complex input buffer. + * for a forward FFT, + * fin should be f[0] , f[1] , ... ,f[nfft-1] + * fout will be F[0] , F[1] , ... ,F[nfft-1] + * Note that each element is complex and can be accessed like + f[k].r and f[k].i + * */ +void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); + +/* + A more generic version of the above function. It reads its input from every Nth sample. + * */ +void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride); + +/* If kiss_fft_alloc allocated a buffer, it is one contiguous + buffer and can be simply free()d when no longer needed*/ +#define kiss_fft_free free + +/* + Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up + your compiler output to call this before you exit. +*/ +void kiss_fft_cleanup(void); + + +/* + * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5) + */ +int kiss_fft_next_fast_size(int n); + +/* for real ffts, we need an even size */ +#define kiss_fftr_next_fast_size_real(n) \ + (kiss_fft_next_fast_size( ((n)+1)>>1)<<1) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/codec2/branches/0.3/src/listensim.sh b/codec2/branches/0.3/src/listensim.sh new file mode 100755 index 00000000..b296cac5 --- /dev/null +++ b/codec2/branches/0.3/src/listensim.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# listensim.sh +# David Rowe 10 Sep 2009 +# +# Listen to files processed with sim.sh + +../script/menu.sh $1_uq.raw $1_lpc10.raw $1_lpcpf.raw $1_phase0.raw $1_phase0_lpcpf.raw $2 $3 $4 $5 + + diff --git a/codec2/branches/0.3/src/lpc.c b/codec2/branches/0.3/src/lpc.c new file mode 100644 index 00000000..d03cb178 --- /dev/null +++ b/codec2/branches/0.3/src/lpc.c @@ -0,0 +1,309 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: lpc.c + AUTHOR......: David Rowe + DATE CREATED: 30 Sep 1990 (!) + + Linear Prediction functions written in C. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2009-2012 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#define LPC_MAX_N 512 /* maximum no. of samples in frame */ +#define PI 3.141592654 /* mathematical constant */ + +#define ALPHA 1.0 +#define BETA 0.94 + +#include +#include +#include "defines.h" +#include "lpc.h" + +/*---------------------------------------------------------------------------*\ + + pre_emp() + + Pre-emphasise (high pass filter with zero close to 0 Hz) a frame of + speech samples. Helps reduce dynamic range of LPC spectrum, giving + greater weight and hensea better match to low energy formants. + + Should be balanced by de-emphasis of the output speech. + +\*---------------------------------------------------------------------------*/ + +void pre_emp( + float Sn_pre[], /* output frame of speech samples */ + float Sn[], /* input frame of speech samples */ + float *mem, /* Sn[-1]single sample memory */ + int Nsam /* number of speech samples to use */ +) +{ + int i; + + for(i=0; i 1.0) + k[i] = 0.0; + + a[i][i] = k[i]; + + for(j=1; j<=i-1; j++) + a[i][j] = a[i-1][j] + k[i]*a[i-1][i-j]; /* Equation 38c, Makhoul */ + + E[i] = (1-k[i]*k[i])*E[i-1]; /* Equation 38d, Makhoul */ + } + + for(i=1; i<=order; i++) + lpcs[i] = a[order][i]; + lpcs[0] = 1.0; +} + +/*---------------------------------------------------------------------------*\ + + inverse_filter() + + Inverse Filter, A(z). Produces an array of residual samples from an array + of input samples and linear prediction coefficients. + + The filter memory is stored in the first order samples of the input array. + +\*---------------------------------------------------------------------------*/ + +void inverse_filter( + float Sn[], /* Nsam input samples */ + float a[], /* LPCs for this frame of samples */ + int Nsam, /* number of samples */ + float res[], /* Nsam residual samples */ + int order /* order of LPC */ +) +{ + int i,j; /* loop variables */ + + for(i=0; i. +*/ + +#ifndef __LPC__ +#define __LPC__ + +#define LPC_MAX_ORDER 20 + +void pre_emp(float Sn_pre[], float Sn[], float *mem, int Nsam); +void de_emp(float Sn_se[], float Sn[], float *mem, int Nsam); +void hanning_window(float Sn[], float Wn[], int Nsam); +void autocorrelate(float Sn[], float Rn[], int Nsam, int order); +void levinson_durbin(float R[], float lpcs[], int order); +void inverse_filter(float Sn[], float a[], int Nsam, float res[], int order); +void synthesis_filter(float res[], float a[], int Nsam, int order, float Sn_[]); +void find_aks(float Sn[], float a[], int Nsam, int order, float *E); +void weight(float ak[], float gamma, int order, float akw[]); + +#endif diff --git a/codec2/branches/0.3/src/lsp.c b/codec2/branches/0.3/src/lsp.c new file mode 100644 index 00000000..c5167b7a --- /dev/null +++ b/codec2/branches/0.3/src/lsp.c @@ -0,0 +1,325 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: lsp.c + AUTHOR......: David Rowe + DATE CREATED: 24/2/93 + + + This file contains functions for LPC to LSP conversion and LSP to + LPC conversion. Note that the LSP coefficients are not in radians + format but in the x domain of the unit circle. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2009 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include "defines.h" +#include "lsp.h" +#include +#include +#include + +/* Only 10 gets used, so far. */ +#define LSP_MAX_ORDER 20 + +/*---------------------------------------------------------------------------*\ + + Introduction to Line Spectrum Pairs (LSPs) + ------------------------------------------ + + LSPs are used to encode the LPC filter coefficients {ak} for + transmission over the channel. LSPs have several properties (like + less sensitivity to quantisation noise) that make them superior to + direct quantisation of {ak}. + + A(z) is a polynomial of order lpcrdr with {ak} as the coefficients. + + A(z) is transformed to P(z) and Q(z) (using a substitution and some + algebra), to obtain something like: + + A(z) = 0.5[P(z)(z+z^-1) + Q(z)(z-z^-1)] (1) + + As you can imagine A(z) has complex zeros all over the z-plane. P(z) + and Q(z) have the very neat property of only having zeros _on_ the + unit circle. So to find them we take a test point z=exp(jw) and + evaluate P (exp(jw)) and Q(exp(jw)) using a grid of points between 0 + and pi. + + The zeros (roots) of P(z) also happen to alternate, which is why we + swap coefficients as we find roots. So the process of finding the + LSP frequencies is basically finding the roots of 5th order + polynomials. + + The root so P(z) and Q(z) occur in symmetrical pairs at +/-w, hence + the name Line Spectrum Pairs (LSPs). + + To convert back to ak we just evaluate (1), "clocking" an impulse + thru it lpcrdr times gives us the impulse response of A(z) which is + {ak}. + +\*---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: cheb_poly_eva() + AUTHOR......: David Rowe + DATE CREATED: 24/2/93 + + This function evalutes a series of chebyshev polynomials + + FIXME: performing memory allocation at run time is very inefficient, + replace with stack variables of MAX_P size. + +\*---------------------------------------------------------------------------*/ + + +static float +cheb_poly_eva(float *coef,float x,int m) +/* float coef[] coefficients of the polynomial to be evaluated */ +/* float x the point where polynomial is to be evaluated */ +/* int m order of the polynomial */ +{ + int i; + float *t,*u,*v,sum; + float T[(LSP_MAX_ORDER / 2) + 1]; + + /* Initialise pointers */ + + t = T; /* T[i-2] */ + *t++ = 1.0; + u = t--; /* T[i-1] */ + *u++ = x; + v = u--; /* T[i] */ + + /* Evaluate chebyshev series formulation using iterative approach */ + + for(i=2;i<=m/2;i++) + *v++ = (2*x)*(*u++) - *t++; /* T[i] = 2*x*T[i-1] - T[i-2] */ + + sum=0.0; /* initialise sum to zero */ + t = T; /* reset pointer */ + + /* Evaluate polynomial and return value also free memory space */ + + for(i=0;i<=m/2;i++) + sum+=coef[(m/2)-i]**t++; + + return sum; +} + + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: lpc_to_lsp() + AUTHOR......: David Rowe + DATE CREATED: 24/2/93 + + This function converts LPC coefficients to LSP coefficients. + +\*---------------------------------------------------------------------------*/ + +int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta) +/* float *a lpc coefficients */ +/* int lpcrdr order of LPC coefficients (10) */ +/* float *freq LSP frequencies in radians */ +/* int nb number of sub-intervals (4) */ +/* float delta grid spacing interval (0.02) */ +{ + float psuml,psumr,psumm,temp_xr,xl,xr,xm = 0; + float temp_psumr; + int i,j,m,flag,k; + float *px; /* ptrs of respective P'(z) & Q'(z) */ + float *qx; + float *p; + float *q; + float *pt; /* ptr used for cheb_poly_eval() + whether P' or Q' */ + int roots=0; /* number of roots found */ + float Q[LSP_MAX_ORDER + 1]; + float P[LSP_MAX_ORDER + 1]; + + flag = 1; + m = lpcrdr/2; /* order of P'(z) & Q'(z) polynimials */ + + /* Allocate memory space for polynomials */ + + /* determine P'(z)'s and Q'(z)'s coefficients where + P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */ + + px = P; /* initilaise ptrs */ + qx = Q; + p = px; + q = qx; + *px++ = 1.0; + *qx++ = 1.0; + for(i=1;i<=m;i++){ + *px++ = a[i]+a[lpcrdr+1-i]-*p++; + *qx++ = a[i]-a[lpcrdr+1-i]+*q++; + } + px = P; + qx = Q; + for(i=0;i= -1.0)){ + xr = xl - delta ; /* interval spacing */ + psumr = cheb_poly_eva(pt,xr,lpcrdr);/* poly(xl-delta_x) */ + temp_psumr = psumr; + temp_xr = xr; + + /* if no sign change increment xr and re-evaluate + poly(xr). Repeat til sign change. if a sign change has + occurred the interval is bisected and then checked again + for a sign change which determines in which interval the + zero lies in. If there is no sign change between poly(xm) + and poly(xl) set interval between xm and xr else set + interval between xl and xr and repeat till root is located + within the specified limits */ + + if(((psumr*psuml)<0.0) || (psumr == 0.0)){ + roots++; + + psumm=psuml; + for(k=0;k<=nb;k++){ + xm = (xl+xr)/2; /* bisect the interval */ + psumm=cheb_poly_eva(pt,xm,lpcrdr); + if(psumm*psuml>0.){ + psuml=psumm; + xl=xm; + } + else{ + psumr=psumm; + xr=xm; + } + } + + /* once zero is found, reset initial interval to xr */ + freq[j] = (xm); + xl = xm; + flag = 0; /* reset flag for next search */ + } + else{ + psuml=temp_psumr; + xl=temp_xr; + } + } + } + + /* convert from x domain to radians */ + + for(i=0; i. +*/ + +#ifndef __LSP__ +#define __LSP__ + +int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta); +void lsp_to_lpc(float *freq, float *ak, int lpcrdr); + +#endif diff --git a/codec2/branches/0.3/src/machdep.h b/codec2/branches/0.3/src/machdep.h new file mode 100644 index 00000000..ef2e6494 --- /dev/null +++ b/codec2/branches/0.3/src/machdep.h @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: machdep.h + AUTHOR......: David Rowe + DATE CREATED: May 2 2013 + + Machine dependant functions. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2013 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#ifndef __MACHDEP__ +#define __MACHDEP__ + +#ifdef TIMER +#define TIMER_VAR(...) unsigned int __VA_ARGS__ +#define TIMER_SAMPLE(timestamp) timestamp = machdep_timer_sample() +#define TIMER_SAMPLE_AND_LOG(timestamp, prev_timestamp, label) \ + timestamp = machdep_timer_sample_and_log(prev_timestamp, label) +#define TIMER_SAMPLE_AND_LOG2(prev_timestamp, label) \ + machdep_timer_sample_and_log(prev_timestamp, label) +#else +#define TIMER_VAR(...) +#define TIMER_SAMPLE(timestamp) +#define TIMER_SAMPLE_AND_LOG(timestamp, prev_timestamp, label) +#define TIMER_SAMPLE_AND_LOG2(prev_timestamp, label) +#endif + +void machdep_timer_init(void); +void machdep_timer_reset(void); +unsigned int machdep_timer_sample(void); +unsigned int machdep_timer_sample_and_log(unsigned int start, char s[]); +void machdep_timer_print_logged_samples(void); + +#endif diff --git a/codec2/branches/0.3/src/nlp.c b/codec2/branches/0.3/src/nlp.c new file mode 100644 index 00000000..7d842e53 --- /dev/null +++ b/codec2/branches/0.3/src/nlp.c @@ -0,0 +1,589 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: nlp.c + AUTHOR......: David Rowe + DATE CREATED: 23/3/93 + + Non Linear Pitch (NLP) estimation functions. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2009 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include "defines.h" +#include "nlp.h" +#include "dump.h" +#include "kiss_fft.h" +#undef TIMER +#include "machdep.h" + +#include +#include +#include + +/*---------------------------------------------------------------------------*\ + + DEFINES + +\*---------------------------------------------------------------------------*/ + +#define PMAX_M 600 /* maximum NLP analysis window size */ +#define COEFF 0.95 /* notch filter parameter */ +#define PE_FFT_SIZE 512 /* DFT size for pitch estimation */ +#define DEC 5 /* decimation factor */ +#define SAMPLE_RATE 8000 +#define PI 3.141592654 /* mathematical constant */ +#define T 0.1 /* threshold for local minima candidate */ +#define F0_MAX 500 +#define CNLP 0.3 /* post processor constant */ +#define NLP_NTAP 48 /* Decimation LPF order */ + +//#undef DUMP + +/*---------------------------------------------------------------------------*\ + + GLOBALS + +\*---------------------------------------------------------------------------*/ + +/* 48 tap 600Hz low pass FIR filter coefficients */ + +const float nlp_fir[] = { + -1.0818124e-03, + -1.1008344e-03, + -9.2768838e-04, + -4.2289438e-04, + 5.5034190e-04, + 2.0029849e-03, + 3.7058509e-03, + 5.1449415e-03, + 5.5924666e-03, + 4.3036754e-03, + 8.0284511e-04, + -4.8204610e-03, + -1.1705810e-02, + -1.8199275e-02, + -2.2065282e-02, + -2.0920610e-02, + -1.2808831e-02, + 3.2204775e-03, + 2.6683811e-02, + 5.5520624e-02, + 8.6305944e-02, + 1.1480192e-01, + 1.3674206e-01, + 1.4867556e-01, + 1.4867556e-01, + 1.3674206e-01, + 1.1480192e-01, + 8.6305944e-02, + 5.5520624e-02, + 2.6683811e-02, + 3.2204775e-03, + -1.2808831e-02, + -2.0920610e-02, + -2.2065282e-02, + -1.8199275e-02, + -1.1705810e-02, + -4.8204610e-03, + 8.0284511e-04, + 4.3036754e-03, + 5.5924666e-03, + 5.1449415e-03, + 3.7058509e-03, + 2.0029849e-03, + 5.5034190e-04, + -4.2289438e-04, + -9.2768838e-04, + -1.1008344e-03, + -1.0818124e-03 +}; + +typedef struct { + int m; + float w[PMAX_M/DEC]; /* DFT window */ + float sq[PMAX_M]; /* squared speech samples */ + float mem_x,mem_y; /* memory for notch filter */ + float mem_fir[NLP_NTAP]; /* decimation FIR filter memory */ + kiss_fft_cfg fft_cfg; /* kiss FFT config */ +} NLP; + +float test_candidate_mbe(COMP Sw[], COMP W[], float f0); +float post_process_mbe(COMP Fw[], int pmin, int pmax, float gmax, COMP Sw[], COMP W[], float *prev_Wo); +float post_process_sub_multiples(COMP Fw[], + int pmin, int pmax, float gmax, int gmax_bin, + float *prev_Wo); + +/*---------------------------------------------------------------------------*\ + + nlp_create() + + Initialisation function for NLP pitch estimator. + +\*---------------------------------------------------------------------------*/ + +void *nlp_create( +int m /* analysis window size */ +) +{ + NLP *nlp; + int i; + + assert(m <= PMAX_M); + + nlp = (NLP*)malloc(sizeof(NLP)); + if (nlp == NULL) + return NULL; + + nlp->m = m; + for(i=0; iw[i] = 0.5 - 0.5*cosf(2*PI*i/(m/DEC-1)); + } + + for(i=0; isq[i] = 0.0; + nlp->mem_x = 0.0; + nlp->mem_y = 0.0; + for(i=0; imem_fir[i] = 0.0; + + nlp->fft_cfg = kiss_fft_alloc (PE_FFT_SIZE, 0, NULL, NULL); + assert(nlp->fft_cfg != NULL); + + return (void*)nlp; +} + +/*---------------------------------------------------------------------------*\ + + nlp_destroy() + + Shut down function for NLP pitch estimator. + +\*---------------------------------------------------------------------------*/ + +void nlp_destroy(void *nlp_state) +{ + NLP *nlp; + assert(nlp_state != NULL); + nlp = (NLP*)nlp_state; + + KISS_FFT_FREE(nlp->fft_cfg); + free(nlp_state); +} + +/*---------------------------------------------------------------------------*\ + + nlp() + + Determines the pitch in samples using the Non Linear Pitch (NLP) + algorithm [1]. Returns the fundamental in Hz. Note that the actual + pitch estimate is for the centre of the M sample Sn[] vector, not + the current N sample input vector. This is (I think) a delay of 2.5 + frames with N=80 samples. You should align further analysis using + this pitch estimate to be centred on the middle of Sn[]. + + Two post processors have been tried, the MBE version (as discussed + in [1]), and a post processor that checks sub-multiples. Both + suffer occasional gross pitch errors (i.e. neither are perfect). In + the presence of background noise the sub-multiple algorithm tends + towards low F0 which leads to better sounding background noise than + the MBE post processor. + + A good way to test and develop the NLP pitch estimator is using the + tnlp (codec2/unittest) and the codec2/octave/plnlp.m Octave script. + + A pitch tracker searching a few frames forward and backward in time + would be a useful addition. + + References: + + [1] http://www.itr.unisa.edu.au/~steven/thesis/dgr.pdf Chapter 4 + +\*---------------------------------------------------------------------------*/ + +float nlp( + void *nlp_state, + float Sn[], /* input speech vector */ + int n, /* frames shift (no. new samples in Sn[]) */ + int pmin, /* minimum pitch value */ + int pmax, /* maximum pitch value */ + float *pitch, /* estimated pitch period in samples */ + COMP Sw[], /* Freq domain version of Sn[] */ + COMP W[], /* Freq domain window */ + float *prev_Wo +) +{ + NLP *nlp; + float notch; /* current notch filter output */ + COMP fw[PE_FFT_SIZE]; /* DFT of squared signal (input) */ + COMP Fw[PE_FFT_SIZE]; /* DFT of squared signal (output) */ + float gmax; + int gmax_bin; + int m, i,j; + float best_f0; + TIMER_VAR(start, tnotch, filter, peakpick, window, fft, magsq, shiftmem); + + assert(nlp_state != NULL); + nlp = (NLP*)nlp_state; + m = nlp->m; + + TIMER_SAMPLE(start); + + /* Square, notch filter at DC, and LP filter vector */ + + for(i=m-n; isq[i] = Sn[i]*Sn[i]; + + for(i=m-n; isq[i] - nlp->mem_x; + notch += COEFF*nlp->mem_y; + nlp->mem_x = nlp->sq[i]; + nlp->mem_y = notch; + nlp->sq[i] = notch + 1.0; /* With 0 input vectors to codec, + kiss_fft() would take a long + time to execute when running in + real time. Problem was traced + to kiss_fft function call in + this function. Adding this small + constant fixed problem. Not + exactly sure why. */ + } + + TIMER_SAMPLE_AND_LOG(tnotch, start, " square and notch"); + + for(i=m-n; imem_fir[j] = nlp->mem_fir[j+1]; + nlp->mem_fir[NLP_NTAP-1] = nlp->sq[i]; + + nlp->sq[i] = 0.0; + for(j=0; jsq[i] += nlp->mem_fir[j]*nlp_fir[j]; + } + + TIMER_SAMPLE_AND_LOG(filter, tnotch, " filter"); + + /* Decimate and DFT */ + + for(i=0; isq[i*DEC]*nlp->w[i]; + } + TIMER_SAMPLE_AND_LOG(window, filter, " window"); + #ifdef DUMP + dump_dec(Fw); + #endif + + kiss_fft(nlp->fft_cfg, (kiss_fft_cpx *)fw, (kiss_fft_cpx *)Fw); + TIMER_SAMPLE_AND_LOG(fft, window, " fft"); + + for(i=0; isq); + dump_Fw(Fw); + #endif + + /* find global peak */ + + gmax = 0.0; + gmax_bin = PE_FFT_SIZE*DEC/pmax; + for(i=PE_FFT_SIZE*DEC/pmax; i<=PE_FFT_SIZE*DEC/pmin; i++) { + if (Fw[i].real > gmax) { + gmax = Fw[i].real; + gmax_bin = i; + } + } + + TIMER_SAMPLE_AND_LOG(peakpick, magsq, " peak pick"); + + //#define POST_PROCESS_MBE + #ifdef POST_PROCESS_MBE + best_f0 = post_process_mbe(Fw, pmin, pmax, gmax, Sw, W, prev_Wo); + #else + best_f0 = post_process_sub_multiples(Fw, pmin, pmax, gmax, gmax_bin, prev_Wo); + #endif + + TIMER_SAMPLE_AND_LOG(shiftmem, peakpick, " post process"); + + /* Shift samples in buffer to make room for new samples */ + + for(i=0; isq[i] = nlp->sq[i+n]; + + /* return pitch and F0 estimate */ + + *pitch = (float)SAMPLE_RATE/best_f0; + + TIMER_SAMPLE_AND_LOG2(shiftmem, " shift mem"); + + TIMER_SAMPLE_AND_LOG2(start, " nlp int"); + + return(best_f0); +} + +/*---------------------------------------------------------------------------*\ + + post_process_sub_multiples() + + Given the global maximma of Fw[] we search integer submultiples for + local maxima. If local maxima exist and they are above an + experimentally derived threshold (OK a magic number I pulled out of + the air) we choose the submultiple as the F0 estimate. + + The rational for this is that the lowest frequency peak of Fw[] + should be F0, as Fw[] can be considered the autocorrelation function + of Sw[] (the speech spectrum). However sometimes due to phase + effects the lowest frequency maxima may not be the global maxima. + + This works OK in practice and favours low F0 values in the presence + of background noise which means the sinusoidal codec does an OK job + of synthesising the background noise. High F0 in background noise + tends to sound more periodic introducing annoying artifacts. + +\*---------------------------------------------------------------------------*/ + +float post_process_sub_multiples(COMP Fw[], + int pmin, int pmax, float gmax, int gmax_bin, + float *prev_Wo) +{ + int min_bin, cmax_bin; + int mult; + float thresh, best_f0; + int b, bmin, bmax, lmax_bin; + float lmax; + int prev_f0_bin; + + /* post process estimate by searching submultiples */ + + mult = 2; + min_bin = PE_FFT_SIZE*DEC/pmax; + cmax_bin = gmax_bin; + prev_f0_bin = *prev_Wo*(4000.0/PI)*(PE_FFT_SIZE*DEC)/SAMPLE_RATE; + + while(gmax_bin/mult >= min_bin) { + + b = gmax_bin/mult; /* determine search interval */ + bmin = 0.8*b; + bmax = 1.2*b; + if (bmin < min_bin) + bmin = min_bin; + + /* lower threshold to favour previous frames pitch estimate, + this is a form of pitch tracking */ + + if ((prev_f0_bin > bmin) && (prev_f0_bin < bmax)) + thresh = CNLP*0.5*gmax; + else + thresh = CNLP*gmax; + + lmax = 0; + lmax_bin = bmin; + for (b=bmin; b<=bmax; b++) /* look for maximum in interval */ + if (Fw[b].real > lmax) { + lmax = Fw[b].real; + lmax_bin = b; + } + + if (lmax > thresh) + if ((lmax > Fw[lmax_bin-1].real) && (lmax > Fw[lmax_bin+1].real)) { + cmax_bin = lmax_bin; + } + + mult++; + } + + best_f0 = (float)cmax_bin*SAMPLE_RATE/(PE_FFT_SIZE*DEC); + + return best_f0; +} + +/*---------------------------------------------------------------------------*\ + + post_process_mbe() + + Use the MBE pitch estimation algorithm to evaluate pitch candidates. This + works OK but the accuracy at low F0 is affected by NW, the analysis window + size used for the DFT of the input speech Sw[]. Also favours high F0 in + the presence of background noise which causes periodic artifacts in the + synthesised speech. + +\*---------------------------------------------------------------------------*/ + +float post_process_mbe(COMP Fw[], int pmin, int pmax, float gmax, COMP Sw[], COMP W[], float *prev_Wo) +{ + float candidate_f0; + float f0,best_f0; /* fundamental frequency */ + float e,e_min; /* MBE cost function */ + int i; + #ifdef DUMP + float e_hz[F0_MAX]; + #endif + #if !defined(NDEBUG) || defined(DUMP) + int bin; + #endif + float f0_min, f0_max; + float f0_start, f0_end; + + f0_min = (float)SAMPLE_RATE/pmax; + f0_max = (float)SAMPLE_RATE/pmin; + + /* Now look for local maxima. Each local maxima is a candidate + that we test using the MBE pitch estimation algotithm */ + + #ifdef DUMP + for(i=0; i Fw[i-1].real) && (Fw[i].real > Fw[i+1].real)) { + + /* local maxima found, lets test if it's big enough */ + + if (Fw[i].real > T*gmax) { + + /* OK, sample MBE cost function over +/- 10Hz range in 2.5Hz steps */ + + candidate_f0 = (float)i*SAMPLE_RATE/(PE_FFT_SIZE*DEC); + f0_start = candidate_f0-20; + f0_end = candidate_f0+20; + if (f0_start < f0_min) f0_start = f0_min; + if (f0_end > f0_max) f0_end = f0_max; + + for(f0=f0_start; f0<=f0_end; f0+= 2.5) { + e = test_candidate_mbe(Sw, W, f0); + #if !defined(NDEBUG) || defined(DUMP) + bin = floor(f0); assert((bin > 0) && (bin < F0_MAX)); + #endif + #ifdef DUMP + e_hz[bin] = e; + #endif + if (e < e_min) { + e_min = e; + best_f0 = f0; + } + } + + } + } + } + + /* finally sample MBE cost function around previous pitch estimate + (form of pitch tracking) */ + + candidate_f0 = *prev_Wo * SAMPLE_RATE/TWO_PI; + f0_start = candidate_f0-20; + f0_end = candidate_f0+20; + if (f0_start < f0_min) f0_start = f0_min; + if (f0_end > f0_max) f0_end = f0_max; + + for(f0=f0_start; f0<=f0_end; f0+= 2.5) { + e = test_candidate_mbe(Sw, W, f0); + #if !defined(NDEBUG) || defined(DUMP) + bin = floor(f0); assert((bin > 0) && (bin < F0_MAX)); + #endif + #ifdef DUMP + e_hz[bin] = e; + #endif + if (e < e_min) { + e_min = e; + best_f0 = f0; + } + } + + #ifdef DUMP + dump_e(e_hz); + #endif + + return best_f0; +} + +/*---------------------------------------------------------------------------*\ + + test_candidate_mbe() + + Returns the error of the MBE cost function for the input f0. + + Note: I think a lot of the operations below can be simplified as + W[].imag = 0 and has been normalised such that den always equals 1. + +\*---------------------------------------------------------------------------*/ + +float test_candidate_mbe( + COMP Sw[], + COMP W[], + float f0 +) +{ + COMP Sw_[FFT_ENC]; /* DFT of all voiced synthesised signal */ + int l,al,bl,m; /* loop variables */ + COMP Am; /* amplitude sample for this band */ + int offset; /* centers Hw[] about current harmonic */ + float den; /* denominator of Am expression */ + float error; /* accumulated error between originl and synthesised */ + float Wo; /* current "test" fundamental freq. */ + int L; + + L = floor((SAMPLE_RATE/2.0)/f0); + Wo = f0*(2*PI/SAMPLE_RATE); + + error = 0.0; + + /* Just test across the harmonics in the first 1000 Hz (L/4) */ + + for(l=1; l. +*/ + +#ifndef __NLP__ +#define __NLP__ + +#include "comp.h" + +void *nlp_create(int m); +void nlp_destroy(void *nlp_state); +float nlp(void *nlp_state, float Sn[], int n, int pmin, int pmax, + float *pitch, COMP Sw[], COMP W[], float *prev_Wo); + +#endif diff --git a/codec2/branches/0.3/src/octave.c b/codec2/branches/0.3/src/octave.c new file mode 100644 index 00000000..2ff5ad14 --- /dev/null +++ b/codec2/branches/0.3/src/octave.c @@ -0,0 +1,85 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: octave.c + AUTHOR......: David Rowe + DATE CREATED: April 28 2012 + + Functions to save C arrays in GNU Octave matrix format. The output text + file can be directly read into Octave using "load filename". + +\*---------------------------------------------------------------------------*/ + + +/* + Copyright (C) 2012 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include "octave.h" + +void octave_save_int(FILE *f, char name[], int data[], int rows, int cols) +{ + int r,c; + + fprintf(f, "# name: %s\n", name); + fprintf(f, "# type: matrix\n"); + fprintf(f, "# rows: %d\n", rows); + fprintf(f, "# columns: %d\n", cols); + + for(r=0; r. +*/ + +#ifndef __OCTAVE__ +#define __OCTAVE__ + +#include "comp.h" + +void octave_save_int(FILE *f, char name[], int data[], int rows, int cols); +void octave_save_float(FILE *f, char name[], float data[], int rows, int cols, int col_len); +void octave_save_complex(FILE *f, char name[], COMP data[], int rows, int cols, int col_len); + +#endif diff --git a/codec2/branches/0.3/src/os.h b/codec2/branches/0.3/src/os.h new file mode 100644 index 00000000..0dae9bfd --- /dev/null +++ b/codec2/branches/0.3/src/os.h @@ -0,0 +1,53 @@ +/* Generate using fir1(47,1/6) in Octave */ + +const float fdmdv_os_filter[]= { + -3.55606818e-04, + -8.98615286e-04, + -1.40119781e-03, + -1.71713852e-03, + -1.56471179e-03, + -6.28128960e-04, + 1.24522223e-03, + 3.83138676e-03, + 6.41309478e-03, + 7.85893186e-03, + 6.93514929e-03, + 2.79361991e-03, + -4.51051400e-03, + -1.36671853e-02, + -2.21034939e-02, + -2.64084653e-02, + -2.31425052e-02, + -9.84218694e-03, + 1.40648474e-02, + 4.67316298e-02, + 8.39615986e-02, + 1.19925275e-01, + 1.48381174e-01, + 1.64097819e-01, + 1.64097819e-01, + 1.48381174e-01, + 1.19925275e-01, + 8.39615986e-02, + 4.67316298e-02, + 1.40648474e-02, + -9.84218694e-03, + -2.31425052e-02, + -2.64084653e-02, + -2.21034939e-02, + -1.36671853e-02, + -4.51051400e-03, + 2.79361991e-03, + 6.93514929e-03, + 7.85893186e-03, + 6.41309478e-03, + 3.83138676e-03, + 1.24522223e-03, + -6.28128960e-04, + -1.56471179e-03, + -1.71713852e-03, + -1.40119781e-03, + -8.98615286e-04, + -3.55606818e-04 +}; + diff --git a/codec2/branches/0.3/src/pack.c b/codec2/branches/0.3/src/pack.c new file mode 100644 index 00000000..b0625645 --- /dev/null +++ b/codec2/branches/0.3/src/pack.c @@ -0,0 +1,140 @@ +/* + Copyright (C) 2010 Perens LLC + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include "defines.h" +#include "quantise.h" +#include + +/* Compile-time constants */ +/* Size of unsigned char in bits. Assumes 8 bits-per-char. */ +static const unsigned int WordSize = 8; + +/* Mask to pick the bit component out of bitIndex. */ +static const unsigned int IndexMask = 0x7; + +/* Used to pick the word component out of bitIndex. */ +static const unsigned int ShiftRight = 3; + +/** Pack a bit field into a bit string, encoding the field in Gray code. + * + * The output is an array of unsigned char data. The fields are efficiently + * packed into the bit string. The Gray coding is a naive attempt to reduce + * the effect of single-bit errors, we expect to do a better job as the + * codec develops. + * + * This code would be simpler if it just set one bit at a time in the string, + * but would hit the same cache line more often. I'm not sure the complexity + * gains us anything here. + * + * Although field is currently of int type rather than unsigned for + * compatibility with the rest of the code, indices are always expected to + * be >= 0. + */ +void +pack( + unsigned char * bitArray, /* The output bit string. */ + unsigned int * bitIndex, /* Index into the string in BITS, not bytes.*/ + int field, /* The bit field to be packed. */ + unsigned int fieldWidth/* Width of the field in BITS, not bytes. */ + ) +{ + pack_natural_or_gray(bitArray, bitIndex, field, fieldWidth, 1); +} + +void +pack_natural_or_gray( + unsigned char * bitArray, /* The output bit string. */ + unsigned int * bitIndex, /* Index into the string in BITS, not bytes.*/ + int field, /* The bit field to be packed. */ + unsigned int fieldWidth,/* Width of the field in BITS, not bytes. */ + unsigned int gray /* non-zero for gray coding */ + ) +{ + if (gray) { + /* Convert the field to Gray code */ + field = (field >> 1) ^ field; + } + + do { + unsigned int bI = *bitIndex; + unsigned int bitsLeft = WordSize - (bI & IndexMask); + unsigned int sliceWidth = + bitsLeft < fieldWidth ? bitsLeft : fieldWidth; + unsigned int wordIndex = bI >> ShiftRight; + + bitArray[wordIndex] |= + ((unsigned char)((field >> (fieldWidth - sliceWidth)) + << (bitsLeft - sliceWidth))); + + *bitIndex = bI + sliceWidth; + fieldWidth -= sliceWidth; + } while ( fieldWidth != 0 ); +} + +/** Unpack a field from a bit string, converting from Gray code to binary. + * + */ +int +unpack( + const unsigned char * bitArray, /* The input bit string. */ + unsigned int * bitIndex, /* Index into the string in BITS, not bytes.*/ + unsigned int fieldWidth/* Width of the field in BITS, not bytes. */ + ) +{ + return unpack_natural_or_gray(bitArray, bitIndex, fieldWidth, 1); +} + +/** Unpack a field from a bit string, to binary, optionally using + * natural or Gray code. + * + */ +int +unpack_natural_or_gray( + const unsigned char * bitArray, /* The input bit string. */ + unsigned int * bitIndex, /* Index into the string in BITS, not bytes.*/ + unsigned int fieldWidth,/* Width of the field in BITS, not bytes. */ + unsigned int gray /* non-zero for Gray coding */ + ) +{ + unsigned int field = 0; + unsigned int t; + + do { + unsigned int bI = *bitIndex; + unsigned int bitsLeft = WordSize - (bI & IndexMask); + unsigned int sliceWidth = + bitsLeft < fieldWidth ? bitsLeft : fieldWidth; + + field |= (((bitArray[bI >> ShiftRight] >> (bitsLeft - sliceWidth)) & ((1 << sliceWidth) - 1)) << (fieldWidth - sliceWidth)); + + *bitIndex = bI + sliceWidth; + fieldWidth -= sliceWidth; + } while ( fieldWidth != 0 ); + + if (gray) { + /* Convert from Gray code to binary. Works for maximum 8-bit fields. */ + t = field ^ (field >> 8); + t ^= (t >> 4); + t ^= (t >> 2); + t ^= (t >> 1); + } + else { + t = field; + } + + return t; +} diff --git a/codec2/branches/0.3/src/phase.c b/codec2/branches/0.3/src/phase.c new file mode 100644 index 00000000..e1476862 --- /dev/null +++ b/codec2/branches/0.3/src/phase.c @@ -0,0 +1,253 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: phase.c + AUTHOR......: David Rowe + DATE CREATED: 1/2/09 + + Functions for modelling and synthesising phase. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2009 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not,see . +*/ + +#include "defines.h" +#include "phase.h" +#include "kiss_fft.h" +#include "comp.h" +#include "sine.h" + +#include +#include +#include +#include +#include + +/*---------------------------------------------------------------------------*\ + + aks_to_H() + + Samples the complex LPC synthesis filter spectrum at the harmonic + frequencies. + +\*---------------------------------------------------------------------------*/ + +void aks_to_H( + kiss_fft_cfg fft_fwd_cfg, + MODEL *model, /* model parameters */ + float aks[], /* LPC's */ + float G, /* energy term */ + COMP H[], /* complex LPC spectral samples */ + int order +) +{ + COMP pw[FFT_ENC]; /* power spectrum (input) */ + COMP Pw[FFT_ENC]; /* power spectrum (output) */ + int i,m; /* loop variables */ + int am,bm; /* limits of current band */ + float r; /* no. rads/bin */ + float Em; /* energy in band */ + float Am; /* spectral amplitude sample */ + int b; /* centre bin of harmonic */ + float phi_; /* phase of LPC spectra */ + + r = TWO_PI/(FFT_ENC); + + /* Determine DFT of A(exp(jw)) ------------------------------------------*/ + + for(i=0; iL; m++) { + am = (int)((m - 0.5)*model->Wo/r + 0.5); + bm = (int)((m + 0.5)*model->Wo/r + 0.5); + b = (int)(m*model->Wo/r + 0.5); + + Em = 0.0; + for(i=am; iWo)*N/2; + */ + + ex_phase[0] += (model->Wo)*N; + ex_phase[0] -= TWO_PI*floorf(ex_phase[0]/TWO_PI + 0.5); + + for(m=1; m<=model->L; m++) { + + /* generate excitation */ + + if (model->voiced) { + + Ex[m].real = cosf(ex_phase[0]*m); + Ex[m].imag = sinf(ex_phase[0]*m); + } + else { + + /* When a few samples were tested I found that LPC filter + phase is not needed in the unvoiced case, but no harm in + keeping it. + */ + float phi = TWO_PI*(float)codec2_rand()/CODEC2_RAND_MAX; + Ex[m].real = cosf(phi); + Ex[m].imag = sinf(phi); + } + + /* filter using LPC filter */ + + A_[m].real = H[m].real*Ex[m].real - H[m].imag*Ex[m].imag; + A_[m].imag = H[m].imag*Ex[m].real + H[m].real*Ex[m].imag; + + /* modify sinusoidal phase */ + + new_phi = atan2f(A_[m].imag, A_[m].real+1E-12); + model->phi[m] = new_phi; + } + +} + diff --git a/codec2/branches/0.3/src/phase.h b/codec2/branches/0.3/src/phase.h new file mode 100644 index 00000000..367948df --- /dev/null +++ b/codec2/branches/0.3/src/phase.h @@ -0,0 +1,39 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: phase.h + AUTHOR......: David Rowe + DATE CREATED: 1/2/09 + + Functions for modelling phase. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2009 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#ifndef __PHASE__ +#define __PHASE__ + +#include "kiss_fft.h" + +void phase_synth_zero_order(kiss_fft_cfg fft_dec_cfg, + MODEL *model, + float aks[], + float *ex_phase, + int order); + +#endif diff --git a/codec2/branches/0.3/src/phaseexp.c b/codec2/branches/0.3/src/phaseexp.c new file mode 100644 index 00000000..be2ad9be --- /dev/null +++ b/codec2/branches/0.3/src/phaseexp.c @@ -0,0 +1,1455 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: phaseexp.c + AUTHOR......: David Rowe + DATE CREATED: June 2012 + + Experimental functions for quantising, modelling and synthesising phase. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2012 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not,see . +*/ + +#include "defines.h" +#include "phase.h" +#include "kiss_fft.h" +#include "comp.h" + +#include +#include +#include +#include +#include + +/* Bruce Perens' funcs to load codebook files */ + +struct codebook { + unsigned int k; + unsigned int log2m; + unsigned int m; + COMP *cb; + unsigned int offset; +}; + +static const char format[] = +"The table format must be:\n" +"\tTwo integers describing the dimensions of the codebook.\n" +"\tThen, enough numbers to fill the specified dimensions.\n"; + +float get_float(FILE * in, const char * name, char * * cursor, char * buffer, int size) +{ + for ( ; ; ) { + char * s = *cursor; + char c; + + while ( (c = *s) != '\0' && !isdigit(c) && c != '-' && c != '.' ) + s++; + + /* Comments start with "#" and continue to the end of the line. */ + if ( c != '\0' && c != '#' ) { + char * end = 0; + float f = 0; + + f = strtod(s, &end); + + if ( end != s ) + *cursor = end; + return f; + } + + if ( fgets(buffer, size, in) == NULL ) { + fprintf(stderr, "%s: Format error. %s\n", name, format); + exit(1); + } + *cursor = buffer; + } +} + +static struct codebook *load(const char * name) +{ + FILE *file; + char line[2048]; + char *cursor = line; + struct codebook *b = malloc(sizeof(struct codebook)); + int i; + int size; + float angle; + + file = fopen(name, "rt"); + assert(file != NULL); + + *cursor = '\0'; + + b->k = (int)get_float(file, name, &cursor, line, sizeof(line)); + b->m = (int)get_float(file, name ,&cursor, line, sizeof(line)); + size = b->k * b->m; + + b->cb = (COMP *)malloc(size * sizeof(COMP)); + + for ( i = 0; i < size; i++ ) { + angle = get_float(file, name, &cursor, line, sizeof(line)); + b->cb[i].real = cos(angle); + b->cb[i].imag = sin(angle); + } + + fclose(file); + + return b; +} + + +/* states for phase experiments */ + +struct PEXP { + float phi1; + float phi_prev[MAX_AMP]; + float Wo_prev; + int frames; + float snr; + float var; + int var_n; + struct codebook *vq1,*vq2,*vq3,*vq4,*vq5; + float vq_var; + int vq_var_n; + MODEL prev_model; + int state; +}; + + +/*---------------------------------------------------------------------------* \ + + phase_experiment_create() + + Inits states for phase quantisation experiments. + +\*---------------------------------------------------------------------------*/ + +struct PEXP * phase_experiment_create() { + struct PEXP *pexp; + int i; + + pexp = (struct PEXP *)malloc(sizeof(struct PEXP)); + assert (pexp != NULL); + + pexp->phi1 = 0; + for(i=0; iphi_prev[i] = 0.0; + pexp->Wo_prev = 0.0; + pexp->frames = 0; + pexp->snr = 0.0; + pexp->var = 0.0; + pexp->var_n = 0; + + /* smoothed 10th order for 1st 1 khz */ + //pexp->vq1 = load("../unittest/ph1_10_1024.txt"); + //pexp->vq1->offset = 0; + + /* load experimental phase VQ */ + + //pexp->vq1 = load("../unittest/testn1_20_1024.txt"); + pexp->vq1 = load("../unittest/test.txt"); + //pexp->vq2 = load("../unittest/testn21_40_1024.txt"); + pexp->vq2 = load("../unittest/test11_20_1024.txt"); + pexp->vq3 = load("../unittest/test21_30_1024.txt"); + pexp->vq4 = load("../unittest/test31_40_1024.txt"); + pexp->vq5 = load("../unittest/test41_60_1024.txt"); + pexp->vq1->offset = 0; + pexp->vq2->offset = 10; + pexp->vq3->offset = 20; + pexp->vq4->offset = 30; + pexp->vq5->offset = 40; + + pexp->vq_var = 0.0; + pexp->vq_var_n = 0; + + pexp->state = 0; + + return pexp; +} + + +/*---------------------------------------------------------------------------* \ + + phase_experiment_destroy() + +\*---------------------------------------------------------------------------*/ + +void phase_experiment_destroy(struct PEXP *pexp) { + assert(pexp != NULL); + if (pexp->snr != 0.0) + printf("snr: %4.2f dB\n", pexp->snr/pexp->frames); + if (pexp->var != 0.0) + printf("var...: %4.3f std dev...: %4.3f (%d non zero phases)\n", + pexp->var/pexp->var_n, sqrt(pexp->var/pexp->var_n), pexp->var_n); + if (pexp->vq_var != 0.0) + printf("vq var: %4.3f vq std dev: %4.3f (%d non zero phases)\n", + pexp->vq_var/pexp->vq_var_n, sqrt(pexp->vq_var/pexp->vq_var_n), pexp->vq_var_n); + free(pexp); +} + + +/*---------------------------------------------------------------------------* \ + + Various test and experimental functions ................ + +\*---------------------------------------------------------------------------*/ + +/* Bubblesort to find highest amplitude harmonics */ + +struct AMPINDEX { + float amp; + int index; +}; + +static void bubbleSort(struct AMPINDEX numbers[], int array_size) +{ + int i, j; + struct AMPINDEX temp; + + for (i = (array_size - 1); i > 0; i--) + { + for (j = 1; j <= i; j++) + { + //printf("i %d j %d %f %f \n", i, j, numbers[j-1].amp, numbers[j].amp); + if (numbers[j-1].amp < numbers[j].amp) + { + temp = numbers[j-1]; + numbers[j-1] = numbers[j]; + numbers[j] = temp; + } + } + } +} + + +static void print_pred_error(struct PEXP *pexp, MODEL *model, int start, int end, float mag_thresh) { + int i; + float mag; + + mag = 0.0; + for(i=start; i<=end; i++) + mag += model->A[i]*model->A[i]; + mag = 10*log10(mag/(end-start)); + + if (mag > mag_thresh) { + for(i=start; i<=end; i++) { + float pred = pexp->phi_prev[i] + N*i*(model->Wo + pexp->Wo_prev)/2.0; + float err = pred - model->phi[i]; + err = atan2(sin(err),cos(err)); + printf("%f\n",err); + } + //printf("\n"); + } + +} + + +static void predict_phases(struct PEXP *pexp, MODEL *model, int start, int end) { + int i; + + for(i=start; i<=end; i++) { + model->phi[i] = pexp->phi_prev[i] + N*i*model->Wo; + } + +} +static float refine_Wo(struct PEXP *pexp, + MODEL *model, + int start, + int end); + +/* Fancy state based phase prediction. Actually works OK on most utterances, + but could use some tuning. Breaks down a bit on mmt1. */ + +static void predict_phases_state(struct PEXP *pexp, MODEL *model, int start, int end) { + int i, next_state; + float best_Wo, dWo; + + //best_Wo = refine_Wo(pexp, model, start, end); + //best_Wo = (model->Wo + pexp->Wo_prev)/2.0; + best_Wo = model->Wo; + + dWo = fabs(model->Wo - pexp->Wo_prev)/model->Wo; + next_state = pexp->state; + switch(pexp->state) { + case 0: + if (dWo < 0.1) { + /* UV -> V transition, so start with phases in lock. They will + drift a bit over voiced track which is kinda what we want, so + we don't get clicky speech. + */ + next_state = 1; + for(i=start; i<=end; i++) + pexp->phi_prev[i] = i*pexp->phi1; + } + + break; + case 1: + if (dWo > 0.1) + next_state = 0; + break; + } + pexp->state = next_state; + + if (pexp->state == 0) + for(i=start; i<=end; i++) { + model->phi[i] = PI*(1.0 - 2.0*rand()/RAND_MAX); + } + else + for(i=start; i<=end; i++) { + model->phi[i] = pexp->phi_prev[i] + N*i*best_Wo; + } + printf("state %d\n", pexp->state); +} + +static void struct_phases(struct PEXP *pexp, MODEL *model, int start, int end) { + int i; + + for(i=start; i<=end; i++) + model->phi[i] = pexp->phi1*i; + +} + + +static void predict_phases2(struct PEXP *pexp, MODEL *model, int start, int end) { + int i; + float pred, str, diff; + + for(i=start; i<=end; i++) { + pred = pexp->phi_prev[i] + N*i*model->Wo; + str = pexp->phi1*i; + diff = str - pred; + diff = atan2(sin(diff), cos(diff)); + if (diff > 0) + pred += PI/16; + else + pred -= PI/16; + model->phi[i] = pred; + } + +} + +static void rand_phases(MODEL *model, int start, int end) { + int i; + + for(i=start; i<=end; i++) + model->phi[i] = PI*(1.0 - 2.0*(float)rand()/RAND_MAX); + +} + +static void quant_phase(float *phase, float min, float max, int bits) { + int levels = 1 << bits; + int index; + float norm, step; + + norm = (*phase - min)/(max - min); + index = floor(levels*norm); + + //printf("phase %f norm %f index %d ", *phase, norm, index); + if (index < 0 ) index = 0; + if (index > (levels-1)) index = levels-1; + //printf("index %d ", index); + step = (max - min)/levels; + *phase = min + step*index + 0.5*step; + //printf("step %f phase %f\n", step, *phase); +} + +static void quant_phases(MODEL *model, int start, int end, int bits) { + int i; + + for(i=start; i<=end; i++) { + quant_phase(&model->phi[i], -PI, PI, bits); + } +} + +static void fixed_bits_per_frame(struct PEXP *pexp, MODEL *model, int m, int budget) { + int res, finished; + + res = 3; + finished = 0; + + while(!finished) { + if (m > model->L/2) + res = 2; + if (((budget - res) < 0) || (m > model->L)) + finished = 1; + else { + quant_phase(&model->phi[m], -PI, PI, res); + budget -= res; + m++; + } + } + printf("m: %d L: %d budget: %d\n", m, model->L, budget); + predict_phases(pexp, model, m, model->L); + //rand_phases(model, m, model->L); +} + +/* used to plot histogram of quantisation error, for 3 bits, 8 levels, + should be uniform between +/- PI/8 */ + +static void check_phase_quant(MODEL *model, float tol) +{ + int m; + float phi_before[MAX_AMP]; + + for(m=1; m<=model->L; m++) + phi_before[m] = model->phi[m]; + + quant_phases(model, 1, model->L, 3); + + for(m=1; m<=model->L; m++) { + float err = phi_before[m] - model->phi[m]; + printf("%f\n", err); + if (fabs(err) > tol) + exit(0); + } +} + + +static float est_phi1(MODEL *model, int start, int end) +{ + int m; + float delta, s, c, phi1_est; + + if (end > model->L) + end = model->L; + + s = c = 0.0; + for(m=start; mphi[m+1] - model->phi[m]; + s += sin(delta); + c += cos(delta); + } + + phi1_est = atan2(s,c); + + return phi1_est; +} + +static void print_phi1_pred_error(MODEL *model, int start, int end) +{ + int m; + float phi1_est; + + phi1_est = est_phi1(model, start, end); + + for(m=start; mphi[m+1] - model->phi[m] - phi1_est; + err = atan2(sin(err),cos(err)); + printf("%f\n", err); + } +} + + +static void first_order_band(MODEL *model, int start, int end, float phi1_est) +{ + int m; + float pred_err, av_pred_err; + float c,s; + + s = c = 0.0; + for(m=start; mphi[m] - phi1_est*m; + s += sin(pred_err); + c += cos(pred_err); + } + + av_pred_err = atan2(s,c); + for(m=start; mphi[m] = av_pred_err + phi1_est*m; + model->phi[m] = atan2(sin(model->phi[m]), cos(model->phi[m])); + } + +} + + +static void sub_linear(MODEL *model, int start, int end, float phi1_est) +{ + int m; + + for(m=start; mphi[m] = m*phi1_est; + } +} + + +static void top_amp(struct PEXP *pexp, MODEL *model, int start, int end, int n_harm, int pred) +{ + int removed = 0, not_removed = 0; + int top, i, j; + struct AMPINDEX sorted[MAX_AMP]; + + /* sort into ascending order of amplitude */ + + printf("\n"); + for(i=start,j=0; iA[i]; + sorted[j].index = i; + printf("%f ", model->A[i]); + } + bubbleSort(sorted, end-start); + + printf("\n"); + for(j=0; jA[i] == sorted[j].amp) { + top = 1; + assert(i == sorted[j].index); + } + } + + #define ALTTOP + #ifdef ALTTOP + model->phi[i] = 0.0; /* make sure */ + if (top) { + model->phi[i] = i*pexp->phi1; + removed++; + } + else { + model->phi[i] = PI*(1.0 - 2.0*(float)rand()/RAND_MAX); // note: try rand for higher harms + removed++; + } + #else + if (!top) { + model->phi[i] = 0.0; /* make sure */ + if (pred) { + //model->phi[i] = pexp->phi_prev[i] + i*N*(model->Wo + pexp->Wo_prev)/2.0; + model->phi[i] = i*model->phi[1]; + } + else + model->phi[i] = PI*(1.0 - 2.0*(float)rand()/RAND_MAX); // note: try rand for higher harms + removed++; + } + else { + /* need to make this work thru budget of bits */ + quant_phase(&model->phi[i], -PI, PI, 3); + not_removed++; + } + #endif + } + printf("dim: %d rem %d not_rem %d\n", end-start, removed, not_removed); + +} + + +static void limit_prediction_error(struct PEXP *pexp, MODEL *model, int start, int end, float limit) +{ + int i; + float pred, pred_error, error; + + for(i=start; i<=end; i++) { + pred = pexp->phi_prev[i] + N*i*(model->Wo + pexp->Wo_prev)/2.0; + pred_error = pred - model->phi[i]; + pred_error -= TWO_PI*floor((pred_error+PI)/TWO_PI); + quant_phase(&pred_error, -limit, limit, 2); + + error = pred - pred_error - model->phi[i]; + error -= TWO_PI*floor((error+PI)/TWO_PI); + printf("%f\n", pred_error); + model->phi[i] = pred - pred_error; + } +} + + +static void quant_prediction_error(struct PEXP *pexp, MODEL *model, int start, int end, float limit) +{ + int i; + float pred, pred_error; + + for(i=start; i<=end; i++) { + pred = pexp->phi_prev[i] + N*i*(model->Wo + pexp->Wo_prev)/2.0; + pred_error = pred - model->phi[i]; + pred_error -= TWO_PI*floor((pred_error+PI)/TWO_PI); + + printf("%f\n", pred_error); + model->phi[i] = pred - pred_error; + } +} + + +static void print_sparse_pred_error(struct PEXP *pexp, MODEL *model, int start, int end, float mag_thresh) +{ + int i, index; + float mag, pred, error; + float sparse_pe[MAX_AMP]; + + mag = 0.0; + for(i=start; i<=end; i++) + mag += model->A[i]*model->A[i]; + mag = 10*log10(mag/(end-start)); + + if (mag > mag_thresh) { + for(i=0; iphi_prev[i] + N*i*(model->Wo + pexp->Wo_prev)/2.0; + error = pred - model->phi[i]; + error = atan2(sin(error),cos(error)); + + index = MAX_AMP*i*model->Wo/PI; + assert(index < MAX_AMP); + sparse_pe[index] = error; + } + + /* dump spare phase vector in polar format */ + + for(i=0; iL; m++) { + signal += model->A[m]*model->A[m]; + diff = cos(model->phi[m]) - cos(before[m]); + noise += pow(model->A[m]*diff, 2.0); + diff = sin(model->phi[m]) - sin(before[m]); + noise += pow(model->A[m]*diff, 2.0); + //printf("%f %f\n", before[m], model->phi[m]); + } + //printf("%f %f snr = %f\n", signal, noise, 10.0*log10(signal/noise)); + pexp->snr += 10.0*log10(signal/noise); +} + + +static void update_variance_calc(struct PEXP *pexp, MODEL *model, float before[]) +{ + int m; + float diff; + + for(m=1; mL; m++) { + diff = model->phi[m] - before[m]; + diff = atan2(sin(diff), cos(diff)); + pexp->var += diff*diff; + } + pexp->var_n += model->L; +} + +void print_vec(COMP cb[], int d, int e) +{ + int i,j; + + for(j=0; jWo + pexp->Wo_prev)/2.0; + best_var = 1E32; + for(Wo=0.97*Wo_est; Wo<=1.03*Wo_est; Wo+=0.001*Wo_est) { + + /* predict phase and sum differences between harmonics */ + + var = 0.0; + for(i=start; i<=end; i++) { + pred = pexp->phi_prev[i] + N*i*Wo; + error = pred - model->phi[i]; + error = atan2(sin(error),cos(error)); + var += error*error; + } + + if (var < best_var) { + best_var = var; + best_Wo = Wo; + } + } + + return best_Wo; +} + + +static void split_vq(COMP sparse_pe_out[], struct PEXP *pexp, struct codebook *vq, float weights[], COMP sparse_pe_in[]) +{ + int i, j, non_zero, vq_ind; + + //printf("\n offset %d k %d m %d j: ", vq->offset, vq->k, vq->m); + vq_ind = vq_phase(vq->cb, &sparse_pe_in[vq->offset], &weights[vq->offset], vq->k, vq->m, &pexp->vq_var); + + non_zero = 0; + for(i=0, j=vq->offset; ik; i++,j++) { + //printf("%f ", atan2(sparse_pe[i].imag, sparse_pe[i].real)); + if ((sparse_pe_in[j].real != 0.0) && (sparse_pe_in[j].imag != 0.0)) { + //printf("%d ", j); + sparse_pe_out[j] = vq->cb[vq->k * vq_ind + i]; + non_zero++; + } + } + pexp->vq_var_n += non_zero; +} + + +static void sparse_vq_pred_error(struct PEXP *pexp, + MODEL *model +) +{ + int i, index; + float pred, error, error_q_angle, best_Wo; + COMP sparse_pe_in[MAX_AMP], sparse_pe_out[MAX_AMP]; + float weights[MAX_AMP]; + COMP error_q_rect; + + best_Wo = refine_Wo(pexp, model, 1, model->L); + //best_Wo = (model->Wo + pexp->Wo_prev)/2.0; + + /* transform to sparse pred error vector */ + + for(i=0; iL; i++) { + pred = pexp->phi_prev[i] + N*i*best_Wo; + error = pred - model->phi[i]; + + index = MAX_AMP*i*model->Wo/PI; + assert(index < MAX_AMP); + sparse_pe_in[index].real = cos(error); + sparse_pe_in[index].imag = sin(error); + sparse_pe_out[index] = sparse_pe_in[index]; + weights[index] = model->A[i]; + //printf("%d ", index); + } + + /* vector quantise */ + + split_vq(sparse_pe_out, pexp, pexp->vq1, weights, sparse_pe_in); + split_vq(sparse_pe_out, pexp, pexp->vq2, weights, sparse_pe_in); + split_vq(sparse_pe_out, pexp, pexp->vq3, weights, sparse_pe_in); + split_vq(sparse_pe_out, pexp, pexp->vq4, weights, sparse_pe_in); + split_vq(sparse_pe_out, pexp, pexp->vq5, weights, sparse_pe_in); + + /* transform quantised phases back */ + + for(i=1; i<=model->L; i++) { + pred = pexp->phi_prev[i] + N*i*best_Wo; + + index = MAX_AMP*i*model->Wo/PI; + assert(index < MAX_AMP); + error_q_rect = sparse_pe_out[index]; + error_q_angle = atan2(error_q_rect.imag, error_q_rect.real); + model->phi[i] = pred - error_q_angle; + model->phi[i] = atan2(sin(model->phi[i]), cos(model->phi[i])); + } +} + + +static void predict_phases1(struct PEXP *pexp, MODEL *model, int start, int end) { + int i; + float best_Wo; + + best_Wo = refine_Wo(pexp, model, 1, model->L); + + for(i=start; i<=end; i++) { + model->phi[i] = pexp->phi_prev[i] + N*i*best_Wo; + } +} + + +/* + This functions tests theory that some bands can be combined together + due to less frequency resolution at higher frequencies. This will + reduce the amount of information we need to encode. +*/ + +void smooth_phase(struct PEXP *pexp, MODEL *model, int mode) +{ + int m, i, j, index, step, v, en, nav, st; + COMP sparse_pe_in[MAX_AMP], av; + COMP sparse_pe_out[MAX_AMP]; + COMP smoothed[MAX_AMP]; + float best_Wo, pred, err; + float weights[MAX_AMP]; + float avw, smoothed_weights[MAX_AMP]; + COMP smoothed_in[MAX_AMP], smoothed_out[MAX_AMP]; + + best_Wo = refine_Wo(pexp, model, 1, model->L); + + for(m=0; mL; m++) { + pred = pexp->phi_prev[m] + N*m*best_Wo; + err = model->phi[m] - pred; + err = atan2(sin(err),cos(err)); + + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + sparse_pe_in[index].real = model->A[m]*cos(err); + sparse_pe_in[index].imag = model->A[m]*sin(err); + sparse_pe_out[index] = sparse_pe_in[index]; + weights[index] = model->A[m]; + } + + /* now combine samples at high frequencies to reduce dimension */ + + step = 2; + st = 0; + for(i=st,v=0; i (MAX_AMP-1)) + en = MAX_AMP-1; + for(j=i; jvq1, smoothed_weights, smoothed_in); + for(i=0; i (MAX_AMP-1)) + en = MAX_AMP-1; + for(j=i; jL; m++) { + index = MAX_AMP*m*model->Wo/PI; + assert(index < MAX_AMP); + pred = pexp->phi_prev[m] + N*m*best_Wo; + err = atan2(sparse_pe_out[index].imag, sparse_pe_out[index].real); + model->phi[m] = pred + err; + } + +} + +/* + Another version of a functions that tests the theory that some bands + can be combined together due to less frequency resolution at higher + frequencies. This will reduce the amount of information we need to + encode. +*/ + +void smooth_phase2(struct PEXP *pexp, MODEL *model) { + float m; + float step; + int a,b,h,i; + float best_Wo, pred, err, s,c, phi1_; + + best_Wo = refine_Wo(pexp, model, 1, model->L); + + step = (float)model->L/30; + printf("\nL: %d step: %3.2f am,bm: ", model->L, step); + for(m=(float)model->L/4; m<=model->L; m+=step) { + a = floor(m); + b = floor(m+step); + if (b > model->L) b = model->L; + h = b-a; + + printf("%d,%d,(%d) ", a, b, h); + c = s = 0.0; + if (h>1) { + for(i=a; iphi_prev[i] + N*i*best_Wo; + err = model->phi[i] - pred; + c += cos(err); s += sin(err); + } + phi1_ = atan2(s,c); + for(i=a; iphi_prev[i] + N*i*best_Wo; + printf("%d: %4.3f -> ", i, model->phi[i]); + model->phi[i] = pred + phi1_; + model->phi[i] = atan2(sin(model->phi[i]),cos(model->phi[i])); + printf("%4.3f ", model->phi[i]); + } + } + } +} + + +#define MAX_BINS 40 +//static float bins[] = {2600.0, 2800.0, 3000.0, 3200.0, 3400.0, 3600.0, 3800.0, 4000.0}; +static float bins[] = {/* + + 1000.0, 1100.0, 1200.0, 1300.0, 1400.0, + 1500.0, 1600.0, 1700.0, 1800.0, 1900.0,*/ + + 2000.0, 2400.0, 2800.0, + 3000.0, 3400.0, 3600.0, 4000.0}; + +void smooth_phase3(struct PEXP *pexp, MODEL *model) { + int m, i; + int nbins; + int b; + float f, best_Wo, pred, err; + COMP av[MAX_BINS]; + + nbins = sizeof(bins)/sizeof(float); + best_Wo = refine_Wo(pexp, model, 1, model->L); + + /* clear all bins */ + + for(i=0; iL; m++) { + f = m*model->Wo*FS/TWO_PI; + if (f > bins[0]) { + + /* find bin */ + + for(i=0; i bins[i]) && (f <= bins[i+1])) + b = i; + assert(b < MAX_BINS); + + /* est predicted phase from average */ + + pred = pexp->phi_prev[m] + N*m*best_Wo; + err = model->phi[m] - pred; + av[b].real += cos(err); av[b].imag += sin(err); + } + + } + + /* use averages to est phases */ + + for(m=1; m<=model->L; m++) { + f = m*model->Wo*FS/TWO_PI; + if (f > bins[0]) { + + /* find bin */ + + for(i=0; i bins[i]) && (f <= bins[i+1])) + b = i; + assert(b < MAX_BINS); + + /* add predicted phase error to this bin */ + + printf("L %d m %d f %4.f b %d\n", model->L, m, f, b); + + pred = pexp->phi_prev[m] + N*m*best_Wo; + err = atan2(av[b].imag, av[b].real); + printf(" %d: %4.3f -> ", m, model->phi[m]); + model->phi[m] = pred + err; + model->phi[m] = atan2(sin(model->phi[m]),cos(model->phi[m])); + printf("%4.3f\n", model->phi[m]); + } + } + printf("\n"); +} + + +/* + Try to code the phase of the largest amplitude in each band. Randomise the + phase of the other harmonics. The theory is that only the largest harmonic + will be audible. +*/ + +void cb_phase1(struct PEXP *pexp, MODEL *model) { + int m, i; + int nbins; + int b; + float f, best_Wo; + float max_val[MAX_BINS]; + int max_ind[MAX_BINS]; + + nbins = sizeof(bins)/sizeof(float); + best_Wo = refine_Wo(pexp, model, 1, model->L); + + for(i=0; iL; m++) { + f = m*model->Wo*FS/TWO_PI; + if (f > bins[0]) { + + /* find bin */ + + for(i=0; i bins[i]) && (f <= bins[i+1])) + b = i; + assert(b < MAX_BINS); + + if (model->A[m] > max_val[b]) { + max_val[b] = model->A[m]; + max_ind[b] = m; + } + } + + } + + /* randomise phase of other harmonics */ + + for(m=1; m<=model->L; m++) { + f = m*model->Wo*FS/TWO_PI; + if (f > bins[0]) { + + /* find bin */ + + for(i=0; i bins[i]) && (f <= bins[i+1])) + b = i; + assert(b < MAX_BINS); + + if (m != max_ind[b]) + model->phi[m] = pexp->phi_prev[m] + N*m*best_Wo; + } + } +} + + +/* + Theory is only the phase of the envelope of signal matters within a + Critical Band. So we estimate the position of an impulse that + approximates the envelope of the signal. +*/ + +void cb_phase2(struct PEXP *pexp, MODEL *model) { + int st, m, i, a, b, step; + float diff,w,c,s,phi1_; + float A[MAX_AMP]; + + for(m=1; m<=model->L; m++) { + A[m] = model->A[m]; + model->A[m] = 0; + } + + st = 2*model->L/4; + step = 3; + model->phi[1] = pexp->phi_prev[1] + (pexp->Wo_prev+model->Wo)*N/2.0; + + printf("L=%d ", model->L); + for(m=st; m model->L) + b = model->L; + + c = s = 0; + for(i=a; iphi[i+1] - model->phi[i]; + //w = (model->A[i+1] + model->A[i])/2; + w = 1.0; + c += w*cos(diff); s += w*sin(diff); + } + phi1_ = atan2(s,c); + printf("replacing: "); + for(i=a; iphi[i] = i*phi1_; + //model->phi[i] = i*model->phi[1]; + //model->phi[i] = m*(pexp->Wo_prev+model->Wo)*N/2.0; + model->A[m] = A[m]; + printf("%d ", i); + } + printf(" . "); + } + printf("\n"); +} + + +static void smooth_phase4(MODEL *model) { + int m; + float phi_m, phi_m_1; + + if (model->L > 25) { + printf("\nL %d\n", model->L); + for(m=model->L/2; m<=model->L; m+=2) { + if ((m+1) <= model->L) { + phi_m = (model->phi[m] - model->phi[m+1])/2.0; + phi_m_1 = (model->phi[m+1] - model->phi[m])/2.0; + model->phi[m] = phi_m; + model->phi[m+1] = phi_m_1; + printf("%d %4.3f %4.3f ", m, phi_m, phi_m_1); + } + } + } + +} + +/* try repeating last frame, just advance phases to account for time shift */ + +static void repeat_phases(struct PEXP *pexp, MODEL *model) { + int m; + + *model = pexp->prev_model; + for(m=1; m<=model->L; m++) + model->phi[m] += N*m*model->Wo; + +} + +/*---------------------------------------------------------------------------*\ + + phase_experiment() + + Phase quantisation experiments. + +\*---------------------------------------------------------------------------*/ + +void phase_experiment(struct PEXP *pexp, MODEL *model, char *arg) { + int m; + float before[MAX_AMP]; + + assert(pexp != NULL); + memcpy(before, &model->phi[0], sizeof(float)*MAX_AMP); + + if (strcmp(arg,"q3") == 0) { + quant_phases(model, 1, model->L, 3); + update_snr_calc(pexp, model, before); + update_variance_calc(pexp, model, before); + } + + if (strcmp(arg,"dec2") == 0) { + if ((pexp->frames % 2) != 0) { + predict_phases(pexp, model, 1, model->L); + update_snr_calc(pexp, model, before); + update_variance_calc(pexp, model, before); + } + } + + if (strcmp(arg,"repeat") == 0) { + if ((pexp->frames % 2) != 0) { + repeat_phases(pexp, model); + update_snr_calc(pexp, model, before); + update_variance_calc(pexp, model, before); + } + } + + if (strcmp(arg,"vq") == 0) { + sparse_vq_pred_error(pexp, model); + update_snr_calc(pexp, model, before); + update_variance_calc(pexp, model, before); + } + + if (strcmp(arg,"pred") == 0) + predict_phases_state(pexp, model, 1, model->L); + + if (strcmp(arg,"pred1k") == 0) + predict_phases(pexp, model, 1, model->L/4); + + if (strcmp(arg,"smooth") == 0) { + smooth_phase(pexp, model,0); + update_snr_calc(pexp, model, before); + } + if (strcmp(arg,"smoothtrain") == 0) + smooth_phase(pexp, model,1); + if (strcmp(arg,"smoothvq") == 0) { + smooth_phase(pexp, model,2); + update_snr_calc(pexp, model, before); + } + + if (strcmp(arg,"smooth2") == 0) + smooth_phase2(pexp, model); + if (strcmp(arg,"smooth3") == 0) + smooth_phase3(pexp, model); + if (strcmp(arg,"smooth4") == 0) + smooth_phase4(model); + if (strcmp(arg,"vqsmooth3") == 0) { + sparse_vq_pred_error(pexp, model); + smooth_phase3(pexp, model); + } + + if (strcmp(arg,"cb1") == 0) { + cb_phase1(pexp, model); + update_snr_calc(pexp, model, before); + } + + if (strcmp(arg,"top") == 0) { + //top_amp(pexp, model, 1, model->L/4, 4, 1); + //top_amp(pexp, model, model->L/4, model->L/3, 4, 1); + //top_amp(pexp, model, model->L/3+1, model->L/2, 4, 1); + //top_amp(pexp, model, model->L/2, model->L, 6, 1); + //rand_phases(model, model->L/2, 3*model->L/4); + //struct_phases(pexp, model, model->L/2, 3*model->L/4); + //update_snr_calc(pexp, model, before); + } + + if (strcmp(arg,"pred23") == 0) { + predict_phases2(pexp, model, model->L/2, model->L); + update_snr_calc(pexp, model, before); + } + + if (strcmp(arg,"struct23") == 0) { + struct_phases(pexp, model, model->L/2, 3*model->L/4 ); + update_snr_calc(pexp, model, before); + } + + if (strcmp(arg,"addnoise") == 0) { + int m; + float max; + + max = 0; + for(m=1; m<=model->L; m++) + if (model->A[m] > max) + max = model->A[m]; + max = 20.0*log10(max); + for(m=1; m<=model->L; m++) + if (20.0*log10(model->A[m]) < (max-20)) { + model->phi[m] += (PI/4)*(1.0 -2.0*rand()/RAND_MAX); + //printf("m %d\n", m); + } + } + + /* normalise phases */ + + for(m=1; m<=model->L; m++) + model->phi[m] = atan2(sin(model->phi[m]), cos(model->phi[m])); + + /* update states */ + + //best_Wo = refine_Wo(pexp, model, model->L/2, model->L); + pexp->phi1 += N*model->Wo; + + for(m=1; m<=model->L; m++) + pexp->phi_prev[m] = model->phi[m]; + pexp->Wo_prev = model->Wo; + pexp->frames++; + pexp->prev_model = *model; +} + +#ifdef OLD_STUFF + //quant_phases(model, 1, model->L, 3); + //update_variance_calc(pexp, model, before); + //print_sparse_pred_error(pexp, model, 1, model->L, 40.0); + + //sparse_vq_pred_error(pexp, model); + + //quant_phases(model, model->L/4+1, model->L, 3); + + //predict_phases1(pexp, model, 1, model->L/4); + //quant_phases(model, model->L/4+1, model->L, 3); + + //quant_phases(model, 1, model->L/8, 3); + + //update_snr_calc(pexp, model, before); + //update_variance_calc(pexp, model, before); + + //fixed_bits_per_frame(pexp, model, 40); + //struct_phases(pexp, model, 1, model->L/4); + //rand_phases(model, 10, model->L); + //for(m=1; m<=model->L; m++) + // model->A[m] = 0.0; + //model->A[model->L/2] = 1000; + //repeat_phases(model, 20); + //predict_phases(pexp, model, 1, model->L/4); + //quant_phases(model, 1, 10, 3); + //quant_phases(model, 10, 20, 2); + //repeat_phases(model, 20); + //rand_phases(model, 3*model->L/4, model->L); + // print_phi1_pred_error(model, 1, model->L); + //predict_phases(pexp, model, 1, model->L/4); + //first_order_band(model, model->L/4, model->L/2); + //first_order_band(model, model->L/2, 3*model->L/4); + //if (fabs(model->Wo - pexp->Wo_prev)< 0.1*model->Wo) + + //print_pred_error(pexp, model, 1, model->L, 40.0); + //print_sparse_pred_error(pexp, model, 1, model->L, 40.0); + + //phi1_est = est_phi1(model, 1, model->L/4); + //print_phi1_pred_error(model, 1, model->L/4); + + //first_order_band(model, 1, model->L/4, phi1_est); + //sub_linear(model, 1, model->L/4, phi1_est); + + //top_amp(pexp, model, 1, model->L/4, 4); + //top_amp(pexp, model, model->L/4, model->L/2, 4); + + //first_order_band(model, 1, model->L/4, phi1_est); + //first_order_band(model, model->L/4, model->L/2, phi1_est); + + //if (fabs(model->Wo - pexp->Wo_prev) > 0.2*model->Wo) + // rand_phases(model, model->L/2, model->L); + + //top_amp(pexp, model, 1, model->L/4, 4); + //top_amp(pexp, model, model->L/4, model->L/2, 8); + //top_amp(pexp, model, model->L/4+1, model->L/2, 10, 1); + //top_amp(pexp, model, 1, model->L/4, 10, 1); + //top_amp(pexp, model, model->L/4+1, 3*model->L/4, 10, 1); + //top_amp(pexp, model, 1, 3*model->L/4, 20, 1); + + #ifdef REAS_CAND1 + predict_phases(pexp, model, 1, model->L/4); + top_amp(pexp, model, model->L/4+1, 3*model->L/4, 10, 1); + rand_phases(model, 3*model->L/4+1, model->L); + #endif + + #ifdef REAS_CAND2 + if ((pexp->frames % 2) == 0) { + //printf("quant\n"); + predict_phases(pexp, model, 1, model->L/4); + //top_amp(pexp, model, model->L/4+1, 3*model->L/4, 20, 1); + top_amp(pexp, model, model->L/4+1, 7*model->L/8, 20, 1); + rand_phases(model, 7*model->L/8+1, model->L); + } + else { + //printf("predict\n"); + predict_phases(pexp, model, 1, model->L); + } + #endif + + //#define REAS_CAND3 + #ifdef REAS_CAND3 + if ((pexp->frames % 3) != 0) { + printf("pred\n"); + predict_phases(pexp, model, 1, model->L); + } + else { + predict_phases(pexp, model, 1, model->L/4); + fixed_bits_per_frame(pexp, model, model->L/4+1, 60); + } + #endif + //predict_phases(pexp, model, model->L/4, model->L); + + + //print_pred_error(pexp, model, 1, model->L); + //limit_prediction_error(pexp, model, model->L/2, model->L, PI/2); +#endif diff --git a/codec2/branches/0.3/src/phaseexp.h b/codec2/branches/0.3/src/phaseexp.h new file mode 100644 index 00000000..b43db75e --- /dev/null +++ b/codec2/branches/0.3/src/phaseexp.h @@ -0,0 +1,39 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: phaseexp.h + AUTHOR......: David Rowe + DATE CREATED: June 2012 + + Experimental functions for quantising, modelling and synthesising phase. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2012 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#ifndef __PHASEEXP__ +#define __PHASEEXP__ + +#include "kiss_fft.h" + +struct PEXP; + +struct PEXP * phase_experiment_create(); +void phase_experiment_destroy(struct PEXP *pexp); +void phase_experiment(struct PEXP *pexp, MODEL *model, char *arg); + +#endif diff --git a/codec2/branches/0.3/src/pilot_coeff.h b/codec2/branches/0.3/src/pilot_coeff.h new file mode 100644 index 00000000..b284af93 --- /dev/null +++ b/codec2/branches/0.3/src/pilot_coeff.h @@ -0,0 +1,34 @@ +/* Generated by pilot_coeff_file() Octave function */ + +const float pilot_coeff[]={ + 0.00223001, + 0.00301037, + 0.00471258, + 0.0075934, + 0.0118145, + 0.0174153, + 0.0242969, + 0.0322204, + 0.0408199, + 0.0496286, + 0.0581172, + 0.0657392, + 0.0719806, + 0.0764066, + 0.0787022, + 0.0787022, + 0.0764066, + 0.0719806, + 0.0657392, + 0.0581172, + 0.0496286, + 0.0408199, + 0.0322204, + 0.0242969, + 0.0174153, + 0.0118145, + 0.0075934, + 0.00471258, + 0.00301037, + 0.00223001 +}; diff --git a/codec2/branches/0.3/src/postfilter.c b/codec2/branches/0.3/src/postfilter.c new file mode 100644 index 00000000..f347658c --- /dev/null +++ b/codec2/branches/0.3/src/postfilter.c @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: postfilter.c + AUTHOR......: David Rowe + DATE CREATED: 13/09/09 + + Postfilter to improve sound quality for speech with high levels of + background noise. Unlike mixed-excitation models requires no bits + to be transmitted to handle background noise. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2009 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include +#include +#include + +#include "defines.h" +#include "comp.h" +#include "dump.h" +#include "sine.h" +#include "postfilter.h" + +/*---------------------------------------------------------------------------*\ + + DEFINES + +\*---------------------------------------------------------------------------*/ + +#define BG_THRESH 40.0 /* only consider low levels signals for bg_est */ +#define BG_BETA 0.1 /* averaging filter constant */ +#define BG_MARGIN 6.0 /* harmonics this far above BG noise are + randomised. Helped make bg noise less + spikey (impulsive) for mmt1, but speech was + perhaps a little rougher. + */ + +/*---------------------------------------------------------------------------*\ + + postfilter() + + The post filter is designed to help with speech corrupted by + background noise. The zero phase model tends to make speech with + background noise sound "clicky". With high levels of background + noise the low level inter-formant parts of the spectrum will contain + noise rather than speech harmonics, so modelling them as voiced + (i.e. a continuous, non-random phase track) is inaccurate. + + Some codecs (like MBE) have a mixed voicing model that breaks the + spectrum into voiced and unvoiced regions. Several bits/frame + (5-12) are required to transmit the frequency selective voicing + information. Mixed excitation also requires accurate voicing + estimation (parameter estimators always break occasionally under + exceptional conditions). + + In our case we use a post filter approach which requires no + additional bits to be transmitted. The decoder measures the average + level of the background noise during unvoiced frames. If a harmonic + is less than this level it is made unvoiced by randomising it's + phases. + + This idea is rather experimental. Some potential problems that may + happen: + + 1/ If someone says "aaaaaaaahhhhhhhhh" will background estimator track + up to speech level? This would be a bad thing. + + 2/ If background noise suddenly dissapears from the source speech does + estimate drop quickly? What is noise suddenly re-appears? + + 3/ Background noise with a non-flat sepctrum. Current algorithm just + comsiders scpetrum as a whole, but this could be broken up into + bands, each with their own estimator. + + 4/ Males and females with the same level of background noise. Check + performance the same. Changing Wo affects width of each band, may + affect bg energy estimates. + + 5/ Not sure what happens during long periods of voiced speech + e.g. "sshhhhhhh" + +\*---------------------------------------------------------------------------*/ + +void postfilter( + MODEL *model, + float *bg_est +) +{ + int m, uv; + float e, thresh; + + /* determine average energy across spectrum */ + + e = 1E-12; + for(m=1; m<=model->L; m++) + e += model->A[m]*model->A[m]; + + assert(e > 0.0); + e = 10.0*log10f(e/model->L); + + /* If beneath threhold, update bg estimate. The idea + of the threshold is to prevent updating during high level + speech. */ + + if ((e < BG_THRESH) && !model->voiced) + *bg_est = *bg_est*(1.0 - BG_BETA) + e*BG_BETA; + + /* now mess with phases during voiced frames to make any harmonics + less then our background estimate unvoiced. + */ + + uv = 0; + thresh = powf(10.0, (*bg_est + BG_MARGIN)/20.0); + if (model->voiced) + for(m=1; m<=model->L; m++) + if (model->A[m] < thresh) { + model->phi[m] = TWO_PI*(float)codec2_rand()/CODEC2_RAND_MAX; + uv++; + } + +#ifdef DUMP + dump_bg(e, *bg_est, 100.0*uv/model->L); +#endif + +} diff --git a/codec2/branches/0.3/src/postfilter.h b/codec2/branches/0.3/src/postfilter.h new file mode 100644 index 00000000..bf080b1b --- /dev/null +++ b/codec2/branches/0.3/src/postfilter.h @@ -0,0 +1,33 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: postfilter.h + AUTHOR......: David Rowe + DATE CREATED: 13/09/09 + + Postfilter header file. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2009 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#ifndef __POSTFILTER__ +#define __POSTFILTER__ + +void postfilter(MODEL *model, float *bg_est); + +#endif diff --git a/codec2/branches/0.3/src/quantise.c b/codec2/branches/0.3/src/quantise.c new file mode 100644 index 00000000..95a45ce6 --- /dev/null +++ b/codec2/branches/0.3/src/quantise.c @@ -0,0 +1,1970 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: quantise.c + AUTHOR......: David Rowe + DATE CREATED: 31/5/92 + + Quantisation functions for the sinusoidal coder. + +\*---------------------------------------------------------------------------*/ + +/* + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . + +*/ + +#include +#include +#include +#include +#include +#include + +#include "defines.h" +#include "dump.h" +#include "quantise.h" +#include "lpc.h" +#include "lsp.h" +#include "kiss_fft.h" +#undef TIMER +#include "machdep.h" + +#define LSP_DELTA1 0.01 /* grid spacing for LSP root searches */ + +/*---------------------------------------------------------------------------*\ + + FUNCTION HEADERS + +\*---------------------------------------------------------------------------*/ + +float speech_to_uq_lsps(float lsp[], float ak[], float Sn[], float w[], + int order); + +/*---------------------------------------------------------------------------*\ + + FUNCTIONS + +\*---------------------------------------------------------------------------*/ + +int lsp_bits(int i) { + return lsp_cb[i].log2m; +} + +int lspd_bits(int i) { + return lsp_cbd[i].log2m; +} + +#ifdef __EXPERIMENTAL__ +int lspdt_bits(int i) { + return lsp_cbdt[i].log2m; +} +#endif + +int lsp_pred_vq_bits(int i) { + return lsp_cbjvm[i].log2m; +} + +/*---------------------------------------------------------------------------*\ + + quantise_init + + Loads the entire LSP quantiser comprised of several vector quantisers + (codebooks). + +\*---------------------------------------------------------------------------*/ + +void quantise_init() +{ +} + +/*---------------------------------------------------------------------------*\ + + quantise + + Quantises vec by choosing the nearest vector in codebook cb, and + returns the vector index. The squared error of the quantised vector + is added to se. + +\*---------------------------------------------------------------------------*/ + +long quantise(const float * cb, float vec[], float w[], int k, int m, float *se) +/* float cb[][K]; current VQ codebook */ +/* float vec[]; vector to quantise */ +/* float w[]; weighting vector */ +/* int k; dimension of vectors */ +/* int m; size of codebook */ +/* float *se; accumulated squared error */ +{ + float e; /* current error */ + long besti; /* best index so far */ + float beste; /* best error so far */ + long j; + int i; + float diff; + + besti = 0; + beste = 1E32; + for(j=0; j 0); + mbest = (struct MBEST *)malloc(sizeof(struct MBEST)); + assert(mbest != NULL); + + mbest->entries = entries; + mbest->list = (struct MBEST_LIST *)malloc(entries*sizeof(struct MBEST_LIST)); + assert(mbest->list != NULL); + + for(i=0; ientries; i++) { + for(j=0; jlist[i].index[j] = 0; + mbest->list[i].error = 1E32; + } + + return mbest; +} + + +static void mbest_destroy(struct MBEST *mbest) { + assert(mbest != NULL); + free(mbest->list); + free(mbest); +} + + +/*---------------------------------------------------------------------------*\ + + mbest_insert + + Insert the results of a vector to codebook entry comparison. The + list is ordered in order or error, so those entries with the + smallest error will be first on the list. + +\*---------------------------------------------------------------------------*/ + +static void mbest_insert(struct MBEST *mbest, int index[], float error) { + int i, j, found; + struct MBEST_LIST *list = mbest->list; + int entries = mbest->entries; + + found = 0; + for(i=0; ii; j--) + list[j] = list[j-1]; + for(j=0; jentries; i++) { + for(j=0; jlist[i].index[j]); + printf(" %f\n", mbest->list[i].error); + } +} + + +/*---------------------------------------------------------------------------*\ + + mbest_search + + Searches vec[] to a codebbook of vectors, and maintains a list of the mbest + closest matches. + +\*---------------------------------------------------------------------------*/ + +static void mbest_search( + const float *cb, /* VQ codebook to search */ + float vec[], /* target vector */ + float w[], /* weighting vector */ + int k, /* dimension of vector */ + int m, /* number on entries in codebook */ + struct MBEST *mbest, /* list of closest matches */ + int index[] /* indexes that lead us here */ +) +{ + float e; + int i,j; + float diff; + + for(j=0; jlist[j].index[0]; + for(i=0; ilist[j].index[1]; + index[1] = n2 = mbest_stage2->list[j].index[0]; + for(i=0; ilist[j].index[2]; + index[2] = n2 = mbest_stage3->list[j].index[1]; + index[1] = n3 = mbest_stage3->list[j].index[0]; + for(i=0; ilist[0].index[3]; + n2 = mbest_stage4->list[0].index[2]; + n3 = mbest_stage4->list[0].index[1]; + n4 = mbest_stage4->list[0].index[0]; + for (i=0;i max_Rw) + max_Rw = Rw[i]; + if (Rw[i] < min_Rw) + min_Rw = Rw[i]; + + } + + TIMER_SAMPLE_AND_LOG(tr, tww, " R"); + + #ifdef DUMP + if (dump) + dump_Rw(Rw); + #endif + + /* create post filter mag spectrum and apply ------------------*/ + + /* measure energy before post filtering */ + + e_before = 1E-4; + for(i=0; iL; m++) { + am = (int)((m - 0.5)*model->Wo/r + 0.5); + bm = (int)((m + 0.5)*model->Wo/r + 0.5); + Em = 0.0; + + for(i=am; iA[m]*model->A[m]; + noise += (model->A[m] - Am)*(model->A[m] - Am); + + /* This code significantly improves perf of LPC model, in + particular when combined with phase0. The LPC spectrum tends + to track just under the peaks of the spectral envelope, and + just above nulls. This algorithm does the reverse to + compensate - raising the amplitudes of spectral peaks, while + attenuating the null. This enhances the formants, and + supresses the energy between formants. */ + + if (sim_pf) { + if (Am > model->A[m]) + Am *= 0.7; + if (Am < model->A[m]) + Am *= 1.4; + } + + model->A[m] = Am; + } + *snr = 10.0*log10f(signal/noise); + + TIMER_SAMPLE_AND_LOG2(tpf, " rec"); +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: encode_Wo() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 + + Encodes Wo using a WO_LEVELS quantiser. + +\*---------------------------------------------------------------------------*/ + +int encode_Wo(float Wo) +{ + int index; + float Wo_min = TWO_PI/P_MAX; + float Wo_max = TWO_PI/P_MIN; + float norm; + + norm = (Wo - Wo_min)/(Wo_max - Wo_min); + index = floorf(WO_LEVELS * norm + 0.5); + if (index < 0 ) index = 0; + if (index > (WO_LEVELS-1)) index = WO_LEVELS-1; + + return index; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: decode_Wo() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 + + Decodes Wo using a WO_LEVELS quantiser. + +\*---------------------------------------------------------------------------*/ + +float decode_Wo(int index) +{ + float Wo_min = TWO_PI/P_MAX; + float Wo_max = TWO_PI/P_MIN; + float step; + float Wo; + + step = (Wo_max - Wo_min)/WO_LEVELS; + Wo = Wo_min + step*(index); + + return Wo; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: encode_Wo_dt() + AUTHOR......: David Rowe + DATE CREATED: 6 Nov 2011 + + Encodes Wo difference from last frame. + +\*---------------------------------------------------------------------------*/ + +int encode_Wo_dt(float Wo, float prev_Wo) +{ + int index, mask, max_index, min_index; + float Wo_min = TWO_PI/P_MAX; + float Wo_max = TWO_PI/P_MIN; + float norm; + + norm = (Wo - prev_Wo)/(Wo_max - Wo_min); + index = floor(WO_LEVELS * norm + 0.5); + //printf("ENC index: %d ", index); + + /* hard limit */ + + max_index = (1 << (WO_DT_BITS-1)) - 1; + min_index = - (max_index+1); + if (index > max_index) index = max_index; + if (index < min_index) index = min_index; + //printf("max_index: %d min_index: %d hard index: %d ", + // max_index, min_index, index); + + /* mask so that only LSB WO_DT_BITS remain, bit WO_DT_BITS is the sign bit */ + + mask = ((1 << WO_DT_BITS) - 1); + index &= mask; + //printf("mask: 0x%x index: 0x%x\n", mask, index); + + return index; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: decode_Wo_dt() + AUTHOR......: David Rowe + DATE CREATED: 6 Nov 2011 + + Decodes Wo using WO_DT_BITS difference from last frame. + +\*---------------------------------------------------------------------------*/ + +float decode_Wo_dt(int index, float prev_Wo) +{ + float Wo_min = TWO_PI/P_MAX; + float Wo_max = TWO_PI/P_MIN; + float step; + float Wo; + int mask; + + /* sign extend index */ + + //printf("DEC index: %d "); + if (index & (1 << (WO_DT_BITS-1))) { + mask = ~((1 << WO_DT_BITS) - 1); + index |= mask; + } + //printf("DEC mask: 0x%x index: %d \n", mask, index); + + step = (Wo_max - Wo_min)/WO_LEVELS; + Wo = prev_Wo + step*(index); + + /* bit errors can make us go out of range leading to all sorts of + probs like seg faults */ + + if (Wo > Wo_max) Wo = Wo_max; + if (Wo < Wo_min) Wo = Wo_min; + + return Wo; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: speech_to_uq_lsps() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 + + Analyse a windowed frame of time domain speech to determine LPCs + which are the converted to LSPs for quantisation and transmission + over the channel. + +\*---------------------------------------------------------------------------*/ + +float speech_to_uq_lsps(float lsp[], + float ak[], + float Sn[], + float w[], + int order +) +{ + int i, roots; + float Wn[M]; + float R[LPC_MAX+1]; + float e, E; + + e = 0.0; + for(i=0; iWo < (PI*150.0/4000)) { + model->A[1] *= 0.032; + } +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: encode_energy() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 + + Encodes LPC energy using an E_LEVELS quantiser. + +\*---------------------------------------------------------------------------*/ + +int encode_energy(float e) +{ + int index; + float e_min = E_MIN_DB; + float e_max = E_MAX_DB; + float norm; + + e = 10.0*log10f(e); + norm = (e - e_min)/(e_max - e_min); + index = floorf(E_LEVELS * norm + 0.5); + if (index < 0 ) index = 0; + if (index > (E_LEVELS-1)) index = E_LEVELS-1; + + return index; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: decode_energy() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 + + Decodes energy using a E_LEVELS quantiser. + +\*---------------------------------------------------------------------------*/ + +float decode_energy(int index) +{ + float e_min = E_MIN_DB; + float e_max = E_MAX_DB; + float step; + float e; + + step = (e_max - e_min)/E_LEVELS; + e = e_min + step*(index); + e = powf(10.0,e/10.0); + + return e; +} + +#ifdef NOT_USED +/*---------------------------------------------------------------------------*\ + + FUNCTION....: decode_amplitudes() + AUTHOR......: David Rowe + DATE CREATED: 22/8/2010 + + Given the amplitude quantiser indexes recovers the harmonic + amplitudes. + +\*---------------------------------------------------------------------------*/ + +float decode_amplitudes(kiss_fft_cfg fft_fwd_cfg, + MODEL *model, + float ak[], + int lsp_indexes[], + int energy_index, + float lsps[], + float *e +) +{ + float snr; + + decode_lsps_scalar(lsps, lsp_indexes, LPC_ORD); + bw_expand_lsps(lsps, LPC_ORD); + lsp_to_lpc(lsps, ak, LPC_ORD); + *e = decode_energy(energy_index); + aks_to_M2(ak, LPC_ORD, model, *e, &snr, 1, 0, 0, 1); + apply_lpc_correction(model); + + return snr; +} +#endif + +static float ge_coeff[2] = {0.8, 0.9}; + +void compute_weights2(const float *x, const float *xp, float *w, int ndim) +{ + w[0] = 30; + w[1] = 1; + if (x[1]<0) + { + w[0] *= .6; + w[1] *= .3; + } + if (x[1]<-10) + { + w[0] *= .3; + w[1] *= .3; + } + /* Higher weight if pitch is stable */ + if (fabsf(x[0]-xp[0])<.2) + { + w[0] *= 2; + w[1] *= 1.5; + } else if (fabsf(x[0]-xp[0])>.5) /* Lower if not stable */ + { + w[0] *= .5; + } + + /* Lower weight for low energy */ + if (x[1] < xp[1]-10) + { + w[1] *= .5; + } + if (x[1] < xp[1]-20) + { + w[1] *= .5; + } + + //w[0] = 30; + //w[1] = 1; + + /* Square the weights because it's applied on the squared error */ + w[0] *= w[0]; + w[1] *= w[1]; + +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: quantise_WoE() + AUTHOR......: Jean-Marc Valin & David Rowe + DATE CREATED: 29 Feb 2012 + + Experimental joint Wo and LPC energy vector quantiser developed by + Jean-Marc Valin. Exploits correlations between the difference in + the log pitch and log energy from frame to frame. For example + both the pitch and energy tend to only change by small amounts + during voiced speech, however it is important that these changes be + coded carefully. During unvoiced speech they both change a lot but + the ear is less sensitve to errors so coarser quantisation is OK. + + The ear is sensitive to log energy and loq pitch so we quantise in + these domains. That way the error measure used to quantise the + values is close to way the ear senses errors. + + See http://jmspeex.livejournal.com/10446.html + +\*---------------------------------------------------------------------------*/ + +void quantise_WoE(MODEL *model, float *e, float xq[]) +{ + int i, n1; + float x[2]; + float err[2]; + float w[2]; + const float *codebook1 = ge_cb[0].cb; + int nb_entries = ge_cb[0].m; + int ndim = ge_cb[0].k; + float Wo_min = TWO_PI/P_MAX; + float Wo_max = TWO_PI/P_MIN; + + x[0] = log10f((model->Wo/PI)*4000.0/50.0)/log10f(2); + x[1] = 10.0*log10f(1e-4 + *e); + + compute_weights2(x, xq, w, ndim); + for (i=0;iWo = powf(2.0, xq[0])*(PI*50.0)/4000.0; + + /* bit errors can make us go out of range leading to all sorts of + probs like seg faults */ + + if (model->Wo > Wo_max) model->Wo = Wo_max; + if (model->Wo < Wo_min) model->Wo = Wo_min; + + model->L = PI/model->Wo; /* if we quantise Wo re-compute L */ + + *e = powf(10.0, xq[1]/10.0); +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: encode_WoE() + AUTHOR......: Jean-Marc Valin & David Rowe + DATE CREATED: 11 May 2012 + + Joint Wo and LPC energy vector quantiser developed my Jean-Marc + Valin. Returns index, and updated states xq[]. + +\*---------------------------------------------------------------------------*/ + +int encode_WoE(MODEL *model, float e, float xq[]) +{ + int i, n1; + float x[2]; + float err[2]; + float w[2]; + const float *codebook1 = ge_cb[0].cb; + int nb_entries = ge_cb[0].m; + int ndim = ge_cb[0].k; + + assert((1<Wo/PI)*4000.0/50.0)/log10f(2); + x[1] = 10.0*log10f(1e-4 + e); + + compute_weights2(x, xq, w, ndim); + for (i=0;iWo = powf(2.0, xq[0])*(PI*50.0)/4000.0; + + /* bit errors can make us go out of range leading to all sorts of + probs like seg faults */ + + if (model->Wo > Wo_max) model->Wo = Wo_max; + if (model->Wo < Wo_min) model->Wo = Wo_min; + + model->L = PI/model->Wo; /* if we quantise Wo re-compute L */ + + *e = powf(10.0, xq[1]/10.0); +} + diff --git a/codec2/branches/0.3/src/quantise.h b/codec2/branches/0.3/src/quantise.h new file mode 100644 index 00000000..007d34d6 --- /dev/null +++ b/codec2/branches/0.3/src/quantise.h @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: quantise.h + AUTHOR......: David Rowe + DATE CREATED: 31/5/92 + + Quantisation functions for the sinusoidal coder. + +\*---------------------------------------------------------------------------*/ + +/* + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#ifndef __QUANTISE__ +#define __QUANTISE__ + +#include "kiss_fft.h" + +#define WO_BITS 7 +#define WO_LEVELS (1<. +*/ + +/*---------------------------------------------------------------------------*\ + + INCLUDES + +\*---------------------------------------------------------------------------*/ + +#include +#include +#include + +#include "defines.h" +#include "sine.h" +#include "kiss_fft.h" + +#define HPF_BETA 0.125 + +/*---------------------------------------------------------------------------*\ + + HEADERS + +\*---------------------------------------------------------------------------*/ + +void hs_pitch_refinement(MODEL *model, COMP Sw[], float pmin, float pmax, + float pstep); + +/*---------------------------------------------------------------------------*\ + + FUNCTIONS + +\*---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: make_analysis_window + AUTHOR......: David Rowe + DATE CREATED: 11/5/94 + + Init function that generates the time domain analysis window and it's DFT. + +\*---------------------------------------------------------------------------*/ + +void make_analysis_window(kiss_fft_cfg fft_fwd_cfg, float w[], COMP W[]) +{ + float m; + COMP wshift[FFT_ENC]; + COMP temp; + int i,j; + + /* + Generate Hamming window centered on M-sample pitch analysis window + + 0 M/2 M-1 + |-------------|-------------| + |-------|-------| + NW samples + + All our analysis/synthsis is centred on the M/2 sample. + */ + + m = 0.0; + for(i=0; iWo + 5; + pmin = TWO_PI/model->Wo - 5; + pstep = 1.0; + hs_pitch_refinement(model,Sw,pmin,pmax,pstep); + + /* Fine refinement */ + + pmax = TWO_PI/model->Wo + 1; + pmin = TWO_PI/model->Wo - 1; + pstep = 0.25; + hs_pitch_refinement(model,Sw,pmin,pmax,pstep); + + /* Limit range */ + + if (model->Wo < TWO_PI/P_MAX) + model->Wo = TWO_PI/P_MAX; + if (model->Wo > TWO_PI/P_MIN) + model->Wo = TWO_PI/P_MIN; + + model->L = floor(PI/model->Wo); +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: hs_pitch_refinement + AUTHOR......: David Rowe + DATE CREATED: 27/5/94 + + Harmonic sum pitch refinement function. + + pmin pitch search range minimum + pmax pitch search range maximum + step pitch search step size + model current pitch estimate in model.Wo + + model refined pitch estimate in model.Wo + +\*---------------------------------------------------------------------------*/ + +void hs_pitch_refinement(MODEL *model, COMP Sw[], float pmin, float pmax, float pstep) +{ + int m; /* loop variable */ + int b; /* bin for current harmonic centre */ + float E; /* energy for current pitch*/ + float Wo; /* current "test" fundamental freq. */ + float Wom; /* Wo that maximises E */ + float Em; /* mamimum energy */ + float r, one_on_r; /* number of rads/bin */ + float p; /* current pitch */ + + /* Initialisation */ + + model->L = PI/model->Wo; /* use initial pitch est. for L */ + Wom = model->Wo; + Em = 0.0; + r = TWO_PI/FFT_ENC; + one_on_r = 1.0/r; + + /* Determine harmonic sum for a range of Wo values */ + + for(p=pmin; p<=pmax; p+=pstep) { + E = 0.0; + Wo = TWO_PI/p; + + /* Sum harmonic magnitudes */ + for(m=1; m<=model->L; m++) { + b = (int)(m*Wo*one_on_r + 0.5); + E += Sw[b].real*Sw[b].real + Sw[b].imag*Sw[b].imag; + } + /* Compare to see if this is a maximum */ + + if (E > Em) { + Em = E; + Wom = Wo; + } + } + + model->Wo = Wom; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: estimate_amplitudes + AUTHOR......: David Rowe + DATE CREATED: 27/5/94 + + Estimates the complex amplitudes of the harmonics. + +\*---------------------------------------------------------------------------*/ + +void estimate_amplitudes(MODEL *model, COMP Sw[], COMP W[], int est_phase) +{ + int i,m; /* loop variables */ + int am,bm; /* bounds of current harmonic */ + int b; /* DFT bin of centre of current harmonic */ + float den; /* denominator of amplitude expression */ + float r, one_on_r; /* number of rads/bin */ + int offset; + COMP Am; + + r = TWO_PI/FFT_ENC; + one_on_r = 1.0/r; + + for(m=1; m<=model->L; m++) { + den = 0.0; + am = (int)((m - 0.5)*model->Wo*one_on_r + 0.5); + bm = (int)((m + 0.5)*model->Wo*one_on_r + 0.5); + b = (int)(m*model->Wo/r + 0.5); + + /* Estimate ampltude of harmonic */ + + den = 0.0; + Am.real = Am.imag = 0.0; + offset = FFT_ENC/2 - (int)(m*model->Wo*one_on_r + 0.5); + for(i=am; iA[m] = sqrtf(den); + + if (est_phase) { + + /* Estimate phase of harmonic, this is expensive in CPU for + embedded devicesso we make it an option */ + + model->phi[m] = atan2(Sw[b].imag,Sw[b].real); + } + } +} + +/*---------------------------------------------------------------------------*\ + + est_voicing_mbe() + + Returns the error of the MBE cost function for a fiven F0. + + Note: I think a lot of the operations below can be simplified as + W[].imag = 0 and has been normalised such that den always equals 1. + +\*---------------------------------------------------------------------------*/ + +float est_voicing_mbe( + MODEL *model, + COMP Sw[], + COMP W[], + COMP Sw_[], /* DFT of all voiced synthesised signal */ + /* useful for debugging/dump file */ + COMP Ew[], /* DFT of error */ + float prev_Wo) +{ + int i,l,al,bl,m; /* loop variables */ + COMP Am; /* amplitude sample for this band */ + int offset; /* centers Hw[] about current harmonic */ + float den; /* denominator of Am expression */ + float error; /* accumulated error between original and synthesised */ + float Wo; + float sig, snr; + float elow, ehigh, eratio; + float sixty; + + sig = 1E-4; + for(l=1; l<=model->L/4; l++) { + sig += model->A[l]*model->A[l]; + } + for(i=0; iWo; + error = 1E-4; + + /* Just test across the harmonics in the first 1000 Hz (L/4) */ + + for(l=1; l<=model->L/4; l++) { + Am.real = 0.0; + Am.imag = 0.0; + den = 0.0; + al = ceil((l - 0.5)*Wo*FFT_ENC/TWO_PI); + bl = ceil((l + 0.5)*Wo*FFT_ENC/TWO_PI); + + /* Estimate amplitude of harmonic assuming harmonic is totally voiced */ + + offset = FFT_ENC/2 - l*Wo*FFT_ENC/TWO_PI + 0.5; + for(m=al; m V_THRESH) + model->voiced = 1; + else + model->voiced = 0; + + /* post processing, helps clean up some voicing errors ------------------*/ + + /* + Determine the ratio of low freqency to high frequency energy, + voiced speech tends to be dominated by low frequency energy, + unvoiced by high frequency. This measure can be used to + determine if we have made any gross errors. + */ + + elow = ehigh = 1E-4; + for(l=1; l<=model->L/2; l++) { + elow += model->A[l]*model->A[l]; + } + for(l=model->L/2; l<=model->L; l++) { + ehigh += model->A[l]*model->A[l]; + } + eratio = 10.0*log10f(elow/ehigh); + + /* Look for Type 1 errors, strongly V speech that has been + accidentally declared UV */ + + if (model->voiced == 0) + if (eratio > 10.0) + model->voiced = 1; + + /* Look for Type 2 errors, strongly UV speech that has been + accidentally declared V */ + + if (model->voiced == 1) { + if (eratio < -10.0) + model->voiced = 0; + + /* A common source of Type 2 errors is the pitch estimator + gives a low (50Hz) estimate for UV speech, which gives a + good match with noise due to the close harmoonic spacing. + These errors are much more common than people with 50Hz3 + pitch, so we have just a small eratio threshold. */ + + sixty = 60.0*TWO_PI/FS; + if ((eratio < -4.0) && (model->Wo <= sixty)) + model->voiced = 0; + } + //printf(" v: %d snr: %f eratio: %3.2f %f\n",model->voiced,snr,eratio,dF0); + + return snr; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: make_synthesis_window + AUTHOR......: David Rowe + DATE CREATED: 11/5/94 + + Init function that generates the trapezoidal (Parzen) sythesis window. + +\*---------------------------------------------------------------------------*/ + +void make_synthesis_window(float Pn[]) +{ + int i; + float win; + + /* Generate Parzen window in time domain */ + + win = 0.0; + for(i=0; i 10ms sound poor. The effect can also + be seen when synthesising test signals like single sine waves, some + sort of amplitude modulation at the frame rate. + + Another possibility is using a larger FFT size (1024 or 2048). + */ + +#define FFT_SYNTHESIS +#ifdef FFT_SYNTHESIS + /* Now set up frequency domain synthesised speech */ + for(l=1; l<=model->L; l++) { + //for(l=model->L/2; l<=model->L; l++) { + //for(l=1; l<=model->L/4; l++) { + b = (int)(l*model->Wo*FFT_DEC/TWO_PI + 0.5); + if (b > ((FFT_DEC/2)-1)) { + b = (FFT_DEC/2)-1; + } + Sw_[b].real = model->A[l]*cosf(model->phi[l]); + Sw_[b].imag = model->A[l]*sinf(model->phi[l]); + Sw_[FFT_DEC-b].real = Sw_[b].real; + Sw_[FFT_DEC-b].imag = -Sw_[b].imag; + } + + /* Perform inverse DFT */ + + kiss_fft(fft_inv_cfg, (kiss_fft_cpx *)Sw_, (kiss_fft_cpx *)sw_); +#else + /* + Direct time domain synthesis using the cos() function. Works + well at 10ms and 20ms frames rates. Note synthesis window is + still used to handle overlap-add between adjacent frames. This + could be simplified as we don't need to synthesise where Pn[] + is zero. + */ + for(l=1; l<=model->L; l++) { + for(i=0,j=-N+1; iA[l]*cos(j*model->Wo*l + model->phi[l]); + } + for(i=N-1,j=0; i<2*N; i++,j++) + Sw_[j].real += 2.0*model->A[l]*cos(j*model->Wo*l + model->phi[l]); + } +#endif + + /* Overlap add to previous samples */ + + for(i=0; i. +*/ + +#ifndef __SINE__ +#define __SINE__ + +#include "defines.h" +#include "comp.h" +#include "kiss_fft.h" + +void make_analysis_window(kiss_fft_cfg fft_fwd_cfg, float w[], COMP W[]); +float hpf(float x, float states[]); +void dft_speech(kiss_fft_cfg fft_fwd_cfg, COMP Sw[], float Sn[], float w[]); +void two_stage_pitch_refinement(MODEL *model, COMP Sw[]); +void estimate_amplitudes(MODEL *model, COMP Sw[], COMP W[], int est_phase); +float est_voicing_mbe(MODEL *model, COMP Sw[], COMP W[], COMP Sw_[],COMP Ew[], + float prev_Wo); +void make_synthesis_window(float Pn[]); +void synthesise(kiss_fft_cfg fft_inv_cfg, float Sn_[], MODEL *model, float Pn[], int shift); + +#define CODEC2_RAND_MAX 32767 +int codec2_rand(void); + +#endif diff --git a/codec2/branches/0.3/src/test_bits.h b/codec2/branches/0.3/src/test_bits.h new file mode 100644 index 00000000..d1c01a03 --- /dev/null +++ b/codec2/branches/0.3/src/test_bits.h @@ -0,0 +1,164 @@ +/* Generated by test_bits_file() Octave function */ + +const int test_bits[]={ + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 1 +}; diff --git a/codec2/branches/0.3/stm32/Makefile b/codec2/branches/0.3/stm32/Makefile new file mode 100644 index 00000000..0288407a --- /dev/null +++ b/codec2/branches/0.3/stm32/Makefile @@ -0,0 +1,215 @@ +# Makefile for stm32f4 Codec 2 test programs + +################################################### + +PROJ_NAME=stm32f4_codec2 +FLOAT_TYPE=hard + +################################################### + +BINPATH=~/gcc-arm-none-eabi-4_7-2013q1/bin +CC=$(BINPATH)/arm-none-eabi-gcc +OBJCOPY=$(BINPATH)/arm-none-eabi-objcopy +SIZE=$(BINPATH)/arm-none-eabi-size + +################################################### + +CFLAGS = -std=gnu99 -O2 -g -Wall -Tstm32_flash.ld -DSTM32F4XX -DCORTEX_M4 +CFLAGS += -mlittle-endian -mthumb -mthumb-interwork -nostartfiles -mcpu=cortex-m4 + +ifeq ($(FLOAT_TYPE), hard) +CFLAGS += -fsingle-precision-constant -Wdouble-promotion +#CFLAGS += -fsingle-precision-constant +CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard -D__FPU_PRESENT=1 -D__FPU_USED=1 +else +CFLAGS += -msoft-float +endif + +################################################### + +# Definitions for the STM32F4 Standard Peripheral Library + +PERIPHLIBURL = http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/firmware/ +PERIPHLIBZIP = stm32f4_dsp_stdperiph_lib.zip +PERIPHLIBVER = V1.1.0 +PERIPHLIBNAME = STM32F4xx_DSP_StdPeriph_Lib +PERIPHLIBDIR = $(PERIPHLIBNAME)_$(PERIPHLIBVER) +CMSIS = $(PERIPHLIBDIR)/Libraries/CMSIS +STM32F4LIB = $(PERIPHLIBDIR)/Libraries/STM32F4xx_StdPeriph_Driver +STM32F4TEMPLATE = $(PERIPHLIBDIR)/Project/STM32F4xx_StdPeriph_Templates +DSPLIB = $(PERIPHLIBDIR)/Libraries/CMSIS/DSP_Lib + +CFLAGS += -DUSE_STDPERIPH_DRIVER -I$(STM32F4LIB)/inc -I$(STM32F4TEMPLATE) +CFLAGS += -I$(CMSIS)/Include -I$(CMSIS)/Device/ST/STM32F4xx/Include +CFLAGS += -DARM_MATH_CM4 + +################################################### + +# Sources + +SRCS = main.c gdb_stdio.c stm32f4_timer.c system_stm32f4xx.c + +# Codec 2 + +CODEC2_SRC=../src +SRCS += \ +$(CODEC2_SRC)/lpc.c \ +$(CODEC2_SRC)/nlp.c \ +$(CODEC2_SRC)/postfilter.c \ +$(CODEC2_SRC)/sine.c \ +$(CODEC2_SRC)/codec2.c \ +$(CODEC2_SRC)/kiss_fft.c \ +$(CODEC2_SRC)/interp.c \ +$(CODEC2_SRC)/lsp.c \ +$(CODEC2_SRC)/phase.c \ +$(CODEC2_SRC)/quantise.c \ +$(CODEC2_SRC)/pack.c \ +$(CODEC2_SRC)/codebook.c \ +$(CODEC2_SRC)/codebookd.c \ +$(CODEC2_SRC)/codebookjvm.c \ +$(CODEC2_SRC)/codebookge.c \ +$(CODEC2_SRC)/dump.c + +CFLAGS += -D__EMBEDDED__ -DTIMER + +#enable this for dump files to help verify optimisation +#CFLAGS += -DDUMP + +CFLAGS += -I../src +CFLAGS += -I../unittest +CFLAGS += -Iinc + +FFT_TEST_SRCS = \ +$(DSPLIB)/Examples/arm_fft_bin_example/arm_fft_bin_data.c \ +fft_test.c \ +src/startup_stm32f4xx.s \ +stm32f4_timer.c \ +gdb_stdio.c \ +../src/kiss_fft.c + +################################################### + +vpath %.c src +vpath %.a lib + +ROOT=$(shell pwd) + +# Library paths + +LIBPATHS = + +# Libraries to link + +LIBS = libstm32f4.a -lg -lnosys -lm + +# startup file + +SRCS += src/startup_stm32f4xx.s src/init.c + +OBJS = $(SRCS:.c=.o) + +################################################### + +all: libstm32f4.a $(PROJ_NAME).elf fft_test.elf dac_ut.elf dac_play.elf adc_rec.elf pwm_ut.elf power_ut.elf + +dl/$(PERIPHLIBZIP): + mkdir -p dl + cd dl; wget $(PERIPHLIBURL)/$(PERIPHLIBZIP) + +$(PERIPHLIBDIR): dl/$(PERIPHLIBZIP) + cd dl; unzip $(PERIPHLIBZIP) + mv dl/$(PERIPHLIBDIR) $(PERIPHLIBDIR) + +libstm32f4.a: $(PERIPHLIBDIR) + $(MAKE) $(STM32F4TEMPLATE)/system_stm32f4xx.o + for F in $(STM32F4LIB)/src/*.c ; do $(MAKE) $${F%.c}.o ; done + for F in $(CMSIS)/DSP_Lib/Source/*/*.c ; do $(MAKE) $${F%.c}.o ; done + find $(PERIPHLIBDIR) -type f -name '*.o' -exec $(AR) crs libstm32f4.a {} ";" + +$(PROJ_NAME).elf: $(SRCS) + $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) + +fft_test.elf: $(FFT_TEST_SRCS) + $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) + +DAC_UT_SRCS=\ +src/dac_ut.c \ +../src/fifo.c \ +src/stm32f4_dac.c \ +src/system_stm32f4xx.c \ +src/startup_stm32f4xx.s \ +src/init.c + +dac_ut.elf: $(DAC_UT_SRCS) + $(CC) $(CFLAGS) -O0 $^ -o $@ $(LIBPATHS) $(LIBS) + +DAC_PLAY_SRCS=\ +src/dac_play.c \ +../src/fifo.c \ +gdb_stdio.c \ +src/stm32f4_dac.c \ +src/system_stm32f4xx.c \ +src/startup_stm32f4xx.s \ +src/init.c + +dac_play.elf: $(DAC_PLAY_SRCS) + $(CC) $(CFLAGS) -O0 $^ -o $@ $(LIBPATHS) $(LIBS) + +ADC_REC_SRCS=\ +src/adc_rec.c \ +../src/fifo.c \ +gdb_stdio.c \ +src/stm32f4_adc.c \ +src/system_stm32f4xx.c \ +src/startup_stm32f4xx.s \ +src/init.c + +adc_rec.elf: $(ADC_REC_SRCS) + $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) + +PWM_UT_SRCS=\ +src/stm32f4_pwm.c \ +src/system_stm32f4xx.c \ +src/startup_stm32f4xx.s \ +src/init.c + +pwm_ut.elf: $(PWM_UT_SRCS) + $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) + +POWER_UT_SRCS=\ +src/power_ut.c \ +gdb_stdio.c \ +../src/fifo.c \ +src/stm32f4_adc.c \ +src/stm32f4_dac.c \ +src/system_stm32f4xx.c \ +src/startup_stm32f4xx.s \ +src/init.c \ +src/stm32f4_timer.c \ + +POWER_UT_SRCS += \ +$(CODEC2_SRC)/lpc.c \ +$(CODEC2_SRC)/nlp.c \ +$(CODEC2_SRC)/postfilter.c \ +$(CODEC2_SRC)/sine.c \ +$(CODEC2_SRC)/codec2.c \ +$(CODEC2_SRC)/kiss_fft.c \ +$(CODEC2_SRC)/interp.c \ +$(CODEC2_SRC)/lsp.c \ +$(CODEC2_SRC)/phase.c \ +$(CODEC2_SRC)/quantise.c \ +$(CODEC2_SRC)/pack.c \ +$(CODEC2_SRC)/codebook.c \ +$(CODEC2_SRC)/codebookd.c \ +$(CODEC2_SRC)/codebookjvm.c \ +$(CODEC2_SRC)/codebookge.c \ +$(CODEC2_SRC)/dump.c + +power_ut.elf: $(POWER_UT_SRCS) + $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) + +clean: + rm -f *.o + rm -f *.elf + rm -f libstm32f4.a + find $(PERIPHLIBDIR) -type f -name '*.o' -exec rm {} \; diff --git a/codec2/branches/0.3/stm32/README.txt b/codec2/branches/0.3/stm32/README.txt new file mode 100644 index 00000000..9b79ee88 --- /dev/null +++ b/codec2/branches/0.3/stm32/README.txt @@ -0,0 +1,114 @@ +README.txt +codec2 support for the stm32f4 +David Rowe May 2013 + +Introduction +------------ + +The Makefile generates several unit tests, stm32f4_codec2.elf is the +most important. It's is equivalent to c2demo.c and runs the encoder +and decoder on raw speech files. It also gathers and prints profiling +information and can dump the codec states to compare changes. + +gdb_stdio system +---------------- + +stutil contains a gdb server that talks to the target firmware. +stutil has been patched to allow "semihosting": stdio requests on the +target are re-directed to the host PC. So if you call printf on the +target, it appears on the host PC console. With printf/fread/fwrite +and gdb it makes developing on bare metal just like developing on any +command line gcc system. + +The root path for files accessed by the target is the path st-util is +run from. + +Getting Started +--------------- + +. Install arm toolchain binary + + $ cd ~ + $ wget https://launchpad.net/gcc-arm-embedded/4.7/4.7-2013-q1-update/+download/gcc-arm-none-eabi-4_7-2013q1-20130313-linux.tar.bz2 + $ tar xjf gcc-arm-none-eabi-4_7-2012q4-20121208-linux.tar.bz2 + +. Build codec2 unit test: + + $ cd codec2_dev/stm32 + If necessary, edit the BINPATH variable in Makefile for your toolchain location + $ make + +. Build stlink: + + $ cd ~ + $ git clone https://github.com/shenki/stlink.git + $ cd stlink + ~/stlink$ sudo apt-get install libusb-1.0-0-dev libelf-dev automake + ~/stlink$ ./autogen.sh + ~/stlink$ ./configure + ~/stlink$ make + +. Place a copy of hts1a.raw in the stlink directory and start st-util: + + ~/stlink$ cp ~/codec2/raw/hts1a.raw stm_in.raw + ~/stlink$ sudo ./st-util -f /home/david/codec2/stm32/stm32f4_codec2.elf + +. In _another_ console start gdb: + + $ ~/codec2/stm32$ ~/gcc-arm-none-eabi-4_7-2013q1/bin/arm-none-eabi-gdb stm32f4_codec2.elf + + (gdb) tar ext :4242 + + (gdb) load + `/home/david/codec2/stm32/fft_test.elf' has changed; re-reading symbols. + Loading section .isr_vector, size 0x188 lma 0x8000000 + Loading section .text, size 0x1a4b4 lma 0x8000188 + Loading section .data, size 0x28f0 lma 0x801a63c + Start address 0x800a885, load size 118572 + Transfer rate: 13 KB/sec, 10779 bytes/write. + +. Power cycle Discovery. + +. Stop st-util using ctrl-C, then restart st-util + +. Back to gdb: + + (gdb) tar ext :4242 + A program is being debugged already. Kill it? (y or n) y + Remote connection closed + (gdb) tar ext :4242 + Remote debugging using :4242 + Reset_Handler () at lib/startup_stm32f4xx.s:69 + 69 movs r1, #0 + + (gdb) c + Continuing. + +. gdb will prints various debug messages, and the codec output file + will be written to ~/stlink. + + ~/stlink$ play -r 8000 -s -2 stm_out.raw + +Process +------- + +1. Profiling macros, grep on TIMER_xxxx + +2. Enable DUMP variable in Makefile to dump files, note profiling + times will be corrupted by this due to latency in talking to Host + +3. Compare outputs using octave/diff_codec. Example: + + octave:> diff_codec("~/stlink/ref/hts1a_out_1300.raw", "~/stlink/hts1a_out_1300.raw","~/stlink/stm32f4", "~/stlink/ref/stm32f4") + +Gotcha +------ + +Using printf rather than gdb_stdio_printf, regular stdio functions are +stubbed out so will link, just nothing will happen. + +TODO +---- + + + check if "CFLAGS: -mlittle-endian -mthumb -mthumb-interwork" needed + + double check if _fini hack is OK (src/init.c) diff --git a/codec2/branches/0.3/stm32/inc/gdb_stdio.h b/codec2/branches/0.3/stm32/inc/gdb_stdio.h new file mode 100644 index 00000000..eafabca4 --- /dev/null +++ b/codec2/branches/0.3/stm32/inc/gdb_stdio.h @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: gdb_stdio.h + AUTHOR......: David Rowe + DATE CREATED: April 23 2013 + + Some stdio I/O functions that perform I/O on the host using gdb. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2013 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#ifndef __GDB_STDIO__ +#define __GDB_STDIO__ + +#include +#include + +void gdb_stdio_fprintf(FILE *file, const char *format, ...); +void gdb_stdio_printf(const char *format, ...); +FILE *gdb_stdio_fopen(char file_name[], char mode[]); +void gdb_stdio_fclose(FILE *file); +int gdb_stdio_fwrite(void *ptr, int size, int nmemb, FILE *file); +int gdb_stdio_fread(void *ptr, int size, int nmemb, FILE *file); + +#define printf gdb_stdio_printf +#define fopen gdb_stdio_fopen +#define fclose gdb_stdio_fclose +#define fread gdb_stdio_fread +#define fwrite gdb_stdio_fwrite + +#endif diff --git a/codec2/branches/0.3/stm32/inc/stm32f4_adc.h b/codec2/branches/0.3/stm32/inc/stm32f4_adc.h new file mode 100644 index 00000000..b14110cb --- /dev/null +++ b/codec2/branches/0.3/stm32/inc/stm32f4_adc.h @@ -0,0 +1,34 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: stm32f4_adc.h + AUTHOR......: David Rowe + DATE CREATED: 30 May 2014 + + ADC driver module for STM32F4. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2014 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#ifndef __STM32F4_ADC__ +#define __STM32F4_ADC__ + +void adc_open(void); +int adc_read(short buf[], int n); + +#endif diff --git a/codec2/branches/0.3/stm32/inc/stm32f4_dac.h b/codec2/branches/0.3/stm32/inc/stm32f4_dac.h new file mode 100644 index 00000000..3a298321 --- /dev/null +++ b/codec2/branches/0.3/stm32/inc/stm32f4_dac.h @@ -0,0 +1,34 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: stm32f4_dac.h + AUTHOR......: David Rowe + DATE CREATED: 1 June 2013 + + DAC driver module for STM32F4. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2013 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#ifndef __STM32F4_DAC__ +#define __STM32F4_DAC__ + +void dac_open(void); +int dac_write(short buf[], int n); + +#endif diff --git a/codec2/branches/0.3/stm32/inc/stm32f4xx_conf.h b/codec2/branches/0.3/stm32/inc/stm32f4xx_conf.h new file mode 100644 index 00000000..a791166d --- /dev/null +++ b/codec2/branches/0.3/stm32/inc/stm32f4xx_conf.h @@ -0,0 +1,94 @@ +/** + ****************************************************************************** + * @file stm32f4xx_conf.h + * @author MCD Application Team + * @version V1.0.0 + * @date 19-September-2011 + * @brief Library configuration file. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_CONF_H +#define __STM32F4xx_CONF_H + +#if defined (HSE_VALUE) +/* Redefine the HSE value; it's equal to 8 MHz on the STM32F4-DISCOVERY Kit */ + #undef HSE_VALUE + #define HSE_VALUE ((uint32_t)8000000) +#endif /* HSE_VALUE */ + +/* Includes ------------------------------------------------------------------*/ +/* Uncomment the line below to enable peripheral header file inclusion */ +#include "stm32f4xx_adc.h" +#include "stm32f4xx_can.h" +#include "stm32f4xx_crc.h" +#include "stm32f4xx_cryp.h" +#include "stm32f4xx_dac.h" +#include "stm32f4xx_dbgmcu.h" +#include "stm32f4xx_dcmi.h" +#include "stm32f4xx_dma.h" +#include "stm32f4xx_exti.h" +#include "stm32f4xx_flash.h" +#include "stm32f4xx_fsmc.h" +#include "stm32f4xx_hash.h" +#include "stm32f4xx_gpio.h" +#include "stm32f4xx_i2c.h" +#include "stm32f4xx_iwdg.h" +#include "stm32f4xx_pwr.h" +#include "stm32f4xx_rcc.h" +#include "stm32f4xx_rng.h" +#include "stm32f4xx_rtc.h" +#include "stm32f4xx_sdio.h" +#include "stm32f4xx_spi.h" +#include "stm32f4xx_syscfg.h" +#include "stm32f4xx_tim.h" +#include "stm32f4xx_usart.h" +#include "stm32f4xx_wwdg.h" +#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* If an external clock source is used, then the value of the following define + should be set to the value of the external clock source, else, if no external + clock is used, keep this define commented */ +/*#define I2S_EXTERNAL_CLOCK_VAL 12288000 */ /* Value of the external clock in Hz */ + + +/* Uncomment the line below to expanse the "assert_param" macro in the + Standard Peripheral Library drivers code */ +/* #define USE_FULL_ASSERT 1 */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT + +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0) +#endif /* USE_FULL_ASSERT */ + +#endif /* __STM32F4xx_CONF_H */ + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/codec2/branches/0.3/stm32/src/adc_rec.c b/codec2/branches/0.3/stm32/src/adc_rec.c new file mode 100644 index 00000000..3d5992f9 --- /dev/null +++ b/codec2/branches/0.3/stm32/src/adc_rec.c @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: adc_rec.c + AUTHOR......: David Rowe + DATE CREATED: 30 May 2014 + + Recordss a 16 kHz sample rate raw file from the STM32F4 ADC. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2014 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include "stm32f4_adc.h" +#include "gdb_stdio.h" + +#define REC_TIME_SECS 10 +#define N 2000 +#define FS 16000 + +int main(void){ + short buf[N]; + FILE *frec; + int i, bufs; + + adc_open(); + + frec = fopen("stm_out.raw", "wb"); + if (frec == NULL) { + printf("Error opening input file: stm_out.raw\n\nTerminating....\n"); + exit(1); + } + bufs = FS*REC_TIME_SECS/N; + + printf("Starting!\n"); + for(i=0; i
© COPYRIGHT 2013 STMicroelectronics
+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ +int interrupts; + + +/* Includes ------------------------------------------------------------------*/ +#include "dac_it.h" + +/** @addtogroup STM32F4xx_StdPeriph_Examples + * @{ + */ + +/** @addtogroup DMA_FLASHToRAM + * @{ + */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/******************************************************************************/ +/* Cortex-M4 Processor Exceptions Handlers */ +/******************************************************************************/ + +/** + * @brief This function handles NMI exception. + * @param None + * @retval None + */ +void NMI_Handler(void) +{ +} + +/** + * @brief This function handles Hard Fault exception. + * @param None + * @retval None + */ +void HardFault_Handler(void) +{ + /* Go to infinite loop when Hard Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Memory Manage exception. + * @param None + * @retval None + */ +void MemManage_Handler(void) +{ + /* Go to infinite loop when Memory Manage exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Bus Fault exception. + * @param None + * @retval None + */ +void BusFault_Handler(void) +{ + /* Go to infinite loop when Bus Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles Usage Fault exception. + * @param None + * @retval None + */ +void UsageFault_Handler(void) +{ + /* Go to infinite loop when Usage Fault exception occurs */ + while (1) + { + } +} + +/** + * @brief This function handles SVCall exception. + * @param None + * @retval None + */ +void SVC_Handler(void) +{ +} + +/** + * @brief This function handles Debug Monitor exception. + * @param None + * @retval None + */ +void DebugMon_Handler(void) +{ +} + +/** + * @brief This function handles PendSVC exception. + * @param None + * @retval None + */ +void PendSV_Handler(void) +{ +} + +/** + * @brief This function handles SysTick Handler. + * @param None + * @retval None + */ +void SysTick_Handler(void) +{ +} + +/******************************************************************************/ +/* STM32F4xx Peripherals Interrupt Handlers */ +/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ +/* available peripheral interrupt handler's name please refer to the startup */ +/* file (startup_stm32f40xx.s/startup_stm32f427x.s). */ +/******************************************************************************/ + +/** + * @brief This function handles DMA Stream interrupt request. + * @param None + * @retval None + */ +void DMA1_Stream6_IRQHandler(void) +{ + + /* Transfer half empty interrupt */ + + if(DMA_GetITStatus(DMA1_Stream6, DMA_IT_HTIF6) != RESET)) + { + /* fill first half from fifo */ + + fifo_read(DMA1_Stream6_fifo, dac_buf, DAC_BUF_SZ/2); + + /* Clear DMA Stream Transfer Complete interrupt pending bit */ + + DMA_ClearITPendingBit(DMA1_Stream6, DMA_IT_HTIF6); + + interrupts++; + } + + /* Transfer complete interrupt */ + + if(DMA_GetITStatus(DMA1_Stream6, DMA_IT_TCIF6) != RESET)) + { + /* fill second half from fifo */ + + fifo_read(DMA1_Stream6_fifo, &dac_buf[DAC_BUF_SZ/2], DAC_BUF_SZ/2); + + /* Clear DMA Stream Transfer Complete interrupt pending bit */ + + DMA_ClearITPendingBit(DMA1_Stream6, DMA_IT_TCIF6); + + interrupts++; + } +} + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/codec2/branches/0.3/stm32/src/dac_play.c b/codec2/branches/0.3/stm32/src/dac_play.c new file mode 100644 index 00000000..ba0ec1ab --- /dev/null +++ b/codec2/branches/0.3/stm32/src/dac_play.c @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: dac_play.c + AUTHOR......: David Rowe + DATE CREATED: 1 June 2013 + + Plays a 16 kHz sample rate raw file to the STM32F4 DAC. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2013 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include "stm32f4_dac.h" +#include "gdb_stdio.h" + +#define N 2000 + +int main(void) { + short buf[N]; + FILE *fplay; + + dac_open(); + + while(1) { + fplay = fopen("stm_in.raw", "rb"); + if (fplay == NULL) { + printf("Error opening input file: stm_in.raw\n\nTerminating....\n"); + exit(1); + } + + printf("Starting!\n"); + + while(fread(buf, sizeof(short), N, fplay) == N) { + while(dac_write(buf, N) == -1); + } + + printf("Finished!\n"); + fclose(fplay); + } + + /* let FIFO empty */ + + while(1); +} + diff --git a/codec2/branches/0.3/stm32/src/dac_ut.c b/codec2/branches/0.3/stm32/src/dac_ut.c new file mode 100644 index 00000000..139dc759 --- /dev/null +++ b/codec2/branches/0.3/stm32/src/dac_ut.c @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: dac_ut.c + AUTHOR......: David Rowe + DATE CREATED: May 31 2013 + + Plays a 500 Hz sine wave sampled at 16 kHz out of PA5 on a Discovery board. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2013 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include "stm32f4_dac.h" + +#define SINE_SAMPLES 32 + + +/* 32 sample sine wave which at Fs=16kHz will be 500Hz. Not sampels + are 16 bit 2's complement, the DAC driver convertsto 12 bit + unsigned. */ + +short aSine[] = { + -16, 6384, 12528, 18192, 23200, 27232, 30256, 32128, 32752, 32128, + 30256, 27232, 23152, 18192, 12528, 6384, -16, -6416, -12560, -18224, + -23184, -27264, -30288, -32160, -32768, -32160, -30288, -27264, -23184, -18224, + -12560, -6416 +}; + +int main(void) { + int i; + + //for(i=0; i<32; i++) + // aSine[i] /= 2; + + dac_open(); + + while (1) { + + /* keep DAC FIFO topped up */ + + dac_write((short*)aSine, SINE_SAMPLES); + } + +} + diff --git a/codec2/branches/0.3/stm32/src/fft_test.c b/codec2/branches/0.3/stm32/src/fft_test.c new file mode 100644 index 00000000..cc25653b --- /dev/null +++ b/codec2/branches/0.3/stm32/src/fft_test.c @@ -0,0 +1,176 @@ +/* ---------------------------------------------------------------------- +* Copyright (C) 2010 ARM Limited. All rights reserved. +* +* $Date: 29. November 2010 +* $Revision: V1.0.3 +* +* Project: CMSIS DSP Library +* Title: arm_fft_bin_example_f32.c +* +* Description: Example code demonstrating calculation of Max energy bin of +* frequency domain of input signal. +* +* Target Processor: Cortex-M4/Cortex-M3 +* +* +* Version 1.0.3 2010/11/29 +* Re-organized the CMSIS folders and updated documentation. +* +* Version 1.0.1 2010/10/05 KK +* Production release and review comments incorporated. +* +* Version 1.0.0 2010/09/20 KK +* Production release and review comments incorporated. +* ------------------------------------------------------------------- */ + +/** + * @ingroup groupExamples + */ + +/** + * @defgroup FrequencyBin Frequency Bin Example + * + * \par Description + * \par + * Demonstrates the calculation of the maximum energy bin in the frequency + * domain of the input signal with the use of Complex FFT, Complex + * Magnitude, and Maximum functions. + * + * \par Algorithm: + * \par + * The input test signal contains a 10 kHz signal with uniformly distributed white noise. + * Calculating the FFT of the input signal will give us the maximum energy of the + * bin corresponding to the input frequency of 10 kHz. + * + * \par Block Diagram: + * \image html FFTBin.gif "Block Diagram" + * \par + * The figure below shows the time domain signal of 10 kHz signal with + * uniformly distributed white noise, and the next figure shows the input + * in the frequency domain. The bin with maximum energy corresponds to 10 kHz signal. + * \par + * \image html FFTBinInput.gif "Input signal in Time domain" + * \image html FFTBinOutput.gif "Input signal in Frequency domain" + * + * \par Variables Description: + * \par + * \li \c testInput_f32_10khz points to the input data + * \li \c testOutput points to the output data + * \li \c fftSize length of FFT + * \li \c ifftFlag flag for the selection of CFFT/CIFFT + * \li \c doBitReverse Flag for selection of normal order or bit reversed order + * \li \c refIndex reference index value at which maximum energy of bin ocuurs + * \li \c testIndex calculated index value at which maximum energy of bin ocuurs + * + * \par CMSIS DSP Software Library Functions Used: + * \par + * - arm_cfft_radix4_init_f32() + * - arm_cfft_radix4_f32() + * - arm_cmplx_mag_f32() + * - arm_max_f32() + * + * Refer + * \link arm_fft_bin_example_f32.c \endlink + * + */ + + +/** \example arm_fft_bin_example_f32.c + */ + + +#include "arm_math.h" +#include "gdb_stdio.h" +#include "machdep.h" +#include "kiss_fft.h" + +#define TEST_LENGTH_SAMPLES 1024 + +/* ------------------------------------------------------------------- +* External Input and Output buffer Declarations for FFT Bin Example +* ------------------------------------------------------------------- */ +extern float32_t testInput_f32_10khz[TEST_LENGTH_SAMPLES]; +static float32_t testOutput[TEST_LENGTH_SAMPLES/2]; +static float32_t kiss_complex_out[TEST_LENGTH_SAMPLES]; + +/* ------------------------------------------------------------------ +* Global variables for FFT Bin Example +* ------------------------------------------------------------------- */ +uint32_t fftSize = TEST_LENGTH_SAMPLES/2; +uint32_t ifftFlag = 0; +uint32_t doBitReverse = 1; + +/* Reference index at which max energy of bin ocuurs */ +uint32_t refIndex = 213, testIndex = 0; + +/* ---------------------------------------------------------------------- +* Max magnitude FFT Bin test +* ------------------------------------------------------------------- */ + +void SystemInit(void); + +int main(void) +{ + + arm_status status; + arm_cfft_radix2_instance_f32 S; + float32_t maxValue; + unsigned int fft_start, kiss_fft_start; + kiss_fft_cfg fft_fwd_cfg; + + SystemInit(); + machdep_timer_init(); + fft_fwd_cfg = kiss_fft_alloc(fftSize, 0, NULL, NULL); + kiss_fft_start = machdep_timer_sample(); + kiss_fft(fft_fwd_cfg, (kiss_fft_cpx *)testInput_f32_10khz, + (kiss_fft_cpx *)kiss_complex_out); + machdep_timer_sample_and_log(kiss_fft_start, " kiss_fft"); + + status = ARM_MATH_SUCCESS; + + /* Initialize the CFFT/CIFFT module */ + status = arm_cfft_radix2_init_f32(&S, fftSize, ifftFlag, doBitReverse); + + /* Process the data through the CFFT/CIFFT module */ + fft_start = machdep_timer_sample(); + arm_cfft_radix2_f32(&S, testInput_f32_10khz); + machdep_timer_sample_and_log(fft_start, " fft"); + machdep_timer_print_logged_samples(); + + /* Process the data through the Complex Magnitude Module for + calculating the magnitude at each bin */ + arm_cmplx_mag_f32(testInput_f32_10khz, testOutput,fftSize); + + /* Calculates maxValue and returns corresponding BIN value */ + arm_max_f32(testOutput, fftSize, &maxValue, &testIndex); + + if(testIndex != refIndex) + { + status = ARM_MATH_TEST_FAILURE; + } + + /* ---------------------------------------------------------------------- + ** Loop here if the signals fail the PASS check. + ** This denotes a test failure + ** ------------------------------------------------------------------- */ + + if( status != ARM_MATH_SUCCESS) + { + while(1); + } + + while(1); /* main function does not return */ + + return 0; +} + + /** \endlink */ + + +/* + * Dummy function to avoid compiler error + */ +void _init() { } + + + diff --git a/codec2/branches/0.3/stm32/src/gdb_stdio.c b/codec2/branches/0.3/stm32/src/gdb_stdio.c new file mode 100644 index 00000000..942d7bae --- /dev/null +++ b/codec2/branches/0.3/stm32/src/gdb_stdio.c @@ -0,0 +1,125 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: gdb_stdio.c + AUTHOR......: David Rowe + DATE CREATED: April 23 2013 + + Some stdio I/O functions that perform I/O on the host using gdb. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2013 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include +#include +#include "gdb_stdio.h" + +#define MAX_STR 2048 + +/* command codes we use to signal host */ + +#define GDB_STDIO_PRINTF 1 +#define GDB_STDIO_FOPEN 2 +#define GDB_STDIO_FCLOSE 3 +#define GDB_STDIO_FWRITE 4 +#define GDB_STDIO_FREAD 5 +#define GDB_STDIO_FPRINTF 6 + +/* globals we use to communicate with host */ + +volatile int gdb_stdio_func = 0; +volatile int gdb_stdio_ret = 0; +volatile char *gdb_stdio_pstr1; +volatile char *gdb_stdio_pstr2; +volatile int gdb_stdio_strlen1; +volatile int gdb_stdio_strlen2; +volatile FILE *gdb_stdio_file; +volatile void *gdb_stdio_ptr; +volatile int gdb_stdio_size; +volatile int gdb_stdio_nmem; + +void gdb_stdio_fprintf(FILE *file, const char *format, ...) { + va_list arg; + char str[MAX_STR]; + + va_start(arg, format); + vsnprintf(str, MAX_STR, format, arg); + va_end(arg); + gdb_stdio_file = file; + gdb_stdio_pstr1 = str; + gdb_stdio_strlen1 = strlen(str); + + gdb_stdio_func = GDB_STDIO_FPRINTF; + while(gdb_stdio_func); +} + +void gdb_stdio_printf(const char *format, ...) { + va_list arg; + char str[MAX_STR]; + + va_start(arg, format); + vsnprintf(str, MAX_STR, format, arg); + va_end(arg); + gdb_stdio_pstr1 = str; + gdb_stdio_strlen1 = strlen(str); + + gdb_stdio_func = GDB_STDIO_PRINTF; + while(gdb_stdio_func); +} + +FILE *gdb_stdio_fopen(char file_name[], char mode[]) { + gdb_stdio_pstr1 = file_name; + gdb_stdio_pstr2 = mode; + gdb_stdio_strlen1 = strlen(file_name); + gdb_stdio_strlen2 = strlen(mode); + + gdb_stdio_func = GDB_STDIO_FOPEN; + while(gdb_stdio_func); + return (FILE*)gdb_stdio_ret; +} + +void gdb_stdio_fclose(FILE *file) { + gdb_stdio_file = file; + + gdb_stdio_func = GDB_STDIO_FCLOSE; + while(gdb_stdio_func); +} + +int gdb_stdio_fwrite(void *ptr, int size, int nmem, FILE *file) { + gdb_stdio_ptr = ptr; + gdb_stdio_size = size; + gdb_stdio_nmem = nmem; + gdb_stdio_file = file; + + gdb_stdio_func = GDB_STDIO_FWRITE; + while(gdb_stdio_func); + return gdb_stdio_ret; +} + +int gdb_stdio_fread(void *ptr, int size, int nmem, FILE *file) { + gdb_stdio_ptr = ptr; + gdb_stdio_size = size; + gdb_stdio_nmem = nmem; + gdb_stdio_file = file; + + gdb_stdio_func = GDB_STDIO_FREAD; + while(gdb_stdio_func); + return gdb_stdio_ret; +} + diff --git a/codec2/branches/0.3/stm32/src/init.c b/codec2/branches/0.3/stm32/src/init.c new file mode 100644 index 00000000..527141d4 --- /dev/null +++ b/codec2/branches/0.3/stm32/src/init.c @@ -0,0 +1,10 @@ +/* + * Dummy function to avoid compiler error + */ +void _init() { + +} +void _fini() { + +} + diff --git a/codec2/branches/0.3/stm32/src/main.c b/codec2/branches/0.3/stm32/src/main.c new file mode 100644 index 00000000..28d8ba75 --- /dev/null +++ b/codec2/branches/0.3/stm32/src/main.c @@ -0,0 +1,156 @@ +#include +#include +#include +#include + +#include "stm32f4xx_conf.h" +#include "stm32f4xx.h" +#include "gdb_stdio.h" +#include "codec2.h" +#include "dump.h" +#include "sine.h" +#include "machdep.h" + +#ifdef __EMBEDDED__ +#define printf gdb_stdio_printf +#define fopen gdb_stdio_fopen +#define fclose gdb_stdio_fclose +#define fread gdb_stdio_fread +#define fwrite gdb_stdio_fwrite +#endif + +static void c2demo(int mode, char inputfile[], char outputfile[]) +{ + struct CODEC2 *codec2; + short *inbuf, *outbuf; + unsigned char *bits; + int nsam, nbit; + FILE *fin, *fout; + int frame; + TIMER_VAR(enc_start, dec_start); + + codec2 = codec2_create(mode); + nsam = codec2_samples_per_frame(codec2); + outbuf = (short*)malloc(nsam*sizeof(short)); + inbuf = (short*)malloc(nsam*sizeof(short)); + nbit = codec2_bits_per_frame(codec2); + bits = (unsigned char*)malloc(nbit*sizeof(char)); + + fin = fopen(inputfile, "rb"); + if (fin == NULL) { + printf("Error opening input file: %s\n\nTerminating....\n",inputfile); + exit(1); + } + + fout = fopen(outputfile, "wb"); + if (fout == NULL) { + printf("Error opening output file: %s\n\nTerminating....\n",outputfile); + exit(1); + } + + #ifdef DUMP + dump_on("stm32f4"); + #endif + frame = 0; + + while (fread(inbuf, sizeof(short), nsam, fin) == nsam) { + TIMER_SAMPLE(enc_start); + codec2_encode(codec2, bits, inbuf); + TIMER_SAMPLE_AND_LOG(dec_start, enc_start, " enc"); + codec2_decode(codec2, outbuf, bits); + TIMER_SAMPLE_AND_LOG2(dec_start, " dec"); + TIMER_SAMPLE_AND_LOG2(enc_start, " enc & dec"); + fwrite((char*)outbuf, sizeof(short), nsam, fout); + printf("frame: %d\n", ++frame); + machdep_timer_print_logged_samples(); + } + + #ifdef DUMP + dump_off("sm32f4"); + #endif + + fclose(fin); + fclose(fout); + free(inbuf); + free(outbuf); + free(bits); + codec2_destroy(codec2); +} + +#define SPEED_TEST_SAMPLES 24000 + +static void c2speedtest(int mode, char inputfile[]) +{ + struct CODEC2 *codec2; + short *inbuf, *outbuf, *pinbuf; + unsigned char *bits; + int nsam, nbit, nframes; + FILE *fin; + int f, nread; + + codec2 = codec2_create(mode); + nsam = codec2_samples_per_frame(codec2); + nframes = SPEED_TEST_SAMPLES/nsam; + outbuf = (short*)malloc(nsam*sizeof(short)); + inbuf = (short*)malloc(SPEED_TEST_SAMPLES*sizeof(short)); + nbit = codec2_bits_per_frame(codec2); + bits = (unsigned char*)malloc(nbit*sizeof(char)); + + fin = fopen(inputfile, "rb"); + if (fin == NULL) { + printf("Error opening input file: %s\nTerminating....\n",inputfile); + exit(1); + } + + nread = fread(inbuf, sizeof(short), SPEED_TEST_SAMPLES, fin); + if (nread != SPEED_TEST_SAMPLES) { + printf("error reading %s, %d samples reqd, %d read\n", + inputfile, SPEED_TEST_SAMPLES, nread); + } + fclose(fin); + + pinbuf = inbuf; + for(f=0; fODR = (1 << 13); + codec2_encode(codec2, bits, pinbuf); + pinbuf += nsam; + GPIOD->ODR &= ~(1 << 13); + codec2_decode(codec2, outbuf, bits); + } + + free(inbuf); + free(outbuf); + free(bits); + codec2_destroy(codec2); +} + +void gpio_init() { + RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN; // enable the clock to GPIOD + GPIOD->MODER = (1 << 26); // set pin 13 to be general + // purpose output +} + +int main(int argc, char *argv[]) { + SystemInit(); + gpio_init(); + machdep_timer_init (); + + printf("Starting c2demo\n"); + + /* File I/O test for profiling or (with #define DUMP) + dumping states for optimisation and tiuning */ + + c2demo(CODEC2_MODE_1600, "stm_in.raw", "stm_out.raw"); + + printf("Starting c2 speed test\n"); + + /* Another test of execution speed. Look at PD13 with a + oscilliscope. On time is enc, off is dec */ + + c2speedtest(CODEC2_MODE_1600, "stm_in.raw"); + + printf("Finished\n"); + + return 0; +} + diff --git a/codec2/branches/0.3/stm32/src/startup_stm32f4xx.s b/codec2/branches/0.3/stm32/src/startup_stm32f4xx.s new file mode 100644 index 00000000..658ab363 --- /dev/null +++ b/codec2/branches/0.3/stm32/src/startup_stm32f4xx.s @@ -0,0 +1,512 @@ +/** + ****************************************************************************** + * @file startup_stm32f4xx.s + * @author MCD Application Team + * @version V1.0.0 + * @date 30-September-2011 + * @brief STM32F4xx Devices vector table for Atollic TrueSTUDIO toolchain. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Configure the clock system and the external SRAM mounted on + * STM324xG-EVAL board to be used as data memory (optional, + * to be enabled by user) + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M4 processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m3 + .fpu softvfp + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss +/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss + +/* Call the clock system intitialization function.*/ + bl SystemInit +/* Call static constructors */ + bl __libc_init_array +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M3. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + + +g_pfnVectors: + .word _estack + .word Reset_Handler + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + + /* External Interrupts */ + .word WWDG_IRQHandler /* Window WatchDog */ + .word PVD_IRQHandler /* PVD through EXTI Line detection */ + .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ + .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ + .word FLASH_IRQHandler /* FLASH */ + .word RCC_IRQHandler /* RCC */ + .word EXTI0_IRQHandler /* EXTI Line0 */ + .word EXTI1_IRQHandler /* EXTI Line1 */ + .word EXTI2_IRQHandler /* EXTI Line2 */ + .word EXTI3_IRQHandler /* EXTI Line3 */ + .word EXTI4_IRQHandler /* EXTI Line4 */ + .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ + .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ + .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ + .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ + .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ + .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ + .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ + .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ + .word CAN1_TX_IRQHandler /* CAN1 TX */ + .word CAN1_RX0_IRQHandler /* CAN1 RX0 */ + .word CAN1_RX1_IRQHandler /* CAN1 RX1 */ + .word CAN1_SCE_IRQHandler /* CAN1 SCE */ + .word EXTI9_5_IRQHandler /* External Line[9:5]s */ + .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ + .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ + .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ + .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ + .word TIM2_IRQHandler /* TIM2 */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM4_IRQHandler /* TIM4 */ + .word I2C1_EV_IRQHandler /* I2C1 Event */ + .word I2C1_ER_IRQHandler /* I2C1 Error */ + .word I2C2_EV_IRQHandler /* I2C2 Event */ + .word I2C2_ER_IRQHandler /* I2C2 Error */ + .word SPI1_IRQHandler /* SPI1 */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ + .word USART2_IRQHandler /* USART2 */ + .word USART3_IRQHandler /* USART3 */ + .word EXTI15_10_IRQHandler /* External Line[15:10]s */ + .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ + .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ + .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ + .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ + .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ + .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ + .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ + .word FSMC_IRQHandler /* FSMC */ + .word SDIO_IRQHandler /* SDIO */ + .word TIM5_IRQHandler /* TIM5 */ + .word SPI3_IRQHandler /* SPI3 */ + .word UART4_IRQHandler /* UART4 */ + .word UART5_IRQHandler /* UART5 */ + .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ + .word TIM7_IRQHandler /* TIM7 */ + .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ + .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ + .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ + .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ + .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ + .word ETH_IRQHandler /* Ethernet */ + .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ + .word CAN2_TX_IRQHandler /* CAN2 TX */ + .word CAN2_RX0_IRQHandler /* CAN2 RX0 */ + .word CAN2_RX1_IRQHandler /* CAN2 RX1 */ + .word CAN2_SCE_IRQHandler /* CAN2 SCE */ + .word OTG_FS_IRQHandler /* USB OTG FS */ + .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ + .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ + .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ + .word USART6_IRQHandler /* USART6 */ + .word I2C3_EV_IRQHandler /* I2C3 event */ + .word I2C3_ER_IRQHandler /* I2C3 error */ + .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ + .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ + .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ + .word OTG_HS_IRQHandler /* USB OTG HS */ + .word DCMI_IRQHandler /* DCMI */ + .word CRYP_IRQHandler /* CRYP crypto */ + .word HASH_RNG_IRQHandler /* Hash and Rng */ + .word FPU_IRQHandler /* FPU */ + + +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_IRQHandler + .thumb_set PVD_IRQHandler,Default_Handler + + .weak TAMP_STAMP_IRQHandler + .thumb_set TAMP_STAMP_IRQHandler,Default_Handler + + .weak RTC_WKUP_IRQHandler + .thumb_set RTC_WKUP_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Stream0_IRQHandler + .thumb_set DMA1_Stream0_IRQHandler,Default_Handler + + .weak DMA1_Stream1_IRQHandler + .thumb_set DMA1_Stream1_IRQHandler,Default_Handler + + .weak DMA1_Stream2_IRQHandler + .thumb_set DMA1_Stream2_IRQHandler,Default_Handler + + .weak DMA1_Stream3_IRQHandler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + + .weak DMA1_Stream4_IRQHandler + .thumb_set DMA1_Stream4_IRQHandler,Default_Handler + + .weak DMA1_Stream5_IRQHandler + .thumb_set DMA1_Stream5_IRQHandler,Default_Handler + + .weak DMA1_Stream6_IRQHandler + .thumb_set DMA1_Stream6_IRQHandler,Default_Handler + + .weak ADC_IRQHandler + .thumb_set ADC_IRQHandler,Default_Handler + + .weak CAN1_TX_IRQHandler + .thumb_set CAN1_TX_IRQHandler,Default_Handler + + .weak CAN1_RX0_IRQHandler + .thumb_set CAN1_RX0_IRQHandler,Default_Handler + + .weak CAN1_RX1_IRQHandler + .thumb_set CAN1_RX1_IRQHandler,Default_Handler + + .weak CAN1_SCE_IRQHandler + .thumb_set CAN1_SCE_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_TIM9_IRQHandler + .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler + + .weak TIM1_UP_TIM10_IRQHandler + .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_TIM11_IRQHandler + .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak USART3_IRQHandler + .thumb_set USART3_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTC_Alarm_IRQHandler + .thumb_set RTC_Alarm_IRQHandler,Default_Handler + + .weak OTG_FS_WKUP_IRQHandler + .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler + + .weak TIM8_BRK_TIM12_IRQHandler + .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler + + .weak TIM8_UP_TIM13_IRQHandler + .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler + + .weak TIM8_TRG_COM_TIM14_IRQHandler + .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler + + .weak TIM8_CC_IRQHandler + .thumb_set TIM8_CC_IRQHandler,Default_Handler + + .weak DMA1_Stream7_IRQHandler + .thumb_set DMA1_Stream7_IRQHandler,Default_Handler + + .weak FSMC_IRQHandler + .thumb_set FSMC_IRQHandler,Default_Handler + + .weak SDIO_IRQHandler + .thumb_set SDIO_IRQHandler,Default_Handler + + .weak TIM5_IRQHandler + .thumb_set TIM5_IRQHandler,Default_Handler + + .weak SPI3_IRQHandler + .thumb_set SPI3_IRQHandler,Default_Handler + + .weak UART4_IRQHandler + .thumb_set UART4_IRQHandler,Default_Handler + + .weak UART5_IRQHandler + .thumb_set UART5_IRQHandler,Default_Handler + + .weak TIM6_DAC_IRQHandler + .thumb_set TIM6_DAC_IRQHandler,Default_Handler + + .weak TIM7_IRQHandler + .thumb_set TIM7_IRQHandler,Default_Handler + + .weak DMA2_Stream0_IRQHandler + .thumb_set DMA2_Stream0_IRQHandler,Default_Handler + + .weak DMA2_Stream1_IRQHandler + .thumb_set DMA2_Stream1_IRQHandler,Default_Handler + + .weak DMA2_Stream2_IRQHandler + .thumb_set DMA2_Stream2_IRQHandler,Default_Handler + + .weak DMA2_Stream3_IRQHandler + .thumb_set DMA2_Stream3_IRQHandler,Default_Handler + + .weak DMA2_Stream4_IRQHandler + .thumb_set DMA2_Stream4_IRQHandler,Default_Handler + + .weak ETH_IRQHandler + .thumb_set ETH_IRQHandler,Default_Handler + + .weak ETH_WKUP_IRQHandler + .thumb_set ETH_WKUP_IRQHandler,Default_Handler + + .weak CAN2_TX_IRQHandler + .thumb_set CAN2_TX_IRQHandler,Default_Handler + + .weak CAN2_RX0_IRQHandler + .thumb_set CAN2_RX0_IRQHandler,Default_Handler + + .weak CAN2_RX1_IRQHandler + .thumb_set CAN2_RX1_IRQHandler,Default_Handler + + .weak CAN2_SCE_IRQHandler + .thumb_set CAN2_SCE_IRQHandler,Default_Handler + + .weak OTG_FS_IRQHandler + .thumb_set OTG_FS_IRQHandler,Default_Handler + + .weak DMA2_Stream5_IRQHandler + .thumb_set DMA2_Stream5_IRQHandler,Default_Handler + + .weak DMA2_Stream6_IRQHandler + .thumb_set DMA2_Stream6_IRQHandler,Default_Handler + + .weak DMA2_Stream7_IRQHandler + .thumb_set DMA2_Stream7_IRQHandler,Default_Handler + + .weak USART6_IRQHandler + .thumb_set USART6_IRQHandler,Default_Handler + + .weak I2C3_EV_IRQHandler + .thumb_set I2C3_EV_IRQHandler,Default_Handler + + .weak I2C3_ER_IRQHandler + .thumb_set I2C3_ER_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_OUT_IRQHandler + .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_IN_IRQHandler + .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_HS_WKUP_IRQHandler + .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler + + .weak OTG_HS_IRQHandler + .thumb_set OTG_HS_IRQHandler,Default_Handler + + .weak DCMI_IRQHandler + .thumb_set DCMI_IRQHandler,Default_Handler + + .weak CRYP_IRQHandler + .thumb_set CRYP_IRQHandler,Default_Handler + + .weak HASH_RNG_IRQHandler + .thumb_set HASH_RNG_IRQHandler,Default_Handler + + .weak FPU_IRQHandler + .thumb_set FPU_IRQHandler,Default_Handler + +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/codec2/branches/0.3/stm32/src/stm32f4_adc.c b/codec2/branches/0.3/stm32/src/stm32f4_adc.c new file mode 100644 index 00000000..62fe8a99 --- /dev/null +++ b/codec2/branches/0.3/stm32/src/stm32f4_adc.c @@ -0,0 +1,314 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: stm32f4_adc.c + AUTHOR......: David Rowe + DATE CREATED: 4 June 2013 + + ADC driver module for STM32F4. + + TODO: + [X] just get ADC to run at all, prove its sampling something.... + [X] as above with DMA + [X] half and finished interrupts, ISR + [X] timer config to drive ADC conversion, measure sample rate and confirm 16kHz + + larger ADC DMA buffer + + fifos + + work out a way to unit test + [ ] ADC working at same time as DAC + [X] remove (or make optional) the TIM_Config() code that sends PWM output to pins + [ ] check comments still valid + [X] convert to driver + [ ] way to determine which timers are used so they don't get re-sued + [ ] way to select different pins/ADCs for multiple channels, multiple channel support + [ ] access functions for halff/full/overflow to trap any issues + [ ] should FIFOs be in this drivr or in UTs connected to stdio? SmartMic will just need + 40ms of buffering + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2013 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include +#include + +#include "stm32f4xx_adc.h" +#include "stm32f4xx_gpio.h" +#include "stm32f4xx_rcc.h" + +#include "codec2_fifo.h" +#include "gdb_stdio.h" +#include "stm32f4_adc.h" + +#define ADC_BUF_SZ 320 +#define FIFO_SZ 1000 + +struct FIFO *DMA2_Stream0_fifo; +unsigned short adc_buf[ADC_BUF_SZ]; +int adc_overflow; +int half,full; + +#define ADCx_DR_ADDRESS ((uint32_t)0x4001204C) +#define DMA_CHANNELx DMA_Channel_0 +#define DMA_STREAMx DMA2_Stream0 +#define ADCx ADC1 + +#define TIM1_CCR3_ADDRESS 0x4001223C + +TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; +TIM_OCInitTypeDef TIM_OCInitStructure; +uint16_t uhTimerPeriod; +uint16_t aSRC_Buffer[3] = {0, 0, 0}; + +void Timer1Config(); +void adc_configure(); + +void adc_open(void) { + DMA2_Stream0_fifo = fifo_create(FIFO_SZ); + assert(DMA2_Stream0_fifo != NULL); + + Timer1Config(); + adc_configure(); + ADC_SoftwareStartConv(ADC1); +} + +/* n signed 16 bit samples in buf[] if return != -1 */ + +int adc_read(short buf[], int n) { + return fifo_read(DMA2_Stream0_fifo, buf, n); +} + +void Timer1Config() { + + /* TIM1 example ------------------------------------------------- + + TIM1 input clock (TIM1CLK) is set to 2 * APB2 clock (PCLK2), since APB2 + prescaler is different from 1. + TIM1CLK = 2 * PCLK2 + PCLK2 = HCLK / 2 + => TIM1CLK = 2 * (HCLK / 2) = HCLK = SystemCoreClock + + TIM1CLK = SystemCoreClock, Prescaler = 0, TIM1 counter clock = SystemCoreClock + SystemCoreClock is set to 168 MHz for STM32F4xx devices. + + The objective is to configure TIM1 channel 3 to generate complementary PWM + signal with a frequency equal to F KHz: + - TIM1_Period = (SystemCoreClock / F) - 1 + + The number of this repetitive requests is defined by the TIM1 Repetion counter, + each 3 Update Requests, the TIM1 Channel 3 Duty Cycle changes to the next new + value defined by the aSRC_Buffer. + + Note: + SystemCoreClock variable holds HCLK frequency and is defined in system_stm32f4xx.c file. + Each time the core clock (HCLK) changes, user had to call SystemCoreClockUpdate() + function to update SystemCoreClock variable value. Otherwise, any configuration + based on this variable will be incorrect. + -----------------------------------------------------------------------------*/ + + /* Compute the value to be set in ARR regiter to generate signal frequency at 16.00 Khz */ + uhTimerPeriod = (SystemCoreClock / 16000 ) - 1; + /* Compute CCR1 value to generate a duty cycle at 50% */ + aSRC_Buffer[0] = (uint16_t) (((uint32_t) 5 * (uhTimerPeriod - 1)) / 10); + /* Compute CCR1 value to generate a duty cycle at 37.5% */ + aSRC_Buffer[1] = (uint16_t) (((uint32_t) 375 * (uhTimerPeriod - 1)) / 1000); + /* Compute CCR1 value to generate a duty cycle at 25% */ + aSRC_Buffer[2] = (uint16_t) (((uint32_t) 25 * (uhTimerPeriod - 1)) / 100); + + /* TIM1 Peripheral Configuration -------------------------------------------*/ + /* TIM1 clock enable */ + RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE); + + /* Time Base configuration */ + + TIM_DeInit(TIM1); + TIM_TimeBaseStructure.TIM_Prescaler = 0; + TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; + TIM_TimeBaseStructure.TIM_Period = uhTimerPeriod; + TIM_TimeBaseStructure.TIM_ClockDivision = 0; + TIM_TimeBaseStructure.TIM_RepetitionCounter = 0; + + TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure); + + /* Channel 3 Configuration in PWM mode */ + + /* I think we just ned to enable channel 3 somehow, but without + (or optionally with) actual ouput to a GPIO pin. */ + + TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2; + TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; + TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable; + TIM_OCInitStructure.TIM_Pulse = aSRC_Buffer[0]; + TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low; + TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_Low; + TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set; + TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset; + + TIM_OC3Init(TIM1, &TIM_OCInitStructure); + + /* Enable preload feature */ + TIM_OC3PreloadConfig(TIM1, TIM_OCPreload_Enable); + + /* TIM1 counter enable */ + TIM_Cmd(TIM1, ENABLE); + + /* Main Output Enable */ + TIM_CtrlPWMOutputs(TIM1, ENABLE); +} + +void adc_configure(){ + ADC_InitTypeDef ADC_init_structure; + GPIO_InitTypeDef GPIO_initStructre; + DMA_InitTypeDef DMA_InitStructure; + NVIC_InitTypeDef NVIC_InitStructure; + + // Clock configuration + + RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1,ENABLE); + RCC_AHB1PeriphClockCmd(RCC_AHB1ENR_GPIOCEN,ENABLE); + RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); + + // Analog pin configuration + + GPIO_initStructre.GPIO_Pin = GPIO_Pin_0; // ADC Channel 10 is connected to PC0 + GPIO_initStructre.GPIO_Mode = GPIO_Mode_AN; + GPIO_initStructre.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOC,&GPIO_initStructre); + + // ADC structure configuration + + ADC_DeInit(); + ADC_init_structure.ADC_DataAlign = ADC_DataAlign_Left; + ADC_init_structure.ADC_Resolution = ADC_Resolution_12b; + ADC_init_structure.ADC_ContinuousConvMode = DISABLE; + ADC_init_structure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC3; + ADC_init_structure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_Rising; + ADC_init_structure.ADC_NbrOfConversion = 1; + ADC_init_structure.ADC_ScanConvMode = DISABLE; + ADC_Init(ADCx,&ADC_init_structure); + + // Select the channel to be read from + + ADC_RegularChannelConfig(ADCx,ADC_Channel_10,1,ADC_SampleTime_144Cycles); + + /* DMA configuration **************************************/ + + DMA_DeInit(DMA_STREAMx); + DMA_InitStructure.DMA_Channel = DMA_CHANNELx; + DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADCx_DR_ADDRESS; + DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)adc_buf; + DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; + DMA_InitStructure.DMA_BufferSize = ADC_BUF_SZ; + DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; + DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; + DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; + DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; + DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; + DMA_InitStructure.DMA_Priority = DMA_Priority_High; + DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; + DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; + DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; + DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; + DMA_Init(DMA_STREAMx, &DMA_InitStructure); + + /* Enable DMA request after last transfer (Single-ADC mode) */ + + ADC_DMARequestAfterLastTransferCmd(ADCx, ENABLE); + + /* Enable ADC1 DMA */ + + ADC_DMACmd(ADCx, ENABLE); + + /* DMA2_Stream0 enable */ + + DMA_Cmd(DMA_STREAMx, ENABLE); + + /* Enable DMA Half & Complete interrupts */ + + DMA_ITConfig(DMA2_Stream0, DMA_IT_TC | DMA_IT_HT, ENABLE); + + /* Enable the DMA Stream IRQ Channel */ + + NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream0_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); + + // Enable ADC conversion + + ADC_Cmd(ADC1,ENABLE); +} + +/* + This function handles DMA Stream interrupt request. +*/ + +void DMA2_Stream0_IRQHandler(void) { + int i, sam; + short signed_buf[ADC_BUF_SZ/2]; + + /* Half transfer interrupt */ + + if(DMA_GetITStatus(DMA2_Stream0, DMA_IT_HTIF0) != RESET) { + half++; + + /* convert to signed */ + + for(i=0; i. +*/ + +#include +#include +#include +#include "stm32f4xx.h" +#include "codec2_fifo.h" +#include "stm32f4_dac.h" + +#define DAC_DHR12R2_ADDRESS 0x40007414 +#define DAC_DHR12L2_ADDRESS 0x40007418 + +#define DAC_BUF_SZ 320 +#define FIFO_SZ 1000 +#define DAC_MAX 4096 + +DAC_InitTypeDef DAC_InitStructure; +struct FIFO *DMA1_Stream6_fifo; + +unsigned short dac_buf[DAC_BUF_SZ]; + +static void TIM6_Config(void); +static void DAC_Ch2_Config(void); + +int dac_underflow; + +void dac_open(void) { + + memset(dac_buf, 32768, sizeof(short)*DAC_BUF_SZ); + + /* Create fifo */ + + DMA1_Stream6_fifo = fifo_create(FIFO_SZ); + assert(DMA1_Stream6_fifo != NULL); + + /*!< At this stage the microcontroller clock setting is already configured, + this is done through SystemInit() function which is called from startup + files (startup_stm32f40xx.s/startup_stm32f427x.s) before to branch to + application main. + To reconfigure the default setting of SystemInit() function, refer to + system_stm32f4xx.c file + */ + + /* Preconfiguration before using DAC----------------------------------------*/ + + GPIO_InitTypeDef GPIO_InitStructure; + + /* DMA1 clock enable */ + RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1, ENABLE); + /* GPIOA clock enable (to be used with DAC) */ + RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); + /* DAC Periph clock enable */ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE); + + /* DAC channel 1 & 2 (DAC_OUT1 = PA.4)(DAC_OUT2 = PA.5) configuration */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOA, &GPIO_InitStructure); + + /* TIM6 Configuration ------------------------------------------------------*/ + + TIM6_Config(); + DAC_Ch2_Config(); + +} + +/* Accepts signed 16 bit samples */ + +int dac_write(short buf[], int n) { + return fifo_write(DMA1_Stream6_fifo, buf, n); +} + +/** + * @brief TIM6 Configuration + * @note TIM6 configuration is based on APB1 frequency + * @note TIM6 Update event occurs each TIM6CLK/256 + * @param None + * @retval None + */ +static void TIM6_Config(void) +{ + TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; + /* TIM6 Periph clock enable */ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE); + + /* -------------------------------------------------------- + + TIM3 input clock (TIM6CLK) is set to 2 * APB1 clock (PCLK1), since + APB1 prescaler is different from 1 (see system_stm32f4xx.c and Fig + 13 clock tree figure in DM0031020.pdf). + + Sample rate Fs = 2*PCLK1/TIM_ClockDivision + = (HCLK/2)/TIM_ClockDivision + + ----------------------------------------------------------- */ + + /* Time base configuration */ + TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); + TIM_TimeBaseStructure.TIM_Period = 5250; + TIM_TimeBaseStructure.TIM_Prescaler = 0; + TIM_TimeBaseStructure.TIM_ClockDivision = 0; + TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; + TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure); + + /* TIM6 TRGO selection */ + + TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update); + + /* TIM6 enable counter */ + TIM_Cmd(TIM6, ENABLE); +} + +/** + * @brief DAC Channel2 SineWave Configuration + * @param None + * @retval None + */ +static void DAC_Ch2_Config(void) +{ + DMA_InitTypeDef DMA_InitStructure; + NVIC_InitTypeDef NVIC_InitStructure; + + /* DAC channel2 Configuration */ + DAC_InitStructure.DAC_Trigger = DAC_Trigger_T6_TRGO; + DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; + DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable; + DAC_Init(DAC_Channel_2, &DAC_InitStructure); + + /* DMA1_Stream6 channel7 configuration **************************************/ + DMA_DeInit(DMA1_Stream6); + DMA_InitStructure.DMA_Channel = DMA_Channel_7; + DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)DAC_DHR12L2_ADDRESS; + DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)dac_buf; + DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; + DMA_InitStructure.DMA_BufferSize = DAC_BUF_SZ; + DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; + DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; + DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; + DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; + DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; + DMA_InitStructure.DMA_Priority = DMA_Priority_High; + DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; + DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; + DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; + DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; + DMA_Init(DMA1_Stream6, &DMA_InitStructure); + + /* Enable DMA Half & Complete interrupts */ + DMA_ITConfig(DMA1_Stream6, DMA_IT_TC | DMA_IT_HT, ENABLE); + + /* Enable the DMA Stream IRQ Channel */ + + NVIC_InitStructure.NVIC_IRQChannel = DMA1_Stream6_IRQn; + NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; + NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; + NVIC_Init(&NVIC_InitStructure); + + /* Enable DMA1_Stream6 */ + DMA_Cmd(DMA1_Stream6, ENABLE); + + /* Enable DAC Channel2 */ + DAC_Cmd(DAC_Channel_2, ENABLE); + + /* Enable DMA for DAC Channel2 */ + DAC_DMACmd(DAC_Channel_2, ENABLE); +} + +/******************************************************************************/ +/* STM32F4xx Peripherals Interrupt Handlers */ +/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ +/* available peripheral interrupt handler's name please refer to the startup */ +/* file (startup_stm32f40xx.s/startup_stm32f427x.s). */ +/******************************************************************************/ + +/* + This function handles DMA Stream interrupt request. +*/ + +void DMA1_Stream6_IRQHandler(void) { + int i, sam; + short signed_buf[DAC_BUF_SZ/2]; + + /* Transfer half empty interrupt */ + + if(DMA_GetITStatus(DMA1_Stream6, DMA_IT_HTIF6) != RESET) { + /* fill first half from fifo */ + + if (fifo_read(DMA1_Stream6_fifo, signed_buf, DAC_BUF_SZ/2) == -1) { + memset(signed_buf, 0, sizeof(short)*DAC_BUF_SZ/2); + dac_underflow++; + } + + /* convert to unsigned */ + + for(i=0; i. +*/ + + +#include +#include +#include + +#include "stm32f4xx_gpio.h" +#include "stm32f4xx_rcc.h" + +#define TIM1_CCR3_ADDRESS 0x4001003C +//#define TIM1_CCR3_ADDRESS 0x4001223C +#define SINE_SAMPLES 32 + +TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; +TIM_OCInitTypeDef TIM_OCInitStructure; +uint16_t uhTimerPeriod; +uint16_t aSRC_Buffer[SINE_SAMPLES] = {0, 0, 0}; + +/* 32 sample sine wave which at Fs=16kHz will be 500Hz. Not sampels + are 16 bit 2's complement, the DAC driver convertsto 12 bit + unsigned. */ + +short aSine[SINE_SAMPLES] = { + -16, 6384, 12528, 18192, 23200, 27232, 30256, 32128, 32752, 32128, + 30256, 27232, 23152, 18192, 12528, 6384, -16, -6416, -12560, -18224, + -23184, -27264, -30288, -32160, -32768, -32160, -30288, -27264, -23184, -18224, + -12560, -6416 +}; + +void Timer1Config(); + +#define FS 16000 + +int main(void){ + Timer1Config(); + while(1); +} + +/* DR: TIM_Config configures a couple of I/O pins for PWM output from + Timer1 Channel 3. Note I dont think any of this is needed, except + perhaps to check timer frequency. Can be removed down the track. */ + +/** + * @brief Configure the TIM1 Pins. + * @param None + * @retval None + */ +static void TIM_Config(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + DMA_InitTypeDef DMA_InitStructure; + + /* GPIOA and GPIOB clock enable */ + RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB, ENABLE); + + /* GPIOA Configuration: Channel 3 as alternate function push-pull */ + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 ; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; + GPIO_Init(GPIOA, &GPIO_InitStructure); + GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_TIM1); + + /* GPIOB Configuration: Channel 3N as alternate function push-pull */ + + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; + GPIO_Init(GPIOB, &GPIO_InitStructure); + GPIO_PinAFConfig(GPIOB, GPIO_PinSource15, GPIO_AF_TIM1); + + /* DMA clock enable */ + RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2 , ENABLE); + + DMA_DeInit(DMA2_Stream6); + DMA_InitStructure.DMA_Channel = DMA_Channel_6; + DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(TIM1_CCR3_ADDRESS) ; + DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)aSRC_Buffer; + DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; + DMA_InitStructure.DMA_BufferSize = SINE_SAMPLES; + DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; + DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; + DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; + DMA_InitStructure.DMA_MemoryDataSize = DMA_PeripheralDataSize_HalfWord; + DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; + DMA_InitStructure.DMA_Priority = DMA_Priority_High; + DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; + DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; + DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; + DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; + + DMA_Init(DMA2_Stream6, &DMA_InitStructure); +} + +void Timer1Config() { + int i; + + /* TIM Configuration */ + + TIM_Config(); + + /* TIM1 example ------------------------------------------------- + + TIM1 input clock (TIM1CLK) is set to 2 * APB2 clock (PCLK2), since APB2 + prescaler is different from 1. + TIM1CLK = 2 * PCLK2 + PCLK2 = HCLK / 2 + => TIM1CLK = 2 * (HCLK / 2) = HCLK = SystemCoreClock + + TIM1CLK = SystemCoreClock, Prescaler = 0, TIM1 counter clock = SystemCoreClock + SystemCoreClock is set to 168 MHz for STM32F4xx devices. + + The objective is to configure TIM1 channel 3 to generate complementary PWM + signal with a frequency equal to F KHz: + - TIM1_Period = (SystemCoreClock / F) - 1 + + The number of this repetitive requests is defined by the TIM1 Repetion counter, + each 3 Update Requests, the TIM1 Channel 3 Duty Cycle changes to the next new + value defined by the aSRC_Buffer. + + Note: + SystemCoreClock variable holds HCLK frequency and is defined in system_stm32f4xx.c file. + Each time the core clock (HCLK) changes, user had to call SystemCoreClockUpdate() + function to update SystemCoreClock variable value. Otherwise, any configuration + based on this variable will be incorrect. + -----------------------------------------------------------------------------*/ + + /* Compute the value to be set in ARR regiter to generate signal frequency at FS */ + + uhTimerPeriod = (SystemCoreClock / FS ) - 1; + + /* Compute CCR1 values to generate a duty cycle at 50% */ + + for(i=0; i. +*/ + +#include +#include "machdep.h" +#include "gdb_stdio.h" + +volatile unsigned int *DWT_CYCCNT = (volatile unsigned int *)0xE0001004; +volatile unsigned int *DWT_CONTROL = (volatile unsigned int *)0xE0001000; +volatile unsigned int *SCB_DEMCR = (volatile unsigned int *)0xE000EDFC; + +#define CORE_CLOCK 168E6 +#define BUF_SZ 4096 + +static char buf[BUF_SZ]; + +void machdep_timer_init(void) +{ + static int enabled = 0; + + if (!enabled) { + *SCB_DEMCR = *SCB_DEMCR | 0x01000000; + *DWT_CYCCNT = 0; // reset the counter + *DWT_CONTROL = *DWT_CONTROL | 1 ; // enable the counter + + enabled = 1; + } + *buf = 0; +} + +void machdep_timer_reset(void) +{ + *DWT_CYCCNT = 0; // reset the counter +} + +unsigned int machdep_timer_sample(void) { + return *DWT_CYCCNT; +} + +/* log to a buffer, we only call printf after timing finished as it is slow */ + +unsigned int machdep_timer_sample_and_log(unsigned int start, char s[]) +{ + char tmp[80]; + + unsigned int dwt = *DWT_CYCCNT - start; + sprintf(tmp, "%s %5.2f msecs\n",s,1000.0*(float)dwt/CORE_CLOCK); + if ((strlen(buf) + strlen(tmp)) < BUF_SZ) + strcat(buf, tmp); + return *DWT_CYCCNT; +} + +void machdep_timer_print_logged_samples(void) +{ + gdb_stdio_printf("%s", buf); + *buf = 0; +} diff --git a/codec2/branches/0.3/stm32/src/system_stm32f4xx.c b/codec2/branches/0.3/stm32/src/system_stm32f4xx.c new file mode 100644 index 00000000..86953137 --- /dev/null +++ b/codec2/branches/0.3/stm32/src/system_stm32f4xx.c @@ -0,0 +1,584 @@ +/** + ****************************************************************************** + * @file system_stm32f4xx.c + * @author MCD Application Team + * @version V1.0.1 + * @date 10-July-2012 + * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File. + * This file contains the system clock configuration for STM32F4xx devices, + * and is generated by the clock configuration tool + * stm32f4xx_Clock_Configuration_V1.0.1.xls + * + * 1. This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier + * and Divider factors, AHB/APBx prescalers and Flash settings), + * depending on the configuration made in the clock xls tool. + * This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32f4xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * 2. After each device reset the HSI (16 MHz) is used as system clock source. + * Then SystemInit() function is called, in "startup_stm32f4xx.s" file, to + * configure the system clock before to branch to main program. + * + * 3. If the system clock source selected by user fails to startup, the SystemInit() + * function will do nothing and HSI still used as system clock source. User can + * add some code to deal with this issue inside the SetSysClock() function. + * + * 4. The default value of HSE crystal is set to 25MHz, refer to "HSE_VALUE" define + * in "stm32f4xx.h" file. When HSE is used as system clock source, directly or + * through PLL, and you are using different crystal you have to adapt the HSE + * value to your own configuration. + * + * 5. This file configures the system clock as follows: + *============================================================================= + *============================================================================= + * Supported STM32F4xx device revision | Rev A + *----------------------------------------------------------------------------- + * System Clock source | PLL (HSE) + *----------------------------------------------------------------------------- + * SYSCLK(Hz) | 168000000 + *----------------------------------------------------------------------------- + * HCLK(Hz) | 168000000 + *----------------------------------------------------------------------------- + * AHB Prescaler | 1 + *----------------------------------------------------------------------------- + * APB1 Prescaler | 4 + *----------------------------------------------------------------------------- + * APB2 Prescaler | 2 + *----------------------------------------------------------------------------- + * HSE Frequency(Hz) | 8000000 + *----------------------------------------------------------------------------- + * PLL_M | 8 + *----------------------------------------------------------------------------- + * PLL_N | 336 + *----------------------------------------------------------------------------- + * PLL_P | 2 + *----------------------------------------------------------------------------- + * PLL_Q | 7 + *----------------------------------------------------------------------------- + * PLLI2S_N | 352 + *----------------------------------------------------------------------------- + * PLLI2S_R | 2 + *----------------------------------------------------------------------------- + * I2S input clock(Hz) | 176000000 + * | + * To achieve the following I2S config: | + * - Master clock output (MCKO): OFF | + * - Frame wide : 16bit | + * - Error % : 0,0000 | + * - Prescaler Odd factor (ODD): 1 | + * - Linear prescaler (DIV) : 14 | + *----------------------------------------------------------------------------- + * VDD(V) | 3,3 + *----------------------------------------------------------------------------- + * Main regulator output voltage | Scale1 mode + *----------------------------------------------------------------------------- + * Flash Latency(WS) | 5 + *----------------------------------------------------------------------------- + * Prefetch Buffer | OFF + *----------------------------------------------------------------------------- + * Instruction cache | ON + *----------------------------------------------------------------------------- + * Data cache | ON + *----------------------------------------------------------------------------- + * Require 48MHz for USB OTG FS, | Enabled + * SDIO and RNG clock | + *----------------------------------------------------------------------------- + *============================================================================= + ****************************************************************************** + * @attention + * + * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS + * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE + * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY + * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING + * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE + * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. + * + *

© COPYRIGHT 2011 STMicroelectronics

+ ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32f4xx_system + * @{ + */ + +/** @addtogroup STM32F4xx_System_Private_Includes + * @{ + */ + +#include "stm32f4xx.h" + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Defines + * @{ + */ + +/************************* Miscellaneous Configuration ************************/ +/*!< Uncomment the following line if you need to use external SRAM mounted + on STM324xG_EVAL board as data memory */ +/* #define DATA_IN_ExtSRAM */ + +/*!< Uncomment the following line if you need to relocate your vector Table in + Internal SRAM. */ +/* #define VECT_TAB_SRAM */ +#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +/******************************************************************************/ + +/************************* PLL Parameters *************************************/ +/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */ +#define PLL_M 8 +#define PLL_N 336 + +/* SYSCLK = PLL_VCO / PLL_P */ +#define PLL_P 2 + +/* USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ */ +#define PLL_Q 7 + +/* PLLI2S_VCO = (HSE_VALUE Or HSI_VALUE / PLL_M) * PLLI2S_N + I2SCLK = PLLI2S_VCO / PLLI2S_R */ +#define START_I2SCLOCK 0 +#define PLLI2S_N 352 +#define PLLI2S_R 2 + +/******************************************************************************/ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Variables + * @{ + */ + +uint32_t SystemCoreClock = 168000000; + +__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes + * @{ + */ + +static void SetSysClock(void); +#ifdef DATA_IN_ExtSRAM +static void SystemInit_ExtMemCtl(void); +#endif /* DATA_IN_ExtSRAM */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system + * Initialize the Embedded Flash Interface, the PLL and update the + * SystemFrequency variable. + * @param None + * @retval None + */ +void SystemInit(void) +{ + /* FPU settings ------------------------------------------------------------*/ +#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ +#endif + /* Reset the RCC clock configuration to the default reset state ------------*/ + /* Set HSION bit */ + RCC->CR |= (uint32_t)0x00000001; + + /* Reset CFGR register */ + RCC->CFGR = 0x00000000; + + /* Reset HSEON, CSSON and PLLON bits */ + RCC->CR &= (uint32_t)0xFEF6FFFF; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x24003010; + + /* Reset HSEBYP bit */ + RCC->CR &= (uint32_t)0xFFFBFFFF; + + /* Disable all interrupts */ + RCC->CIR = 0x00000000; + +#ifdef DATA_IN_ExtSRAM + SystemInit_ExtMemCtl(); +#endif /* DATA_IN_ExtSRAM */ + + /* Configure the System clock source, PLL Multiplier and Divider factors, + AHB/APBx prescalers and Flash settings ----------------------------------*/ + SetSysClock(); + + /* Configure the Vector Table location add offset address ------------------*/ +#ifdef VECT_TAB_SRAM + SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#else + SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ +#endif +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) + * or HSI_VALUE(*) multiplied/divided by the PLL factors. + * + * (*) HSI_VALUE is a constant defined in stm32f4xx.h file (default value + * 16 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (**) HSE_VALUE is a constant defined in stm32f4xx.h file (default value + * 25 MHz), user has to ensure that HSE_VALUE is same as the real + * frequency of the crystal used. Otherwise, this function may + * have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * + * @param None + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2; + + /* Get SYSCLK source -------------------------------------------------------*/ + tmp = RCC->CFGR & RCC_CFGR_SWS; + + switch (tmp) + { + case 0x00: /* HSI used as system clock source */ + SystemCoreClock = HSI_VALUE; + break; + case 0x04: /* HSE used as system clock source */ + SystemCoreClock = HSE_VALUE; + break; + case 0x08: /* PLL used as system clock source */ + + /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N + SYSCLK = PLL_VCO / PLL_P + */ + pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22; + pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM; + + if (pllsource != 0) + { + /* HSE used as PLL clock source */ + pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); + } + else + { + /* HSI used as PLL clock source */ + pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); + } + + pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2; + SystemCoreClock = pllvco/pllp; + break; + default: + SystemCoreClock = HSI_VALUE; + break; + } + /* Compute HCLK frequency --------------------------------------------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; + /* HCLK frequency */ + SystemCoreClock >>= tmp; +} + +/** + * @brief Configures the System clock source, PLL Multiplier and Divider factors, + * AHB/APBx prescalers and Flash settings + * @Note This function should be called only once the RCC clock configuration + * is reset to the default reset state (done in SystemInit() function). + * @param None + * @retval None + */ +static void SetSysClock(void) +{ + /******************************************************************************/ + /* PLL (clocked by HSE) used as System clock source */ + /******************************************************************************/ + __IO uint32_t StartUpCounter = 0, HSEStatus = 0; + + /* Enable HSE */ + RCC->CR |= ((uint32_t)RCC_CR_HSEON); + + /* Wait till HSE is ready and if Time out is reached exit */ + do + { + HSEStatus = RCC->CR & RCC_CR_HSERDY; + StartUpCounter++; + } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT)); + + if ((RCC->CR & RCC_CR_HSERDY) != RESET) + { + HSEStatus = (uint32_t)0x01; + } + else + { + HSEStatus = (uint32_t)0x00; + } + + if (HSEStatus == (uint32_t)0x01) + { + /* Select regulator voltage output Scale 1 mode, System frequency up to 168 MHz */ + RCC->APB1ENR |= RCC_APB1ENR_PWREN; + PWR->CR |= PWR_CR_VOS; + + /* HCLK = SYSCLK / 1*/ + RCC->CFGR |= RCC_CFGR_HPRE_DIV1; + + /* PCLK2 = HCLK / 2*/ + RCC->CFGR |= RCC_CFGR_PPRE2_DIV2; + + /* PCLK1 = HCLK / 4*/ + RCC->CFGR |= RCC_CFGR_PPRE1_DIV4; + + /* Configure the main PLL */ + RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) -1) << 16) | + (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24); + + /* Enable the main PLL */ + RCC->CR |= RCC_CR_PLLON; + + /* Wait till the main PLL is ready */ + while((RCC->CR & RCC_CR_PLLRDY) == 0) + { + } + + /* Configure Flash prefetch, Instruction cache, Data cache and wait state */ + FLASH->ACR = FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS; + + /* Select the main PLL as system clock source */ + RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); + RCC->CFGR |= RCC_CFGR_SW_PLL; + + /* Wait till the main PLL is used as system clock source */ + while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL); + { + } + } + else + { /* If HSE fails to start-up, the application will have wrong clock + configuration. User can add here some code to deal with this error */ + } + + + /******************************************************************************/ + /* I2S clock configuration */ + /******************************************************************************/ + +#if START_I2SCLOCK + /* PLLI2S clock used as I2S clock source */ + RCC->CFGR &= ~RCC_CFGR_I2SSRC; + + /* Configure PLLI2S */ + RCC->PLLI2SCFGR = (PLLI2S_N << 6) | (PLLI2S_R << 28); + + /* Enable PLLI2S */ + RCC->CR |= ((uint32_t)RCC_CR_PLLI2SON); + + /* Wait till PLLI2S is ready */ + while((RCC->CR & RCC_CR_PLLI2SRDY) == 0) + { + } +#endif +} + +/** + * @brief Setup the external memory controller. Called in startup_stm32f4xx.s + * before jump to __main + * @param None + * @retval None + */ +#ifdef DATA_IN_ExtSRAM +/** + * @brief Setup the external memory controller. + * Called in startup_stm32f4xx.s before jump to main. + * This function configures the external SRAM mounted on STM324xG_EVAL board + * This SRAM will be used as program data memory (including heap and stack). + * @param None + * @retval None + */ +void SystemInit_ExtMemCtl(void) +{ + /*-- GPIOs Configuration -----------------------------------------------------*/ + /* + +-------------------+--------------------+------------------+------------------+ + + SRAM pins assignment + + +-------------------+--------------------+------------------+------------------+ + | PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 | + | PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 | + | PD4 <-> FSMC_NOE | PE3 <-> FSMC_A19 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 | + | PD5 <-> FSMC_NWE | PE4 <-> FSMC_A20 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 | + | PD8 <-> FSMC_D13 | PE7 <-> FSMC_D4 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 | + | PD9 <-> FSMC_D14 | PE8 <-> FSMC_D5 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 | + | PD10 <-> FSMC_D15 | PE9 <-> FSMC_D6 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 | + | PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7 | PF13 <-> FSMC_A7 |------------------+ + | PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8 | PF14 <-> FSMC_A8 | + | PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9 | PF15 <-> FSMC_A9 | + | PD14 <-> FSMC_D0 | PE13 <-> FSMC_D10 |------------------+ + | PD15 <-> FSMC_D1 | PE14 <-> FSMC_D11 | + | | PE15 <-> FSMC_D12 | + +-------------------+--------------------+ + */ + /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */ + RCC->AHB1ENR = 0x00000078; + + /* Connect PDx pins to FSMC Alternate function */ + GPIOD->AFR[0] = 0x00cc00cc; + GPIOD->AFR[1] = 0xcc0ccccc; + /* Configure PDx pins in Alternate function mode */ + GPIOD->MODER = 0xaaaa0a0a; + /* Configure PDx pins speed to 100 MHz */ + GPIOD->OSPEEDR = 0xffff0f0f; + /* Configure PDx pins Output type to push-pull */ + GPIOD->OTYPER = 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOD->PUPDR = 0x00000000; + + /* Connect PEx pins to FSMC Alternate function */ + GPIOE->AFR[0] = 0xc00cc0cc; + GPIOE->AFR[1] = 0xcccccccc; + /* Configure PEx pins in Alternate function mode */ + GPIOE->MODER = 0xaaaa828a; + /* Configure PEx pins speed to 100 MHz */ + GPIOE->OSPEEDR = 0xffffc3cf; + /* Configure PEx pins Output type to push-pull */ + GPIOE->OTYPER = 0x00000000; + /* No pull-up, pull-down for PEx pins */ + GPIOE->PUPDR = 0x00000000; + + /* Connect PFx pins to FSMC Alternate function */ + GPIOF->AFR[0] = 0x00cccccc; + GPIOF->AFR[1] = 0xcccc0000; + /* Configure PFx pins in Alternate function mode */ + GPIOF->MODER = 0xaa000aaa; + /* Configure PFx pins speed to 100 MHz */ + GPIOF->OSPEEDR = 0xff000fff; + /* Configure PFx pins Output type to push-pull */ + GPIOF->OTYPER = 0x00000000; + /* No pull-up, pull-down for PFx pins */ + GPIOF->PUPDR = 0x00000000; + + /* Connect PGx pins to FSMC Alternate function */ + GPIOG->AFR[0] = 0x00cccccc; + GPIOG->AFR[1] = 0x000000c0; + /* Configure PGx pins in Alternate function mode */ + GPIOG->MODER = 0x00080aaa; + /* Configure PGx pins speed to 100 MHz */ + GPIOG->OSPEEDR = 0x000c0fff; + /* Configure PGx pins Output type to push-pull */ + GPIOG->OTYPER = 0x00000000; + /* No pull-up, pull-down for PGx pins */ + GPIOG->PUPDR = 0x00000000; + + /*-- FSMC Configuration ------------------------------------------------------*/ + /* Enable the FSMC interface clock */ + RCC->AHB3ENR = 0x00000001; + + /* Configure and enable Bank1_SRAM2 */ + FSMC_Bank1->BTCR[2] = 0x00001015; + FSMC_Bank1->BTCR[3] = 0x00010603; + FSMC_Bank1E->BWTR[2] = 0x0fffffff; + /* + Bank1_SRAM2 is configured as follow: + + p.FSMC_AddressSetupTime = 3; + p.FSMC_AddressHoldTime = 0; + p.FSMC_DataSetupTime = 6; + p.FSMC_BusTurnAroundDuration = 1; + p.FSMC_CLKDivision = 0; + p.FSMC_DataLatency = 0; + p.FSMC_AccessMode = FSMC_AccessMode_A; + + FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2; + FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; + FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_PSRAM; + FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; + FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; + FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; + FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; + FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; + FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; + FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; + FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; + */ +} +#endif /* DATA_IN_ExtSRAM */ + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/codec2/branches/0.3/stm32/stlink/elfsym.c b/codec2/branches/0.3/stm32/stlink/elfsym.c new file mode 100644 index 00000000..1a62981b --- /dev/null +++ b/codec2/branches/0.3/stm32/stlink/elfsym.c @@ -0,0 +1,145 @@ +/* + elfsym.c + + Read symbol adresses from a .elf file. + + Based on libelf-howto.c from: http://em386.blogspot.com + + Unit test with: + + gcc elfsym.c -o elfsym -D__UNITTEST__ -Wall -lelf + ./elfsym elf_file.elf +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "elfsym.h" + +#define ERR -1 + +int elfsym_open(char file[]) { + int fd; /* File Descriptor */ + char *base_ptr; /* ptr to our object in memory */ + struct stat elf_stats; /* fstat struct */ + + if((fd = open(file, O_RDWR)) == ERR) { + printf("couldnt open %s\n", file); + return ERR; + } + + if((fstat(fd, &elf_stats))) { + printf("could not fstat %s\n", file); + close(fd); + return ERR; + } + + if((base_ptr = (char *) malloc(elf_stats.st_size)) == NULL) { + fprintf(stderr, "could not malloc\n"); + close(fd); + return ERR; + } + + if((read(fd, base_ptr, elf_stats.st_size)) < elf_stats.st_size) { + fprintf(stderr, "could not read %s\n", file); + free(base_ptr); + close(fd); + return ERR; + } + + /* Check libelf version first */ + + if(elf_version(EV_CURRENT) == EV_NONE) { + fprintf(stderr, "WARNING Elf Library is out of date!\n"); + } + + free(base_ptr); + + return fd; +} + + +void elfsym_close(int fd) { + close(fd); +} + +unsigned int elfsym_get_symbol_address(int fd, char symbol_name[]) +{ + Elf_Scn *scn; /* Section Descriptor */ + Elf_Data *edata; /* Data Descriptor */ + GElf_Sym sym; /* Symbol */ + GElf_Shdr shdr; /* Section Header */ + Elf *elf; /* Our Elf pointer for libelf */ + unsigned int symbol_address; + int symbol_count; + int i; + + /* Iterate through section headers, stop when we find symbols, + and check for match */ + + elf = elf_begin(fd, ELF_C_READ, NULL); + if (elf == 0) { + fprintf(stderr, "could not elf_begin\n"); + } + symbol_address = 0; + scn = NULL; + + while((scn = elf_nextscn(elf, scn)) != 0) { + gelf_getshdr(scn, &shdr); + + // When we find a section header marked SHT_SYMTAB stop and get symbols + edata = NULL; + if(shdr.sh_type == SHT_SYMTAB) { + // edata points to our symbol table + edata = elf_getdata(scn, edata); + + // how many symbols are there? this number comes from the size of + // the section divided by the entry size + symbol_count = shdr.sh_size / shdr.sh_entsize; + + // loop through to grab all symbols + for(i = 0; i < symbol_count; i++) { + // libelf grabs the symbol data using gelf_getsym() + gelf_getsym(edata, i, &sym); + + if (strcmp(symbol_name, + elf_strptr(elf, shdr.sh_link, sym.st_name)) == 0) { + symbol_address = sym.st_value; + } + } + + } + } + + return symbol_address; +} + +#ifdef __UNITTEST__ + +int main(int argc, char *argv[]) +{ + int fd; + unsigned int flag_addr, ptr_addr, file_addr, len_addr; + + fd = elfsym_open(argv[1]); + flag_addr = elfsym_get_symbol_address(fd, "syscalls_gdb_flag"); + ptr_addr = elfsym_get_symbol_address(fd, "syscalls_gdb_ptr"); + file_addr = elfsym_get_symbol_address(fd, "syscalls_gdb_file"); + len_addr = elfsym_get_symbol_address(fd, "syscalls_gdb_len"); + elfsym_close(fd); + + printf("flag_addr: 0x%x\n", flag_addr); + printf("ptr_addr: 0x%x\n", ptr_addr); + printf("file_addr: 0x%x\n", file_addr); + printf("len_addr: 0x%x\n", len_addr); + + return 0; +} + +#endif diff --git a/codec2/branches/0.3/stm32/stlink/elfsym.h b/codec2/branches/0.3/stm32/stlink/elfsym.h new file mode 100644 index 00000000..fcd287ab --- /dev/null +++ b/codec2/branches/0.3/stm32/stlink/elfsym.h @@ -0,0 +1,14 @@ +/* + elfsym.h + + Read symbol adresses from a .elf file. +*/ + +#ifndef __ELFSYM__ +#define __ELFSYM__ + +int elfsym_open(char file[]); +void elfsym_close(int fd); +unsigned int elfsym_get_symbol_address(int fd, char symbol_name[]); + +#endif diff --git a/codec2/branches/0.3/stm32/stlink/stlink.patch b/codec2/branches/0.3/stm32/stlink/stlink.patch new file mode 100644 index 00000000..74cf2401 --- /dev/null +++ b/codec2/branches/0.3/stm32/stlink/stlink.patch @@ -0,0 +1,428 @@ +diff --git Makefile.am Makefile.am +index a315dd7..7406216 100644 +--- Makefile.am ++++ Makefile.am +@@ -7,7 +7,7 @@ bin_PROGRAMS = st-flash st-util + noinst_LIBRARIES = libstlink.a + + st_flash_SOURCES = flash/main.c +-st_util_SOURCES = gdbserver/gdb-remote.c gdbserver/gdb-remote.h gdbserver/gdb-server.c mingw/mingw.c mingw/mingw.h ++st_util_SOURCES = gdbserver/gdb-remote.c gdbserver/gdb-remote.h gdbserver/gdb-server.c gdbserver/elfsym.c mingw/mingw.c mingw/mingw.h + + CFILES = \ + src/stlink-common.c \ +@@ -24,14 +24,14 @@ HFILES = \ + + libstlink_a_SOURCES = $(CFILES) $(HFILES) + +-libstlink_a_CPPFLAGS = -std=gnu99 -Wall -Wextra -O2 ++libstlink_a_CPPFLAGS = -std=gnu99 -Wall -Wextra -g + libstlink_a_LIBADD = $(LIBOBJS) + + st_flash_LDADD = libstlink.a +-st_flash_CPPFLAGS = -std=gnu99 -Wall -Wextra -O2 -I$(top_srcdir)/src -I$(top_srcdir)/mingw ++st_flash_CPPFLAGS = -std=gnu99 -Wall -Wextra -g -I$(top_srcdir)/src -I$(top_srcdir)/mingw + +-st_util_LDADD = libstlink.a +-st_util_CPPFLAGS = -std=gnu99 -Wall -Wextra -O2 -I$(top_srcdir)/src -I$(top_srcdir)/mingw ++st_util_LDADD = libstlink.a -lelf ++st_util_CPPFLAGS = -std=gnu99 -Wall -Wextra -g -I$(top_srcdir)/src -I$(top_srcdir)/mingw + + EXTRA_DIST = autogen.sh + +diff --git gdbserver/Makefile gdbserver/Makefile +index bd5c73d..6763388 100644 +--- gdbserver/Makefile ++++ gdbserver/Makefile +@@ -1,12 +1,11 @@ + PRG := st-util +-OBJS = gdb-remote.o gdb-server.o ++OBJS = gdb-remote.o gdb-server.o elfsym.o + + CFLAGS+=-g -Wall -Werror -std=gnu99 -I../src + LDFLAGS=-L.. -lstlink + + # libusb location +-LDFLAGS+=`pkg-config --libs libusb-1.0` +-CFLAGS+=`pkg-config --cflags libusb-1.0` ++LDFLAGS+=`pkg-config --libs libusb-1.0` -lelfCFLAGS+=`pkg-config --cflags libusb-1.0` + + all: $(PRG) + +diff --git gdbserver/gdb-server.c gdbserver/gdb-server.c +index f92fc05..e54d136 100644 +--- gdbserver/gdb-server.c ++++ gdbserver/gdb-server.c +@@ -1,11 +1,12 @@ + /* -*- tab-width:8 -*- */ +-#define DEBUG 0 ++//#define DEBUG 0 + /* + Copyright (C) 2011 Peter Zotov + Use of this source code is governed by a BSD-style + license that can be found in the LICENSE file. + */ + ++#include + #include + #include + #include +@@ -20,14 +21,29 @@ + #include + #include + #endif ++#include ++#include ++#include + + #include + + #include "gdb-remote.h" ++#include "elfsym.h" + + #define DEFAULT_LOGGING_LEVEL 50 + #define DEFAULT_GDB_LISTEN_PORT 4242 + ++/* stdio command codes from target */ ++ ++#define GDB_STDIO_PRINTF 1 ++#define GDB_STDIO_FOPEN 2 ++#define GDB_STDIO_FCLOSE 3 ++#define GDB_STDIO_FWRITE 4 ++#define GDB_STDIO_FREAD 5 ++#define GDB_STDIO_FPRINTF 6 ++ ++#define MAX_STR 256 ++ + #define STRINGIFY_inner(name) #name + #define STRINGIFY(name) STRINGIFY_inner(name) + +@@ -46,11 +62,12 @@ typedef struct _st_state_t { + // "/dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTE531X6-if00-port0" is only 58 chars + char devicename[100]; + int logging_level; +- int listen_port; ++ int listen_port; ++ char elf_filename[255]; + } st_state_t; + + +-int serve(stlink_t *sl, int port); ++int serve(stlink_t *sl, int port, char *elf_filename); + char* make_memory_map(stlink_t *sl); + + +@@ -76,13 +93,14 @@ int parse_options(int argc, char** argv, st_state_t *st) { + " -p 4242, --listen_port=1234\n" + "\t\t\tSet the gdb server listen port. " + "(default port: " STRINGIFY(DEFAULT_GDB_LISTEN_PORT) ")\n" ++ " -f \tenable File I/O of target executable elf_filename" + ; + + + int option_index = 0; + int c; + int q; +- while ((c = getopt_long(argc, argv, "hv::d:s:1p:", long_options, &option_index)) != -1) { ++ while ((c = getopt_long(argc, argv, "hv::d:s:1p:1f:", long_options, &option_index)) != -1) { + switch (c) { + case 0: + printf("XXXXX Shouldn't really normally come here, only if there's no corresponding option\n"); +@@ -110,25 +128,29 @@ int parse_options(int argc, char** argv, st_state_t *st) { + strcpy(st->devicename, optarg); + } + break; +- case '1': +- st->stlink_version = 1; +- break; +- case 's': +- sscanf(optarg, "%i", &q); +- if (q < 0 || q > 2) { +- fprintf(stderr, "stlink version %d unknown!\n", q); +- exit(EXIT_FAILURE); +- } +- st->stlink_version = q; +- break; +- case 'p': +- sscanf(optarg, "%i", &q); +- if (q < 0) { +- fprintf(stderr, "Can't use a negative port to listen on: %d\n", q); +- exit(EXIT_FAILURE); +- } +- st->listen_port = q; +- break; ++ case '1': ++ st->stlink_version = 1; ++ break; ++ case 's': ++ sscanf(optarg, "%i", &q); ++ if (q < 0 || q > 2) { ++ fprintf(stderr, "stlink version %d unknown!\n", q); ++ exit(EXIT_FAILURE); ++ } ++ st->stlink_version = q; ++ break; ++ case 'p': ++ sscanf(optarg, "%i", &q); ++ if (q < 0) { ++ fprintf(stderr, "Can't use a negative port to listen on: %d\n", q); ++ exit(EXIT_FAILURE); ++ } ++ st->listen_port = q; ++ break; ++ case 'f': ++ sscanf(optarg, "%s", st->elf_filename); ++ printf("-f arg; %s\n", st->elf_filename); ++ break; + } + } + +@@ -162,7 +184,7 @@ int main(int argc, char** argv) { + sl = stlink_v1_open(state.logging_level); + if(sl == NULL) return 1; + break; +- } ++ } + + printf("Chip ID is %08x, Core ID is %08x.\n", sl->chip_id, sl->core_id); + +@@ -177,7 +199,7 @@ int main(int argc, char** argv) { + } + #endif + +- while(serve(sl, state.listen_port) == 0); ++ while(serve(sl, state.listen_port, state.elf_filename) == 0); + + #ifdef __MINGW32__ + winsock_error: +@@ -625,7 +647,179 @@ error: + return error; + } + +-int serve(stlink_t *sl, int port) { ++static unsigned int func_addr, ret_addr, pstr1_addr, pstr2_addr; ++static unsigned int strlen1_addr, strlen2_addr, file_addr, ptr_addr; ++static unsigned int size_addr, nmem_addr; ++ ++static void write_buffer(stlink_t *sl, int target_addr, char* buf, size_t size) { ++ /* write the buffer right after the loader */ ++ size_t chunk = size & ~0x3; ++ size_t rem = size & 0x3; ++ ++ if (chunk) { ++ memcpy(sl->q_buf, buf, chunk); ++ stlink_write_mem32(sl, target_addr, chunk); ++ } ++ if (rem) { ++ memcpy(sl->q_buf, buf+chunk, rem); ++ stlink_write_mem8(sl, target_addr+chunk, rem); ++ } ++} ++ ++static void read_buffer(stlink_t *sl, int target_addr, char* buf, size_t size) { ++ unsigned adj_start = target_addr % 4; ++ unsigned count_rnd = (size + adj_start + 4 - 1) / 4 * 4; ++ size_t i; ++ ++ stlink_read_mem32(sl, target_addr - adj_start, count_rnd); ++ ++ for(i=0; iq_buf[i + adj_start]; ++} ++ ++static void fileio(stlink_t *sl) ++{ ++ int func, pstr1, pstr2, strlen1, strlen2, ptr, size, nmem; ++ int ret = 0; ++ FILE *file; ++ char file_name[MAX_STR]; ++ char mode[MAX_STR]; ++ char *buf; ++ ++ stlink_read_mem32(sl, func_addr, 4); ++ func = read_uint32(sl->q_buf, 0); ++ ++ /* func != 0 means target has requested a system call */ ++ ++ switch(func) { ++ ++ case GDB_STDIO_PRINTF: ++ stlink_read_mem32(sl, pstr1_addr, 4); ++ pstr1 = read_uint32(sl->q_buf, 0); ++ stlink_read_mem32(sl, strlen1_addr, 4); ++ strlen1 = read_uint32(sl->q_buf, 0); ++ buf = (char*)malloc(strlen1+1); ++ assert(buf != NULL); ++ read_buffer(sl, pstr1, buf, strlen1); ++ buf[strlen1] = 0; ++ #ifdef DEBUG ++ //printf("gdb_stdio printf pstr1: 0x%0x strlen1: %d buf: %s\n", pstr1, strlen1, buf); ++ #endif ++ fputs(buf, stdout); ++ free(buf); ++ ++ break; ++ ++ case GDB_STDIO_FPRINTF: ++ stlink_read_mem32(sl, file_addr, 4); ++ file = (FILE*)read_uint32(sl->q_buf, 0); ++ stlink_read_mem32(sl, pstr1_addr, 4); ++ pstr1 = read_uint32(sl->q_buf, 0); ++ stlink_read_mem32(sl, strlen1_addr, 4); ++ strlen1 = read_uint32(sl->q_buf, 0); ++ buf = (char*)malloc(strlen1+1); ++ assert(buf != NULL); ++ read_buffer(sl, pstr1, buf, strlen1); ++ buf[strlen1] = 0; ++ #ifdef DEBUG ++ //printf("gdb_stdio fprintf pstr1: 0x%0x strlen1: %d buf: %s file: 0x%x\n", pstr1, strlen1, buf, (unsigned int)file); ++ #endif ++ fputs(buf, file); ++ free(buf); ++ ++ break; ++ ++ case GDB_STDIO_FOPEN: ++ stlink_read_mem32(sl, pstr1_addr, 4); ++ pstr1 = read_uint32(sl->q_buf, 0); ++ stlink_read_mem32(sl, strlen1_addr, 4); ++ strlen1 = read_uint32(sl->q_buf, 0); ++ assert(strlen1 < MAX_STR); ++ read_buffer(sl, pstr1, file_name, strlen1); ++ file_name[strlen1] = 0; ++ ++ stlink_read_mem32(sl, pstr2_addr, 4); ++ pstr2 = read_uint32(sl->q_buf, 0); ++ stlink_read_mem32(sl, strlen2_addr, 4); ++ strlen2 = read_uint32(sl->q_buf, 0); ++ assert(strlen2 < MAX_STR); ++ read_buffer(sl, pstr2, mode, strlen2); ++ mode[strlen2] = 0; ++ ++ file = fopen(file_name, mode); ++ ++ ret = (int)file; ++ #ifdef DEBUG ++ printf("gdb_stdio fopen file_name: %s mode: %s file: 0x%x\n", file_name, mode, (unsigned int)file); ++ #endif ++ break; ++ ++ case GDB_STDIO_FCLOSE: ++ stlink_read_mem32(sl, file_addr, 4); ++ file = (FILE*)read_uint32(sl->q_buf, 0); ++ fclose(file); ++ ++ #ifdef DEBUG ++ printf("gdb_stdio fclose file: 0x%x\n", (unsigned int)file); ++ #endif ++ break; ++ ++ case GDB_STDIO_FWRITE: ++ stlink_read_mem32(sl, ptr_addr, 4); ++ ptr = read_uint32(sl->q_buf, 0); ++ stlink_read_mem32(sl, size_addr, 4); ++ size = read_uint32(sl->q_buf, 0); ++ stlink_read_mem32(sl, nmem_addr, 4); ++ nmem = read_uint32(sl->q_buf, 0); ++ stlink_read_mem32(sl, file_addr, 4); ++ file = (FILE*)read_uint32(sl->q_buf, 0); ++ ++ buf = (char*)malloc(size*nmem); ++ assert(buf != NULL); ++ read_buffer(sl, ptr, buf, size*nmem); ++ ret = fwrite(buf, size, nmem, file); ++ free(buf); ++ #ifdef DEBUG ++ printf("gdb_stdio fwrite ptr: 0x%x size: %d nmem: %d file: 0x%x\n", ++ ptr, size, nmem, (unsigned int)file); ++ #endif ++ break; ++ ++ case GDB_STDIO_FREAD: ++ stlink_read_mem32(sl, ptr_addr, 4); ++ ptr = read_uint32(sl->q_buf, 0); ++ stlink_read_mem32(sl, size_addr, 4); ++ size = read_uint32(sl->q_buf, 0); ++ stlink_read_mem32(sl, nmem_addr, 4); ++ nmem = read_uint32(sl->q_buf, 0); ++ stlink_read_mem32(sl, file_addr, 4); ++ file = (FILE*)read_uint32(sl->q_buf, 0); ++ ++ buf = (char*)malloc(size*nmem); ++ assert(buf != NULL); ++ ret = fread(buf, size, nmem, file); ++ write_buffer(sl, ptr, buf, size*nmem); ++ free(buf); ++ ++ #ifdef DEBUG ++ printf("gdb_stdio fread ptr: 0x%x size: %d nmem: %d file: 0x%x\n", ++ ptr, size, nmem, (unsigned int)file); ++ #endif ++ break; ++ } ++ ++ if (func) { ++ memcpy(sl->q_buf, &ret, sizeof(int)); ++ stlink_write_mem32(sl, ret_addr, 4); ++ ++ func = 0; ++ memcpy(sl->q_buf, &func, sizeof(int)); ++ stlink_write_mem32(sl, func_addr, 4); ++ } ++} ++ ++ ++int serve(stlink_t *sl, int port, char *elf_filename) { + int sock = socket(AF_INET, SOCK_STREAM, 0); + if(sock < 0) { + perror("socket"); +@@ -650,7 +844,33 @@ int serve(stlink_t *sl, int port) { + perror("listen"); + return 1; + } +- ++ ++ /* init for file I/O */ ++ ++ func_addr = ret_addr = pstr1_addr = pstr2_addr = strlen1_addr = strlen2_addr = 0; ++ file_addr = ptr_addr = size_addr = nmem_addr = 0; ++ ++ printf("elf_filename: %s----------------------------------\n", elf_filename); ++ if (*elf_filename != 0) { ++ int fd = elfsym_open(elf_filename); ++ if (fd == -1) ++ exit(0); ++ func_addr = elfsym_get_symbol_address(fd, "gdb_stdio_func"); ++ ret_addr = elfsym_get_symbol_address(fd, "gdb_stdio_ret"); ++ pstr1_addr = elfsym_get_symbol_address(fd, "gdb_stdio_pstr1"); ++ pstr2_addr = elfsym_get_symbol_address(fd, "gdb_stdio_pstr2"); ++ strlen1_addr = elfsym_get_symbol_address(fd, "gdb_stdio_strlen1"); ++ strlen2_addr = elfsym_get_symbol_address(fd, "gdb_stdio_strlen2"); ++ file_addr = elfsym_get_symbol_address(fd, "gdb_stdio_file"); ++ ptr_addr = elfsym_get_symbol_address(fd, "gdb_stdio_ptr"); ++ size_addr = elfsym_get_symbol_address(fd, "gdb_stdio_size"); ++ nmem_addr = elfsym_get_symbol_address(fd, "gdb_stdio_nmem"); ++ elfsym_close(fd); ++ #ifdef DEBUG ++ printf("func_addr: 0x%x\n", func_addr); ++ #endif ++ } ++ + start_again: + stlink_force_debug(sl); + stlink_reset(sl); +@@ -924,8 +1144,13 @@ start_again: + if(sl->core_stat == STLINK_CORE_HALTED) { + break; + } ++ ++ /* file I/O if enabled */ ++ ++ if (*elf_filename != 0) ++ fileio(sl); + +- usleep(100000); ++ usleep(10000); + } + + reply = strdup("S05"); // TRAP diff --git a/codec2/branches/0.3/stm32/stm32_flash.ld b/codec2/branches/0.3/stm32/stm32_flash.ld new file mode 100644 index 00000000..6822ffad --- /dev/null +++ b/codec2/branches/0.3/stm32/stm32_flash.ld @@ -0,0 +1,116 @@ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20020000; /* end of 128K RAM on AHB bus*/ + +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K + CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K +} + +SECTIONS +{ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) + . = ALIGN(4); + } >FLASH + + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + _exit = .; + } >FLASH + + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array*)) + KEEP (*(SORT(.fini_array.*))) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = .; + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : AT ( _sidata ) + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(4); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(4); + } >RAM +} diff --git a/codec2/branches/0.3/stm32/stm32_ram.ld b/codec2/branches/0.3/stm32/stm32_ram.ld new file mode 100644 index 00000000..88c735a3 --- /dev/null +++ b/codec2/branches/0.3/stm32/stm32_ram.ld @@ -0,0 +1,116 @@ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20020000; /* end of 128K RAM on AHB bus*/ + +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K + CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K +} + +SECTIONS +{ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) + . = ALIGN(4); + } >RAM + + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + _exit = .; + } >RAM + + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >RAM + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >RAM + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >RAM + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >RAM + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array*)) + KEEP (*(SORT(.fini_array.*))) + PROVIDE_HIDDEN (__fini_array_end = .); + } >RAM + + /* used by the startup to initialize data */ + _sidata = .; + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : AT ( _sidata ) + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(4); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(4); + } >RAM +} diff --git a/codec2/branches/0.3/unittest/CMakeLists.txt b/codec2/branches/0.3/unittest/CMakeLists.txt new file mode 100644 index 00000000..af72e13d --- /dev/null +++ b/codec2/branches/0.3/unittest/CMakeLists.txt @@ -0,0 +1,83 @@ +add_definitions(-DFLOATING_POINT -DVAR_ARRAYS) +include_directories(../src) + +add_executable(genres genres.c ../src/lpc.c) +target_link_libraries(genres codec2) + +add_executable(genlsp genlsp.c ../src/lpc.c ../src/lsp.c) +target_link_libraries(genlsp codec2) + +add_executable(extract extract.c) +target_link_libraries(extract codec2) + +add_executable(vqtrain vqtrain.c) +target_link_libraries(vqtrain codec2) + +add_executable(vqtrainjnd vqtrainjnd.c) +target_link_libraries(vqtrainjnd codec2) + +add_executable(vqtrainph vqtrainph.c) +target_link_libraries(vqtrainph codec2) + +add_executable(vqtrainsp vqtrainsp.c) +target_link_libraries(vqtrainsp codec2) + +add_executable(genphdata genphdata.c) +target_link_libraries(genphdata codec2) + +add_executable(genampdata genampdata.c) +target_link_libraries(genampdata codec2) + +add_executable(polar2rect polar2rect.c) +target_link_libraries(polar2rect codec2) + +add_executable(vq_train_jvm vq_train_jvm.c) +target_link_libraries(vq_train_jvm codec2) + +set(CODEBOOKS ../src/codebook.c ../src/codebookd.c ../src/codebookvq.c ../src/codebookjnd.c ../src/codebookdt.c ../src/codebookjvm.c ../src/codebookvqanssi.c ../src/codebookge.c) + +add_executable(tnlp tnlp.c ../src/sine.c ../src/nlp.c ../src/kiss_fft.c ../src/dump.c) +target_link_libraries(tnlp codec2) + +add_executable(tinterp tinterp.c ../src/sine.c ../src/kiss_fft.c ../src/interp.c ../src/lpc.c ../src/lsp.c ../src/quantise.c ${CODEBOOKS} ../src/dump.c) +target_link_libraries(tinterp codec2) + +add_executable(tquant tquant.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c ${CODEBOOKS}) +target_link_libraries(tquant codec2) + +add_executable(scalarlsptest scalarlsptest.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c ${CODEBOOKS}) +target_link_libraries(scalarlsptest codec2) + +add_executable(tfdmdv tfdmdv.c ../src/fdmdv.c ../src/kiss_fft.c ../src/octave.c) +target_link_libraries(tfdmdv codec2) + +add_executable(t48_8 t48_8.c ../src/fdmdv.c ../src/kiss_fft.c) +target_link_libraries(t48_8 codec2) + +add_executable(lspsync lspsync.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c ../src/codec2.c ../src/sine.c ../src/nlp.c ../src/postfilter.c ../src/phase.c ../src/interp.c ../src/pack.c ${CODEBOOKS}) +target_link_libraries(lspsync codec2) + +add_executable(create_interleaver create_interleaver.c) +target_link_libraries(create_interleaver codec2) + +add_executable(tlspsens tlspsens.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c ../src/codec2.c ../src/sine.c ../src/nlp.c ../src/pack.c ../src/interp.c ../src/postfilter.c ../src/phase.c ${CODEBOOKS}) +target_link_libraries(tlspsens codec2) + +add_executable(tprede tprede.c ../src/lpc.c) +target_link_libraries(tprede codec2) + +add_executable(pre pre.c ../src/lpc.c) +target_link_libraries(pre codec2) + +add_executable(de de.c ../src/lpc.c) +target_link_libraries(de codec2) + +add_executable(tfifo tfifo.c ../src/fifo.c) +target_link_libraries(tfifo codec2 ${CMAKE_THREAD_LIBS_INIT}) + +add_executable(raw2h raw2h.c) +target_link_libraries(raw2h codec2) + +add_definitions(-D__UNITTEST__) +add_executable(c2validate c2validate.c) +target_link_libraries(c2validate codec2) diff --git a/codec2/branches/0.3/unittest/Makefile.am b/codec2/branches/0.3/unittest/Makefile.am new file mode 100644 index 00000000..998446fb --- /dev/null +++ b/codec2/branches/0.3/unittest/Makefile.am @@ -0,0 +1,114 @@ +AM_CFLAGS = -I../src -fPIC -g -DFLOATING_POINT -DVAR_ARRAYS -O2 -Wall +AUTOMAKE_OPTS = gnu +NAME = libcodec2 +AM_CPPFLAGS = $(AM_CFLAGS) + +noinst_PROGRAMS = genres genlsp extract vqtrain vqtrainjnd tnlp tinterp tquant vq_train_jvm scalarlsptest tfdmdv t48_8 lspsync create_interleaver tlspsens vqtrainph genphdata genampdata polar2rect vqtrainsp tprede pre de tfifo raw2h c2validate + +genres_SOURCES = genres.c ../src/lpc.c +genres_LDADD = $(lib_LTLIBRARIES) +genres_LDFLAGS = $(LIBS) + +genlsp_SOURCES = genlsp.c ../src/lpc.c ../src/lsp.c +genlsp_LDADD = $(lib_LTLIBRARIES) +genlsp_LDFLAGS = $(LIBS) + +extract_SOURCES = extract.c +extract_LDADD = $(lib_LTLIBRARIES) +extract_LDFLAGS = $(LIBS) + +vqtrain_SOURCES = vqtrain.c +vqtrain_LDADD = $(lib_LTLIBRARIES) +vqtrain_LDFLAGS = $(LIBS) + +vqtrainjnd_SOURCES = vqtrainjnd.c +vqtrainjnd_LDADD = $(lib_LTLIBRARIES) +vqtrainjnd_LDFLAGS = $(LIBS) + +vqtrainph_SOURCES = vqtrainph.c +vqtrainph_LDADD = $(lib_LTLIBRARIES) +vqtrainph_LDFLAGS = $(LIBS) + +vqtrainsp_SOURCES = vqtrainsp.c +vqtrainsp_LDADD = $(lib_LTLIBRARIES) +vqtrainsp_LDFLAGS = $(LIBS) + +genphdata_SOURCES = genphdata.c +genphdata_LDADD = $(lib_LTLIBRARIES) +genphdata_LDFLAGS = $(LIBS) + +genampdata_SOURCES = genampdata.c +genampdata_LDADD = $(lib_LTLIBRARIES) +genampdata_LDFLAGS = $(LIBS) + +polar2rect_SOURCES = polar2rect.c +polar2rect_LDADD = $(lib_LTLIBRARIES) +polar2rect_LDFLAGS = $(LIBS) + +vq_train_jvm_SOURCES = vq_train_jvm.c +vq_train_jvm_LDADD = $(lib_LTLIBRARIES) +vq_train_jvm_LDFLAGS = $(LIBS) + +CODEBOOKS = ../src/codebook.c ../src/codebookd.c ../src/codebookvq.c ../src/codebookjnd.c ../src/codebookdt.c ../src/codebookjvm.c ../src/codebookvqanssi.c ../src/codebookge.c + +tnlp_SOURCES = tnlp.c ../src/sine.c ../src/nlp.c ../src/kiss_fft.c ../src/dump.c +tnlp_LDADD = $(lib_LTLIBRARIES) +tnlp_LDFLAGS = $(LIBS) + +tinterp_SOURCES = tinterp.c ../src/sine.c ../src/kiss_fft.c ../src/interp.c ../src/lpc.c ../src/lsp.c ../src/quantise.c $(CODEBOOKS) ../src/dump.c +tinterp_LDADD = $(lib_LTLIBRARIES) +tinterp_LDFLAGS = $(LIBS) + +tquant_SOURCES = tquant.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c $(CODEBOOKS) +tquant_LDADD = $(lib_LTLIBRARIES) +tquant_LDFLAGS = $(LIBS) + +scalarlsptest_SOURCES = scalarlsptest.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c $(CODEBOOKS) +scalarlsptest_LDADD = $(lib_LTLIBRARIES) +scalarlsptest_LDFLAGS = $(LIBS) + +tfdmdv_SOURCES = tfdmdv.c ../src/fdmdv.c ../src/kiss_fft.c ../src/octave.c +tfdmdv_LDADD = $(lib_LTLIBRARIES) +tfdmdv_LDFLAGS = $(LIBS) + +t48_8_SOURCES = t48_8.c ../src/fdmdv.c ../src/kiss_fft.c +t48_8_LDADD = $(lib_LTLIBRARIES) +t48_8_LDFLAGS = $(LIBS) + +lspsync_SOURCES = lspsync.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c \ +../src/codec2.c ../src/sine.c ../src/nlp.c ../src/postfilter.c ../src/phase.c ../src/interp.c ../src/pack.c $(CODEBOOKS) +lspsync_LDADD = $(lib_LTLIBRARIES) +lspsync_LDFLAGS = $(LIBS) + +create_interleaver_SOURCES = create_interleaver.c +create_interleaver_LDADD = $(lib_LTLIBRARIES) +create_interleaver_LDFLAGS = $(LIBS) + +tlspsens_SOURCES = tlspsens.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c ../src/codec2.c ../src/sine.c ../src/nlp.c ../src/pack.c ../src/interp.c ../src/postfilter.c ../src/phase.c $(CODEBOOKS) +tlspsens_LDADD = $(lib_LTLIBRARIES) +tlspsens_LDFLAGS = $(LIBS) + +tprede_SOURCES = tprede.c ../src/lpc.c +tprede_LDADD = $(lib_LTLIBRARIES) +tprede_LDFLAGS = $(LIBS) + +pre_SOURCES = pre.c ../src/lpc.c +pre_LDADD = $(lib_LTLIBRARIES) +pre_LDFLAGS = $(LIBS) + +de_SOURCES = de.c ../src/lpc.c +de_LDADD = $(lib_LTLIBRARIES) +de_LDFLAGS = $(LIBS) + +tfifo_SOURCES = tfifo.c ../src/fifo.c +tfifo_LDADD = $(lib_LTLIBRARIES) -lpthread +tfifo_LDFLAGS = $(LIBS) + +raw2h_SOURCES = raw2h.c +raw2h_LDADD = $(lib_LTLIBRARIES) +raw2h_LDFLAGS = $(LIBS) + +c2validate_CFLAGS = -D__UNITTEST__ +c2validate_SOURCES = c2validate.c +c2validate_LDADD = $(lib_LTLIBRARIES) ../src/libcodec2.la +c2validate_LDFLAGS = $(LIBS) \ No newline at end of file diff --git a/codec2/branches/0.3/unittest/Makefile.in b/codec2/branches/0.3/unittest/Makefile.in new file mode 100644 index 00000000..aac2791c --- /dev/null +++ b/codec2/branches/0.3/unittest/Makefile.in @@ -0,0 +1,1090 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +noinst_PROGRAMS = genres$(EXEEXT) genlsp$(EXEEXT) extract$(EXEEXT) \ + vqtrain$(EXEEXT) vqtrainjnd$(EXEEXT) tnlp$(EXEEXT) \ + tinterp$(EXEEXT) tquant$(EXEEXT) vq_train_jvm$(EXEEXT) \ + scalarlsptest$(EXEEXT) tfdmdv$(EXEEXT) t48_8$(EXEEXT) \ + lspsync$(EXEEXT) create_interleaver$(EXEEXT) tlspsens$(EXEEXT) \ + vqtrainph$(EXEEXT) genphdata$(EXEEXT) genampdata$(EXEEXT) \ + polar2rect$(EXEEXT) vqtrainsp$(EXEEXT) tprede$(EXEEXT) \ + pre$(EXEEXT) de$(EXEEXT) tfifo$(EXEEXT) raw2h$(EXEEXT) \ + c2validate$(EXEEXT) +subdir = unittest +DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +PROGRAMS = $(noinst_PROGRAMS) +am_c2validate_OBJECTS = c2validate-c2validate.$(OBJEXT) +c2validate_OBJECTS = $(am_c2validate_OBJECTS) +c2validate_DEPENDENCIES = ../src/libcodec2.la +am_create_interleaver_OBJECTS = create_interleaver.$(OBJEXT) +create_interleaver_OBJECTS = $(am_create_interleaver_OBJECTS) +create_interleaver_DEPENDENCIES = +am_de_OBJECTS = de.$(OBJEXT) lpc.$(OBJEXT) +de_OBJECTS = $(am_de_OBJECTS) +de_DEPENDENCIES = +am_extract_OBJECTS = extract.$(OBJEXT) +extract_OBJECTS = $(am_extract_OBJECTS) +extract_DEPENDENCIES = +am_genampdata_OBJECTS = genampdata.$(OBJEXT) +genampdata_OBJECTS = $(am_genampdata_OBJECTS) +genampdata_DEPENDENCIES = +am_genlsp_OBJECTS = genlsp.$(OBJEXT) lpc.$(OBJEXT) lsp.$(OBJEXT) +genlsp_OBJECTS = $(am_genlsp_OBJECTS) +genlsp_DEPENDENCIES = +am_genphdata_OBJECTS = genphdata.$(OBJEXT) +genphdata_OBJECTS = $(am_genphdata_OBJECTS) +genphdata_DEPENDENCIES = +am_genres_OBJECTS = genres.$(OBJEXT) lpc.$(OBJEXT) +genres_OBJECTS = $(am_genres_OBJECTS) +genres_DEPENDENCIES = +am__objects_1 = codebook.$(OBJEXT) codebookd.$(OBJEXT) \ + codebookvq.$(OBJEXT) codebookjnd.$(OBJEXT) \ + codebookdt.$(OBJEXT) codebookjvm.$(OBJEXT) \ + codebookvqanssi.$(OBJEXT) codebookge.$(OBJEXT) +am_lspsync_OBJECTS = lspsync.$(OBJEXT) quantise.$(OBJEXT) \ + lpc.$(OBJEXT) lsp.$(OBJEXT) dump.$(OBJEXT) kiss_fft.$(OBJEXT) \ + codec2.$(OBJEXT) sine.$(OBJEXT) nlp.$(OBJEXT) \ + postfilter.$(OBJEXT) phase.$(OBJEXT) interp.$(OBJEXT) \ + pack.$(OBJEXT) $(am__objects_1) +lspsync_OBJECTS = $(am_lspsync_OBJECTS) +lspsync_DEPENDENCIES = +am_polar2rect_OBJECTS = polar2rect.$(OBJEXT) +polar2rect_OBJECTS = $(am_polar2rect_OBJECTS) +polar2rect_DEPENDENCIES = +am_pre_OBJECTS = pre.$(OBJEXT) lpc.$(OBJEXT) +pre_OBJECTS = $(am_pre_OBJECTS) +pre_DEPENDENCIES = +am_raw2h_OBJECTS = raw2h.$(OBJEXT) +raw2h_OBJECTS = $(am_raw2h_OBJECTS) +raw2h_DEPENDENCIES = +am_scalarlsptest_OBJECTS = scalarlsptest.$(OBJEXT) quantise.$(OBJEXT) \ + lpc.$(OBJEXT) lsp.$(OBJEXT) dump.$(OBJEXT) kiss_fft.$(OBJEXT) \ + $(am__objects_1) +scalarlsptest_OBJECTS = $(am_scalarlsptest_OBJECTS) +scalarlsptest_DEPENDENCIES = +am_t48_8_OBJECTS = t48_8.$(OBJEXT) fdmdv.$(OBJEXT) kiss_fft.$(OBJEXT) +t48_8_OBJECTS = $(am_t48_8_OBJECTS) +t48_8_DEPENDENCIES = +am_tfdmdv_OBJECTS = tfdmdv.$(OBJEXT) fdmdv.$(OBJEXT) \ + kiss_fft.$(OBJEXT) octave.$(OBJEXT) +tfdmdv_OBJECTS = $(am_tfdmdv_OBJECTS) +tfdmdv_DEPENDENCIES = +am_tfifo_OBJECTS = tfifo.$(OBJEXT) fifo.$(OBJEXT) +tfifo_OBJECTS = $(am_tfifo_OBJECTS) +tfifo_DEPENDENCIES = +am_tinterp_OBJECTS = tinterp.$(OBJEXT) sine.$(OBJEXT) \ + kiss_fft.$(OBJEXT) interp.$(OBJEXT) lpc.$(OBJEXT) \ + lsp.$(OBJEXT) quantise.$(OBJEXT) $(am__objects_1) \ + dump.$(OBJEXT) +tinterp_OBJECTS = $(am_tinterp_OBJECTS) +tinterp_DEPENDENCIES = +am_tlspsens_OBJECTS = tlspsens.$(OBJEXT) quantise.$(OBJEXT) \ + lpc.$(OBJEXT) lsp.$(OBJEXT) dump.$(OBJEXT) kiss_fft.$(OBJEXT) \ + codec2.$(OBJEXT) sine.$(OBJEXT) nlp.$(OBJEXT) pack.$(OBJEXT) \ + interp.$(OBJEXT) postfilter.$(OBJEXT) phase.$(OBJEXT) \ + $(am__objects_1) +tlspsens_OBJECTS = $(am_tlspsens_OBJECTS) +tlspsens_DEPENDENCIES = +am_tnlp_OBJECTS = tnlp.$(OBJEXT) sine.$(OBJEXT) nlp.$(OBJEXT) \ + kiss_fft.$(OBJEXT) dump.$(OBJEXT) +tnlp_OBJECTS = $(am_tnlp_OBJECTS) +tnlp_DEPENDENCIES = +am_tprede_OBJECTS = tprede.$(OBJEXT) lpc.$(OBJEXT) +tprede_OBJECTS = $(am_tprede_OBJECTS) +tprede_DEPENDENCIES = +am_tquant_OBJECTS = tquant.$(OBJEXT) quantise.$(OBJEXT) lpc.$(OBJEXT) \ + lsp.$(OBJEXT) dump.$(OBJEXT) kiss_fft.$(OBJEXT) \ + $(am__objects_1) +tquant_OBJECTS = $(am_tquant_OBJECTS) +tquant_DEPENDENCIES = +am_vq_train_jvm_OBJECTS = vq_train_jvm.$(OBJEXT) +vq_train_jvm_OBJECTS = $(am_vq_train_jvm_OBJECTS) +vq_train_jvm_DEPENDENCIES = +am_vqtrain_OBJECTS = vqtrain.$(OBJEXT) +vqtrain_OBJECTS = $(am_vqtrain_OBJECTS) +vqtrain_DEPENDENCIES = +am_vqtrainjnd_OBJECTS = vqtrainjnd.$(OBJEXT) +vqtrainjnd_OBJECTS = $(am_vqtrainjnd_OBJECTS) +vqtrainjnd_DEPENDENCIES = +am_vqtrainph_OBJECTS = vqtrainph.$(OBJEXT) +vqtrainph_OBJECTS = $(am_vqtrainph_OBJECTS) +vqtrainph_DEPENDENCIES = +am_vqtrainsp_OBJECTS = vqtrainsp.$(OBJEXT) +vqtrainsp_OBJECTS = $(am_vqtrainsp_OBJECTS) +vqtrainsp_DEPENDENCIES = +DEFAULT_INCLUDES = -I. -I$(srcdir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(c2validate_SOURCES) $(create_interleaver_SOURCES) \ + $(de_SOURCES) $(extract_SOURCES) $(genampdata_SOURCES) \ + $(genlsp_SOURCES) $(genphdata_SOURCES) $(genres_SOURCES) \ + $(lspsync_SOURCES) $(polar2rect_SOURCES) $(pre_SOURCES) \ + $(raw2h_SOURCES) $(scalarlsptest_SOURCES) $(t48_8_SOURCES) \ + $(tfdmdv_SOURCES) $(tfifo_SOURCES) $(tinterp_SOURCES) \ + $(tlspsens_SOURCES) $(tnlp_SOURCES) $(tprede_SOURCES) \ + $(tquant_SOURCES) $(vq_train_jvm_SOURCES) $(vqtrain_SOURCES) \ + $(vqtrainjnd_SOURCES) $(vqtrainph_SOURCES) \ + $(vqtrainsp_SOURCES) +DIST_SOURCES = $(c2validate_SOURCES) $(create_interleaver_SOURCES) \ + $(de_SOURCES) $(extract_SOURCES) $(genampdata_SOURCES) \ + $(genlsp_SOURCES) $(genphdata_SOURCES) $(genres_SOURCES) \ + $(lspsync_SOURCES) $(polar2rect_SOURCES) $(pre_SOURCES) \ + $(raw2h_SOURCES) $(scalarlsptest_SOURCES) $(t48_8_SOURCES) \ + $(tfdmdv_SOURCES) $(tfifo_SOURCES) $(tinterp_SOURCES) \ + $(tlspsens_SOURCES) $(tnlp_SOURCES) $(tprede_SOURCES) \ + $(tquant_SOURCES) $(vq_train_jvm_SOURCES) $(vqtrain_SOURCES) \ + $(vqtrainjnd_SOURCES) $(vqtrainph_SOURCES) \ + $(vqtrainsp_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +AM_CFLAGS = -I../src -fPIC -g -DFLOATING_POINT -DVAR_ARRAYS -O2 -Wall +AUTOMAKE_OPTS = gnu +NAME = libcodec2 +AM_CPPFLAGS = $(AM_CFLAGS) +genres_SOURCES = genres.c ../src/lpc.c +genres_LDADD = $(lib_LTLIBRARIES) +genres_LDFLAGS = $(LIBS) +genlsp_SOURCES = genlsp.c ../src/lpc.c ../src/lsp.c +genlsp_LDADD = $(lib_LTLIBRARIES) +genlsp_LDFLAGS = $(LIBS) +extract_SOURCES = extract.c +extract_LDADD = $(lib_LTLIBRARIES) +extract_LDFLAGS = $(LIBS) +vqtrain_SOURCES = vqtrain.c +vqtrain_LDADD = $(lib_LTLIBRARIES) +vqtrain_LDFLAGS = $(LIBS) +vqtrainjnd_SOURCES = vqtrainjnd.c +vqtrainjnd_LDADD = $(lib_LTLIBRARIES) +vqtrainjnd_LDFLAGS = $(LIBS) +vqtrainph_SOURCES = vqtrainph.c +vqtrainph_LDADD = $(lib_LTLIBRARIES) +vqtrainph_LDFLAGS = $(LIBS) +vqtrainsp_SOURCES = vqtrainsp.c +vqtrainsp_LDADD = $(lib_LTLIBRARIES) +vqtrainsp_LDFLAGS = $(LIBS) +genphdata_SOURCES = genphdata.c +genphdata_LDADD = $(lib_LTLIBRARIES) +genphdata_LDFLAGS = $(LIBS) +genampdata_SOURCES = genampdata.c +genampdata_LDADD = $(lib_LTLIBRARIES) +genampdata_LDFLAGS = $(LIBS) +polar2rect_SOURCES = polar2rect.c +polar2rect_LDADD = $(lib_LTLIBRARIES) +polar2rect_LDFLAGS = $(LIBS) +vq_train_jvm_SOURCES = vq_train_jvm.c +vq_train_jvm_LDADD = $(lib_LTLIBRARIES) +vq_train_jvm_LDFLAGS = $(LIBS) +CODEBOOKS = ../src/codebook.c ../src/codebookd.c ../src/codebookvq.c ../src/codebookjnd.c ../src/codebookdt.c ../src/codebookjvm.c ../src/codebookvqanssi.c ../src/codebookge.c +tnlp_SOURCES = tnlp.c ../src/sine.c ../src/nlp.c ../src/kiss_fft.c ../src/dump.c +tnlp_LDADD = $(lib_LTLIBRARIES) +tnlp_LDFLAGS = $(LIBS) +tinterp_SOURCES = tinterp.c ../src/sine.c ../src/kiss_fft.c ../src/interp.c ../src/lpc.c ../src/lsp.c ../src/quantise.c $(CODEBOOKS) ../src/dump.c +tinterp_LDADD = $(lib_LTLIBRARIES) +tinterp_LDFLAGS = $(LIBS) +tquant_SOURCES = tquant.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c $(CODEBOOKS) +tquant_LDADD = $(lib_LTLIBRARIES) +tquant_LDFLAGS = $(LIBS) +scalarlsptest_SOURCES = scalarlsptest.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c $(CODEBOOKS) +scalarlsptest_LDADD = $(lib_LTLIBRARIES) +scalarlsptest_LDFLAGS = $(LIBS) +tfdmdv_SOURCES = tfdmdv.c ../src/fdmdv.c ../src/kiss_fft.c ../src/octave.c +tfdmdv_LDADD = $(lib_LTLIBRARIES) +tfdmdv_LDFLAGS = $(LIBS) +t48_8_SOURCES = t48_8.c ../src/fdmdv.c ../src/kiss_fft.c +t48_8_LDADD = $(lib_LTLIBRARIES) +t48_8_LDFLAGS = $(LIBS) +lspsync_SOURCES = lspsync.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c \ +../src/codec2.c ../src/sine.c ../src/nlp.c ../src/postfilter.c ../src/phase.c ../src/interp.c ../src/pack.c $(CODEBOOKS) + +lspsync_LDADD = $(lib_LTLIBRARIES) +lspsync_LDFLAGS = $(LIBS) +create_interleaver_SOURCES = create_interleaver.c +create_interleaver_LDADD = $(lib_LTLIBRARIES) +create_interleaver_LDFLAGS = $(LIBS) +tlspsens_SOURCES = tlspsens.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c ../src/codec2.c ../src/sine.c ../src/nlp.c ../src/pack.c ../src/interp.c ../src/postfilter.c ../src/phase.c $(CODEBOOKS) +tlspsens_LDADD = $(lib_LTLIBRARIES) +tlspsens_LDFLAGS = $(LIBS) +tprede_SOURCES = tprede.c ../src/lpc.c +tprede_LDADD = $(lib_LTLIBRARIES) +tprede_LDFLAGS = $(LIBS) +pre_SOURCES = pre.c ../src/lpc.c +pre_LDADD = $(lib_LTLIBRARIES) +pre_LDFLAGS = $(LIBS) +de_SOURCES = de.c ../src/lpc.c +de_LDADD = $(lib_LTLIBRARIES) +de_LDFLAGS = $(LIBS) +tfifo_SOURCES = tfifo.c ../src/fifo.c +tfifo_LDADD = $(lib_LTLIBRARIES) -lpthread +tfifo_LDFLAGS = $(LIBS) +raw2h_SOURCES = raw2h.c +raw2h_LDADD = $(lib_LTLIBRARIES) +raw2h_LDFLAGS = $(LIBS) +c2validate_CFLAGS = -D__UNITTEST__ +c2validate_SOURCES = c2validate.c +c2validate_LDADD = $(lib_LTLIBRARIES) ../src/libcodec2.la +c2validate_LDFLAGS = $(LIBS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu unittest/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu unittest/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +c2validate$(EXEEXT): $(c2validate_OBJECTS) $(c2validate_DEPENDENCIES) + @rm -f c2validate$(EXEEXT) + $(LINK) $(c2validate_LDFLAGS) $(c2validate_OBJECTS) $(c2validate_LDADD) $(LIBS) +create_interleaver$(EXEEXT): $(create_interleaver_OBJECTS) $(create_interleaver_DEPENDENCIES) + @rm -f create_interleaver$(EXEEXT) + $(LINK) $(create_interleaver_LDFLAGS) $(create_interleaver_OBJECTS) $(create_interleaver_LDADD) $(LIBS) +de$(EXEEXT): $(de_OBJECTS) $(de_DEPENDENCIES) + @rm -f de$(EXEEXT) + $(LINK) $(de_LDFLAGS) $(de_OBJECTS) $(de_LDADD) $(LIBS) +extract$(EXEEXT): $(extract_OBJECTS) $(extract_DEPENDENCIES) + @rm -f extract$(EXEEXT) + $(LINK) $(extract_LDFLAGS) $(extract_OBJECTS) $(extract_LDADD) $(LIBS) +genampdata$(EXEEXT): $(genampdata_OBJECTS) $(genampdata_DEPENDENCIES) + @rm -f genampdata$(EXEEXT) + $(LINK) $(genampdata_LDFLAGS) $(genampdata_OBJECTS) $(genampdata_LDADD) $(LIBS) +genlsp$(EXEEXT): $(genlsp_OBJECTS) $(genlsp_DEPENDENCIES) + @rm -f genlsp$(EXEEXT) + $(LINK) $(genlsp_LDFLAGS) $(genlsp_OBJECTS) $(genlsp_LDADD) $(LIBS) +genphdata$(EXEEXT): $(genphdata_OBJECTS) $(genphdata_DEPENDENCIES) + @rm -f genphdata$(EXEEXT) + $(LINK) $(genphdata_LDFLAGS) $(genphdata_OBJECTS) $(genphdata_LDADD) $(LIBS) +genres$(EXEEXT): $(genres_OBJECTS) $(genres_DEPENDENCIES) + @rm -f genres$(EXEEXT) + $(LINK) $(genres_LDFLAGS) $(genres_OBJECTS) $(genres_LDADD) $(LIBS) +lspsync$(EXEEXT): $(lspsync_OBJECTS) $(lspsync_DEPENDENCIES) + @rm -f lspsync$(EXEEXT) + $(LINK) $(lspsync_LDFLAGS) $(lspsync_OBJECTS) $(lspsync_LDADD) $(LIBS) +polar2rect$(EXEEXT): $(polar2rect_OBJECTS) $(polar2rect_DEPENDENCIES) + @rm -f polar2rect$(EXEEXT) + $(LINK) $(polar2rect_LDFLAGS) $(polar2rect_OBJECTS) $(polar2rect_LDADD) $(LIBS) +pre$(EXEEXT): $(pre_OBJECTS) $(pre_DEPENDENCIES) + @rm -f pre$(EXEEXT) + $(LINK) $(pre_LDFLAGS) $(pre_OBJECTS) $(pre_LDADD) $(LIBS) +raw2h$(EXEEXT): $(raw2h_OBJECTS) $(raw2h_DEPENDENCIES) + @rm -f raw2h$(EXEEXT) + $(LINK) $(raw2h_LDFLAGS) $(raw2h_OBJECTS) $(raw2h_LDADD) $(LIBS) +scalarlsptest$(EXEEXT): $(scalarlsptest_OBJECTS) $(scalarlsptest_DEPENDENCIES) + @rm -f scalarlsptest$(EXEEXT) + $(LINK) $(scalarlsptest_LDFLAGS) $(scalarlsptest_OBJECTS) $(scalarlsptest_LDADD) $(LIBS) +t48_8$(EXEEXT): $(t48_8_OBJECTS) $(t48_8_DEPENDENCIES) + @rm -f t48_8$(EXEEXT) + $(LINK) $(t48_8_LDFLAGS) $(t48_8_OBJECTS) $(t48_8_LDADD) $(LIBS) +tfdmdv$(EXEEXT): $(tfdmdv_OBJECTS) $(tfdmdv_DEPENDENCIES) + @rm -f tfdmdv$(EXEEXT) + $(LINK) $(tfdmdv_LDFLAGS) $(tfdmdv_OBJECTS) $(tfdmdv_LDADD) $(LIBS) +tfifo$(EXEEXT): $(tfifo_OBJECTS) $(tfifo_DEPENDENCIES) + @rm -f tfifo$(EXEEXT) + $(LINK) $(tfifo_LDFLAGS) $(tfifo_OBJECTS) $(tfifo_LDADD) $(LIBS) +tinterp$(EXEEXT): $(tinterp_OBJECTS) $(tinterp_DEPENDENCIES) + @rm -f tinterp$(EXEEXT) + $(LINK) $(tinterp_LDFLAGS) $(tinterp_OBJECTS) $(tinterp_LDADD) $(LIBS) +tlspsens$(EXEEXT): $(tlspsens_OBJECTS) $(tlspsens_DEPENDENCIES) + @rm -f tlspsens$(EXEEXT) + $(LINK) $(tlspsens_LDFLAGS) $(tlspsens_OBJECTS) $(tlspsens_LDADD) $(LIBS) +tnlp$(EXEEXT): $(tnlp_OBJECTS) $(tnlp_DEPENDENCIES) + @rm -f tnlp$(EXEEXT) + $(LINK) $(tnlp_LDFLAGS) $(tnlp_OBJECTS) $(tnlp_LDADD) $(LIBS) +tprede$(EXEEXT): $(tprede_OBJECTS) $(tprede_DEPENDENCIES) + @rm -f tprede$(EXEEXT) + $(LINK) $(tprede_LDFLAGS) $(tprede_OBJECTS) $(tprede_LDADD) $(LIBS) +tquant$(EXEEXT): $(tquant_OBJECTS) $(tquant_DEPENDENCIES) + @rm -f tquant$(EXEEXT) + $(LINK) $(tquant_LDFLAGS) $(tquant_OBJECTS) $(tquant_LDADD) $(LIBS) +vq_train_jvm$(EXEEXT): $(vq_train_jvm_OBJECTS) $(vq_train_jvm_DEPENDENCIES) + @rm -f vq_train_jvm$(EXEEXT) + $(LINK) $(vq_train_jvm_LDFLAGS) $(vq_train_jvm_OBJECTS) $(vq_train_jvm_LDADD) $(LIBS) +vqtrain$(EXEEXT): $(vqtrain_OBJECTS) $(vqtrain_DEPENDENCIES) + @rm -f vqtrain$(EXEEXT) + $(LINK) $(vqtrain_LDFLAGS) $(vqtrain_OBJECTS) $(vqtrain_LDADD) $(LIBS) +vqtrainjnd$(EXEEXT): $(vqtrainjnd_OBJECTS) $(vqtrainjnd_DEPENDENCIES) + @rm -f vqtrainjnd$(EXEEXT) + $(LINK) $(vqtrainjnd_LDFLAGS) $(vqtrainjnd_OBJECTS) $(vqtrainjnd_LDADD) $(LIBS) +vqtrainph$(EXEEXT): $(vqtrainph_OBJECTS) $(vqtrainph_DEPENDENCIES) + @rm -f vqtrainph$(EXEEXT) + $(LINK) $(vqtrainph_LDFLAGS) $(vqtrainph_OBJECTS) $(vqtrainph_LDADD) $(LIBS) +vqtrainsp$(EXEEXT): $(vqtrainsp_OBJECTS) $(vqtrainsp_DEPENDENCIES) + @rm -f vqtrainsp$(EXEEXT) + $(LINK) $(vqtrainsp_LDFLAGS) $(vqtrainsp_OBJECTS) $(vqtrainsp_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c2validate-c2validate.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebook.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebookd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebookdt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebookge.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebookjnd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebookjvm.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebookvq.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebookvqanssi.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codec2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/create_interleaver.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/de.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dump.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extract.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdmdv.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fifo.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genampdata.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genlsp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genphdata.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genres.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kiss_fft.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lpc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lsp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lspsync.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nlp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/octave.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pack.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/phase.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polar2rect.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/postfilter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pre.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/quantise.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raw2h.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scalarlsptest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sine.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t48_8.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tfdmdv.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tfifo.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tinterp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tlspsens.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tnlp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tprede.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tquant.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vq_train_jvm.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vqtrain.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vqtrainjnd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vqtrainph.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vqtrainsp.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +c2validate-c2validate.o: c2validate.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(c2validate_CFLAGS) $(CFLAGS) -MT c2validate-c2validate.o -MD -MP -MF "$(DEPDIR)/c2validate-c2validate.Tpo" -c -o c2validate-c2validate.o `test -f 'c2validate.c' || echo '$(srcdir)/'`c2validate.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/c2validate-c2validate.Tpo" "$(DEPDIR)/c2validate-c2validate.Po"; else rm -f "$(DEPDIR)/c2validate-c2validate.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='c2validate.c' object='c2validate-c2validate.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(c2validate_CFLAGS) $(CFLAGS) -c -o c2validate-c2validate.o `test -f 'c2validate.c' || echo '$(srcdir)/'`c2validate.c + +c2validate-c2validate.obj: c2validate.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(c2validate_CFLAGS) $(CFLAGS) -MT c2validate-c2validate.obj -MD -MP -MF "$(DEPDIR)/c2validate-c2validate.Tpo" -c -o c2validate-c2validate.obj `if test -f 'c2validate.c'; then $(CYGPATH_W) 'c2validate.c'; else $(CYGPATH_W) '$(srcdir)/c2validate.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/c2validate-c2validate.Tpo" "$(DEPDIR)/c2validate-c2validate.Po"; else rm -f "$(DEPDIR)/c2validate-c2validate.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='c2validate.c' object='c2validate-c2validate.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(c2validate_CFLAGS) $(CFLAGS) -c -o c2validate-c2validate.obj `if test -f 'c2validate.c'; then $(CYGPATH_W) 'c2validate.c'; else $(CYGPATH_W) '$(srcdir)/c2validate.c'; fi` + +lpc.o: ../src/lpc.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lpc.o -MD -MP -MF "$(DEPDIR)/lpc.Tpo" -c -o lpc.o `test -f '../src/lpc.c' || echo '$(srcdir)/'`../src/lpc.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lpc.Tpo" "$(DEPDIR)/lpc.Po"; else rm -f "$(DEPDIR)/lpc.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/lpc.c' object='lpc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lpc.o `test -f '../src/lpc.c' || echo '$(srcdir)/'`../src/lpc.c + +lpc.obj: ../src/lpc.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lpc.obj -MD -MP -MF "$(DEPDIR)/lpc.Tpo" -c -o lpc.obj `if test -f '../src/lpc.c'; then $(CYGPATH_W) '../src/lpc.c'; else $(CYGPATH_W) '$(srcdir)/../src/lpc.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lpc.Tpo" "$(DEPDIR)/lpc.Po"; else rm -f "$(DEPDIR)/lpc.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/lpc.c' object='lpc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lpc.obj `if test -f '../src/lpc.c'; then $(CYGPATH_W) '../src/lpc.c'; else $(CYGPATH_W) '$(srcdir)/../src/lpc.c'; fi` + +lsp.o: ../src/lsp.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lsp.o -MD -MP -MF "$(DEPDIR)/lsp.Tpo" -c -o lsp.o `test -f '../src/lsp.c' || echo '$(srcdir)/'`../src/lsp.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lsp.Tpo" "$(DEPDIR)/lsp.Po"; else rm -f "$(DEPDIR)/lsp.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/lsp.c' object='lsp.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lsp.o `test -f '../src/lsp.c' || echo '$(srcdir)/'`../src/lsp.c + +lsp.obj: ../src/lsp.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lsp.obj -MD -MP -MF "$(DEPDIR)/lsp.Tpo" -c -o lsp.obj `if test -f '../src/lsp.c'; then $(CYGPATH_W) '../src/lsp.c'; else $(CYGPATH_W) '$(srcdir)/../src/lsp.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lsp.Tpo" "$(DEPDIR)/lsp.Po"; else rm -f "$(DEPDIR)/lsp.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/lsp.c' object='lsp.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lsp.obj `if test -f '../src/lsp.c'; then $(CYGPATH_W) '../src/lsp.c'; else $(CYGPATH_W) '$(srcdir)/../src/lsp.c'; fi` + +quantise.o: ../src/quantise.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT quantise.o -MD -MP -MF "$(DEPDIR)/quantise.Tpo" -c -o quantise.o `test -f '../src/quantise.c' || echo '$(srcdir)/'`../src/quantise.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/quantise.Tpo" "$(DEPDIR)/quantise.Po"; else rm -f "$(DEPDIR)/quantise.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/quantise.c' object='quantise.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o quantise.o `test -f '../src/quantise.c' || echo '$(srcdir)/'`../src/quantise.c + +quantise.obj: ../src/quantise.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT quantise.obj -MD -MP -MF "$(DEPDIR)/quantise.Tpo" -c -o quantise.obj `if test -f '../src/quantise.c'; then $(CYGPATH_W) '../src/quantise.c'; else $(CYGPATH_W) '$(srcdir)/../src/quantise.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/quantise.Tpo" "$(DEPDIR)/quantise.Po"; else rm -f "$(DEPDIR)/quantise.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/quantise.c' object='quantise.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o quantise.obj `if test -f '../src/quantise.c'; then $(CYGPATH_W) '../src/quantise.c'; else $(CYGPATH_W) '$(srcdir)/../src/quantise.c'; fi` + +dump.o: ../src/dump.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dump.o -MD -MP -MF "$(DEPDIR)/dump.Tpo" -c -o dump.o `test -f '../src/dump.c' || echo '$(srcdir)/'`../src/dump.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/dump.Tpo" "$(DEPDIR)/dump.Po"; else rm -f "$(DEPDIR)/dump.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/dump.c' object='dump.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dump.o `test -f '../src/dump.c' || echo '$(srcdir)/'`../src/dump.c + +dump.obj: ../src/dump.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dump.obj -MD -MP -MF "$(DEPDIR)/dump.Tpo" -c -o dump.obj `if test -f '../src/dump.c'; then $(CYGPATH_W) '../src/dump.c'; else $(CYGPATH_W) '$(srcdir)/../src/dump.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/dump.Tpo" "$(DEPDIR)/dump.Po"; else rm -f "$(DEPDIR)/dump.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/dump.c' object='dump.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dump.obj `if test -f '../src/dump.c'; then $(CYGPATH_W) '../src/dump.c'; else $(CYGPATH_W) '$(srcdir)/../src/dump.c'; fi` + +kiss_fft.o: ../src/kiss_fft.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT kiss_fft.o -MD -MP -MF "$(DEPDIR)/kiss_fft.Tpo" -c -o kiss_fft.o `test -f '../src/kiss_fft.c' || echo '$(srcdir)/'`../src/kiss_fft.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/kiss_fft.Tpo" "$(DEPDIR)/kiss_fft.Po"; else rm -f "$(DEPDIR)/kiss_fft.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/kiss_fft.c' object='kiss_fft.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o kiss_fft.o `test -f '../src/kiss_fft.c' || echo '$(srcdir)/'`../src/kiss_fft.c + +kiss_fft.obj: ../src/kiss_fft.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT kiss_fft.obj -MD -MP -MF "$(DEPDIR)/kiss_fft.Tpo" -c -o kiss_fft.obj `if test -f '../src/kiss_fft.c'; then $(CYGPATH_W) '../src/kiss_fft.c'; else $(CYGPATH_W) '$(srcdir)/../src/kiss_fft.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/kiss_fft.Tpo" "$(DEPDIR)/kiss_fft.Po"; else rm -f "$(DEPDIR)/kiss_fft.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/kiss_fft.c' object='kiss_fft.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o kiss_fft.obj `if test -f '../src/kiss_fft.c'; then $(CYGPATH_W) '../src/kiss_fft.c'; else $(CYGPATH_W) '$(srcdir)/../src/kiss_fft.c'; fi` + +codec2.o: ../src/codec2.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codec2.o -MD -MP -MF "$(DEPDIR)/codec2.Tpo" -c -o codec2.o `test -f '../src/codec2.c' || echo '$(srcdir)/'`../src/codec2.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codec2.Tpo" "$(DEPDIR)/codec2.Po"; else rm -f "$(DEPDIR)/codec2.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codec2.c' object='codec2.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codec2.o `test -f '../src/codec2.c' || echo '$(srcdir)/'`../src/codec2.c + +codec2.obj: ../src/codec2.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codec2.obj -MD -MP -MF "$(DEPDIR)/codec2.Tpo" -c -o codec2.obj `if test -f '../src/codec2.c'; then $(CYGPATH_W) '../src/codec2.c'; else $(CYGPATH_W) '$(srcdir)/../src/codec2.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codec2.Tpo" "$(DEPDIR)/codec2.Po"; else rm -f "$(DEPDIR)/codec2.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codec2.c' object='codec2.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codec2.obj `if test -f '../src/codec2.c'; then $(CYGPATH_W) '../src/codec2.c'; else $(CYGPATH_W) '$(srcdir)/../src/codec2.c'; fi` + +sine.o: ../src/sine.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sine.o -MD -MP -MF "$(DEPDIR)/sine.Tpo" -c -o sine.o `test -f '../src/sine.c' || echo '$(srcdir)/'`../src/sine.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/sine.Tpo" "$(DEPDIR)/sine.Po"; else rm -f "$(DEPDIR)/sine.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/sine.c' object='sine.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sine.o `test -f '../src/sine.c' || echo '$(srcdir)/'`../src/sine.c + +sine.obj: ../src/sine.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sine.obj -MD -MP -MF "$(DEPDIR)/sine.Tpo" -c -o sine.obj `if test -f '../src/sine.c'; then $(CYGPATH_W) '../src/sine.c'; else $(CYGPATH_W) '$(srcdir)/../src/sine.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/sine.Tpo" "$(DEPDIR)/sine.Po"; else rm -f "$(DEPDIR)/sine.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/sine.c' object='sine.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sine.obj `if test -f '../src/sine.c'; then $(CYGPATH_W) '../src/sine.c'; else $(CYGPATH_W) '$(srcdir)/../src/sine.c'; fi` + +nlp.o: ../src/nlp.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nlp.o -MD -MP -MF "$(DEPDIR)/nlp.Tpo" -c -o nlp.o `test -f '../src/nlp.c' || echo '$(srcdir)/'`../src/nlp.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/nlp.Tpo" "$(DEPDIR)/nlp.Po"; else rm -f "$(DEPDIR)/nlp.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/nlp.c' object='nlp.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nlp.o `test -f '../src/nlp.c' || echo '$(srcdir)/'`../src/nlp.c + +nlp.obj: ../src/nlp.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nlp.obj -MD -MP -MF "$(DEPDIR)/nlp.Tpo" -c -o nlp.obj `if test -f '../src/nlp.c'; then $(CYGPATH_W) '../src/nlp.c'; else $(CYGPATH_W) '$(srcdir)/../src/nlp.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/nlp.Tpo" "$(DEPDIR)/nlp.Po"; else rm -f "$(DEPDIR)/nlp.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/nlp.c' object='nlp.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nlp.obj `if test -f '../src/nlp.c'; then $(CYGPATH_W) '../src/nlp.c'; else $(CYGPATH_W) '$(srcdir)/../src/nlp.c'; fi` + +postfilter.o: ../src/postfilter.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT postfilter.o -MD -MP -MF "$(DEPDIR)/postfilter.Tpo" -c -o postfilter.o `test -f '../src/postfilter.c' || echo '$(srcdir)/'`../src/postfilter.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/postfilter.Tpo" "$(DEPDIR)/postfilter.Po"; else rm -f "$(DEPDIR)/postfilter.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/postfilter.c' object='postfilter.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o postfilter.o `test -f '../src/postfilter.c' || echo '$(srcdir)/'`../src/postfilter.c + +postfilter.obj: ../src/postfilter.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT postfilter.obj -MD -MP -MF "$(DEPDIR)/postfilter.Tpo" -c -o postfilter.obj `if test -f '../src/postfilter.c'; then $(CYGPATH_W) '../src/postfilter.c'; else $(CYGPATH_W) '$(srcdir)/../src/postfilter.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/postfilter.Tpo" "$(DEPDIR)/postfilter.Po"; else rm -f "$(DEPDIR)/postfilter.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/postfilter.c' object='postfilter.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o postfilter.obj `if test -f '../src/postfilter.c'; then $(CYGPATH_W) '../src/postfilter.c'; else $(CYGPATH_W) '$(srcdir)/../src/postfilter.c'; fi` + +phase.o: ../src/phase.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT phase.o -MD -MP -MF "$(DEPDIR)/phase.Tpo" -c -o phase.o `test -f '../src/phase.c' || echo '$(srcdir)/'`../src/phase.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/phase.Tpo" "$(DEPDIR)/phase.Po"; else rm -f "$(DEPDIR)/phase.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/phase.c' object='phase.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o phase.o `test -f '../src/phase.c' || echo '$(srcdir)/'`../src/phase.c + +phase.obj: ../src/phase.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT phase.obj -MD -MP -MF "$(DEPDIR)/phase.Tpo" -c -o phase.obj `if test -f '../src/phase.c'; then $(CYGPATH_W) '../src/phase.c'; else $(CYGPATH_W) '$(srcdir)/../src/phase.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/phase.Tpo" "$(DEPDIR)/phase.Po"; else rm -f "$(DEPDIR)/phase.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/phase.c' object='phase.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o phase.obj `if test -f '../src/phase.c'; then $(CYGPATH_W) '../src/phase.c'; else $(CYGPATH_W) '$(srcdir)/../src/phase.c'; fi` + +interp.o: ../src/interp.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interp.o -MD -MP -MF "$(DEPDIR)/interp.Tpo" -c -o interp.o `test -f '../src/interp.c' || echo '$(srcdir)/'`../src/interp.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/interp.Tpo" "$(DEPDIR)/interp.Po"; else rm -f "$(DEPDIR)/interp.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/interp.c' object='interp.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interp.o `test -f '../src/interp.c' || echo '$(srcdir)/'`../src/interp.c + +interp.obj: ../src/interp.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interp.obj -MD -MP -MF "$(DEPDIR)/interp.Tpo" -c -o interp.obj `if test -f '../src/interp.c'; then $(CYGPATH_W) '../src/interp.c'; else $(CYGPATH_W) '$(srcdir)/../src/interp.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/interp.Tpo" "$(DEPDIR)/interp.Po"; else rm -f "$(DEPDIR)/interp.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/interp.c' object='interp.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interp.obj `if test -f '../src/interp.c'; then $(CYGPATH_W) '../src/interp.c'; else $(CYGPATH_W) '$(srcdir)/../src/interp.c'; fi` + +pack.o: ../src/pack.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pack.o -MD -MP -MF "$(DEPDIR)/pack.Tpo" -c -o pack.o `test -f '../src/pack.c' || echo '$(srcdir)/'`../src/pack.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/pack.Tpo" "$(DEPDIR)/pack.Po"; else rm -f "$(DEPDIR)/pack.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/pack.c' object='pack.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pack.o `test -f '../src/pack.c' || echo '$(srcdir)/'`../src/pack.c + +pack.obj: ../src/pack.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pack.obj -MD -MP -MF "$(DEPDIR)/pack.Tpo" -c -o pack.obj `if test -f '../src/pack.c'; then $(CYGPATH_W) '../src/pack.c'; else $(CYGPATH_W) '$(srcdir)/../src/pack.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/pack.Tpo" "$(DEPDIR)/pack.Po"; else rm -f "$(DEPDIR)/pack.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/pack.c' object='pack.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pack.obj `if test -f '../src/pack.c'; then $(CYGPATH_W) '../src/pack.c'; else $(CYGPATH_W) '$(srcdir)/../src/pack.c'; fi` + +codebook.o: ../src/codebook.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebook.o -MD -MP -MF "$(DEPDIR)/codebook.Tpo" -c -o codebook.o `test -f '../src/codebook.c' || echo '$(srcdir)/'`../src/codebook.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebook.Tpo" "$(DEPDIR)/codebook.Po"; else rm -f "$(DEPDIR)/codebook.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebook.c' object='codebook.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebook.o `test -f '../src/codebook.c' || echo '$(srcdir)/'`../src/codebook.c + +codebook.obj: ../src/codebook.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebook.obj -MD -MP -MF "$(DEPDIR)/codebook.Tpo" -c -o codebook.obj `if test -f '../src/codebook.c'; then $(CYGPATH_W) '../src/codebook.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebook.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebook.Tpo" "$(DEPDIR)/codebook.Po"; else rm -f "$(DEPDIR)/codebook.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebook.c' object='codebook.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebook.obj `if test -f '../src/codebook.c'; then $(CYGPATH_W) '../src/codebook.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebook.c'; fi` + +codebookd.o: ../src/codebookd.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookd.o -MD -MP -MF "$(DEPDIR)/codebookd.Tpo" -c -o codebookd.o `test -f '../src/codebookd.c' || echo '$(srcdir)/'`../src/codebookd.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookd.Tpo" "$(DEPDIR)/codebookd.Po"; else rm -f "$(DEPDIR)/codebookd.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookd.c' object='codebookd.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookd.o `test -f '../src/codebookd.c' || echo '$(srcdir)/'`../src/codebookd.c + +codebookd.obj: ../src/codebookd.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookd.obj -MD -MP -MF "$(DEPDIR)/codebookd.Tpo" -c -o codebookd.obj `if test -f '../src/codebookd.c'; then $(CYGPATH_W) '../src/codebookd.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookd.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookd.Tpo" "$(DEPDIR)/codebookd.Po"; else rm -f "$(DEPDIR)/codebookd.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookd.c' object='codebookd.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookd.obj `if test -f '../src/codebookd.c'; then $(CYGPATH_W) '../src/codebookd.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookd.c'; fi` + +codebookvq.o: ../src/codebookvq.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookvq.o -MD -MP -MF "$(DEPDIR)/codebookvq.Tpo" -c -o codebookvq.o `test -f '../src/codebookvq.c' || echo '$(srcdir)/'`../src/codebookvq.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookvq.Tpo" "$(DEPDIR)/codebookvq.Po"; else rm -f "$(DEPDIR)/codebookvq.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookvq.c' object='codebookvq.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookvq.o `test -f '../src/codebookvq.c' || echo '$(srcdir)/'`../src/codebookvq.c + +codebookvq.obj: ../src/codebookvq.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookvq.obj -MD -MP -MF "$(DEPDIR)/codebookvq.Tpo" -c -o codebookvq.obj `if test -f '../src/codebookvq.c'; then $(CYGPATH_W) '../src/codebookvq.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookvq.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookvq.Tpo" "$(DEPDIR)/codebookvq.Po"; else rm -f "$(DEPDIR)/codebookvq.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookvq.c' object='codebookvq.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookvq.obj `if test -f '../src/codebookvq.c'; then $(CYGPATH_W) '../src/codebookvq.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookvq.c'; fi` + +codebookjnd.o: ../src/codebookjnd.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookjnd.o -MD -MP -MF "$(DEPDIR)/codebookjnd.Tpo" -c -o codebookjnd.o `test -f '../src/codebookjnd.c' || echo '$(srcdir)/'`../src/codebookjnd.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookjnd.Tpo" "$(DEPDIR)/codebookjnd.Po"; else rm -f "$(DEPDIR)/codebookjnd.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookjnd.c' object='codebookjnd.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookjnd.o `test -f '../src/codebookjnd.c' || echo '$(srcdir)/'`../src/codebookjnd.c + +codebookjnd.obj: ../src/codebookjnd.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookjnd.obj -MD -MP -MF "$(DEPDIR)/codebookjnd.Tpo" -c -o codebookjnd.obj `if test -f '../src/codebookjnd.c'; then $(CYGPATH_W) '../src/codebookjnd.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookjnd.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookjnd.Tpo" "$(DEPDIR)/codebookjnd.Po"; else rm -f "$(DEPDIR)/codebookjnd.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookjnd.c' object='codebookjnd.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookjnd.obj `if test -f '../src/codebookjnd.c'; then $(CYGPATH_W) '../src/codebookjnd.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookjnd.c'; fi` + +codebookdt.o: ../src/codebookdt.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookdt.o -MD -MP -MF "$(DEPDIR)/codebookdt.Tpo" -c -o codebookdt.o `test -f '../src/codebookdt.c' || echo '$(srcdir)/'`../src/codebookdt.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookdt.Tpo" "$(DEPDIR)/codebookdt.Po"; else rm -f "$(DEPDIR)/codebookdt.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookdt.c' object='codebookdt.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookdt.o `test -f '../src/codebookdt.c' || echo '$(srcdir)/'`../src/codebookdt.c + +codebookdt.obj: ../src/codebookdt.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookdt.obj -MD -MP -MF "$(DEPDIR)/codebookdt.Tpo" -c -o codebookdt.obj `if test -f '../src/codebookdt.c'; then $(CYGPATH_W) '../src/codebookdt.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookdt.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookdt.Tpo" "$(DEPDIR)/codebookdt.Po"; else rm -f "$(DEPDIR)/codebookdt.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookdt.c' object='codebookdt.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookdt.obj `if test -f '../src/codebookdt.c'; then $(CYGPATH_W) '../src/codebookdt.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookdt.c'; fi` + +codebookjvm.o: ../src/codebookjvm.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookjvm.o -MD -MP -MF "$(DEPDIR)/codebookjvm.Tpo" -c -o codebookjvm.o `test -f '../src/codebookjvm.c' || echo '$(srcdir)/'`../src/codebookjvm.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookjvm.Tpo" "$(DEPDIR)/codebookjvm.Po"; else rm -f "$(DEPDIR)/codebookjvm.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookjvm.c' object='codebookjvm.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookjvm.o `test -f '../src/codebookjvm.c' || echo '$(srcdir)/'`../src/codebookjvm.c + +codebookjvm.obj: ../src/codebookjvm.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookjvm.obj -MD -MP -MF "$(DEPDIR)/codebookjvm.Tpo" -c -o codebookjvm.obj `if test -f '../src/codebookjvm.c'; then $(CYGPATH_W) '../src/codebookjvm.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookjvm.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookjvm.Tpo" "$(DEPDIR)/codebookjvm.Po"; else rm -f "$(DEPDIR)/codebookjvm.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookjvm.c' object='codebookjvm.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookjvm.obj `if test -f '../src/codebookjvm.c'; then $(CYGPATH_W) '../src/codebookjvm.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookjvm.c'; fi` + +codebookvqanssi.o: ../src/codebookvqanssi.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookvqanssi.o -MD -MP -MF "$(DEPDIR)/codebookvqanssi.Tpo" -c -o codebookvqanssi.o `test -f '../src/codebookvqanssi.c' || echo '$(srcdir)/'`../src/codebookvqanssi.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookvqanssi.Tpo" "$(DEPDIR)/codebookvqanssi.Po"; else rm -f "$(DEPDIR)/codebookvqanssi.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookvqanssi.c' object='codebookvqanssi.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookvqanssi.o `test -f '../src/codebookvqanssi.c' || echo '$(srcdir)/'`../src/codebookvqanssi.c + +codebookvqanssi.obj: ../src/codebookvqanssi.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookvqanssi.obj -MD -MP -MF "$(DEPDIR)/codebookvqanssi.Tpo" -c -o codebookvqanssi.obj `if test -f '../src/codebookvqanssi.c'; then $(CYGPATH_W) '../src/codebookvqanssi.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookvqanssi.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookvqanssi.Tpo" "$(DEPDIR)/codebookvqanssi.Po"; else rm -f "$(DEPDIR)/codebookvqanssi.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookvqanssi.c' object='codebookvqanssi.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookvqanssi.obj `if test -f '../src/codebookvqanssi.c'; then $(CYGPATH_W) '../src/codebookvqanssi.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookvqanssi.c'; fi` + +codebookge.o: ../src/codebookge.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookge.o -MD -MP -MF "$(DEPDIR)/codebookge.Tpo" -c -o codebookge.o `test -f '../src/codebookge.c' || echo '$(srcdir)/'`../src/codebookge.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookge.Tpo" "$(DEPDIR)/codebookge.Po"; else rm -f "$(DEPDIR)/codebookge.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookge.c' object='codebookge.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookge.o `test -f '../src/codebookge.c' || echo '$(srcdir)/'`../src/codebookge.c + +codebookge.obj: ../src/codebookge.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookge.obj -MD -MP -MF "$(DEPDIR)/codebookge.Tpo" -c -o codebookge.obj `if test -f '../src/codebookge.c'; then $(CYGPATH_W) '../src/codebookge.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookge.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookge.Tpo" "$(DEPDIR)/codebookge.Po"; else rm -f "$(DEPDIR)/codebookge.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookge.c' object='codebookge.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookge.obj `if test -f '../src/codebookge.c'; then $(CYGPATH_W) '../src/codebookge.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookge.c'; fi` + +fdmdv.o: ../src/fdmdv.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT fdmdv.o -MD -MP -MF "$(DEPDIR)/fdmdv.Tpo" -c -o fdmdv.o `test -f '../src/fdmdv.c' || echo '$(srcdir)/'`../src/fdmdv.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/fdmdv.Tpo" "$(DEPDIR)/fdmdv.Po"; else rm -f "$(DEPDIR)/fdmdv.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/fdmdv.c' object='fdmdv.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o fdmdv.o `test -f '../src/fdmdv.c' || echo '$(srcdir)/'`../src/fdmdv.c + +fdmdv.obj: ../src/fdmdv.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT fdmdv.obj -MD -MP -MF "$(DEPDIR)/fdmdv.Tpo" -c -o fdmdv.obj `if test -f '../src/fdmdv.c'; then $(CYGPATH_W) '../src/fdmdv.c'; else $(CYGPATH_W) '$(srcdir)/../src/fdmdv.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/fdmdv.Tpo" "$(DEPDIR)/fdmdv.Po"; else rm -f "$(DEPDIR)/fdmdv.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/fdmdv.c' object='fdmdv.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o fdmdv.obj `if test -f '../src/fdmdv.c'; then $(CYGPATH_W) '../src/fdmdv.c'; else $(CYGPATH_W) '$(srcdir)/../src/fdmdv.c'; fi` + +octave.o: ../src/octave.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT octave.o -MD -MP -MF "$(DEPDIR)/octave.Tpo" -c -o octave.o `test -f '../src/octave.c' || echo '$(srcdir)/'`../src/octave.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/octave.Tpo" "$(DEPDIR)/octave.Po"; else rm -f "$(DEPDIR)/octave.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/octave.c' object='octave.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o octave.o `test -f '../src/octave.c' || echo '$(srcdir)/'`../src/octave.c + +octave.obj: ../src/octave.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT octave.obj -MD -MP -MF "$(DEPDIR)/octave.Tpo" -c -o octave.obj `if test -f '../src/octave.c'; then $(CYGPATH_W) '../src/octave.c'; else $(CYGPATH_W) '$(srcdir)/../src/octave.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/octave.Tpo" "$(DEPDIR)/octave.Po"; else rm -f "$(DEPDIR)/octave.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/octave.c' object='octave.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o octave.obj `if test -f '../src/octave.c'; then $(CYGPATH_W) '../src/octave.c'; else $(CYGPATH_W) '$(srcdir)/../src/octave.c'; fi` + +fifo.o: ../src/fifo.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT fifo.o -MD -MP -MF "$(DEPDIR)/fifo.Tpo" -c -o fifo.o `test -f '../src/fifo.c' || echo '$(srcdir)/'`../src/fifo.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/fifo.Tpo" "$(DEPDIR)/fifo.Po"; else rm -f "$(DEPDIR)/fifo.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/fifo.c' object='fifo.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o fifo.o `test -f '../src/fifo.c' || echo '$(srcdir)/'`../src/fifo.c + +fifo.obj: ../src/fifo.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT fifo.obj -MD -MP -MF "$(DEPDIR)/fifo.Tpo" -c -o fifo.obj `if test -f '../src/fifo.c'; then $(CYGPATH_W) '../src/fifo.c'; else $(CYGPATH_W) '$(srcdir)/../src/fifo.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/fifo.Tpo" "$(DEPDIR)/fifo.Po"; else rm -f "$(DEPDIR)/fifo.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/fifo.c' object='fifo.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o fifo.obj `if test -f '../src/fifo.c'; then $(CYGPATH_W) '../src/fifo.c'; else $(CYGPATH_W) '$(srcdir)/../src/fifo.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstPROGRAMS ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/codec2/branches/0.3/unittest/README b/codec2/branches/0.3/unittest/README new file mode 100644 index 00000000..0e8776b7 --- /dev/null +++ b/codec2/branches/0.3/unittest/README @@ -0,0 +1,43 @@ +README +for codec2/unittest +Created David Rowe 31 July 2012 + +Training (experimental) sparse phase VQs: + +1/ In ../src/phase.c phase_experiment() enable: + + print_sparse_pred_error() + + and 'make' c2sim (in src) + +2/ Run over a training database: + + $ ./c2sim /xhome1/codec2/samples/train.spc --phaseexp > train_phtrain.txt + + a) check stats in Octave: + octave> load ../src/train_phtrain.txt + octave> std(nonzeros(train_phtrain(:,1:20))) + octave> hist(nonzeros(train_phtrain(:,1:20)),20) +3/ Extract and convert to floats vector you wish to train for example + first 20 (out of MAX_AMP == 80): + + $ ./extract ../src/train_phtrain.txt train_phtrain.flt 1 20 + +4/ Convert to rectangular: + + $ ./polar2rect train_phtrain.flt train_phtrainr.flt + +5/ Run this program: + + $ ./vqtrainph train_phtrainr.flt 20 1024 vq.txt + + Ouput is vq.txt + +Tests +----- + ++ build up insmallest possible stesp ++ impl errors v alg errors ++ use actual phase data as codebook ++ test vq with rand phases first or known data + diff --git a/codec2/branches/0.3/unittest/c2validate.c b/codec2/branches/0.3/unittest/c2validate.c new file mode 100644 index 00000000..5906017d --- /dev/null +++ b/codec2/branches/0.3/unittest/c2validate.c @@ -0,0 +1,103 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: c2validate.c + AUTHOR......: David Rowe + DATE CREATED: 10 April 2013 + + Encodes and decodes an array of speech samples using Codec 2 and compares + it to a previously stored output to validate Codec operation. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2013 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include "codec2.h" +#ifdef __UNITTEST__ +#include "hts1a.h" +#include "hts1a_1300.h" +#endif + +#include +#include +#include +#ifdef __EMBEDDED__ +#include "gdb_stdio.h" +#define fopen gdb_stdio_fopen +#define fwrite gdb_stdio_fwrite +#define fclose gdb_stdio_fclose +#endif + +int c2validate(int mode, short input_samples[], short output_samples[], char outfile[], int nsamples) +{ + struct CODEC2 *codec2; + short *pinput, *poutput, *outbuf; + unsigned char *bits; + int nsam, nbit; + int nframes, i, result, j; + FILE *fout; + + codec2 = codec2_create(mode); + nsam = codec2_samples_per_frame(codec2); + outbuf = (short*)malloc(nsam*sizeof(short)); + nbit = codec2_bits_per_frame(codec2); + bits = (unsigned char*)malloc(nbit*sizeof(char)); + if (strlen(outfile)) + fout = fopen(outfile, "wb"); + else + fout = NULL; + + nframes = nsamples/nsam; + pinput = input_samples; + poutput = output_samples; + result = 1; + + for(i=0; i. +*/ + +#ifndef __C2VALIDATE__ + +int c2validate(int mode, short input_samples[], short output_samples[], char outfile[], int nsamples); + +#endif diff --git a/codec2/branches/0.3/unittest/create_interleaver.c b/codec2/branches/0.3/unittest/create_interleaver.c new file mode 100644 index 00000000..39ff99c0 --- /dev/null +++ b/codec2/branches/0.3/unittest/create_interleaver.c @@ -0,0 +1,48 @@ +/* + create_interleaver.c + David Rowe + May 27 2012 + + Creates an interleaver for Codec 2. +*/ + +#include +#include +#include + +int main(int argc, char * argv[]) { + int m,i, src_bit, dest_bit; + FILE *f; + int *interleaver; + + if (argc != 3) { + printf("usage: %s InterleaverBits InterleaverFile\n", argv[0]); + exit(1); + } + + m = atoi(argv[1]); + f = fopen(argv[2],"wt"); + assert(f != NULL); + + + interleaver = (int*)malloc(m*sizeof(int)); + assert(interleaver != NULL); + for(i=0; i +#include +#include +#include +#include +#include +#include "lpc.h" + +#define N 80 + +int main(int argc, char *argv[]) { + FILE *fin, *fout; + short buf[N]; + float Sn[N], Sn_de[N]; + float de_mem = 0.0; + int i; + + if (argc != 3) { + printf("usage: de InputRawSpeechFile OutputRawSpeechFile\n"); + printf("e.g de input.raw output.raw"); + exit(1); + } + + if (strcmp(argv[1], "-") == 0) fin = stdin; + else if ( (fin = fopen(argv[1],"rb")) == NULL ) { + fprintf(stderr, "Error opening input speech file: %s: %s.\n", + argv[1], strerror(errno)); + exit(1); + } + + if (strcmp(argv[2], "-") == 0) fout = stdout; + else if ( (fout = fopen(argv[2],"wb")) == NULL ) { + fprintf(stderr, "Error opening output speech file: %s: %s.\n", + argv[2], strerror(errno)); + exit(1); + } + + while(fread(buf, sizeof(short), N, fin) == N) { + for(i=0; i. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_STR 1024 +#define LEN_TARGET_NAME_RESPONSE 14 +#define N 160 + +/* message parsing state machine states */ + +#define MSGSTATE_HDR1 0 +#define MSGSTATE_HDR2 1 +#define MSGSTATE_DATA 2 + +#define LENGTH_MASK 0x1FFF /* mask for message length */ +#define TYPE_MASK 0xE0 /* mask for upper byte of header */ +#define TYPE_C 0x20 /* compressed speech from target */ +#define TYPE_UC 0x40 /* uncompressed speech from target */ + +#define MAX_MSG_LEN 8192 + +/* Control items sent to DV Dongle */ + +char target_name[] = {0x04, 0x20, 0x01, 0x00}; + +/* note [2] appears to be in error, specifies run as 0x02, stop as 0x01 */ + +char run_state_stop[] = {0x05, 0x00, 0x18, 0x00, 0x00}; +char run_state_run[] = {0x05, 0x00, 0x18, 0x00, 0x01}; + +/* Control item codes from DV Dongle */ + +char data_item_0[] = {0x42, 0x81}; +char data_item_1[] = {0x32, 0xa0}; +char run_state[] = {0x05, 0x00}; +char idle[] = {0x00, 0x00}; + +typedef struct { + short header; + char power; + char control1; + short rate[5]; + short unused[3]; + short dtmf; + short control2; + short channel_data[12]; +} COMPRESSED; + +COMPRESSED c_in; +COMPRESSED c_out; +FILE *fin, *fout, *f; +int fd, c_msg, uc_msg; + +int initport(int fd) { + struct termios options; + + // Set the options for the port... + + cfmakeraw(&options); + cfsetispeed(&options, B230400); + cfsetospeed(&options, B230400); + options.c_cflag |= (CLOCAL | CREAD); + tcsetattr(fd, TCSANOW, &options); + + return 1; +} + +int getbaud(int fd) { + struct termios termAttr; + int inputSpeed = -1; + speed_t baudRate; + + tcgetattr(fd, &termAttr); + + /* Get the input speed */ + + baudRate = cfgetispeed(&termAttr); + switch (baudRate) { + case B0: inputSpeed = 0; break; + case B50: inputSpeed = 50; break; + case B110: inputSpeed = 110; break; + case B134: inputSpeed = 134; break; + case B150: inputSpeed = 150; break; + case B200: inputSpeed = 200; break; + case B300: inputSpeed = 300; break; + case B600: inputSpeed = 600; break; + case B1200: inputSpeed = 1200; break; + case B1800: inputSpeed = 1800; break; + case B2400: inputSpeed = 2400; break; + case B4800: inputSpeed = 4800; break; + case B9600: inputSpeed = 9600; break; + case B19200: inputSpeed = 19200; break; + case B38400: inputSpeed = 38400; break; + case B57600: inputSpeed = 38400; break; + case B115200: inputSpeed = 38400; break; + case B230400: inputSpeed = 230400; break; + } + + return inputSpeed; +} + +void write_dongle(int fd, char *data, int len) { + int n; + //printf(" writing %d bytes\n", len); + n = write(fd, data, len); + if (n < 0) { + perror("write failed"); + exit(1); + } +} + +void read_dongle(int fd, char *data, int len) { + int n; + //printf(" reading %d bytes \n", len); + + n = read(fd, data, len); + if (n < 0) { + perror("read failed"); + exit(1); + } + //printf(" read %d bytes\n", len); +} + +void parse_message(int msg_type, int msg_len, char msg_data[]) { + short buf[N]; + COMPRESSED *c_out; + + //printf("msg_type: 0x%02x msg_len: %d\n", msg_type, msg_len); + + /* echo compressed speech frames back to target */ + + if (msg_type == TYPE_C) { + c_out = (COMPRESSED*)msg_data; +#ifdef TMP + printf("control1 0x%04x\n", c_out->control1 & 0xff); + printf("rate[0] 0x%04x\n", c_out->rate[0]); + printf("rate[1] 0x%04x\n", c_out->rate[1]); + printf("rate[2] 0x%04x\n", c_out->rate[2]); + printf("rate[3] 0x%04x\n", c_out->rate[3]); + printf("rate[4] 0x%04x\n", c_out->rate[4]); + printf("control2 0x%04x\n", c_out->control2 & 0xffff); + printf("cd[0] 0x%04x\n", c_out->channel_data[0] & 0xffff); + printf("cd[1] 0x%04x\n", c_out->channel_data[1] & 0xffff); + printf("cd[2] 0x%04x\n", c_out->channel_data[2] & 0xffff); + printf("cd[3] 0x%04x\n", c_out->channel_data[3] & 0xffff); + printf("cd[4] 0x%04x\n", c_out->channel_data[4] & 0xffff); + printf("cd[5] 0x%04x\n", c_out->channel_data[5] & 0xffff); + printf("cd[6] 0x%04x\n", c_out->channel_data[6] & 0xffff); + printf("uc_msg %d\n", uc_msg); +#endif + printf("bit errors %d\n", c_out->unused[2]); + memcpy(&c_in.channel_data, + &c_out->channel_data, + sizeof(c_in.channel_data)); + + write_dongle(fd, data_item_1, sizeof(data_item_1)); + write_dongle(fd, (char*)&c_in, sizeof(c_in)); + + c_msg++; + } + + /* write speech buffers to disk */ + + if (msg_type == TYPE_UC) { + + if (fout != NULL) { + fwrite(msg_data, sizeof(char), msg_len-2, fout); + printf("msg_len %d\n", msg_len); + } + + if (fin != NULL) + fread(buf, sizeof(short), N, fin); + else + memset(buf, 0, sizeof(buf)); + + write_dongle(fd, data_item_0, sizeof(data_item_0)); + write_dongle(fd, (char*)buf, sizeof(buf)); + + uc_msg++; + } +} + +int main(int argc, char **argv) { + char response[MAX_STR]; + int i; + int state, next_state; + short header; + int msg_type, msg_length; + char msg_data[MAX_MSG_LEN]; + int n, length; + int r; + + char data; + + f = fopen("/tmp/log.txt", "wt"); + assert(f != NULL); + + /* open and configure serial port */ + + fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY); + if (fd == -1) { + perror("open_port: Unable to open /dev/ttyS0 - "); + exit(1); + } else { + fcntl(fd, F_SETFL, 0); + } + + initport(fd); + + fin = NULL; + if (argc >= 2) { + fin = fopen(argv[1],"rb"); + assert(fin != NULL); + } + fout = NULL; + if (argc == 3) { + fout = fopen(argv[2],"wb"); + assert(fout != NULL); + } + + /* check DV Dongle is alive */ + + write_dongle(fd, target_name, sizeof(target_name)); + read_dongle(fd, response, LEN_TARGET_NAME_RESPONSE); + if (strcmp(&response[4],"DV Dongle") != 0) { + printf("DV Dongle not responding\n"); + exit(1); + } + printf("Found DV Dongle....\n"); + + c_in.header = 0x13ec; + c_in.power = 0x0; + c_in.control1 = 0x0; + +#define RATE2000 +#ifdef RATE2000 + c_in.rate[0] = 0x0028; /* 2000 bit/s, no FEC */ + c_in.rate[1] = 0x0000; + c_in.rate[2] = 0x0000; + c_in.rate[3] = 0x0000; + c_in.rate[4] = 0x6248; +#endif + +#ifdef RATE3600_1200 + c_in.rate[0] = 0x5048; /* 3600 bit/s, 1200 bit/s FEC */ + c_in.rate[1] = 0x0001; + c_in.rate[2] = 0x0000; + c_in.rate[3] = 0x2412; + c_in.rate[4] = 0x6860; +#endif + + c_in.unused[0] = 0x0; + c_in.unused[1] = 0x0; + c_in.unused[2] = 0x0; + c_in.dtmf = 0x00ff; + c_in.control2 = 0x8000; + + /* put codec in run mode */ + + write_dongle(fd, run_state_run, sizeof(run_state_run)); + //write_dongle(fd, data_item_1, sizeof(data_item_1)); + //write_dongle(fd, (char*)&c_in, sizeof(c_in)); + + state = MSGSTATE_HDR1; + header = msg_type = msg_length = n = length = 0; + c_msg = uc_msg = 0; + + for(i=0; i<100000; i++) { + /* + We can only reliably read one byte at a time. Until I + realised this there was "much wailing and gnashing of + teeth". Trying to read() n bytes read() returns n but may + actually reads some number between 1 and n. So it may only + read 1 byte int data[] but return n. + */ + r = read(fd, &data, 1); + assert(r == 1); + + /* used state machine design from ambetest103.zip, SerialPort.cpp */ + + next_state = state; + switch(state) { + case MSGSTATE_HDR1: + header = data; + next_state = MSGSTATE_HDR2; + break; + case MSGSTATE_HDR2: + header |= data<<8; + msg_length = header & LENGTH_MASK; + msg_type = header & TYPE_MASK; + //printf("%0x %d\n", msg_type, msg_length); + if (length == 2) { + parse_message(msg_type, msg_length, msg_data); + next_state = MSGSTATE_HDR1; + } + else { + if (msg_length == 0x0) + length = 8192; + else + length = msg_length - 2; + n = 0; + next_state = MSGSTATE_DATA; + } + break; + case MSGSTATE_DATA: + msg_data[n++] = data; + length--; + if (length == 0) { + parse_message(msg_type, msg_length, msg_data); + next_state = MSGSTATE_HDR1; + } + break; + } + state = next_state; + } + + printf("finished, c_msg = %d uc_msg = %d\n", c_msg, uc_msg); + + write_dongle(fd, run_state_stop, sizeof(run_state_stop)); + + close(fd); + if (fin != NULL) + fclose(fin); + if (fout != NULL) + fclose(fout); + fclose(f); + + return 0; +} diff --git a/codec2/branches/0.3/unittest/extract.c b/codec2/branches/0.3/unittest/extract.c new file mode 100644 index 00000000..2812d55e --- /dev/null +++ b/codec2/branches/0.3/unittest/extract.c @@ -0,0 +1,126 @@ +/*--------------------------------------------------------------------------*\ + + FILE........: extract.c + AUTHOR......: David Rowe + DATE CREATED: 23/2/95 + + This program extracts a float file of vectors from a text file + of vectors. The float files are easier to process quickly + during VQ training. A subset of the text file VQ may be + extracted to faciltate split VQ of scaler VQ design. + +\*--------------------------------------------------------------------------*/ + +/* + Copyright (C) 2009 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#define MAX_STR 2048 /* maximum string length */ + +#include +#include +#include +#include +#include + +void scan_line(FILE *fp, float f[], int n); + +int main(int argc, char *argv[]) { + FILE *ftext; /* text file of vectors */ + FILE *ffloat; /* float file of vectors */ + int st,en; /* start and end values of vector to copy */ + float *buf; /* ptr to vector read from ftext */ + long lines; /* lines read so far */ + + if (argc != 5) { + printf("usage: %s TextFile FloatFile start(1 .. 10) end(1 .. 10)\n", argv[0]); + exit(1); + } + + /* read command line arguments and open files */ + + ftext = fopen(argv[1],"rt"); + if (ftext == NULL) { + printf("Error opening text file: %s\n",argv[1]); + exit(1); + } + + ffloat = fopen(argv[2],"wb"); + if (ffloat == NULL) { + printf("Error opening float file: %s\n",argv[2]); + exit(1); + } + + st = atoi(argv[3]); + en = atoi(argv[4]); + + buf = (float*)malloc(en*sizeof(float)); + if (buf == NULL) { + printf("Error in malloc()\n"); + exit(1); + } + + lines = 0; + while(!feof(ftext)) { + scan_line(ftext, buf, en); + if (!feof(ftext)) { + fwrite(&buf[st-1], sizeof(float), en-st+1, ffloat); + printf("\r%ld lines",++lines); + } + } + printf("\n"); + + /* clean up and exit */ + + free(buf); + fclose(ftext); + fclose(ffloat); + + return 0; +} + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: scan_line() + + AUTHOR......: David Rowe + DATE CREATED: 20/2/95 + + This function reads a vector of floats from a line in a text file. + +\*---------------------------------------------------------------------------*/ + +void scan_line(FILE *fp, float f[], int n) +/* FILE *fp; file ptr to text file */ +/* float f[]; array of floats to return */ +/* int n; number of floats in line */ +{ + char s[MAX_STR]; + char *ps,*pe; + int i; + + memset(s, 0, MAX_STR); + ps = pe = fgets(s,MAX_STR,fp); + if (ps == NULL) + return; + for(i=0; i quantized + + The first column is the log2 of the pitch compared to the lowest freq, + so log2(wo/pi*4000/50) where wo is the frequency your patch outputs. The + second column is the energy in dB, so 10*log10(1e-4+E) +*/ + +/* + Copyright (C) 2012 Jean-Marc Valin + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include + +#include +#include +#include + +#define MIN(a,b) ((a)<(b)?(a):(b)) +//#define COEF 0.0 + +static float COEF[2] = {0.8, 0.9}; +//static float COEF[2] = {0.0, 0.}; + +#define MAX_ENTRIES 16384 + +void compute_weights2(const float *x, const float *xp, float *w, int ndim) +{ + w[0] = 30; + w[1] = 1; + if (x[1]<0) + { + w[0] *= .6; + w[1] *= .3; + } + if (x[1]<-10) + { + w[0] *= .3; + w[1] *= .3; + } + /* Higher weight if pitch is stable */ + if (fabs(x[0]-xp[0])<.2) + { + w[0] *= 2; + w[1] *= 1.5; + } else if (fabs(x[0]-xp[0])>.5) /* Lower if not stable */ + { + w[0] *= .5; + } + + /* Lower weight for low energy */ + if (x[1] < xp[1]-10) + { + w[1] *= .5; + } + if (x[1] < xp[1]-20) + { + w[1] *= .5; + } + + //w[0] = 30; + //w[1] = 1; + + /* Square the weights because it's applied on the squared error */ + w[0] *= w[0]; + w[1] *= w[1]; + +} + +int find_nearest_weighted(const float *codebook, int nb_entries, float *x, const float *w, int ndim) +{ + int i, j; + float min_dist = 1e15; + int nearest = 0; + + for (i=0;i +#include +#include +#include +#include +#include +#include "../src/defines.h" + +typedef struct { + float real; + float imag; +} COMP; + +#define NVEC 200000 +#define D 2 +#define E 8 + +int main(void) { + FILE *f=fopen("testamp.flt", "wb"); + int i, j, m, L, index; + float amp, noisey_amp, pitch, Wo; + float sparse_pe[MAX_AMP]; + + #ifdef TEST1 + /* D fixed amplitude vectors of E elements long, + with D=2, E=8: + + $ ./vqtrainsp testamp.flt 2 8 test.txt + + test.txt should be same as training data. + */ + for(i=0; i. +*/ + +#define P 12 /* LP order */ +#define LSP_DELTA1 0.01 /* grid spacing for LSP root searches */ +#define NW 279 /* frame size in samples */ +#define N 80 /* frame to frame shift */ +#define THRESH 40.0 /* threshold energy/sample for frame inclusion */ +#define PI 3.141592654 /* mathematical constant */ + +#include +#include +#include +#include +#include "lpc.h" /* LPC analysis functions */ +#include "lsp.h" /* LSP encode/decode functions */ + +int switch_present(sw,argc,argv) + char sw[]; /* switch in string form */ + int argc; /* number of command line arguments */ + char *argv[]; /* array of command line arguments in string form */ +{ + int i; /* loop variable */ + + for(i=1; i THRESH) { + af++; + printf("Active Frame: %ld unstables: %d\n",af, unstables); + + find_aks(Sn, ak, NW, P, &Eres); + roots = lpc_to_lsp(ak, P , lsp, 5, LSP_DELTA1); + if (roots == P) { + if (lspd) { + if (log) { + fprintf(flsp,"%f ",log10(lsp[0])); + for(i=1; i +#include +#include +#include +#include +#include +#include "../src/defines.h" + +typedef struct { + float real; + float imag; +} COMP; + +#define NVEC 100000 +#define D 2 +#define E 8 + +int main(void) { + FILE *f=fopen("testph.flt", "wb"); + int i, m, L, index; + float angle, noisey_angle, pitch, Wo; + COMP c; + COMP sparse_pe[MAX_AMP]; + + #ifdef TEST1 + for(i=0; i. +*/ + +#include +#include +#include + +#define N 160 +#define P 10 + +int main(int argc, char *argv[]) +{ + FILE *fin,*fres; /* input and output files */ + short buf[N]; /* buffer of 16 bit speech samples */ + float Sn[P+N]; /* input speech samples */ + float res[N]; /* residual after LPC filtering */ + float E; + float ak[P+1]; /* LP coeffs */ + + int frames; /* frames processed so far */ + int i; /* loop variables */ + + if (argc < 3) { + printf("usage: %s InputFile ResidualFile\n", argv[0]); + exit(1); + } + + /* Open files */ + + if ((fin = fopen(argv[1],"rb")) == NULL) { + printf("Error opening input file: %s\n",argv[1]); + exit(0); + } + + if ((fres = fopen(argv[2],"wb")) == NULL) { + printf("Error opening output residual file: %s\n",argv[2]); + exit(0); + } + + /* Initialise */ + + frames = 0; + for(i=0; i +#include +#include +#include "codec2.h" +#include "defines.h" +#include "quantise.h" + +#define F 6 /* look at LSP ordering in F-1 frames */ +#define CORRECT_OFFSET 10 /* LSPs start 10 bits int frame qt 2400 bit/s */ + + +static int check_candidate(char bits[], int offset) +{ + int i; + int lsp_indexes[LPC_ORD]; + float lsps[LPC_ORD]; + unsigned int nbit = offset; + int swaps; + + for(i=0; i +#include +#include +#include + +#define TWO_PI 6.283185307 +#define FS 8000.0 +#define AMP 10000.0 + +int main(int argc, char *argv[]) { + FILE *f; + int i,n; + float freq, length; + short *buf; + + if (argc != 4) { + printf("usage: %s outputFile frequencyHz lengthSecs\n", argv[0]); + exit(1); + } + + f = fopen(argv[1] ,"wb"); + freq = atof(argv[2]); + length = atof(argv[3]); + n = length*FS; + buf = (short*)malloc(sizeof(short)*n); + assert(buf != NULL); + + for(i=0; i +#include +#include +#include + +typedef struct { + float real; + float imag; +} COMP; + +int main(int argc, char *argv[]) { + FILE *fpolar; + FILE *frect; + float polar; + COMP rect; + + if (argc != 3) { + printf("usage: %s polarFile rectFile\n", argv[0]); + exit(0); + } + + fpolar = fopen(argv[1], "rb"); + assert(fpolar != NULL); + frect = fopen(argv[2], "wb"); + assert(frect != NULL); + + while (fread(&polar, sizeof(float), 1, fpolar) != 0) { + if (polar == 0.0) { + /* this values indicates the VQ training should ignore + this vector element. It's not a valid phase as it + doesn't have mangitude of 1.0 */ + rect.real = 0.0; + rect.imag = 0.0; + } + else { + rect.real = cos(polar); + rect.imag = sin(polar); + } + fwrite(&rect, sizeof(COMP), 1, frect); + } + + fclose(fpolar); + fclose(frect); + + return 0; +} diff --git a/codec2/branches/0.3/unittest/pre.c b/codec2/branches/0.3/unittest/pre.c new file mode 100644 index 00000000..49e5c99c --- /dev/null +++ b/codec2/branches/0.3/unittest/pre.c @@ -0,0 +1,59 @@ +/* + pre.c + David Rowe + Sep 26 2012 + + Takes audio from a file, pre-emphasises, and sends to output file. +*/ + +#include +#include +#include +#include +#include +#include +#include "lpc.h" + +#define N 80 + +int main(int argc, char*argv[]) { + FILE *fin, *fout; + short buf[N]; + float Sn[N], Sn_pre[N]; + float pre_mem = 0.0; + int i; + + if (argc != 3) { + printf("usage: pre InputRawSpeechFile OutputRawSpeechFile\n"); + printf("e.g pre input.raw output.raw"); + exit(1); + } + + if (strcmp(argv[1], "-") == 0) fin = stdin; + else if ( (fin = fopen(argv[1],"rb")) == NULL ) { + fprintf(stderr, "Error opening input speech file: %s: %s.\n", + argv[1], strerror(errno)); + exit(1); + } + + if (strcmp(argv[2], "-") == 0) fout = stdout; + else if ( (fout = fopen(argv[2],"wb")) == NULL ) { + fprintf(stderr, "Error opening output speech file: %s: %s.\n", + argv[2], strerror(errno)); + exit(1); + } + + while(fread(buf, sizeof(short), N, fin) == N) { + for(i=0; i +#include +#include +#include + +int main(int argc, char *argv[]) { + FILE *fraw, *fheader; + int i, samples, ret; + short sam; + + if (argc != 5) { + printf("usage: %s inputRawFile outputHeaderFile arrayName samples\n", argv[0]); + exit(1); + } + + fraw = fopen(argv[1] ,"rb"); + assert(fraw != NULL); + fheader = fopen(argv[2],"wt"); + assert(fheader != NULL); + samples = atoi(argv[4]); + + fprintf(fheader, "short %s[] = {\n", argv[3]); + for(i=0; i. +*/ + +#include +#include +#include + +#include "defines.h" +#include "quantise.h" + +/*---------------------------------------------------------------------------*\ + + MAIN + +\*---------------------------------------------------------------------------*/ + +int main(int argc, char *argv[]) +{ + FILE *ftrain; /* LSP training data text file */ + float lsp[LPC_ORD]; /* LSP input vector in rads */ + float lsp_hz[LPC_ORD]; /* LSP input vector in Hz */ + int vectors; /* number LSP vectors processed */ + int k,m; /* LSP vector order and codebook size */ + int index; + float wt[1]; /* weighting (not used here for scalars) */ + const float *cb; /* LSP quantiser codebook */ + int i, ret; + float total_se; + + if (argc < 2) { + printf("usage: %s InputFile\n", argv[0]); + exit(1); + } + + if ((ftrain = fopen(argv[1],"rt")) == NULL) { + printf("Error opening input file: %s\n",argv[1]); + exit(0); + } + + total_se = 0.0; + vectors = 0; + wt[0] = 1.0; + + /* Main loop */ + + while(!feof(ftrain)) { + + /* Read LSP input vector speech */ + + for (i=0; i. +*/ + +#define MAX_N 2048 /* maximum DFT size */ + +#include +#include "four1.h" +#include "comp.h" +#include "sd.h" + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: spectral_dist() + + AUTHOR......: David Rowe + DATE CREATED: 20/7/93 + + This function returns the soectral distoertion between two + sets of LPCs. + +\*---------------------------------------------------------------------------*/ + +float spectral_dist(float ak1[], float ak2[], int p, int n) +/* float ak1[]; unquantised set of p+1 LPCs */ +/* float ak2[]; quantised set of p+1 LPCs */ +/* int p; LP order */ +/* int n; DFT size to use for SD calculations (power of 2) */ +{ + COMP A1[MAX_N]; /* DFT of ak1[] */ + COMP A2[MAX_N]; /* DFT of ak2[] */ + float P1,P2; /* power of current bin */ + float sd; + int i; + + for(i=0; i. +*/ + +#ifndef __SD__ +#define __SD__ + +float spectral_dist(float ak1[], float ak2[], int p, int n); + +#endif /* __SD__ */ diff --git a/codec2/branches/0.3/unittest/speexlsptest.c b/codec2/branches/0.3/unittest/speexlsptest.c new file mode 100644 index 00000000..3350894a --- /dev/null +++ b/codec2/branches/0.3/unittest/speexlsptest.c @@ -0,0 +1,176 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: speexlsptest.c + AUTHOR......: David Rowe + DATE CREATED: 24/8/09 + + Test LPC to LSP conversion and quantisation using Speex LSP quantiser. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2009 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include +#include +#include +#include +#include + +#define N 160 +#define P 10 + +#define LPC_FLOOR 0.0002 /* autocorrelation floor */ +#define LSP_DELTA1 0.2 /* grid spacing for LSP root searches */ +#define NDFT 256 /* DFT size for SD calculation */ + +/* Speex lag window */ + +const float lag_window[11] = { + 1.00000, 0.99716, 0.98869, 0.97474, 0.95554, 0.93140, 0.90273, 0.86998, + 0.83367, 0.79434, 0.75258 +}; + +/*---------------------------------------------------------------------------*\ + + find_aks_for_lsp() + + This function takes a frame of samples, and determines the linear + prediction coefficients for that frame of samples. Modified version of + find_aks from lpc.c to include autocorrelation noise floor and lag window + to match Speex processing steps prior to LSP conversion. + +\*---------------------------------------------------------------------------*/ + +void find_aks_for_lsp( + float Sn[], /* Nsam samples with order sample memory */ + float a[], /* order+1 LPCs with first coeff 1.0 */ + int Nsam, /* number of input speech samples */ + int order, /* order of the LPC analysis */ + float *E /* residual energy */ +) +{ + float Wn[N]; /* windowed frame of Nsam speech samples */ + float R[P+1]; /* order+1 autocorrelation values of Sn[] */ + int i; + + hanning_window(Sn,Wn,Nsam); + + autocorrelate(Wn,R,Nsam,order); + R[0] += LPC_FLOOR; + assert(order == 10); /* lag window only defined for order == 10 */ + for(i=0; i<=order; i++) + R[i] *= lag_window[i]; + levinson_durbin(R,a,order); + + *E = 0.0; + for(i=0; i<=order; i++) + *E += a[i]*R[i]; + if (*E < 0.0) + *E = 1E-12; +} + +/*---------------------------------------------------------------------------*\ + + MAIN + +\*---------------------------------------------------------------------------*/ + +int main(int argc, char *argv[]) +{ + FILE *fin; /* input speech files */ + short buf[N]; /* buffer of 16 bit speech samples */ + float Sn[P+N]; /* input speech samples */ + float E; + float ak[P+1]; /* LP coeffs */ + float ak_[P+1]; /* quantised LP coeffs */ + float lsp[P]; + float lsp_[P]; /* quantised LSPs */ + int roots; /* number of LSP roots found */ + int frames; /* frames processed so far */ + int i; /* loop variables */ + + SpeexBits bits; + + float sd; /* SD for this frame */ + float totsd; /* accumulated SD so far */ + int gt2,gt4; /* number of frames > 2 and 4 dB SD */ + int unstables; /* number of unstable LSP frames */ + + if (argc < 2) { + printf("usage: %s InputFile\n", argv[0]); + exit(0); + } + + /* Open files */ + + if ((fin = fopen(argv[1],"rb")) == NULL) { + printf("Error opening input file: %s\n",argv[1]); + exit(0); + } + + /* Initialise */ + + frames = 0; + for(i=0; i 2.0) gt2++; + if (sd > 4.0) gt4++; + totsd += sd; + } + else + unstables++; + } + + fclose(fin); + + printf("frames = %d Av sd = %3.2f dB", frames, totsd/frames); + printf(" >2 dB %3.2f%% >4 dB %3.2f%% unstables: %d\n",gt2*100.0/frames, + gt4*100.0/frames, unstables); + + return 0; +} + diff --git a/codec2/branches/0.3/unittest/t48_8.c b/codec2/branches/0.3/unittest/t48_8.c new file mode 100644 index 00000000..61a1bfa2 --- /dev/null +++ b/codec2/branches/0.3/unittest/t48_8.c @@ -0,0 +1,112 @@ +/* + t48_8.c + David Rowe + May 10 2012 + + Unit test for 48 to 8 kHz sample rate conversion functions. I + evaluated output by plotting using Octave and looking for jaggies: + + pl("../unittest/out48.raw",1,3000) + pl("../unittest/out8.raw",1,3000) + + Listening to it also shows up anything nasty: + + $ play -s -2 -r 48000 out48.raw + $ play -s -2 -r 8000 out8.raw + + */ + +#include +#include +#include +#include +#include "codec2_fdmdv.h" + +#define N8 160 /* procssing buffer size at 8 kHz */ +#define N48 (N8*FDMDV_OS) +#define MEM8 (FDMDV_OS_TAPS/FDMDV_OS) +#define FRAMES 50 +#define TWO_PI 6.283185307 +#define FS 8000 + +#define SINE + +int main() { + float in8k[MEM8 + N8]; + float out48k[N48]; + short out48k_short[N48]; + FILE *f48; + + float in48k[FDMDV_OS_TAPS + N48]; + float out8k[N48]; + short out8k_short[N8]; + FILE *f8; + + int i,f,t,t1; + float freq = 800.0; + + f48 = fopen("out48.raw", "wb"); + assert(f48 != NULL); + f8 = fopen("out8.raw", "wb"); + assert(f8 != NULL); + + /* clear filter memories */ + + for(i=0; i. +*/ + +#include +#include +#include +#include +#include +#include "defines.h" +#include "comp.h" +#include "codec2.h" +#include "quantise.h" +#include "interp.h" + +/* CODEC2 struct copies from codec2.c to help with testing */ + +struct CODEC2 { + int mode; + float w[M]; /* time domain hamming window */ + COMP W[FFT_ENC]; /* DFT of w[] */ + float Pn[2*N]; /* trapezoidal synthesis window */ + float Sn[M]; /* input speech */ + float hpf_states[2]; /* high pass filter states */ + void *nlp; /* pitch predictor states */ + float Sn_[2*N]; /* synthesised output speech */ + float ex_phase; /* excitation model phase track */ + float bg_est; /* background noise estimate for post filter */ + float prev_Wo; /* previous frame's pitch estimate */ + MODEL prev_model; /* previous frame's model parameters */ + float prev_lsps_[LPC_ORD]; /* previous frame's LSPs */ + float prev_energy; /* previous frame's LPC energy */ +}; + +void analyse_one_frame(struct CODEC2 *c2, MODEL *model, short speech[]); +void synthesise_one_frame(struct CODEC2 *c2, short speech[], MODEL *model, float ak[]); + +int test1() +{ + FILE *fin, *fout; + short buf[N]; + struct CODEC2 *c2; + MODEL model; + float ak[LPC_ORD+1]; + float lsps[LPC_ORD]; + + c2 = codec2_create(CODEC2_MODE_2400); + + fin = fopen("../raw/hts1a.raw", "rb"); + assert(fin != NULL); + fout = fopen("hts1a_test.raw", "wb"); + assert(fout != NULL); + + while(fread(buf, sizeof(short), N, fin) == N) { + analyse_one_frame(c2, &model, buf); + speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); + synthesise_one_frame(c2, buf, &model, ak); + fwrite(buf, sizeof(short), N, fout); + } + + codec2_destroy(c2); + + fclose(fin); + fclose(fout); + + return 0; +} + +int test2() +{ + FILE *fin, *fout; + short buf[2*N]; + struct CODEC2 *c2; + MODEL model, model_interp; + float ak[LPC_ORD+1]; + int voiced1, voiced2; + int lsp_indexes[LPC_ORD]; + int energy_index; + int Wo_index; + char *bits; + int nbit; + int i; + float lsps[LPC_ORD]; + float e; + + c2 = codec2_create(CODEC2_MODE_2400); + bits = (char*)malloc(codec2_bits_per_frame(c2)); + assert(bits != NULL); + fin = fopen("../raw/hts1a.raw", "rb"); + assert(fin != NULL); + fout = fopen("hts1a_test.raw", "wb"); + assert(fout != NULL); + + while(fread(buf, sizeof(short), 2*N, fin) == 2*N) { + /* first 10ms analysis frame - we just want voicing */ + + analyse_one_frame(c2, &model, buf); + voiced1 = model.voiced; + + /* second 10ms analysis frame */ + + analyse_one_frame(c2, &model, &buf[N]); + voiced2 = model.voiced; + + Wo_index = encode_Wo(model.Wo); + e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); + encode_lsps_scalar(lsp_indexes, lsps, LPC_ORD); + energy_index = encode_energy(e); + nbit = 0; + pack((unsigned char*)bits, (unsigned *)&nbit, Wo_index, WO_BITS); + for(i=0; iprev_model, &model); + + synthesise_one_frame(c2, buf, &model_interp, ak); + synthesise_one_frame(c2, &buf[N], &model, ak); + + memcpy(&c2->prev_model, &model, sizeof(MODEL)); + fwrite(buf, sizeof(short), 2*N, fout); + } + + free(bits); + codec2_destroy(c2); + + fclose(fin); + fclose(fout); + + return 0; +} + +int test3() +{ + FILE *fin, *fout, *fbits; + short buf1[2*N]; + short buf2[2*N]; + char *bits; + struct CODEC2 *c2; + + c2 = codec2_create(CODEC2_MODE_2400); + int numBits = codec2_bits_per_frame(c2); + int numBytes = (numBits+7)>>3; + + bits = (char*)malloc(numBytes); + + fin = fopen("../raw/hts1a.raw", "rb"); + assert(fin != NULL); + fout = fopen("hts1a_test.raw", "wb"); + assert(fout != NULL); + fbits = fopen("hts1a_test3.bit", "wb"); + assert(fout != NULL); + + while(fread(buf1, sizeof(short), 2*N, fin) == 2*N) { + codec2_encode(c2, (void*)bits, buf1); + fwrite(bits, sizeof(char), numBytes, fbits); + codec2_decode(c2, buf2, (void*)bits); + fwrite(buf2, sizeof(short), numBytes, fout); + } + + free(bits); + codec2_destroy(c2); + + fclose(fin); + fclose(fout); + fclose(fbits); + + return 0; +} + +int main() { + test3(); + return 0; +} diff --git a/codec2/branches/0.3/unittest/tcontphase.c b/codec2/branches/0.3/unittest/tcontphase.c new file mode 100644 index 00000000..6761bac8 --- /dev/null +++ b/codec2/branches/0.3/unittest/tcontphase.c @@ -0,0 +1,186 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: tcontphase.c + AUTHOR......: David Rowe + DATE CREATED: 11/9/09 + + Test program for developing continuous phase track synthesis algorithm. + However while developing this it was discovered that synthesis_mixed() + worked just as well. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2009 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#define N 80 /* frame size */ +#define F 160 /* frames to synthesis */ +#define P 10 /* LPC order */ + +#include +#include +#include +#include +#include "sine.h" +#include "dump.h" +#include "synth.h" +#include "phase.h" + +int frames; + +float ak[] = { + 1.000000, +-1.455836, + 1.361841, +-0.879267, + 0.915985, +-1.002202, + 0.944103, +-0.743094, + 1.053356, +-0.817491, + 0.431222 +}; + + +/*---------------------------------------------------------------------------*\ + + switch_present() + + Searches the command line arguments for a "switch". If the switch is + found, returns the command line argument where it ws found, else returns + NULL. + +\*---------------------------------------------------------------------------*/ + +int switch_present(sw,argc,argv) + char sw[]; /* switch in string form */ + int argc; /* number of command line arguments */ + char *argv[]; /* array of command line arguments in string form */ +{ + int i; /* loop variable */ + + for(i=1; i. +*/ + +#include +#include +#include +#include +#include + +#include "fdmdv_internal.h" +#include "codec2_fdmdv.h" +#include "octave.h" + +#define FRAMES 25 +#define CHANNEL_BUF_SIZE (10*M) + +extern float pilot_coeff[]; + +int main(int argc, char *argv[]) +{ + struct FDMDV *fdmdv; + int tx_bits[FDMDV_BITS_PER_FRAME]; + COMP tx_symbols[FDMDV_NC+1]; + COMP tx_baseband[NC+1][M]; + COMP tx_fdm[M]; + float channel[CHANNEL_BUF_SIZE]; + int channel_count; + COMP rx_fdm[M+M/P]; + float foff_coarse; + int nin, next_nin; + COMP rx_fdm_fcorr[M+M/P]; + COMP rx_baseband[NC+1][M+M/P]; + COMP rx_filt[NC+1][P+1]; + float rx_timing; + float env[NT*P]; + COMP rx_symbols[FDMDV_NC+1]; + int rx_bits[FDMDV_BITS_PER_FRAME]; + float foff_fine; + int sync_bit, reliable_sync_bit; + + int tx_bits_log[FDMDV_BITS_PER_FRAME*FRAMES]; + COMP tx_symbols_log[(FDMDV_NC+1)*FRAMES]; + COMP tx_baseband_log[(NC+1)][M*FRAMES]; + COMP tx_fdm_log[M*FRAMES]; + COMP pilot_baseband1_log[NPILOTBASEBAND*FRAMES]; + COMP pilot_baseband2_log[NPILOTBASEBAND*FRAMES]; + COMP pilot_lpf1_log[NPILOTLPF*FRAMES]; + COMP pilot_lpf2_log[NPILOTLPF*FRAMES]; + COMP S1_log[MPILOTFFT*FRAMES]; + COMP S2_log[MPILOTFFT*FRAMES]; + float foff_coarse_log[FRAMES]; + float foff_log[FRAMES]; + COMP rx_baseband_log[(NC+1)][(M+M/P)*FRAMES]; + int rx_baseband_log_col_index; + COMP rx_filt_log[NC+1][(P+1)*FRAMES]; + int rx_filt_log_col_index; + float env_log[NT*P*FRAMES]; + float rx_timing_log[FRAMES]; + COMP rx_symbols_log[FDMDV_NC+1][FRAMES]; + COMP phase_difference_log[FDMDV_NC+1][FRAMES]; + float sig_est_log[FDMDV_NC+1][FRAMES]; + float noise_est_log[FDMDV_NC+1][FRAMES]; + int rx_bits_log[FDMDV_BITS_PER_FRAME*FRAMES]; + float foff_fine_log[FRAMES]; + int sync_bit_log[FRAMES]; + int sync_log[FRAMES]; + int nin_log[FRAMES]; + + FILE *fout; + int f,c,i,j; + + fdmdv = fdmdv_create(FDMDV_NC); + next_nin = M; + channel_count = 0; + + rx_baseband_log_col_index = 0; + rx_filt_log_col_index = 0; + + printf("sizeof FDMDV states: %d bytes\n", sizeof(struct FDMDV)); + + for(f=0; fprev_tx_symbols, tx_bits, &fdmdv->tx_pilot_bit, 0); + memcpy(fdmdv->prev_tx_symbols, tx_symbols, sizeof(COMP)*(FDMDV_NC+1)); + tx_filter(tx_baseband, FDMDV_NC, tx_symbols, fdmdv->tx_filter_memory); + fdm_upconvert(tx_fdm, FDMDV_NC, tx_baseband, fdmdv->phase_tx, fdmdv->freq); + + /* --------------------------------------------------------*\ + Channel + \*---------------------------------------------------------*/ + + nin = next_nin; + /* + if (f == 2) + nin = 120; + if (f == 3) + nin = 200; + if ((f !=2) && (f != 3)) + nin = M; + */ + nin = M; + /* add M tx samples to end of buffer */ + + assert((channel_count + M) < CHANNEL_BUF_SIZE); + for(i=0; isync = 0; + if (fdmdv->sync == 0) + fdmdv->foff = foff_coarse; + fdmdv_freq_shift(rx_fdm_fcorr, rx_fdm, foff_coarse, &fdmdv->foff_phase_rect, nin); + + /* baseband processing */ + + fdm_downconvert(rx_baseband, FDMDV_NC, rx_fdm_fcorr, fdmdv->phase_rx, fdmdv->freq, nin); + rx_filter(rx_filt, FDMDV_NC, rx_baseband, fdmdv->rx_filter_memory, nin); + rx_timing = rx_est_timing(rx_symbols, FDMDV_NC, rx_filt, rx_baseband, fdmdv->rx_filter_mem_timing, env, fdmdv->rx_baseband_mem_timing, nin); + foff_fine = qpsk_to_bits(rx_bits, &sync_bit, FDMDV_NC, fdmdv->phase_difference, fdmdv->prev_rx_symbols, rx_symbols, 0); + //for(i=0; iprev_rx_symbols[i].real, fdmdv->prev_rx_symbols[i].imag, fdmdv->phase_difference[i].real, fdmdv->phase_difference[i].imag); + //if (f==1) + // exit(0); + snr_update(fdmdv->sig_est, fdmdv->noise_est, FDMDV_NC, fdmdv->phase_difference); + memcpy(fdmdv->prev_rx_symbols, rx_symbols, sizeof(COMP)*(FDMDV_NC+1)); + + next_nin = M; + + if (rx_timing > 2*M/P) + next_nin += M/P; + + if (rx_timing < 0) + next_nin -= M/P; + + fdmdv->sync = freq_state(&reliable_sync_bit, sync_bit, &fdmdv->fest_state, &fdmdv->timer, fdmdv->sync_mem); + fdmdv->foff -= TRACK_COEFF*foff_fine; + + /* --------------------------------------------------------*\ + Log each vector + \*---------------------------------------------------------*/ + + memcpy(&tx_bits_log[FDMDV_BITS_PER_FRAME*f], tx_bits, sizeof(int)*FDMDV_BITS_PER_FRAME); + memcpy(&tx_symbols_log[(FDMDV_NC+1)*f], tx_symbols, sizeof(COMP)*(FDMDV_NC+1)); + for(c=0; cpilot_baseband1, sizeof(COMP)*NPILOTBASEBAND); + memcpy(&pilot_baseband2_log[f*NPILOTBASEBAND], fdmdv->pilot_baseband2, sizeof(COMP)*NPILOTBASEBAND); + memcpy(&pilot_lpf1_log[f*NPILOTLPF], fdmdv->pilot_lpf1, sizeof(COMP)*NPILOTLPF); + memcpy(&pilot_lpf2_log[f*NPILOTLPF], fdmdv->pilot_lpf2, sizeof(COMP)*NPILOTLPF); + memcpy(&S1_log[f*MPILOTFFT], fdmdv->S1, sizeof(COMP)*MPILOTFFT); + memcpy(&S2_log[f*MPILOTFFT], fdmdv->S2, sizeof(COMP)*MPILOTFFT); + foff_coarse_log[f] = foff_coarse; + foff_log[f] = fdmdv->foff; + + /* rx down conversion */ + + for(c=0; cphase_difference[c]; + } + + /* qpsk_to_bits() */ + + memcpy(&rx_bits_log[FDMDV_BITS_PER_FRAME*f], rx_bits, sizeof(int)*FDMDV_BITS_PER_FRAME); + for(c=0; csig_est[c]; + noise_est_log[c][f] = fdmdv->noise_est[c]; + } + foff_fine_log[f] = foff_fine; + sync_bit_log[f] = sync_bit; + + sync_log[f] = fdmdv->sync; + } + + + /*---------------------------------------------------------*\ + Dump logs to Octave file for evaluation + by tfdmdv.m Octave script + \*---------------------------------------------------------*/ + + fout = fopen("tfdmdv_out.txt","wt"); + assert(fout != NULL); + fprintf(fout, "# Created by tfdmdv.c\n"); + octave_save_int(fout, "tx_bits_log_c", tx_bits_log, 1, FDMDV_BITS_PER_FRAME*FRAMES); + octave_save_complex(fout, "tx_symbols_log_c", tx_symbols_log, 1, (FDMDV_NC+1)*FRAMES, (FDMDV_NC+1)*FRAMES); + octave_save_complex(fout, "tx_baseband_log_c", (COMP*)tx_baseband_log, (FDMDV_NC+1), M*FRAMES, M*FRAMES); + octave_save_complex(fout, "tx_fdm_log_c", (COMP*)tx_fdm_log, 1, M*FRAMES, M*FRAMES); + octave_save_complex(fout, "pilot_lut_c", (COMP*)fdmdv->pilot_lut, 1, NPILOT_LUT, NPILOT_LUT); + octave_save_complex(fout, "pilot_baseband1_log_c", pilot_baseband1_log, 1, NPILOTBASEBAND*FRAMES, NPILOTBASEBAND*FRAMES); + octave_save_complex(fout, "pilot_baseband2_log_c", pilot_baseband2_log, 1, NPILOTBASEBAND*FRAMES, NPILOTBASEBAND*FRAMES); + octave_save_float(fout, "pilot_coeff_c", pilot_coeff, 1, NPILOTCOEFF, NPILOTCOEFF); + octave_save_complex(fout, "pilot_lpf1_log_c", pilot_lpf1_log, 1, NPILOTLPF*FRAMES, NPILOTLPF*FRAMES); + octave_save_complex(fout, "pilot_lpf2_log_c", pilot_lpf2_log, 1, NPILOTLPF*FRAMES, NPILOTLPF*FRAMES); + octave_save_complex(fout, "S1_log_c", S1_log, 1, MPILOTFFT*FRAMES, MPILOTFFT*FRAMES); + octave_save_complex(fout, "S2_log_c", S2_log, 1, MPILOTFFT*FRAMES, MPILOTFFT*FRAMES); + octave_save_float(fout, "foff_log_c", foff_log, 1, FRAMES, FRAMES); + octave_save_float(fout, "foff_coarse_log_c", foff_coarse_log, 1, FRAMES, FRAMES); + octave_save_complex(fout, "rx_baseband_log_c", (COMP*)rx_baseband_log, (FDMDV_NC+1), rx_baseband_log_col_index, (M+M/P)*FRAMES); + octave_save_complex(fout, "rx_filt_log_c", (COMP*)rx_filt_log, (FDMDV_NC+1), rx_filt_log_col_index, (P+1)*FRAMES); + octave_save_float(fout, "env_log_c", env_log, 1, NT*P*FRAMES, NT*P*FRAMES); + octave_save_float(fout, "rx_timing_log_c", rx_timing_log, 1, FRAMES, FRAMES); + octave_save_complex(fout, "rx_symbols_log_c", (COMP*)rx_symbols_log, (FDMDV_NC+1), FRAMES, FRAMES); + octave_save_complex(fout, "phase_difference_log_c", (COMP*)phase_difference_log, (FDMDV_NC+1), FRAMES, FRAMES); + octave_save_float(fout, "sig_est_log_c", (float*)sig_est_log, (FDMDV_NC+1), FRAMES, FRAMES); + octave_save_float(fout, "noise_est_log_c", (float*)noise_est_log, (FDMDV_NC+1), FRAMES, FRAMES); + octave_save_int(fout, "rx_bits_log_c", rx_bits_log, 1, FDMDV_BITS_PER_FRAME*FRAMES); + octave_save_float(fout, "foff_fine_log_c", foff_fine_log, 1, FRAMES, FRAMES); + octave_save_int(fout, "sync_bit_log_c", sync_bit_log, 1, FRAMES); + octave_save_int(fout, "sync_log_c", sync_log, 1, FRAMES); + octave_save_int(fout, "nin_log_c", nin_log, 1, FRAMES); + fclose(fout); + + fdmdv_destroy(fdmdv); + + return 0; +} + diff --git a/codec2/branches/0.3/unittest/tfifo.c b/codec2/branches/0.3/unittest/tfifo.c new file mode 100644 index 00000000..12e0d2b6 --- /dev/null +++ b/codec2/branches/0.3/unittest/tfifo.c @@ -0,0 +1,103 @@ +/* + tfifo.c + David Rowe + Nov 19 2012 + + Takes FIFOs, in particular thread safety. +*/ + +#include +#include +#include +#include "codec2_fifo.h" + +#define FIFO_SZ 1024 +#define WRITE_SZ 10 +#define READ_SZ 8 +#define N_MAX 100 +#define LOOPS 1000000 + +int run_thread = 1; +struct FIFO *f; + +void writer(void); +void *writer_thread(void *data); +pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + +#define USE_THREADS +//#define USE_MUTEX + +int main() { + pthread_t awriter_thread; + int i,j; + short read_buf[READ_SZ]; + int n_out = 0; + int sucess; + + f = fifo_create(FIFO_SZ); + #ifdef USE_THREADS + pthread_create(&awriter_thread, NULL, writer_thread, NULL); + #endif + + for(i=0; i WRITE_SZ) { + for(i=0; i. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "defines.h" +#include "sine.h" +#include "interp.h" + +void make_amp(MODEL *model, float f0, float cdB, float mdBHz) +{ + int i; + float mdBrad = mdBHz*FS/TWO_PI; + + model->Wo = f0*TWO_PI/FS; + model->L = PI/model->Wo; + for(i=0; i<=model->L; i++) + model->A[i] = pow(10.0,(cdB + (float)i*model->Wo*mdBrad)/20.0); + model->voiced = 1; +} + +void write_amp(char file[], MODEL *model) +{ + FILE *f; + int i; + + f = fopen(file,"wt"); + for(i=1; i<=model->L; i++) + fprintf(f, "%f\t%f\n", model->Wo*i, model->A[i]); + fclose(f); +} + +const char *get_next_float(const char *s, float *num) +{ + const char *p = s; + char tmp[MAX_STR]; + + while(*p && !isspace(*p)) + p++; + assert((p-s) < (int)(sizeof(tmp)-1)); + memcpy(tmp, s, p-s); + tmp[p-s] = 0; + *num = atof(tmp); + + return p+1; +} + +const char *get_next_int(const char *s, int *num) +{ + const char *p = s; + char tmp[MAX_STR]; + + while(*p && !isspace(*p)) + p++; + assert((p-s) < (int)(sizeof(tmp)-1)); + memcpy(tmp, s, p-s); + tmp[p-s] = 0; + *num = atoi(tmp); + + return p+1; +} + +void load_amp(MODEL *model, const char * file, int frame) +{ + FILE *f; + int i; + char s[1024]; + const char *ps; + + f = fopen(file,"rt"); + assert(f); + + for(i=0; iWo); + ps = get_next_int(ps, &model->L); + for(i=1; i<=model->L; i++) + ps = get_next_float(ps, &model->A[i]); + + fclose(f); +} + +void load_or_make_amp(MODEL *model, + const char * filename, int frame, + float f0, float cdB, float mdBHz) +{ + struct stat buf; + int rc = stat(filename, &buf); + if (rc || !S_ISREG(buf.st_mode) || ((buf.st_mode & S_IRUSR) != S_IRUSR)) + { + make_amp(model, f0, cdB, mdBHz); + } + else + { + load_amp(model, filename, frame); + } +} +int main() { + MODEL prev, next, interp; + + load_or_make_amp(&prev, + "../src/hts1a_model.txt", 32, + 50.0, 60.0, 6E-3); + load_or_make_amp(&next, + "../src/hts1a_model.txt", 34, + 50.0, 40.0, 6E-3); + + interp.voiced = 1; + interpolate(&interp, &prev, &next); + + write_amp("tinterp_prev.txt", &prev); + write_amp("tinterp_interp.txt", &interp); + write_amp("tinterp_next.txt", &next); + + return 0; +} diff --git a/codec2/branches/0.3/unittest/tlspsens.c b/codec2/branches/0.3/unittest/tlspsens.c new file mode 100644 index 00000000..a53a66cd --- /dev/null +++ b/codec2/branches/0.3/unittest/tlspsens.c @@ -0,0 +1,127 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: tlspsens.c + AUTHOR......: David Rowe + DATE CREATED: 31 May 2012 + + Testing bit error sensitivity of LSP bits, first step in devising an unequal + error protection scheme. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2012 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include +#include +#include +#include +#include "defines.h" +#include "comp.h" +#include "codec2.h" +#include "quantise.h" +#include "interp.h" +#include "codec2_internal.h" + +float run_a_test(char raw_file_name[], int bit_to_corrupt) +{ + FILE *fin; + short buf[N]; + struct CODEC2 *c2; + kiss_fft_cfg fft_fwd_cfg; + MODEL model; + float ak[LPC_ORD+1]; + float lsps[LPC_ORD], e; + int lsp_indexes[LPC_ORD], found_bit; + float snr, snr_sum; + int frames, i, mask, index; + + c2 = codec2_create(CODEC2_MODE_2400); + fft_fwd_cfg = kiss_fft_alloc(FFT_ENC, 0, NULL, NULL); + + fin = fopen(raw_file_name, "rb"); + assert(fin != NULL); + + /* find bit we are corrupting */ + + found_bit = 0; + for(i=0; i lsp_bits(i)) + bit_to_corrupt -= lsp_bits(i); + else { + index = i; + mask = (1 << bit_to_corrupt); + printf(" index: %d bit: %d mask: 0x%x ", index, bit_to_corrupt, mask); + found_bit = 1; + } + } + } + assert(found_bit == 1); + + /* OK test a sample file, flipping bit */ + + snr_sum = 0.0; + frames = 0; + while(fread(buf, sizeof(short), N, fin) == N) { + analyse_one_frame(c2, &model, buf); + e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); + encode_lsps_scalar(lsp_indexes, lsps, LPC_ORD); + + /* find and flip bit we are testing */ + + lsp_indexes[index] ^= mask; + + /* decode LSPs and measure SNR */ + + decode_lsps_scalar(lsps, lsp_indexes, LPC_ORD); + check_lsp_order(lsps, LPC_ORD); + bw_expand_lsps(lsps, LPC_ORD, 50.0, 100.0); + lsp_to_lpc(lsps, ak, LPC_ORD); + aks_to_M2(fft_fwd_cfg, ak, LPC_ORD, &model, e, &snr, 0, 0, 1, 1, LPCPF_BETA, LPCPF_GAMMA); + snr_sum += snr; + frames++; + } + + codec2_destroy(c2); + + fclose(fin); + + return snr_sum/frames; +} + +int main(int argc, char *argv[]) { + int i; + int total_lsp_bits = 0; + float snr; + + if (argc != 2) { + printf("usage: %s RawFile\n", argv[0]); + exit(1); + } + + for(i=0; i. +*/ + +#define N 80 /* frame size */ +#define M 320 /* pitch analysis window size */ +#define PITCH_MIN 20 +#define PITCH_MAX 160 +#define TNLP + +#include +#include +#include +#include + +#include "defines.h" +#include "dump.h" +#include "sine.h" +#include "nlp.h" +#include "kiss_fft.h" + +int frames; + +/*---------------------------------------------------------------------------*\ + + switch_present() + + Searches the command line arguments for a "switch". If the switch is + found, returns the command line argument where it ws found, else returns + NULL. + +\*---------------------------------------------------------------------------*/ + +int switch_present(sw,argc,argv) + char sw[]; /* switch in string form */ + int argc; /* number of command line arguments */ + char *argv[]; /* array of command line arguments in string form */ +{ + int i; /* loop variable */ + + for(i=1; i +#include +#include +#include +#include "lpc.h" + +#define N 10 +#define F 10 + +int main() { + FILE *fprede; + float Sn[N], Sn_pre[N], Sn_de[N]; + float pre_mem = 0.0, de_mem = 0.0; + int i, f; + + fprede = fopen("prede.txt", "wt"); + assert(fprede != NULL); + + for(i=0; i. +*/ + +#include +#include +#include +#include +#include + +#include "defines.h" +#include "dump.h" +#include "quantise.h" + +int test_Wo_quant(); +int test_lsp_quant(); +int test_lsp(int lsp_number, int levels, float max_error_hz); +int test_energy_quant(int levels, float max_error_dB); + +int main() { + quantise_init(); + test_Wo_quant(); + test_lsp_quant(); + test_energy_quant(E_LEVELS, 0.5*(E_MAX_DB - E_MIN_DB)/E_LEVELS); + + return 0; +} + +int test_lsp_quant() { + test_lsp( 1, 16, 12.5); + test_lsp( 2, 16, 12.5); + test_lsp( 3, 16, 25); + test_lsp( 4, 16, 50); + test_lsp( 5, 16, 50); + test_lsp( 6, 16, 50); + test_lsp( 7, 16, 50); + test_lsp( 8, 8, 50); + test_lsp( 9, 8, 50); + test_lsp(10, 4, 100); + + return 0; +} + +int test_energy_quant(int levels, float max_error_dB) { + FILE *fe; + float e,e_dec, error, low_e, high_e; + int index, index_in, index_out, i; + + /* check 1:1 match between input and output levels */ + + for(i=0; i max_error_dB) { + printf("error: %f %f\n", error, max_error_dB); + exit(0); + } + } + + fclose(fe); + return 0; +} + +int test_lsp(int lsp_number, int levels, float max_error_hz) { + float lsp[LPC_ORD]; + int indexes_in[LPC_ORD]; + int indexes_out[LPC_ORD]; + int indexes[LPC_ORD]; + int i; + float lowf, highf, f, error; + char s[MAX_STR]; + FILE *flsp; + float max_error_rads; + + lsp_number--; + max_error_rads = max_error_hz*TWO_PI/FS; + + for(i=0; i max_error_rads) { + printf("%d error: %f %f\n", lsp_number+1, error, max_error_rads); + exit(0); + } + } + + fclose(flsp); + + printf("OK\n"); + + return 0; +} + +int test_Wo_quant() { + int c; + FILE *f; + float Wo,Wo_dec, error, step_size; + int index, index_in, index_out; + + /* output Wo quant curve for plotting */ + + f = fopen("quant_pitch.txt","wt"); + + for(Wo=0.9*(TWO_PI/P_MAX); Wo<=1.1*(TWO_PI/P_MIN); Wo += 0.001) { + index = encode_Wo(Wo); + fprintf(f, "%f %d\n", Wo, index); + } + + fclose(f); + + /* check for all Wo codes we get 1:1 match between encoder + and decoder Wo levels */ + + for(c=0; c (step_size/2.0)) { + printf("error: %f step_size/2: %f\n", error, step_size/2.0); + exit(0); + } + fprintf(f,"%f\n",error); + } + printf("OK\n"); + + fclose(f); + return 0; +} diff --git a/codec2/branches/0.3/unittest/tsrc.c b/codec2/branches/0.3/unittest/tsrc.c new file mode 100644 index 00000000..0c2c604a --- /dev/null +++ b/codec2/branches/0.3/unittest/tsrc.c @@ -0,0 +1,64 @@ +/* + tsrc.c + David Rowe + Sat Nov 3 2012 + + Unit test for libresample code. + + */ + +#include +#include +#include +#include +#include + +#define N8 160 /* processing buffer size at 8 kHz */ +#define N48 ((int)N8*(48000/8000)) /* buf size assuming 48k max sample rate */ + +int main(int argc, char *argv[]) { + FILE *f8k, *fout; + short in8k_short[N8]; + float in8k[N8]; + float out[N48]; + short out_short[N48]; + SRC_STATE *src; + SRC_DATA data; + int error; + + if (argc != 4) { + printf("usage %s inputRawFile OutputRawFile OutputSamplerate\n", argv[0]); + exit(0); + } + + f8k = fopen(argv[1], "rb"); + assert(f8k != NULL); + + fout = fopen(argv[2], "wb"); + assert(fout != NULL); + + src = src_new(SRC_SINC_FASTEST, 1, &error); + assert(src != NULL); + + data.data_in = in8k; + data.data_out = out; + data.input_frames = N8; + data.output_frames = N48; + data.end_of_input = 0; + data.src_ratio = atof(argv[3])/8000; + printf("%f\n", data.src_ratio); + + while(fread(in8k_short, sizeof(short), N8, f8k) == N8) { + src_short_to_float_array(in8k_short, in8k, N8); + src_process(src, &data); + printf("%d %d\n", (int)data.output_frames , (int)data.output_frames_gen); + assert(data.output_frames_gen <= N48); + src_float_to_short_array(out, out_short, data.output_frames_gen); + fwrite(out_short, sizeof(short), data.output_frames_gen, fout); + } + + fclose(fout); + fclose(f8k); + + return 0; +} diff --git a/codec2/branches/0.3/unittest/vq_train_jvm.c b/codec2/branches/0.3/unittest/vq_train_jvm.c new file mode 100755 index 00000000..9da091e0 --- /dev/null +++ b/codec2/branches/0.3/unittest/vq_train_jvm.c @@ -0,0 +1,486 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: vq_train_jvm.c + AUTHOR......: Jean-Marc Valin + DATE CREATED: 21 Jan 2012 + + Multi-stage Vector Quantoser training program developed by Jean-Marc at + linux.conf.au 2012. Minor mods by David Rowe + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2012 Jean-Marc Valin + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + + +#ifdef VALGRIND +#include +#endif + +#include +#include +#include +#include + +#define MIN(a,b) ((a)<(b)?(a):(b)) +#define COEF 0.0f +#define MAX_ENTRIES 16384 + +void compute_weights(const float *x, float *w, int ndim) +{ + int i; + w[0] = MIN(x[0], x[1]-x[0]); + for (i=1;i. +*/ + +/*-----------------------------------------------------------------------*\ + + INCLUDES + +\*-----------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include + +/*-----------------------------------------------------------------------*\ + + DEFINES + +\*-----------------------------------------------------------------------*/ + +#define DELTAQ 0.01 /* quiting distortion */ +#define MAX_STR 80 /* maximum string length */ + +/*-----------------------------------------------------------------------*\ + + FUNCTION PROTOTYPES + +\*-----------------------------------------------------------------------*/ + +void zero(float v[], int k); +void acc(float v1[], float v2[], int k); +void norm(float v[], int k, long n); +long quantise(float cb[], float vec[], int k, int m, float *se); + +/*-----------------------------------------------------------------------* \ + + MAIN + +\*-----------------------------------------------------------------------*/ + +int main(int argc, char *argv[]) { + long k,m; /* dimension and codebook size */ + float *vec; /* current vector */ + float *cb; /* vector codebook */ + float *cent; /* centroids for each codebook entry */ + long *n; /* number of vectors in this interval */ + long J; /* number of vectors in training set */ + long i,j; + long ind; /* index of current vector */ + float se; /* squared error for this iteration */ + float Dn,Dn_1; /* current and previous iterations distortion */ + float delta; /* improvement in distortion */ + FILE *ftrain; /* file containing training set */ + FILE *fvq; /* file containing vector quantiser */ + int ret; + + /* Interpret command line arguments */ + + if (argc != 5) { + printf("usage: %s TrainFile K(dimension) M(codebook size) VQFile\n", argv[0]); + exit(1); + } + + /* Open training file */ + + ftrain = fopen(argv[1],"rb"); + if (ftrain == NULL) { + printf("Error opening training database file: %s\n",argv[1]); + exit(1); + } + + /* determine k and m, and allocate arrays */ + + k = atol(argv[2]); + m = atol(argv[3]); + printf("dimension K=%ld number of entries M=%ld\n", k, m); + vec = (float*)malloc(sizeof(float)*k); + cb = (float*)malloc(sizeof(float)*k*m); + cent = (float*)malloc(sizeof(float)*k*m); + n = (long*)malloc(sizeof(long)*m); + if (cb == NULL || cb == NULL || cent == NULL || vec == NULL) { + printf("Error in malloc.\n"); + exit(1); + } + + /* determine size of training set */ + + J = 0; + while(fread(vec, sizeof(float), k, ftrain) == (size_t)k) + J++; + printf("J=%ld entries in training set\n", J); + + /* set up initial codebook state from samples of training set */ + + rewind(ftrain); + ret = fread(cb, sizeof(float), k*m, ftrain); + + /* main loop */ + + Dn = 1E32; + j = 1; + do { + Dn_1 = Dn; + + /* zero centroids */ + + for(i=0; i DELTAQ) + for(i=0; i DELTAQ); + + /* save codebook to disk */ + + fvq = fopen(argv[4],"wt"); + if (fvq == NULL) { + printf("Error opening VQ file: %s\n",argv[4]); + exit(1); + } + + fprintf(fvq,"%ld %ld\n",k,m); + for(j=0; j. +*/ + +/*-----------------------------------------------------------------------*\ + + INCLUDES + +\*-----------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +/*-----------------------------------------------------------------------*\ + + DEFINES + +\*-----------------------------------------------------------------------*/ + +#define PI 3.141592654 /* mathematical constant */ +#define MAX_POP 10 + +/*-----------------------------------------------------------------------*\ + + FUNCTION PROTOTYPES + +\*-----------------------------------------------------------------------*/ + +void zero(float v[], int k); +void acc(float v1[], float v2[], int k); +void norm(float v[], int k, long n); +void locate_lsps_jnd_steps(float lsps[], float step, int k); + +/*-----------------------------------------------------------------------* \ + + MAIN + +\*-----------------------------------------------------------------------*/ + +int main(int argc, char *argv[]) { + int k; /* dimension and codebook size */ + float *vec; /* current vector */ + int *n; /* number of vectors in this interval */ + int J; /* number of vectors in training set */ + int i,j; + FILE *ftrain; /* file containing training set */ + float *train; /* training database */ + //float *pend_train; /* last entry */ + float *pt; + int ntrain, match, vec_exists, vec_index=0, entry; + int popular[MAX_POP], pop_thresh; + FILE *fvq; + float jnd; + + /* Interpret command line arguments */ + + if (argc != 6) { + printf("usage: %s TrainFile K(dimension) JND popThresh VQFile\n", + argv[0]); + exit(1); + } + + /* Open training file */ + + ftrain = fopen(argv[1],"rb"); + if (ftrain == NULL) { + printf("Error opening training database file: %s\n",argv[1]); + exit(1); + } + + /* determine k and m, and allocate arrays */ + + k = atol(argv[2]); + jnd = atof(argv[3]); + pop_thresh = atol(argv[4]); + printf("dimension K=%d popThresh=%d JND=%3.1f Hz\n", + k, pop_thresh, jnd); + vec = (float*)malloc(sizeof(float)*k); + if (vec == NULL) { + printf("Error in malloc.\n"); + exit(1); + } + + /* determine size of training set */ + + J = 0; + while(fread(vec, sizeof(float), k, ftrain) == (size_t)k) + J++; + printf("J=%d entries in training set\n", J); + train = (float*)malloc(sizeof(float)*k*J); + if (train == NULL) { + printf("Error in malloc.\n"); + exit(1); + } + printf("training array is %d bytes\n", sizeof(float)*k*J); + + n = (int*)malloc(sizeof(int)*J); + if (n == NULL) { + printf("Error in malloc.\n"); + exit(1); + } + for(i=0; i pop_thresh) { + for(j=0; j. +*/ + +/*-----------------------------------------------------------------------*\ + + INCLUDES + +\*-----------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include + +typedef struct { + float real; + float imag; +} COMP; + +/*-----------------------------------------------------------------------* \ + + DEFINES + +\*-----------------------------------------------------------------------*/ + +#define DELTAQ 0.01 /* quiting distortion */ +#define MAX_STR 80 /* maximum string length */ +#define PI 3.141592654 + +/*-----------------------------------------------------------------------*\ + + FUNCTION PROTOTYPES + +\*-----------------------------------------------------------------------*/ + +void zero(COMP v[], int d); +void acc(COMP v1[], COMP v2[], int d); +void norm(COMP v[], int k); +int quantise(COMP cb[], COMP vec[], int d, int e, float *se); +void print_vec(COMP cb[], int d, int e); + +/*-----------------------------------------------------------------------* \ + + MAIN + +\*-----------------------------------------------------------------------*/ + +int main(int argc, char *argv[]) { + int d,e; /* dimension and codebook size */ + COMP *vec; /* current vector */ + COMP *cb; /* vector codebook */ + COMP *cent; /* centroids for each codebook entry */ + int *n; /* number of vectors in this interval */ + int J; /* number of vectors in training set */ + int ind; /* index of current vector */ + float se; /* total squared error for this iteration */ + float var; /* variance */ + float var_1; /* previous variance */ + float delta; /* improvement in distortion */ + FILE *ftrain; /* file containing training set */ + FILE *fvq; /* file containing vector quantiser */ + int ret; + int i,j, finished, iterations; + float b; /* equivalent number of bits */ + float improvement; + float sd_vec, sd_element, sd_theory, bits_theory; + int var_n; + + /* Interpret command line arguments */ + + if (argc != 5) { + printf("usage: %s TrainFile D(dimension) E(number of entries) VQFile\n", argv[0]); + exit(1); + } + + /* Open training file */ + + ftrain = fopen(argv[1],"rb"); + if (ftrain == NULL) { + printf("Error opening training database file: %s\n",argv[1]); + exit(1); + } + + /* determine k and m, and allocate arrays */ + + d = atoi(argv[2]); + e = atoi(argv[3]); + printf("\n"); + printf("dimension D=%d number of entries E=%d\n", d, e); + vec = (COMP*)malloc(sizeof(COMP)*d); + cb = (COMP*)malloc(sizeof(COMP)*d*e); + cent = (COMP*)malloc(sizeof(COMP)*d*e); + n = (int*)malloc(sizeof(int)*e); + if (cb == NULL || cb == NULL || cent == NULL || vec == NULL) { + printf("Error in malloc.\n"); + exit(1); + } + + /* determine size of training set */ + + J = 0; + var_n = 0; + while(fread(vec, sizeof(COMP), d, ftrain) == (size_t)d) { + for(j=0; j 1) { + if (var > 0.0) { + delta = (var_1 - var)/var; + } + else + delta = 0; + if (delta < DELTAQ) + finished = 1; + } + + if (!finished) { + /* determine new codebook from centroids */ + + for(i=0; i. +*/ + +/*-----------------------------------------------------------------------*\ + + INCLUDES + +\*-----------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include + +typedef struct { + float real; + float imag; +} COMP; + +/*-----------------------------------------------------------------------* \ + + DEFINES + +\*-----------------------------------------------------------------------*/ + +#define DELTAQ 0.01 /* quiting distortion */ +#define MAX_STR 80 /* maximum string length */ + +/*-----------------------------------------------------------------------*\ + + FUNCTION PROTOTYPES + +\*-----------------------------------------------------------------------*/ + +void zero(float v[], int d); +void acc(float v1[], float v2[], int d); +void norm(float v[], int k, int n[]); +int quantise(float cb[], float vec[], int d, int e, float *se); +void print_vec(float cb[], int d, int e); +void split(float cb[], int d, int b); +int gain_shape_quantise(float cb[], float vec[], int d, int e, float *se, float *best_gain); + +/*-----------------------------------------------------------------------* \ + + MAIN + +\*-----------------------------------------------------------------------*/ + +int main(int argc, char *argv[]) { + int d,e; /* dimension and codebook size */ + float *vec; /* current vector */ + float *cb; /* vector codebook */ + float *cent; /* centroids for each codebook entry */ + int *n; /* number of vectors in this interval */ + int J; /* number of vectors in training set */ + int ind; /* index of current vector */ + float se; /* total squared error for this iteration */ + float var; /* variance */ + float var_1; /* previous variance */ + float delta; /* improvement in distortion */ + FILE *ftrain; /* file containing training set */ + FILE *fvq; /* file containing vector quantiser */ + int ret; + int i,j, finished, iterations; + float sd; + int var_n, bits, b, levels; + + /* Interpret command line arguments */ + + if (argc < 5) { + printf("usage: %s TrainFile D(dimension) B(number of bits) VQFile [error.txt file]\n", argv[0]); + exit(1); + } + + /* Open training file */ + + ftrain = fopen(argv[1],"rb"); + if (ftrain == NULL) { + printf("Error opening training database file: %s\n",argv[1]); + exit(1); + } + + /* determine k and m, and allocate arrays */ + + d = atoi(argv[2]); + bits = atoi(argv[3]); + e = 1< 1) { + if (var > 0.0) { + delta = (var_1 - var)/var; + } + else + delta = 0; + if (delta < DELTAQ) + finished = 1; + } + + if (!finished) { + /* determine new codebook from centroids */ + + for(i=0; i -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "portaudio.h" - -#include "fdmdv.h" -#include "codec2.h" - -#define MIN_DB -40.0 -#define MAX_DB 0.0 -#define BETA 0.1 // constant for time averageing spectrum data -#define MIN_HZ 0 -#define MAX_HZ 4000 -#define WATERFALL_SECS_Y 5 // number of seconds respresented by y axis of waterfall -#define DT 0.02 // time between samples -#define FS 8000 // FDMDV modem sample rate - -#define SCATTER_MEM (FDMDV_NSYM)*50 -#define SCATTER_X_MAX 3.0 -#define SCATTER_Y_MAX 3.0 - -// main window params - -#define W 1200 -#define W3 (W/3) -#define H 600 -#define H2 (H/2) -#define SP 20 - -// sound card - -#define SAMPLE_RATE 48000 /* 48 kHz sampling rate rec. as we - can trust accuracy of sound - card */ -#define N8 FDMDV_NOM_SAMPLES_PER_FRAME /* processing buffer size at 8 kHz */ -#define MEM8 (FDMDV_OS_TAPS/FDMDV_OS) -#define N48 (N8*FDMDV_OS) /* processing buffer size at 48 kHz */ -#define NUM_CHANNELS 2 /* I think most sound cards prefer stereo, - we will convert to mono */ - -#define BITS_PER_CODEC_FRAME (2*FDMDV_BITS_PER_FRAME) -#define BYTES_PER_CODEC_FRAME (BITS_PER_CODEC_FRAME/8) - -// forward class declarations - -class Spectrum; -class Waterfall; -class Scatter; -class Scalar; - -// Globals -------------------------------------- - -char *fin_name = NULL; -char *fout_name = NULL; -char *sound_dev_name = NULL; -FILE *fin = NULL; -FILE *fout = NULL; -struct FDMDV *fdmdv; -struct CODEC2 *codec2; -float av_mag[FDMDV_NSPEC]; // shared between a few classes - -// GUI variables -------------------------------- - -Fl_Group *agroup; -Fl_Window *window; -Fl_Window *zoomSpectrumWindow = NULL; -Fl_Window *zoomWaterfallWindow = NULL; -Spectrum *aSpectrum; -Spectrum *aZoomedSpectrum; -Waterfall *aWaterfall; -Waterfall *aZoomedWaterfall; -Scatter *aScatter; -Scalar *aTimingEst; -Scalar *aFreqEst; -Scalar *aSNR; -int zoom_spectrum = 0; - -// Main processing loop states ------------------ - -float Ts = 0.0; -short input_buf[2*FDMDV_NOM_SAMPLES_PER_FRAME]; -int n_input_buf = 0; -int nin = FDMDV_NOM_SAMPLES_PER_FRAME; -short *output_buf; -int n_output_buf = 0; -int codec_bits[2*FDMDV_BITS_PER_FRAME]; -int state = 0; - -// Portaudio states ----------------------------- - -PaStream *stream = NULL; -PaError err; - -typedef struct { - float in48k[FDMDV_OS_TAPS + N48]; - float in8k[MEM8 + N8]; -} paCallBackData; - -// Class for each window type ------------------ - -class Spectrum: public Fl_Box { -protected: - int handle(int event) { - - // detect a left mouse down if inside the spectrum window - - if ((event == FL_NO_EVENT) && (Fl::event_button() == 1)) { - if ((Fl::event_x() > x()) && (Fl::event_x() < (x() + w())) && - (Fl::event_y() > y()) && (Fl::event_y() < (y() + h()))) { - - // show zoomed spectrum window - - zoomSpectrumWindow->show(); - } - - } - return 0; - } - - void draw() { - float x_px_per_point = 0.0; - float y_px_per_dB = 0.0; - int i, x1, y1, x2, y2; - float mag1, mag2; - char label[20]; - float px_per_hz; - - Fl_Box::draw(); - fl_color(FL_BLACK); - fl_rectf(x(),y(),w(),h()); - fl_color(FL_GREEN); - fl_line_style(FL_SOLID); - - fl_push_clip(x(),y(),w(),h()); - //printf("%d %d\n", w(), h()); - x_px_per_point = (float)w()/FDMDV_NSPEC; - y_px_per_dB = (float)h()/(MAX_DB - MIN_DB); - - // plot spectrum - - for(i=0; i x()) && (Fl::event_x() < (x() + w())) && - (Fl::event_y() > y()) && (Fl::event_y() < (y() + h()))) { - - // show zoomed spectrum window - - zoomWaterfallWindow->show(); - } - - } - return 0; - } - - // map val to a rgb colour - // from http://eddiema.ca/2011/01/21/c-sharp-heatmaps/ - - unsigned heatmap(float val, float min, float max) { - unsigned r = 0; - unsigned g = 0; - unsigned b = 0; - - val = (val - min) / (max - min); - if(val <= 0.2) { - b = (unsigned)((val / 0.2) * 255); - } else if(val > 0.2 && val <= 0.7) { - b = (unsigned)((1.0 - ((val - 0.2) / 0.5)) * 255); - } - if(val >= 0.2 && val <= 0.6) { - g = (unsigned)(((val - 0.2) / 0.4) * 255); - } else if(val > 0.6 && val <= 0.9) { - g = (unsigned)((1.0 - ((val - 0.6) / 0.3)) * 255); - } - if(val >= 0.5) { - r = (unsigned)(((val - 0.5) / 0.5) * 255); - } - - //printf("%f %x %x %x\n", val, r, g, b); - - return (b << 16) + (g << 8) + r; - } - - void draw() { - float spec_index_per_px, intensity_per_dB; - int px_per_sec; - int index, dy, dy_blocks, bytes_in_row_of_blocks, b; - int px, py, intensity; - unsigned *last_row, *pdest, *psrc; - - /* detect resizing of window */ - - if ((h() != prev_h) || (w() != prev_w)) { - delete pixel_buf; - new_pixel_buf(w(), h()); - } - - Fl_Box::draw(); - - // determine dy, the height of one "block" - - px_per_sec = (float)h()/WATERFALL_SECS_Y; - dy = DT*px_per_sec; - - // number of dy high blocks in spectrogram - - dy_blocks = h()/dy; - - // shift previous bit map - - bytes_in_row_of_blocks = dy*w()*sizeof(unsigned); - - for(b=0; b 255) intensity = 255; - if (intensity < 0) intensity = 0; - - if (greyscale) { - for(py=0; py (h()/2 - 10)) - y1 = h()/2 - 10; - if (y1 < -(h()/2 - 10)) - y1 = -(h()/2 - 10); - return y1; - } - - void draw() { - float x_scale; - float y_scale; - int i, x1, y1, x2, y2; - char label[100]; - - Fl_Box::draw(); - - /* detect resizing of window */ - - if ((h() != prev_h) || (w() != prev_w) || (x() != prev_x) || (y() != prev_y)) { - fl_color(FL_BLACK); - fl_rectf(x(),y(),w(),h()); - prev_h = h(); prev_w = w(); prev_x = x(); prev_y = y(); - } - - fl_push_clip(x(),y(),w(),h()); - - x_scale = (float)w()/x_max; - y_scale = (float)h()/(2.0*y_max); - - // erase last sample - - fl_color(FL_BLACK); - x1 = x_scale * index + x(); - y1 = y_scale * mem[index]; - y1 = clip(y1); - y1 = y() + h()/2 - y1; - fl_point(x1, y1); - - // draw new sample - - fl_color(FL_GREEN); - x1 = x_scale * index + x(); - y1 = y_scale * new_sample; - y1 = clip(y1); - y1 = y() + h()/2 - y1; - fl_point(x1, y1); - mem[index] = new_sample; - - index++; - if (index >= x_max) - index = 0; - - // y axis graticule - - step = 10; - - while ((2.0*y_max/step) > 10) - step *= 2.0; - while ((2.0*y_max/step) < 4) - step /= 2.0; - - fl_color(FL_DARK_GREEN); - fl_line_style(FL_DOT); - for(i=-y_max; i= *nin) { - - // demod per frame processing - - for(i=0; i<*nin; i++) - rx_fdm[i] = (float)input_buf[i]/FDMDV_SCALE; - nin_prev = *nin; - fdmdv_demod(fdmdv, rx_bits, &sync_bit, rx_fdm, nin); - *n_input_buf -= nin_prev; - assert(*n_input_buf >= 0); - - // shift input buffer - - for(i=0; i<*n_input_buf; i++) - input_buf[i] = input_buf[i+nin_prev]; - - // compute rx spectrum & get demod stats, and update GUI plot data - - fdmdv_get_rx_spectrum(fdmdv, rx_spec, rx_fdm, nin_prev); - fdmdv_get_demod_stats(fdmdv, &stats); - new_data(rx_spec); - aScatter->add_new_samples(stats.rx_symbols); - aTimingEst->add_new_sample(stats.rx_timing); - aFreqEst->add_new_sample(stats.foff); - aSNR->add_new_sample(stats.snr_est); - - /* - State machine to: - - + Mute decoded audio when out of sync. The demod is synced - when we are using the fine freq estimate and SNR is above - a thresh. - - + Decode codec bits only if we have a 0,1 sync bit - sequence. Collects two frames of demod bits to decode - one frame of codec bits. - */ - - next_state = *state; - switch (*state) { - case 0: - /* mute output audio when out of sync */ - - if (*n_output_buf < 2*codec2_samples_per_frame(c2) - N8) { - for(i=0; i 3.0)) - next_state = 1; - - break; - case 1: - if (sync_bit == 0) { - next_state = 2; - - /* first half of frame of codec bits */ - - memcpy(codec_bits, rx_bits, FDMDV_BITS_PER_FRAME*sizeof(int)); - } - else - next_state = 1; - - if (stats.fest_coarse_fine == 0) - next_state = 0; - - break; - case 2: - next_state = 1; - - if (stats.fest_coarse_fine == 0) - next_state = 0; - - if (sync_bit == 1) { - /* second half of frame of codec bits */ - - memcpy(&codec_bits[FDMDV_BITS_PER_FRAME], rx_bits, FDMDV_BITS_PER_FRAME*sizeof(int)); - - /* pack bits, MSB received first */ - - bit = 7; byte = 0; - memset(packed_bits, 0, BYTES_PER_CODEC_FRAME); - for(i=0; i= DT) { - *Ts -= DT; - if (!zoomSpectrumWindow->shown() && !zoomWaterfallWindow->shown()) { - aSpectrum->redraw(); - aWaterfall->redraw(); - aScatter->redraw(); - aTimingEst->redraw(); - aFreqEst->redraw(); - aSNR->redraw(); - } - if (zoomSpectrumWindow->shown()) - aZoomedSpectrum->redraw(); - if (zoomWaterfallWindow->shown()) - aZoomedWaterfall->redraw(); - } -} - - -/* - idle() is the FLTK function that gets continusouly called when FLTK - is not doing GUI work. We use this function for providing file - input to update the GUI when simulating real time operation. -*/ - -void idle(void*) { - int ret, i; - - if (fin_name != NULL) { - ret = fread(&input_buf[n_input_buf], - sizeof(short), - FDMDV_NOM_SAMPLES_PER_FRAME, - fin); - n_input_buf += FDMDV_NOM_SAMPLES_PER_FRAME; - - per_frame_rx_processing(output_buf, &n_output_buf, - codec_bits, - input_buf, &n_input_buf, - &nin, &state, codec2); - - if (fout_name != NULL) { - if (n_output_buf >= N8) { - ret = fwrite(output_buf, sizeof(short), N8, fout); - n_output_buf -= N8; - assert(n_output_buf >= 0); - - /* shift speech sample output buffer */ - - for(i=0; iin8k; - float *in48k = cbData->in48k; - float out8k[N8]; - float out48k[N48]; - short out48k_short[N48]; - - (void) timeInfo; - (void) statusFlags; - - assert(inputBuffer != NULL); - - /* Convert input model samples from 48 to 8 kHz ------------ */ - - /* just use left channel */ - - for(i=0; i= N8) { - if (state == 0) { - for(i=0; i= 0); - - /* shift speech samples in output buffer */ - - for(i=0; i<(uint)n_output_buf; i++) - output_buf[i] = output_buf[i+N8]; - - /* Convert output speech to 48 kHz sample rate ------------- */ - - /* upsample and update filter memory */ - - fdmdv_8_to_48(out48k, &in8k[MEM8], N8); - for(i=0; i= argc) - return 0; - fin_name = argv[i+1]; - i += 2; - return 2; - } - if (argv[i][1] == 'o') { - if ((i+1) >= argc) - return 0; - fout_name = argv[i+1]; - i += 2; - return 2; - } - if (argv[i][1] == 's') { - if ((i+1) >= argc) - return 0; - sound_dev_name = argv[i+1]; - i += 2; - return 2; - } - return 0; -} - -/*------------------------------------------------------------*\ - - MAIN - -\*------------------------------------------------------------*/ - -int main(int argc, char **argv) { - int ret; - int i; - PaStreamParameters inputParameters, outputParameters; - paCallBackData cbData; - - i = 1; - Fl::args(argc,argv,i,arg_callback); - - if (argc == 1) { - printf("usage: %s [-i inputFdmdvRawFile] [-o outputRawSoundFile] [-s inputSoundDevice]\n", argv[0]); - exit(0); - } - - if (fin_name != NULL) { - fin = fopen(fin_name,"rb"); - if (fin == NULL) { - fprintf(stderr, "Error opening input fdmdv raw file %s\n", fin_name); - exit(1); - } - } - - if (fout_name != NULL) { - fout = fopen(fout_name,"wb"); - if (fout == NULL) { - fprintf(stderr, "Error opening output speech raw file %s\n", fout_name); - exit(1); - } - } - - for(i=0; idefaultLowInputLatency; - inputParameters.hostApiSpecificStreamInfo = NULL; - - outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */ - if (outputParameters.device == paNoDevice) { - fprintf(stderr,"Error: No default output device.\n"); - goto pa_error; - } - outputParameters.channelCount = NUM_CHANNELS; /* stereo output */ - outputParameters.sampleFormat = paInt16; - outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; - outputParameters.hostApiSpecificStreamInfo = NULL; - - err = Pa_OpenStream( - &stream, - &inputParameters, - &outputParameters, - SAMPLE_RATE, - N48, - paClipOff, - callback, - &cbData); - - if( err != paNoError ) goto pa_error; - } - - /*------------------------------------------------------------------------*\ - - Init GUI - - \*------------------------------------------------------------------------*/ - - // recommended to prevent dithering and stopped display being - // covered by black flickering squares - - Fl::visual(FL_RGB); - - // set up main window - - window = new Fl_Window(W, SP+H2+SP+SP+H2+SP, "fl_fmdv"); - //window->size_range(100, 100); - //window->resizable(); - aSpectrum = new Spectrum(SP, SP, W3-2*SP, H2); - aWaterfall = new Waterfall(SP, SP+H2+SP+SP, W3-2*SP, H2); - aScatter = new Scatter(W3+SP, SP, W3-2*SP, H2); - aTimingEst = new Scalar(W3+SP, SP+H2+SP+SP, W3-2*SP, H2, 100, 80, "Timing Est"); - aFreqEst = new Scalar(2*W3+SP, SP, W3-2*SP, H2, 100, 100, "Frequency Est"); - aSNR = new Scalar(2*W3+SP, SP+H2+SP+SP, W3-2*SP, H2, 100, 20, "SNR"); - - Fl::add_idle(idle); - - window->end(); - - // set up zoomed spectrum window - - zoomSpectrumWindow = new Fl_Window(W, H, "Spectrum"); - aZoomedSpectrum = new Spectrum(SP, SP, W-2*SP, H-2*SP); - zoomSpectrumWindow->end(); - - // set up zoomed waterfall window - - zoomWaterfallWindow = new Fl_Window(W, H, "Waterfall"); - aZoomedWaterfall = new Waterfall(SP, SP, W-2*SP, H-2*SP); - zoomWaterfallWindow->end(); - - if (sound_dev_name != NULL) { - err = Pa_StartStream( stream ); - if( err != paNoError ) goto pa_error; - } - - // show the main window and start running - - window->show(argc, argv); - Fl::run(); - - if (sound_dev_name != NULL) { - err = Pa_StopStream( stream ); - if( err != paNoError ) goto pa_error; - Pa_CloseStream( stream ); - Pa_Terminate(); - } - - fdmdv_destroy(fdmdv); - codec2_destroy(codec2); - free(output_buf); - - if (fin_name != NULL) - fclose(fin); - if (fout_name != NULL) - fclose(fout); - - return ret; - - // Portaudio error handling - -pa_error: - if( stream ) { - Pa_AbortStream( stream ); - Pa_CloseStream( stream ); - } - Pa_Terminate(); - fprintf( stderr, "An error occured while using the portaudio stream\n" ); - fprintf( stderr, "Error number: %d\n", err ); - fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); - return -1; -} diff --git a/codec2/octave/README.txt b/codec2/octave/README.txt deleted file mode 100644 index 05d63f20..00000000 --- a/codec2/octave/README.txt +++ /dev/null @@ -1,17 +0,0 @@ -README.txt -For codec2/octave directory -Created 24 June 2012 by David Rowe - -1/ To support some of the Octave scripts (in particular fdmdv) in this - directory the following Octave packages need to be installed: - - control image miscellaneous optim signal specfun struct - -2/ Download these tar balls from: - - http://octave.sourceforge.net/packages.php - -3/ Install each package from the Octave command line with: - - octave:3> pkg install package_file_name.tar.gz - diff --git a/codec2/octave/av_imp.m b/codec2/octave/av_imp.m deleted file mode 100644 index 8b7fa608..00000000 --- a/codec2/octave/av_imp.m +++ /dev/null @@ -1,43 +0,0 @@ -% av_imp.m -% David Rowe Aug 2012 -% Averages the impulse response samples - -function imp = av_imp(imp_filename, period_in_secs, st, en) - f = fopen(imp_filename,"rb"); - s = fread(f, Inf, "short")'; - - Fs = 8000; - n = period_in_secs * Fs; - - [r c] = size(s); - - imp = zeros(1,n); - for i=1:n:c-n - imp = imp + s(i:i+n-1); - endfor - - % user supplies start and end samples after viweing plot - - if (nargin == 4) - imp = imp(st:en); - end - - % normalise - - imp /= sqrt(sum(imp .^ 2)); - - [h w] = freqz(imp, 1, 4000); - - figure(1); - clf; - plot(imp); - - figure(2); - clf; - subplot(211) - plot(10*log10(abs(h))) - subplot(212) - plot(angle(h)) - -endfunction - diff --git a/codec2/octave/cbphase.m b/codec2/octave/cbphase.m deleted file mode 100644 index 8e82da1c..00000000 --- a/codec2/octave/cbphase.m +++ /dev/null @@ -1,98 +0,0 @@ -% cbphase.m -% David Rowe Aug 2012 -% Used to experiment with critical band phase perception and smoothing - -function cbphase - - Wo = 100.0*pi/4000; - L = floor(pi/Wo); - - A = zeros(1,L); - phi = zeros(1,L); - - % three harmonics in this band - - b = 4; a = b-1; c = b+1; - - % set up phases and mags for 2nd order system (see phasesecord.m) - - wres = b*Wo; - phi(a) = 3*pi/4 + wres; - phi(b) = pi/2 + wres; - phi(c) = pi/4 + wres; - - A(a) = 0.707; - A(b) = 1; - A(c) = 0.707; - - % add linear component - - phi(1) = pi; - phi(2:L) = phi(2:L) + (2:L)*phi(1); - phi = phi - 2*pi*(floor(phi/(2*pi)) + 0.5); - - N = 16000; - Nplot = 250; - s = zeros(1,N); - - for m=a:c - s_m = A(m)*cos(m*Wo*(0:(N-1)) + phi(m)); - s = s + s_m; - endfor - - figure(2); - clf; - subplot(211) - plot((1:L)*Wo*4000/pi, A,'+'); - subplot(212) - plot((1:L)*Wo*4000/pi, phi,'+'); - - %v = A(a)*exp(j*phi(a)) + A(b)*exp(j*phi(b)) + A(c)*exp(j*phi(c)); - %compass(v,"r") - %hold off; - - % est phi1 - - diff = phi(b) - phi(a) - sumi = sin(diff); - sumr = cos(diff); - diff = phi(c) - phi(b) - sumi += sin(diff); - sumr += cos(diff); - phi1_ = atan2(sumi, sumr) - s_v = cos(Wo*(0:(N-1)) + phi1_); - - figure(1); - clf; - subplot(211) - plot(s(1:Nplot)); - hold on; - plot(s_v(1:Nplot),"r"); - hold off; - - % build (hopefully) perceptually similar phase - - phi_(a) = a*phi1_; - phi_(b) = b*phi1_; - phi_(c) = c*phi1_; - - s_ = zeros(1,N); - - for m=a:c - s_m = A(m)*cos(m*Wo*(0:(N-1)) + phi_(m)); - s_ = s_ + s_m; - endfor - - subplot(212) - plot(s_(1:Nplot)); - - gain = 8000; - fs=fopen("orig_ph.raw","wb"); - fwrite(fs,gain*s,"short"); - fclose(fs); - fs=fopen("mod_ph.raw","wb"); - fwrite(fs,gain*s_,"short"); - fclose(fs); - -endfunction - diff --git a/codec2/octave/codec2_demo.m b/codec2/octave/codec2_demo.m deleted file mode 100644 index 6cd26970..00000000 --- a/codec2/octave/codec2_demo.m +++ /dev/null @@ -1,108 +0,0 @@ -% Copyright David Rowe 2012 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% -% codec2_demo.m - -% Designed as an educational tool to explain the operation of Codec 2 -% for conference and user group presentations on a projector. An -% alternative to static overhead slides. -% -% Derived from codec2/octave/plamp.m -% -% usage: -% octave:1> plamp("../src/hts2a",40) -% -% Then press: -% c - to cycle through the wavform being displayed on the figure -% n - next frame -% b - back one frame -% -% tip: hold down n or b to animate the display -% -% The text files used as input are generated using c2sim: -% -% /codec2/src$ c2sim ../raw/hts2a.raw --dump hts2a -% -% The Codec 2 README explains how to build c2sim with dump files -% enabled. - -function codec2_demo(samname, f) - - sn_name = strcat(samname,"_sn.txt"); - Sn = load(sn_name); - - sw_name = strcat(samname,"_sw.txt"); - Sw = load(sw_name); - - model_name = strcat(samname,"_model.txt"); - model = load(model_name); - - figure(1); - - k = ' '; - wf = "Sn"; - do - - if strcmp(wf,"Sn") - clf; - s = [ Sn(2*f-1,:) Sn(2*f,:) ]; - plot(s); - axis([1 length(s) -20000 20000]); - end - - if (strcmp(wf,"Sw")) - clf; - plot((0:255)*4000/256, Sw(f,:),";Sw;"); - end - - if strcmp(wf,"SwAm") - Wo = model(f,1); - L = model(f,2); - Am = model(f,3:(L+2)); - plot((0:255)*4000/256, Sw(f,:),";Sw;"); - hold on; - plot((1:L)*Wo*4000/pi, 20*log10(Am),"+;Am;r"); - axis([1 4000 -10 80]); - hold off; - end - - if strcmp(wf,"Am") - Wo = model(f,1); - L = model(f,2); - Am = model(f,3:(L+2)); - plot((1:L)*Wo*4000/pi, 20*log10(Am),"+;Am;r"); - axis([1 4000 -10 80]); - end - - % interactive menu - - printf("\rframe: %d menu: n-next b-back w-cycle window q-quit", f); - fflush(stdout); - k = kbhit(); - if (k == 'n') - f = f + 1; - end - if (k == 'b') - f = f - 1; - end - if (k == 'w') - if strcmp(wf,"Sn") - next_wf = "Sw"; - end - if strcmp(wf,"Sw") - next_wf = "SwAm"; - end - if strcmp(wf,"SwAm") - next_wf = "Am"; - end - if strcmp(wf,"Am") - next_wf = "Sn"; - end - wf = next_wf; - end - - until (k == 'q') - printf("\n"); - -endfunction diff --git a/codec2/octave/cspec.m b/codec2/octave/cspec.m deleted file mode 100644 index e0ca15b6..00000000 --- a/codec2/octave/cspec.m +++ /dev/null @@ -1,54 +0,0 @@ -% cspec.m -% David Rowe Aug 2012 -% Used to compare spectromgrams while experimenting with phase - -function cspec(s1,s2) - f1 = fopen(s1,"rb"); - s1 = fread(f1,Inf,"short"); - f2 = fopen(s2,"rb"); - s2 = fread(f2,Inf,"short"); - - Fs = 8000; - spec_win = 512; - - state = 's1'; - do - if strcmp(state,'s1') - spec(s1,Fs,spec_win); - %title(s1); - end - if strcmp(state,'s2') - spec(s2,Fs,spec_win); - %title(s2); - end - if strcmp(state,'diff') - spec(s1-s2,Fs,spec_win); - %title("difference"); - end - - printf("\rstate: %s space-toggle d-diff q-quit", state); - fflush(stdout); - k = kbhit(); - - if k == ' ' - if strcmp(state,"diff") - next_state = 's1'; - end - if strcmp(state,"s1") - next_state = 's2'; - end - if strcmp(state,'s2') - next_state = 's1'; - end - end - - if k == 'd' - next_state = 'diff'; - end - - state = next_state; - until (k == 'q') - - printf("\n"); - -endfunction diff --git a/codec2/octave/diff_codec.m b/codec2/octave/diff_codec.m deleted file mode 100644 index 2ad204ff..00000000 --- a/codec2/octave/diff_codec.m +++ /dev/null @@ -1,96 +0,0 @@ -% diff_codec.m -% -% Plots differences between two states in two runs of the codec, -% e.g. x86 and embedded. -% -% Copyright David Rowe 2013 -% -% This program is distributed under the terms of the GNU General Public License -% Version 2 - -function diff_codec(samname1, samname2, model1_prefix, model2_prefix) - - fs1=fopen(samname1,"rb"); - s1=fread(fs1,Inf,"short"); - fs2=fopen(samname2,"rb"); - s2=fread(fs2,Inf,"short"); - - st = 1; - en = length(s1); - - figure(1); - clf; - subplot(211); - l1 = strcat("r;",samname1,";"); - plot(s1(st:en), l1); - axis([1 en-st min(s1(st:en)) max(s1(st:en))]); - subplot(212); - l2 = strcat("r;",samname2,";"); - plot(s2(st:en),l2); - axis([1 en-st min(s1(st:en)) max(s1(st:en))]); - - figure(2) - plot(s1(st:en)-s2(st:en)); - max(s1(st:en)-s2(st:en)); - - model_name1 = strcat(model1_prefix,"_model.txt"); - model1 = load(model_name1); - model_name1q = strcat(model1_prefix,"_qmodel.txt"); - model1q = load(model_name1q); - - model_name2 = strcat(model2_prefix,"_model.txt"); - model2 = load(model_name2); - model_name2q = strcat(model2_prefix,"_qmodel.txt"); - model2q = load(model_name2q); - - Wo1 = model1(:,1); - L1 = model1(:,2); - Am1 = model1(:,3:82); - Wo1q = model1q(:,1); - L1q = model1q(:,2); - Am1q = model1q(:,3:82); - - Wo2 = model2(:,1); - L2 = model2(:,2); - Am2 = model2(:,3:82); - Wo2q = model2q(:,1); - L2q = model2q(:,2); - Am2q = model2q(:,3:82); - - figure(3) - subplot(211) - plot(Wo1) - title('Wo1'); - subplot(212) - plot(Wo1-Wo2) - figure(4) - subplot(211) - plot(Wo1q) - title('Wo1q'); - subplot(212) - plot(Wo1q-Wo2q) - - figure(5) - subplot(211) - plot(L1) - title('L1'); - subplot(212) - plot(L1-L2) - figure(6) - subplot(211) - plot(L1q) - title('L1q'); - subplot(212) - plot(L1q-L2q) - - figure(7) - l=length(L1q); - sm=zeros(1,l); - for f=1:l - %printf("f %d L1q %d L2q %d\n",f,L1q(f),L2q(f)); - sm(f) = sum(10*log10(Am1q(f,1:L1q(f))) - 10*log10(Am2q(f,1:L2q(f)))); - end - plot(sm) - title('Am1q - Am2q'); - -endfunction diff --git a/codec2/octave/fdmdv.m b/codec2/octave/fdmdv.m deleted file mode 100644 index f64fe895..00000000 --- a/codec2/octave/fdmdv.m +++ /dev/null @@ -1,1087 +0,0 @@ -% fdmdv.m -% -% Functions that implement a Frequency Divison Multiplexed Modem for -% Digital Voice (FDMDV) over HF channels. -% -% Copyright David Rowe 2012 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% - -% reqd to mak sure we get same random bits at mod and demod - -rand('state',1); -randn('state',1); - -% Constants - -global Fs = 8000; % sample rate in Hz -global T = 1/Fs; % sample period in seconds -global Rs; - Rs = 50; % symbol rate in Hz -global Nc; % number of carriers -if isempty(NumCarriers) - Nc = 14; -else - Nc = NumCarriers; -end -global Nb; - Nb = 2; % Bits/symbol for PSK modulation -global Rb; - Rb = Nc*Rs*Nb; % bit rate -global M = Fs/Rs; % oversampling factor -global Nsym = 6; % number of symbols to filter over -global Fsep; - Fsep = 75; % Separation between carriers (Hz) -global Fcentre = 1500; % Centre frequency, Nc/2 carriers below this, N/c carriers above (Hz) -global Nt = 5; % number of symbols we estimate timing over -global P = 4; % oversample factor used for rx symbol filtering -global Nfilter = Nsym*M; -global Nfiltertiming = M+Nfilter+M; -alpha = 0.5; -global snr_coeff; - snr_coeff = 0.9;% SNR est averaging filter coeff -global Nph; - Nph = 9; % number of symbols to estimate phase over - % must be odd number as we take centre symbol - -% root raised cosine (Root Nyquist) filter - -global gt_alpha5_root; -gt_alpha5_root = gen_rn_coeffs(alpha, T, Rs, Nsym, M); - -% Converts gray code to natural binary - -global m4_gray_to_binary = [ - bin2dec("00") - bin2dec("01") - bin2dec("11") - bin2dec("10") - ]; -global m8_gray_to_binary = [ - bin2dec("000") - bin2dec("001") - bin2dec("011") - bin2dec("010") - bin2dec("111") - bin2dec("110") - bin2dec("100") - bin2dec("101") - ]; - -% Convert natural binary to gray code - -global m4_binary_to_gray = [ - bin2dec("00") - bin2dec("01") - bin2dec("11") - bin2dec("10") - ]; - -global m8_binary_to_gray = [ - bin2dec("000") - bin2dec("001") - bin2dec("011") - bin2dec("010") - bin2dec("110") - bin2dec("111") - bin2dec("101") - bin2dec("100") - ]; - -% Functions ---------------------------------------------------- - - -% generate Nc+1 PSK symbols from vector of (1,Nc*Nb) input bits. The -% Nc+1 symbol is the +1 -1 +1 .... BPSK sync carrier - -function tx_symbols = bits_to_psk(prev_tx_symbols, tx_bits) - global Nc; - global Nb; - global pilot_bit; - global m4_gray_to_binary; - global m8_gray_to_binary; - - assert(length(tx_bits) == Nc*Nb, "Incorrect number of bits"); - - m = 2 .^ Nb; - assert((m == 4) || (m == 8)); - - for c=1:Nc - - % extract bits for this symbol - - bits_binary = tx_bits((c-1)*Nb+1:c*Nb); - bits_decimal = sum(bits_binary .* 2.^(Nb-1:-1:0)); - - % determine phase shift using gray code mapping - - if m == 4 - phase_shift = (2*pi/m)*m4_gray_to_binary(bits_decimal+1); - else - phase_shift = (2*pi/m)*m8_gray_to_binary(bits_decimal+1); - end - - % apply phase shift from previous symbol - - tx_symbols(c) = exp(j*phase_shift) * prev_tx_symbols(c); - end - - % +1 -1 +1 -1 BPSK sync carrier, once filtered becomes two spectral - % lines at +/- Rs/2 - - if pilot_bit - tx_symbols(Nc+1) = -prev_tx_symbols(Nc+1); - else - tx_symbols(Nc+1) = prev_tx_symbols(Nc+1); - end - if pilot_bit - pilot_bit = 0; - else - pilot_bit = 1; - end - -endfunction - - -% Given Nc*Nb bits construct M samples (1 symbol) of Nc filtered -% symbols streams - -function tx_baseband = tx_filter(tx_symbols) - global Nc; - global M; - global tx_filter_memory; - global Nfilter; - global gt_alpha5_root; - - tx_baseband = zeros(Nc+1,M); - - % tx filter each symbol, generate M filtered output samples for each symbol. - % Efficient polyphase filter techniques used as tx_filter_memory is sparse - - tx_filter_memory(:,Nfilter) = sqrt(2)/2*tx_symbols; - - for i=1:M - tx_baseband(:,i) = M*tx_filter_memory(:,M:M:Nfilter) * gt_alpha5_root(M-i+1:M:Nfilter)'; - end - tx_filter_memory(:,1:Nfilter-M) = tx_filter_memory(:,M+1:Nfilter); - tx_filter_memory(:,Nfilter-M+1:Nfilter) = zeros(Nc+1,M); - -endfunction - - -% Construct FDM signal by frequency shifting each filtered symbol -% stream. Returns complex signal so we can apply frequency offsets -% easily. - -function tx_fdm = fdm_upconvert(tx_filt) - global Fs; - global M; - global Nc; - global Fsep; - global phase_tx; - global freq; - - tx_fdm = zeros(1,M); - - % Nc/2 tones below centre freq - - for c=1:Nc/2 - for i=1:M - phase_tx(c) = phase_tx(c) * freq(c); - tx_fdm(i) = tx_fdm(i) + tx_filt(c,i)*phase_tx(c); - end - end - - % Nc/2 tones above centre freq - - for c=Nc/2+1:Nc - for i=1:M - phase_tx(c) = phase_tx(c) * freq(c); - tx_fdm(i) = tx_fdm(i) + tx_filt(c,i)*phase_tx(c); - end - end - - % add centre pilot tone - - c = Nc+1; - for i=1:M - phase_tx(c) = phase_tx(c) * freq(c); - pilot(i) = 2*tx_filt(c,i)*phase_tx(c); - tx_fdm(i) = tx_fdm(i) + pilot(i); - end - - % Scale such that total Carrier power C of real(tx_fdm) = Nc. This - % excludes the power of the pilot tone. - % We return the complex (single sided) signal to make frequency - % shifting for the purpose of testing easier - - tx_fdm = 2*tx_fdm; -endfunction - - -% Frequency shift each modem carrier down to Nc+1 baseband signals - -function rx_baseband = fdm_downconvert(rx_fdm, nin) - global Fs; - global M; - global Nc; - global Fsep; - global phase_rx; - global freq; - - rx_baseband = zeros(1,nin); - - % Nc/2 tones below centre freq - - for c=1:Nc/2 - for i=1:nin - phase_rx(c) = phase_rx(c) * freq(c); - rx_baseband(c,i) = rx_fdm(i)*phase_rx(c)'; - end - end - - % Nc/2 tones above centre freq - - for c=Nc/2+1:Nc - for i=1:nin - phase_rx(c) = phase_rx(c) * freq(c); - rx_baseband(c,i) = rx_fdm(i)*phase_rx(c)'; - end - end - - % Pilot - - c = Nc+1; - for i=1:nin - phase_rx(c) = phase_rx(c) * freq(c); - rx_baseband(c,i) = rx_fdm(i)*phase_rx(c)'; - end - -endfunction - - -% Receive filter each baseband signal at oversample rate P - -function rx_filt = rx_filter(rx_baseband, nin) - global Nc; - global M; - global P; - global rx_filter_memory; - global Nfilter; - global gt_alpha5_root; - global Fsep; - - rx_filt = zeros(Nc+1,nin*P/M); - - % rx filter each symbol, generate P filtered output samples for each symbol. - % Note we keep memory at rate M, it's just the filter output at rate P - - N=M/P; - j=1; - for i=1:N:nin - rx_filter_memory(:,Nfilter-N+1:Nfilter) = rx_baseband(:,i:i-1+N); - rx_filt(:,j) = rx_filter_memory * gt_alpha5_root'; - rx_filter_memory(:,1:Nfilter-N) = rx_filter_memory(:,1+N:Nfilter); - j+=1; - end -endfunction - - -% LPF and peak pick part of freq est, put in a function as we call it twice - -function [foff imax pilot_lpf S] = lpf_peak_pick(pilot_baseband, pilot_lpf, nin) - global M; - global Npilotlpf; - global Npilotcoeff; - global Fs; - global Mpilotfft; - global pilot_coeff; - - % LPF cutoff 200Hz, so we can handle max +/- 200 Hz freq offset - - pilot_lpf(1:Npilotlpf-nin) = pilot_lpf(nin+1:Npilotlpf); - j = 1; - for i = Npilotlpf-nin+1:Npilotlpf - pilot_lpf(i) = pilot_baseband(j:j+Npilotcoeff-1) * pilot_coeff'; - j++; - end - - % decimate to improve DFT resolution, window and DFT - - Mpilot = Fs/(2*200); % calc decimation rate given new sample rate is twice LPF freq - h = hanning(Npilotlpf); - s = pilot_lpf(1:Mpilot:Npilotlpf) .* h(1:Mpilot:Npilotlpf)'; - s = [s zeros(1,Mpilotfft-Npilotlpf/Mpilot)]; - S = fft(s, Mpilotfft); - - % peak pick and convert to Hz - - [imax ix] = max(S); - r = 2*200/Mpilotfft; % maps FFT bin to frequency in Hz - - if ix > Mpilotfft/2 - foff = (ix - Mpilotfft - 1)*r; - else - foff = (ix - 1)*r; - endif - -endfunction - - -% Estimate frequency offset of FDM signal using BPSK pilot. This is quite -% sensitive to pilot tone level wrt other carriers - -function [foff S1 S2] = rx_est_freq_offset(rx_fdm, pilot, pilot_prev, nin) - global M; - global Npilotbaseband; - global pilot_baseband1; - global pilot_baseband2; - global pilot_lpf1; - global pilot_lpf2; - - % down convert latest nin samples of pilot by multiplying by - % ideal BPSK pilot signal we have generated locally. This - % peak of the resulting signal is sensitive to the time shift between - % the received and local version of the pilot, so we do it twice at - % different time shifts and choose the maximum. - - pilot_baseband1(1:Npilotbaseband-nin) = pilot_baseband1(nin+1:Npilotbaseband); - pilot_baseband2(1:Npilotbaseband-nin) = pilot_baseband2(nin+1:Npilotbaseband); - for i=1:nin - pilot_baseband1(Npilotbaseband-nin+i) = rx_fdm(i) * conj(pilot(i)); - pilot_baseband2(Npilotbaseband-nin+i) = rx_fdm(i) * conj(pilot_prev(i)); - end - - [foff1 max1 pilot_lpf1 S1] = lpf_peak_pick(pilot_baseband1, pilot_lpf1, nin); - [foff2 max2 pilot_lpf2 S2] = lpf_peak_pick(pilot_baseband2, pilot_lpf2, nin); - - if max1 > max2 - foff = foff1; - else - foff = foff2; - end -endfunction - - -% Estimate optimum timing offset, re-filter receive symbols - -function [rx_symbols rx_timing env] = rx_est_timing(rx_filt, rx_baseband, nin) - global M; - global Nt; - global Nc; - global rx_filter_mem_timing; - global rx_baseband_mem_timing; - global P; - global Nfilter; - global Nfiltertiming; - global gt_alpha5_root; - - % nin adjust - % -------------------------------- - % 120 -1 (one less rate P sample) - % 160 0 (nominal) - % 200 1 (one more rate P sample) - - adjust = P - nin*P/M; - - % update buffer of Nt rate P filtered symbols - - rx_filter_mem_timing(:,1:(Nt-1)*P+adjust) = rx_filter_mem_timing(:,P+1-adjust:Nt*P); - rx_filter_mem_timing(:,(Nt-1)*P+1+adjust:Nt*P) = rx_filt(:,:); - - % sum envelopes of all carriers - - env = sum(abs(rx_filter_mem_timing(:,:))); % use all Nc+1 carriers for timing - %env = abs(rx_filter_mem_timing(Nc+1,:)); % just use BPSK pilot - [n m] = size(env); - - % The envelope has a frequency component at the symbol rate. The - % phase of this frequency component indicates the timing. So work out - % single DFT at frequency 2*pi/P - - x = env * exp(-j*2*pi*(0:m-1)/P)'; - - % map phase to estimated optimum timing instant at rate M - % the M/4 part was adjusted by experiment, I know not why.... - - rx_timing = angle(x)*M/(2*pi) + M/4; - if (rx_timing > M) - rx_timing -= M; - end - if (rx_timing < -M) - rx_timing += M; - end - - % rx_baseband_mem_timing contains M + Nfilter + M samples of the - % baseband signal at rate M this enables us to resample the filtered - % rx symbol with M sample precision once we have rx_timing - - rx_baseband_mem_timing(:,1:Nfiltertiming-nin) = rx_baseband_mem_timing(:,nin+1:Nfiltertiming); - rx_baseband_mem_timing(:,Nfiltertiming-nin+1:Nfiltertiming) = rx_baseband; - - % sample right in the middle of the timing estimator window, by filtering - % at rate M - - s = round(rx_timing) + M; - rx_symbols = rx_baseband_mem_timing(:,s+1:s+Nfilter) * gt_alpha5_root'; - -endfunction - - -% Experimental "feed forward" phase estimation function - estimates -% phase over a windows of Nph (e.g. Nph = 9) symbols. May not work -% well on HF channels but lets see. Has a phase ambiguity of m(pi/4) -% where m=0,1,2 which needs to be corrected outside of this function - -function [phase_offsets ferr] = rx_est_phase(rx_symbols) - global rx_symbols_mem; - global prev_phase_offsets; - global phase_amb; - global Nph; - global Nc; - - % keep record of Nph symbols - - rx_symbols_mem(:,1:Nph-1) = rx_symbols_mem(:,2:Nph); - rx_symbols_mem(:,Nph) = rx_symbols; - - % estimate and correct phase offset based of modulation stripped samples - - phase_offsets = zeros(Nc+1,1); - for c=1:Nc+1 - - % rotate QPSK constellation to a single point - mod_stripped = abs(rx_symbols_mem(c,:)) .* exp(j*4*angle(rx_symbols_mem(c,:))); - - % find average phase offset, which will be on -pi/4 .. pi/4 - sum_real = sum(real(mod_stripped)); - sum_imag = sum(imag(mod_stripped)); - phase_offsets(c) = atan2(sum_imag, sum_real)/4; - - % determine if phase has jumped from - -> + - if (prev_phase_offsets(c) < -pi/8) && (phase_offsets(c) > pi/8) - phase_amb(c) -= pi/2; - if (phase_amb(c) < -pi) - phase_amb(c) += 2*pi; - end - end - - % determine if phase has jumped from + -> - - if (prev_phase_offsets(c) > pi/8) && (phase_offsets(c) < -pi/8) - phase_amb(c) += pi/2; - if (phase_amb(c) > pi) - phase_amb(c) -= 2*pi; - end - end - end - - ferr = mean(phase_offsets - prev_phase_offsets); - prev_phase_offsets = phase_offsets; - -endfunction - - -% convert symbols back to an array of bits - -function [rx_bits sync_bit f_err phase_difference] = psk_to_bits(prev_rx_symbols, rx_symbols, modulation) - global Nc; - global Nb; - global m4_binary_to_gray; - global m8_binary_to_gray; - - m = 2 .^ Nb; - assert((m == 4) || (m == 8)); - - phase_difference = zeros(Nc+1,1); - phase_difference(1:Nc) = rx_symbols(1:Nc) .* conj(prev_rx_symbols(1:Nc)./(1E-6+abs(prev_rx_symbols(1:Nc)))); - - for c=1:Nc - - % determine index of constellation point received 0,1,...,m-1 - - index = floor(angle(phase_difference(c))*m/(2*pi) + 0.5); - - if index < 0 - index += m; - end - - % map to decimal version of bits encoded in symbol - - if m == 4 - bits_decimal = m4_binary_to_gray(index+1); - else - bits_decimal = m8_binary_to_gray(index+1); - end - - % convert back to an array of received bits - - for i=1:Nb - if bitand(bits_decimal, 2.^(Nb-i)) - rx_bits((c-1)*Nb+i) = 1; - else - rx_bits((c-1)*Nb+i) = 0; - end - end - - end - - assert(length(rx_bits) == Nc*Nb); - - % Extract DBPSK encoded Sync bit - - phase_difference(Nc+1,1) = rx_symbols(Nc+1) .* conj(prev_rx_symbols(Nc+1)./(1E-6+abs(prev_rx_symbols(Nc+1)))); - if (real(phase_difference(Nc+1)) < 0) - sync_bit = 1; - f_err = imag(phase_difference(Nc+1)); - else - sync_bit = 0; - f_err = -imag(phase_difference(Nc+1)); - end - - % extra pi/4 rotation as we need for snr_update and scatter diagram - - phase_difference *= exp(j*pi/4); - -endfunction - - -% given phase differences update estimates of signal and noise levels - -function [sig_est noise_est] = snr_update(sig_est, noise_est, phase_difference) - global snr_coeff; - global Nc; - - % mag of each symbol is distance from origin, this gives us a - % vector of mags, one for each carrier. - - s = abs(phase_difference); - - % signal mag estimate for each carrier is a smoothed version - % of instantaneous magntitude, this gives us a vector of smoothed - % mag estimates, one for each carrier. - - sig_est = snr_coeff*sig_est + (1 - snr_coeff)*s; - - %printf("s: %f sig_est: %f snr_coeff: %f\n", s(1), sig_est(1), snr_coeff); - - % noise mag estimate is distance of current symbol from average - % location of that symbol. We reflect all symbols into the first - % quadrant for convenience. - - refl_symbols = abs(real(phase_difference)) + j*abs(imag(phase_difference)); - n = abs(exp(j*pi/4)*sig_est - refl_symbols); - - % noise mag estimate for each carrier is a smoothed version of - % instantaneous noise mag, this gives us a vector of smoothed - % noise power estimates, one for each carrier. - - noise_est = snr_coeff*noise_est + (1 - snr_coeff)*n; - -endfunction - - -% calculate current sig estimate for eeach carrier - -function snr_dB = calc_snr(sig_est, noise_est) - global Rs; - - % find total signal power by summing power in all carriers - - S = sum(sig_est .^2); - SdB = 10*log10(S); - - % Average noise mag across all carriers and square to get an average - % noise power. This is an estimate of the noise power in Rs = 50Hz of - % BW (note for raised root cosine filters Rs is the noise BW of the - % filter) - - N50 = mean(noise_est).^2; - N50dB = 10*log10(N50); - - % Now multiply by (3000 Hz)/(50 Hz) to find the total noise power in - % 3000 Hz - - N3000dB = N50dB + 10*log10(3000/Rs); - - snr_dB = SdB - N3000dB; - -endfunction - - -% returns nbits from a repeating sequence of random data - -function bits = get_test_bits(nbits) - global Ntest_bits; % length of test sequence - global current_test_bit; - global test_bits; - - for i=1:nbits - bits(i) = test_bits(current_test_bit++); - %if (mod(i,2) == 0) - % bits(i) = 1; - %else - % bits(i) = 0; - %end - - if (current_test_bit > Ntest_bits) - current_test_bit = 1; - endif - end - -endfunction - - -% Accepts nbits from rx and attempts to sync with test_bits sequence. -% if sync OK measures bit errors - -function [sync bit_errors error_pattern] = put_test_bits(test_bits, rx_bits) - global Ntest_bits; % length of test sequence - global rx_test_bits_mem; - - % Append to our memory - - [m n] = size(rx_bits); - rx_test_bits_mem(1:Ntest_bits-n) = rx_test_bits_mem(n+1:Ntest_bits); - rx_test_bits_mem(Ntest_bits-n+1:Ntest_bits) = rx_bits; - - % see how many bit errors we get when checked against test sequence - - error_pattern = xor(test_bits,rx_test_bits_mem); - bit_errors = sum(error_pattern); - - % if less than a thresh we are aligned and in sync with test sequence - - ber = bit_errors/Ntest_bits; - - sync = 0; - if (ber < 0.2) - sync = 1; - endif -endfunction - - - -% Generate M samples of DBPSK pilot signal for Freq offset estimation - -function [pilot_fdm bit symbol filter_mem phase] = generate_pilot_fdm(bit, symbol, filter_mem, phase, freq) - global M; - global Nfilter; - global gt_alpha5_root; - - % +1 -1 +1 -1 DBPSK sync carrier, once filtered becomes two spectral - % lines at +/- Rs/2 - - if bit - symbol = -symbol; - else - symbol = symbol; - end - if bit - bit = 0; - else - bit = 1; - end - - % filter DPSK symbol to create M baseband samples - - filter_mem(Nfilter) = (sqrt(2)/2)*symbol; - for i=1:M - tx_baseband(i) = M*filter_mem(M:M:Nfilter) * gt_alpha5_root(M-i+1:M:Nfilter)'; - end - filter_mem(1:Nfilter-M) = filter_mem(M+1:Nfilter); - filter_mem(Nfilter-M+1:Nfilter) = zeros(1,M); - - % upconvert - - for i=1:M - phase = phase * freq; - pilot_fdm(i) = sqrt(2)*2*tx_baseband(i)*phase; - end - -endfunction - - -% Generate a 4M sample vector of DBPSK pilot signal. As the pilot signal -% is periodic in 4M samples we can then use this vector as a look up table -% for pilot signal generation in the demod. - -function pilot_lut = generate_pilot_lut() - global Nc; - global Nfilter; - global M; - global freq; - - % pilot states - - pilot_rx_bit = 0; - pilot_symbol = sqrt(2); - pilot_freq = freq(Nc+1); - pilot_phase = 1; - pilot_filter_mem = zeros(1, Nfilter); - %prev_pilot = zeros(M,1); - - pilot_lut = []; - - F=8; - - for f=1:F - [pilot pilot_rx_bit pilot_symbol pilot_filter_mem pilot_phase] = generate_pilot_fdm(pilot_rx_bit, pilot_symbol, pilot_filter_mem, pilot_phase, pilot_freq); - %prev_pilot = pilot; - pilot_lut = [pilot_lut pilot]; - end - - % discard first 4 symbols as filter memory is filling, just keep last - % four symbols - - pilot_lut = pilot_lut(4*M+1:M*F); - -endfunction - - -% grab next pilot samples for freq offset estimation at demod - -function [pilot prev_pilot pilot_lut_index prev_pilot_lut_index] = get_pilot(pilot_lut_index, prev_pilot_lut_index, nin) - global M; - global pilot_lut; - - for i=1:nin - pilot(i) = pilot_lut(pilot_lut_index); - pilot_lut_index++; - if pilot_lut_index > 4*M - pilot_lut_index = 1; - end - prev_pilot(i) = pilot_lut(prev_pilot_lut_index); - prev_pilot_lut_index++; - if prev_pilot_lut_index > 4*M - prev_pilot_lut_index = 1; - end - end -endfunction - - - -% Change the sample rate by a small amount, for example 1000ppm (ratio -% = 1.001). Always returns nout samples in buf_out, but uses a -% variable number of input samples nin to accomodate the change in -% sample rate. nin is nominally set to nout, but may use nout +/- 2 -% samples to accomodate the different sample rates. buf_in should be -% of length nout+6 samples to accomodate this, and buf_in should be -% updated externally based on the nin returned each time. "ratio" is -% Fs_in/Fs_out, for example 48048/48000 = 1.001 (+1000ppm) or -% 47952/48000 = 0.999 (-1000ppm). Uses linear interpolation to -% perform the resampling. This requires a highly over-sampled signal, -% for example 48000Hz sample rate for the modem signal centred on -% 1kHz, otherwise linear interpolation will have a low pass filter effect -% (for example an 8000Hz sample rate for modem signal centred on 1kHz -% would cause problems). - -function [buf_out t nin] = resample(buf_in, t, ratio, nout) - - for i=1:nout - c = floor(t); - a = t - c; - b = 1 - a; - buf_out(i) = buf_in(c)*b + buf_in(c+1)*a; - t += ratio; - end - - t -= nout; - - % adjust nin and t so that on next call we start with 3 < t < 4, - % this gives us +/- 2 samples room to move before we hit start or - % end of buf_in - - delta = floor(t - 3); - nin = nout + delta; - t -= delta; - -endfunction - - -% freq offset state machine. Moves between acquire and track states based -% on BPSK pilot sequence. Freq offset estimator occasionally makes mistakes -% when used continuously. So we use it until we have acquired the BPSK pilot, -% then switch to a more robust tracking algorithm. If we lose sync we switch -% back to acquire mode for fast-requisition. - -function [entered_track track state bad_sync] = freq_state(sync_bit, state, bad_sync) - - entered_track = 0; - - % acquire state, look for 6 symbol 010101 sequence from sync bit - - next_state = state; - if state == 0 - if sync_bit == 0 - next_state = 1; - end - end - if state == 1 - if sync_bit == 1 - next_state = 2; - else - next_state = 0; - end - end - if state == 2 - if sync_bit == 0 - next_state = 3; - else - next_state = 0; - end - end - if state == 3 - if sync_bit == 1 - next_state = 4; - else - next_state = 0; - end - end - if state == 4 - if sync_bit == 0 - next_state = 5; - else - next_state = 0; - end - end - if state == 5 - if sync_bit == 1 - entered_track = 1; - next_state = 6; - bad_sync = 0; - else - next_state = 0; - end - end - - % states 6 and above are track mode, make sure we keep getting 0101 sync bit sequence - - if state == 6 - next_state = 7; - if sync_bit == 0 - bad_sync = 0; - else - bad_sync++; - if bad_sync > 2 - next_state = 0; - end - end - end - - if state == 7 - next_state = 6; - if sync_bit == 1 - bad_sync = 0; - else - bad_sync++; - if bad_sync > 2 - next_state = 0; - end - end - end - - %printf("state: %d next_state: %d sync_bit: %d bad_sync: %d\n", state, next_state, sync_bit, bad_sync); - - state = next_state; - if state >= 6 - track = 1; - else - track = 0; - end -endfunction - - -% Save test bits to a text file in the form of a C array - -function test_bits_file(filename) - global test_bits; - global Ntest_bits; - - f=fopen(filename,"wt"); - fprintf(f,"/* Generated by test_bits_file() Octave function */\n\n"); - fprintf(f,"const int test_bits[]={\n"); - for m=1:Ntest_bits-1 - fprintf(f," %d,\n",test_bits(m)); - endfor - fprintf(f," %d\n};\n",test_bits(Ntest_bits)); - fclose(f); -endfunction - - -% Saves RN filter coeffs to a text file in the form of a C array - -function rn_file(filename) - global gt_alpha5_root; - global Nfilter; - - f=fopen(filename,"wt"); - fprintf(f,"/* Generated by rn_file() Octave function */\n\n"); - fprintf(f,"const float gt_alpha5_root[]={\n"); - for m=1:Nfilter-1 - fprintf(f," %g,\n",gt_alpha5_root(m)); - endfor - fprintf(f," %g\n};\n",gt_alpha5_root(Nfilter)); - fclose(f); -endfunction - -function pilot_coeff_file(filename) - global pilot_coeff; - global Npilotcoeff; - - f=fopen(filename,"wt"); - fprintf(f,"/* Generated by pilot_coeff_file() Octave function */\n\n"); - fprintf(f,"const float pilot_coeff[]={\n"); - for m=1:Npilotcoeff-1 - fprintf(f," %g,\n",pilot_coeff(m)); - endfor - fprintf(f," %g\n};\n",pilot_coeff(Npilotcoeff)); - fclose(f); -endfunction - - -% Saves hanning window coeffs to a text file in the form of a C array - -function hanning_file(filename) - global Npilotlpf; - - h = hanning(Npilotlpf); - - f=fopen(filename,"wt"); - fprintf(f,"/* Generated by hanning_file() Octave function */\n\n"); - fprintf(f,"const float hanning[]={\n"); - for m=1:Npilotlpf-1 - fprintf(f," %g,\n", h(m)); - endfor - fprintf(f," %g\n};\n", h(Npilotlpf)); - fclose(f); -endfunction - - -function png_file(fig, pngfilename) - figure(fig); - - pngname = sprintf("%s.png",pngfilename); - print(pngname, '-dpng', "-S500,500") - pngname = sprintf("%s_large.png",pngfilename); - print(pngname, '-dpng', "-S800,600") -endfunction - - -% dump rx_bits in hex - -function dump_bits(rx_bits) - - % pack into bytes, MSB first - - packed = zeros(1,floor(length(rx_bits)+7)/8); - bit = 7; byte = 1; - for i=1:length(rx_bits) - packed(byte) = bitor(packed(byte), bitshift(rx_bits(i),bit)); - bit--; - if (bit < 0) - bit = 7; - byte++; - end - end - - for i=1:length(packed) - printf("0x%02x ", packed(i)); - end - printf("\n"); - -endfunction - - -% Initialise ---------------------------------------------------- - -global pilot_bit; -pilot_bit = 0; % current value of pilot bit - -global tx_filter_memory; -tx_filter_memory = zeros(Nc+1, Nfilter); -global rx_filter_memory; -rx_filter_memory = zeros(Nc+1, Nfilter); - -% phasors used for up and down converters - -global freq; -freq = zeros(Nc+1,1); -for c=1:Nc/2 - carrier_freq = (-Nc/2 - 1 + c)*Fsep + Fcentre; - freq(c) = exp(j*2*pi*carrier_freq/Fs); -end -for c=Nc/2+1:Nc - carrier_freq = (-Nc/2 + c)*Fsep + Fcentre; - freq(c) = exp(j*2*pi*carrier_freq/Fs); -end - -freq(Nc+1) = exp(j*2*pi*Fcentre/Fs); - -% Spread initial FDM carrier phase out as far as possible. This -% helped PAPR for a few dB. We don't need to adjust rx phase as DQPSK -% takes care of that. - -global phase_tx; -phase_tx = ones(Nc+1,1); -phase_tx = exp(j*2*pi*(0:Nc)/(Nc+1)); -%phase_tx = exp(j*2*pi*(0:Nc)/4); -%phase_tx(Nc+1) = -1; -global phase_rx; -phase_rx = ones(Nc+1,1); - -% Freq offset estimator constants - -global Mpilotfft = 256; -global Npilotcoeff = 30; % number of pilot LPF coeffs -global pilot_coeff = fir1(Npilotcoeff-1, 200/(Fs/2))'; % 200Hz LPF -global Npilotbaseband = Npilotcoeff + M + M/P; % number of pilot baseband samples reqd for pilot LPF -global Npilotlpf = 4*M; % number of samples we DFT pilot over, pilot est window - -% pilot LUT, used for copy of pilot at rx - -global pilot_lut; -pilot_lut = generate_pilot_lut(); -pilot_lut_index = 1; -prev_pilot_lut_index = 3*M+1; - -% Freq offset estimator states - -global pilot_baseband1; -global pilot_baseband2; -pilot_baseband1 = zeros(1, Npilotbaseband); % pilot baseband samples -pilot_baseband2 = zeros(1, Npilotbaseband); % pilot baseband samples -global pilot_lpf1 -global pilot_lpf2 -pilot_lpf1 = zeros(1, Npilotlpf); % LPF pilot samples -pilot_lpf2 = zeros(1, Npilotlpf); % LPF pilot samples - -% Timing estimator states - -global rx_filter_mem_timing; -rx_filter_mem_timing = zeros(Nc+1, Nt*P); -global rx_baseband_mem_timing; -rx_baseband_mem_timing = zeros(Nc+1, Nfiltertiming); - -% Test bit stream constants - -global Ntest_bits; - Ntest_bits = Nc*Nb*4; % length of test sequence -global test_bits; - test_bits = rand(1,Ntest_bits) > 0.5; - -% Test bit stream state variables - -global current_test_bit = 1; -current_test_bit = 1; -global rx_test_bits_mem; -rx_test_bits_mem = zeros(1,Ntest_bits); - -% Experimental phase estimator states ---------------------- - -global rx_symbols_mem; -rx_symbols_mem = zeros(Nc+1, Nph); -global prev_phase_offsets; -prev_phase_offsets = zeros(Nc+1, 1); -global phase_amb; -phase_amb = zeros(Nc+1, 1); diff --git a/codec2/octave/fdmdv_demod.m b/codec2/octave/fdmdv_demod.m deleted file mode 100644 index 2e403cc6..00000000 --- a/codec2/octave/fdmdv_demod.m +++ /dev/null @@ -1,350 +0,0 @@ -% fdmdv_demod.m -% -% Demodulator function for FDMDV modem (Octave version). Requires -% 8kHz sample rate raw files as input -% -% Copyright David Rowe 2012 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% - -function fdmdv_demod(rawfilename, nbits, NumCarriers, errorpatternfilename, symbolfilename) - - fdmdv; % include modem code - - modulation = 'dqpsk'; - - fin = fopen(rawfilename, "rb"); - gain = 1000; - frames = nbits/(Nc*Nb); - - prev_rx_symbols = ones(Nc+1,1); - foff_phase = 1; - - % BER stats - - total_bit_errors = 0; - total_bits = 0; - bit_errors_log = []; - sync_log = []; - test_frame_sync_log = []; - test_frame_sync_state = 0; - error_pattern_log = []; - - % SNR states - - sig_est = zeros(Nc+1,1); - noise_est = zeros(Nc+1,1); - - % logs of various states for plotting - - rx_symbols_log = []; - rx_timing_log = []; - foff_log = []; - rx_fdm_log = []; - snr_est_log = []; - - % misc states - - nin = M; % timing correction for sample rate differences - foff = 0; - track_log = []; - track = 0; - fest_state = 0; - bad_sync = 0; - sync_track = 0; - entered_track_log = []; - - % spectrum states - - Nspec=1024; - spec_mem=zeros(1,Nspec); - SdB = zeros(1,Nspec); - - % optionally save output symbols - - if nargin == 5 - fm = fopen(symbolfilename,"wb"); - dual_rx_symbols = zeros(1, 2*Nc); - dual_rx_bits = zeros(1,2*Nc*Nb); - end - - % Main loop ---------------------------------------------------- - - for f=1:frames - - % obtain nin samples of the test input signal - - for i=1:nin - rx_fdm(i) = fread(fin, 1, "short")/gain; - end - - rx_fdm_log = [rx_fdm_log rx_fdm(1:nin)]; - - % update spectrum - - l=length(rx_fdm); - spec_mem(1:Nspec-l) = spec_mem(l+1:Nspec); - spec_mem(Nspec-l+1:Nspec) = rx_fdm; - S=fft(spec_mem.*hanning(Nspec)',Nspec); - SdB = 0.9*SdB + 0.1*20*log10(abs(S)); - - % frequency offset estimation and correction - - [pilot prev_pilot pilot_lut_index prev_pilot_lut_index] = get_pilot(pilot_lut_index, prev_pilot_lut_index, nin); - [foff_coarse S1 S2] = rx_est_freq_offset(rx_fdm, pilot, prev_pilot, nin); - - if track == 0 - foff = foff_coarse = 0; - end - foff_log = [ foff_log foff ]; - foff_rect = exp(j*2*pi*foff/Fs); - - for i=1:nin - foff_phase *= foff_rect'; - rx_fdm(i) = rx_fdm(i)*foff_phase; - end - - % baseband processing - - rx_baseband = fdm_downconvert(rx_fdm, nin); - rx_filt = rx_filter(rx_baseband, nin); - - [rx_symbols rx_timing] = rx_est_timing(rx_filt, rx_baseband, nin); - - rx_timing_log = [rx_timing_log rx_timing]; - nin = M; - if rx_timing > 2*M/P - nin += M/P; - end - if rx_timing < 0; - nin -= M/P; - end - - if strcmp(modulation,'dqpsk') - rx_symbols_log = [rx_symbols_log rx_symbols.*conj(prev_rx_symbols./abs(prev_rx_symbols))*exp(j*pi/4)]; - else - rx_symbols_log = [rx_symbols_log rx_symbols]; - endif - [rx_bits sync f_err pd] = psk_to_bits(prev_rx_symbols, rx_symbols, modulation); - - % optionally save output symbols - - if (nargin == 5) - - % this free runs, and is reset by an "entered sync" state - - if (sync_track == 0) - sync_track = 1; - else - sync_track = 0; - end - - if (track == 1) && (sync_track == 1) - dual_rx_symbols(Nc+1:2*Nc) = rx_symbols(1:Nc).*conj(prev_rx_symbols(1:Nc)./abs(prev_rx_symbols(1:Nc))); - dual_rx_symbols_float32 = []; k = 1; - for i=1:2*Nc - dual_rx_symbols_float32(k++) = real(dual_rx_symbols(i)); - dual_rx_symbols_float32(k++) = imag(dual_rx_symbols(i)); - end - fwrite(fm, dual_rx_symbols_float32, "float32"); - dual_rx_bits(Nc*Nb+1:2*Nc*Nb) = rx_bits; - %dump_bits(dual_rx_bits); - else - dual_rx_symbols(1:Nc) = rx_symbols(1:Nc).*conj(prev_rx_symbols(1:Nc)./abs(prev_rx_symbols(1:Nc))); - dual_rx_bits(1:Nc*Nb) = rx_bits; - end - end - - % update some states - - [sig_est noise_est] = snr_update(sig_est, noise_est, pd); - snr_est = calc_snr(sig_est, noise_est); - snr_est_log = [snr_est_log snr_est]; - foff -= 0.5*f_err; - prev_rx_symbols = rx_symbols; - sync_log = [sync_log sync]; - - % freq est state machine - - [entered_track track fest_state bad_sync] = freq_state(sync, fest_state, bad_sync); - track_log = [track_log track]; - if (entered_track == 1) - sync_track = 1; - end - entered_track_log = [entered_track_log entered_track]; - - % count bit errors if we find a test frame - - [test_frame_sync bit_errors error_pattern] = put_test_bits(test_bits, rx_bits); - if (test_frame_sync == 1) - total_bit_errors = total_bit_errors + bit_errors; - total_bits = total_bits + Ntest_bits; - bit_errors_log = [bit_errors_log bit_errors/Ntest_bits]; - else - bit_errors_log = [bit_errors_log 0]; - end - - % test frame sync state machine, just for more informative plots - - next_test_frame_sync_state = test_frame_sync_state; - if (test_frame_sync_state == 0) - if (test_frame_sync == 1) - next_test_frame_sync_state = 1; - test_frame_count = 0; - end - end - - if (test_frame_sync_state == 1) - % we only expect another test_frame_sync pulse every 4 symbols - test_frame_count++; - if (test_frame_count == 4) - test_frame_count = 0; - if ((test_frame_sync == 0)) - next_test_frame_sync_state = 0; - else - error_pattern_log = [error_pattern_log error_pattern]; - end - end - end - test_frame_sync_state = next_test_frame_sync_state; - test_frame_sync_log = [test_frame_sync_log test_frame_sync_state]; - end - - if nargin == 5 - fclose(fm); - etfilename = strcat(strtok(symbolfilename,"."),"_et.bin"); - fet = fopen(etfilename, "wb"); - fwrite(fet, entered_track_log, "short"); - fclose(fet); - end - - % --------------------------------------------------------------------- - % Print Stats - % --------------------------------------------------------------------- - - % Peak to Average Power Ratio calcs from http://www.dsplog.com - - papr = max(rx_fdm_log.*conj(rx_fdm_log)) / mean(rx_fdm_log.*conj(rx_fdm_log)); - papr_dB = 10*log10(papr); - - ber = total_bit_errors / total_bits; - printf("%d bits %d errors BER: %1.4f PAPR(rx): %1.2f dB\n",total_bits, total_bit_errors, ber, papr_dB); - - % --------------------------------------------------------------------- - % Plots - % --------------------------------------------------------------------- - - xt = (1:frames)/Rs; - secs = frames/Rs; - - figure(1) - clf; - [n m] = size(rx_symbols_log); - plot(real(rx_symbols_log(1:Nc+1,15:m)),imag(rx_symbols_log(1:Nc+1,15:m)),'+') - axis([-2 2 -2 2]); - title('Scatter Diagram'); - - figure(2) - clf; - subplot(211) - plot(xt, rx_timing_log) - title('timing offset (samples)'); - subplot(212) - plot(xt, foff_log, '-;freq offset;') - hold on; - plot(xt, track_log*75, 'r;course-fine;'); - hold off; - title('Freq offset (Hz)'); - grid - - figure(3) - clf; - spec(rx_fdm_log,8000); - - figure(4) - clf; - subplot(311) - stem(xt, sync_log) - axis([0 secs 0 1.5]); - title('BPSK Sync') - subplot(312) - stem(xt, bit_errors_log); - title('Bit Errors for test frames') - subplot(313) - plot(xt, test_frame_sync_log); - axis([0 secs 0 1.5]); - title('Test Frame Sync') - - figure(5) - clf; - subplot(211); - plot(xt, snr_est_log); - title('SNR Estimates') - subplot(212) - snrdB_pc = 20*log10(sig_est(1:Nc+1)) - 20*log10(noise_est(1:Nc+1)); - bar(snrdB_pc(1:Nc) - mean(snrdB_pc(1:Nc))) - axis([0 Nc+1 -3 3]); - - figure(6) - clf; - hold on; - lep = length(error_pattern_log); - if lep != 0 - for p=1:Nc - plot(p + 0.25*error_pattern_log((p-1)*2+1:Nc*Nb:lep)); - plot(0.30 + p + 0.25*error_pattern_log(p*2:Nc*Nb:lep),'r') - end - hold off; - axis([1 lep/(Nc*Nb) 0 Nc]) - end - - figure(7) - clf; - subplot(211) - [a b] = size(rx_fdm_log); - xt1 = (1:b)/Fs; - plot(xt1, rx_fdm_log); - title('Rx FDM Signal'); - subplot(212) - plot((0:Nspec/2-1)*Fs/Nspec, SdB(1:Nspec/2) - 20*log10(Nspec/2)) - axis([0 Fs/2 -40 0]) - grid - title('FDM Rx Spectrum'); - -if 0 - % interleaving tests - - load ../unittest/inter560.txt - lep = length(error_pattern_log); - lep = floor(lep/560)*560; - error_pattern_log_inter = zeros(1,lep); - for i=1:560:lep - for j=1:560 - %printf("i: %4d j: %4d inter560(j): %4d\n", i,j,inter560(j)); - index = inter560(j); - error_pattern_log_inter(i-1+index+1) = error_pattern_log(i-1+j); - end - end - - figure(8) - clf; - hold on; - for p=1:Nc - plot(p + 0.25*error_pattern_log_inter((p-1)*2+1:Nc*Nb:lep)); - plot(0.30 + p + 0.25*error_pattern_log_inter(p*2:Nc*Nb:lep),'r') - end - hold off; - axis([1 lep/(Nc*Nb) 0 Nc]) -end - - % optionally save error pattern file - - if nargin == 4 - fout = fopen(errorpatternfilename, "wb"); - fwrite(fout, error_pattern_log, "short"); - fclose(fout); - end - - -endfunction diff --git a/codec2/octave/fdmdv_demod_c.m b/codec2/octave/fdmdv_demod_c.m deleted file mode 100644 index c2813e62..00000000 --- a/codec2/octave/fdmdv_demod_c.m +++ /dev/null @@ -1,129 +0,0 @@ -% fdmdv_demod_c.m -% -% Plots Octave dump file information from C FDMDV demodulator program, -% to give a similar set of plots to fdmdv_demod.m. Useful for off -% line analysis of demod performance. -% -% Copyright David Rowe 2012 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% - -function fdmdv_demod_c(dumpfilename, bits) - - fdmdv; % include modem code - - frames = bits/(Nc*Nb); - - load(dumpfilename); - - % BER stats - - total_bit_errors = 0; - total_bits = 0; - bit_errors_log = []; - sync_log = []; - test_frame_sync_log = []; - test_frame_sync_state = 0; - - % Run thru received bits to look for test pattern - - bits_per_frame = Nc*Nb; - - for f=1:frames - - rx_bits = rx_bits_log_c((f-1)*bits_per_frame+1:f*bits_per_frame); - - % count bit errors if we find a test frame - - [test_frame_sync bit_errors] = put_test_bits(test_bits, rx_bits); - if (test_frame_sync == 1) - total_bit_errors = total_bit_errors + bit_errors; - total_bits = total_bits + Ntest_bits; - bit_errors_log = [bit_errors_log bit_errors/Ntest_bits]; - else - bit_errors_log = [bit_errors_log 0]; - end - - % test frame sync state machine, just for more informative plots - - next_test_frame_sync_state = test_frame_sync_state; - if (test_frame_sync_state == 0) - if (test_frame_sync == 1) - next_test_frame_sync_state = 1; - test_frame_count = 0; - end - end - - if (test_frame_sync_state == 1) - % we only expect another test_frame_sync pulse every 4 symbols - test_frame_count++; - if (test_frame_count == 4) - test_frame_count = 0; - if ((test_frame_sync == 0)) - next_test_frame_sync_state = 0; - end - end - end - test_frame_sync_state = next_test_frame_sync_state; - test_frame_sync_log = [test_frame_sync_log test_frame_sync_state]; - end - - % --------------------------------------------------------------------- - % Plots - % --------------------------------------------------------------------- - - xt = (1:frames)/Rs; - secs = frames/Rs; - - figure(1) - clf; - plot(real(rx_symbols_log_c(1:Nc+1,15:frames)),imag(rx_symbols_log_c(1:Nc+1,15:frames)),'+') - %plot(real(rx_symbols_log_c(Nc+1,15:frames)),imag(rx_symbols_log_c(Nc+1,15:frames)),'+') - axis([-2 2 -2 2]); - title('Scatter Diagram'); - - figure(2) - clf; - subplot(211) - plot(xt, rx_timing_log_c(1:frames)) - title('timing offset (samples)'); - subplot(212) - plot(xt, foff_log_c(1:frames), '-;freq offset;') - hold on; - plot(xt, coarse_fine_log_c(1:frames)*75, 'r;course-fine;'); - hold off; - title('Freq offset (Hz)'); - grid - - figure(3) - clf; - subplot(211) - b = M*frames; - xt1 = (1:b)/Fs; - plot(xt1, rx_fdm_log_c(1:b)); - title('Rx FDM Signal'); - subplot(212) - spec(rx_fdm_log_c(1:b),8000); - title('FDM Rx Spectrogram'); - - figure(4) - clf; - subplot(311) - stem(xt, sync_bit_log_c(1:frames)) - axis([0 secs 0 1.5]); - title('BPSK Sync') - subplot(312) - stem(xt, bit_errors_log); - title('Bit Errors for test frames') - subplot(313) - plot(xt, test_frame_sync_log); - axis([0 secs 0 1.5]); - title('Test Frame Sync') - - figure(5) - clf; - plot(xt, snr_est_log_c(1:frames)); - title('SNR Estimates') - -endfunction diff --git a/codec2/octave/fdmdv_demod_coh.m b/codec2/octave/fdmdv_demod_coh.m deleted file mode 100644 index 94b08802..00000000 --- a/codec2/octave/fdmdv_demod_coh.m +++ /dev/null @@ -1,253 +0,0 @@ -% fdmdv_demod_coh.m -% -% Demodulator function for FDMDV modem (Octave version). Requires -% 8kHz sample rate raw files as input. This version uses experimental -% psuedo coherent demodulation. -% -% Copyright David Rowe 2013 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% - -function fdmdv_demod_coh(rawfilename, nbits, pngname) - - fdmdv; % include modem code - - modulation = 'dqpsk'; - - fin = fopen(rawfilename, "rb"); - gain = 1000; - frames = nbits/(Nc*Nb); - - prev_rx_symbols = ones(Nc+1,1); - foff_phase = 1; - - % BER stats - - total_bit_errors = 0; - total_bits = 0; - bit_errors_log = []; - sync_log = []; - test_frame_sync_log = []; - test_frame_sync_state = 0; - - % SNR states - - sig_est = zeros(Nc+1,1); - noise_est = zeros(Nc+1,1); - - % logs of various states for plotting - - rx_symbols_log = []; - rx_timing_log = []; - foff_log = []; - rx_fdm_log = []; - snr_est_log = []; - - % misc states - - nin = M; % timing correction for sample rate differences - foff = 0; - track_log = []; - track = 0; - fest_state = 0; - - % psuedo coherent demod states - - rx_symbols_ph_log = []; - prev_rx_symbols_ph = ones(Nc+1,1); - rx_phase_offsets_log = []; - phase_amb_log = []; - - % Main loop ---------------------------------------------------- - - for f=1:frames - - % obtain nin samples of the test input signal - - for i=1:nin - rx_fdm(i) = fread(fin, 1, "short")/gain; - end - - rx_fdm_log = [rx_fdm_log rx_fdm(1:nin)]; - - % frequency offset estimation and correction - - [pilot prev_pilot pilot_lut_index prev_pilot_lut_index] = get_pilot(pilot_lut_index, prev_pilot_lut_index, nin); - [foff_coarse S1 S2] = rx_est_freq_offset(rx_fdm, pilot, prev_pilot, nin); - - if track == 0 - foff = foff_coarse; - end - foff_log = [ foff_log foff ]; - foff_rect = exp(j*2*pi*foff/Fs); - - for i=1:nin - foff_phase *= foff_rect'; - rx_fdm(i) = rx_fdm(i)*foff_phase; - end - - % baseband processing - - rx_baseband = fdm_downconvert(rx_fdm, nin); - rx_filt = rx_filter(rx_baseband, nin); - - [rx_symbols rx_timing] = rx_est_timing(rx_filt, rx_baseband, nin); - rx_timing_log = [rx_timing_log rx_timing]; - - nin = M; - if rx_timing > 2*M/P - nin += M/P; - end - if rx_timing < 0; - nin -= M/P; - end - - rx_symbols_log = [rx_symbols_log rx_symbols.*(conj(prev_rx_symbols)./abs(prev_rx_symbols))*exp(j*pi/4)]; - - % coherent phase offset estimation ------------------------------------ - - [rx_phase_offsets ferr] = rx_est_phase(rx_symbols); - rx_phase_offsets_log = [rx_phase_offsets_log rx_phase_offsets]; - phase_amb_log = [phase_amb_log phase_amb]; - rx_symbols_ph = rx_symbols_mem(:,floor(Nph/2)+1) .* exp(-j*(rx_phase_offsets + phase_amb)); - rx_symbols_ph_log = [rx_symbols_ph_log rx_symbols_ph .* exp(j*pi/4)]; - rx_symbols_ph = -1 + 2*(real(rx_symbols_ph .* exp(j*pi/4)) > 0) + j*(-1 + 2*(imag(rx_symbols_ph .* exp(j*pi/4)) > 0)); - - % Std differential (used for freq offset est and BPSK sync) and psuedo coherent detection ----------------------- - - [rx_bits_unused sync f_err pd ] = qpsk_to_bits(prev_rx_symbols, rx_symbols, modulation); - [rx_bits sync_unused ferr_unused pd_unused] = qpsk_to_bits(prev_rx_symbols_ph, rx_symbols_ph, 'dqpsk'); - - foff -= 0.5*f_err; - prev_rx_symbols = rx_symbols; - prev_rx_symbols_ph = rx_symbols_ph; - sync_log = [sync_log sync]; - - [sig_est noise_est] = snr_update(sig_est, noise_est, pd); - snr_est = calc_snr(sig_est, noise_est); - snr_est_log = [snr_est_log snr_est]; - - % freq est state machine - - [track fest_state] = freq_state(sync, fest_state); - track_log = [track_log track]; - - % count bit errors if we find a test frame - - [test_frame_sync bit_errors] = put_test_bits(test_bits, rx_bits); - if (test_frame_sync == 1) - total_bit_errors = total_bit_errors + bit_errors; - total_bits = total_bits + Ntest_bits; - bit_errors_log = [bit_errors_log bit_errors/Ntest_bits]; - else - bit_errors_log = [bit_errors_log 0]; - end - - % test frame sync state machine, just for more informative plots - - next_test_frame_sync_state = test_frame_sync_state; - if (test_frame_sync_state == 0) - if (test_frame_sync == 1) - next_test_frame_sync_state = 1; - test_frame_count = 0; - end - end - - if (test_frame_sync_state == 1) - % we only expect another test_frame_sync pulse every 4 symbols - test_frame_count++; - if (test_frame_count == 4) - test_frame_count = 0; - if ((test_frame_sync == 0)) - next_test_frame_sync_state = 0; - end - end - end - test_frame_sync_state = next_test_frame_sync_state; - test_frame_sync_log = [test_frame_sync_log test_frame_sync_state]; - - end - - % --------------------------------------------------------------------- - % Print Stats - % --------------------------------------------------------------------- - - ber = total_bit_errors / total_bits; - - printf("%d bits %d errors BER: %1.4f\n",total_bits, total_bit_errors, ber); - - % --------------------------------------------------------------------- - % Plots - % --------------------------------------------------------------------- - - xt = (1:frames)/Rs; - secs = frames/Rs; - - figure(1) - clf; - [n m] = size(rx_symbols_log); - plot(real(rx_symbols_log(1:Nc+1,15:m)),imag(rx_symbols_log(1:Nc+1,15:m)),'+') - axis([-2 2 -2 2]); - title('Scatter Diagram'); - - figure(2) - clf; - subplot(211) - plot(xt, rx_timing_log) - title('timing offset (samples)'); - subplot(212) - plot(xt, foff_log, '-;freq offset;') - hold on; - plot(xt, track_log*75, 'r;course-fine;'); - hold off; - title('Freq offset (Hz)'); - grid - - figure(3) - clf; - subplot(211) - [a b] = size(rx_fdm_log); - xt1 = (1:b)/Fs; - plot(xt1, rx_fdm_log); - title('Rx FDM Signal'); - subplot(212) - spec(rx_fdm_log,8000); - title('FDM Rx Spectrogram'); - - figure(4) - clf; - subplot(311) - stem(xt, sync_log) - axis([0 secs 0 1.5]); - title('BPSK Sync') - subplot(312) - stem(xt, bit_errors_log); - title('Bit Errors for test frames') - subplot(313) - plot(xt, test_frame_sync_log); - axis([0 secs 0 1.5]); - title('Test Frame Sync') - - figure(5) - clf; - plot(xt, snr_est_log); - title('SNR Estimates') - - figure(6) - clf; - [n m] = size(rx_symbols_ph_log); - plot(real(rx_symbols_ph_log(1:Nc+1,15:m)),imag(rx_symbols_ph_log(1:Nc+1,15:m)),'+') - %plot(real(rx_symbols_ph_log(2,15:m)),imag(rx_symbols_ph_log(2,15:m)),'+') - axis([-2 2 -2 2]); - title('Scatter Diagram - after phase correction'); - - figure(7) - clf; - subplot(211) - plot(rx_phase_offsets_log(1,:)) - subplot(212) - plot(phase_amb_log(1,:)) - title('Rx Phase Offset Est') - -endfunction diff --git a/codec2/octave/fdmdv_mod.m b/codec2/octave/fdmdv_mod.m deleted file mode 100644 index eed85a2b..00000000 --- a/codec2/octave/fdmdv_mod.m +++ /dev/null @@ -1,32 +0,0 @@ -% fdmdv_mod.m -% -% Modulator function for FDMDV modem, uses test frames as input and -% outputs a raw file of 16 bit shorts at a sample rate of 8 kHz. -% -% Copyright David Rowe 2012 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% - -function tx_fdm = fdmdv_mod(rawfilename, nbits) - - fdmdv; % include modem code - - frames = floor(nbits/(Nc*Nb)) - tx_fdm = []; - gain = 1000; % Scale up to 16 bit shorts - prev_tx_symbols = ones(Nc+1,1); - - for i=1:frames - tx_bits = get_test_bits(Nc*Nb); - tx_symbols = bits_to_qpsk(prev_tx_symbols, tx_bits,'dqpsk'); - prev_tx_symbols = tx_symbols; - tx_baseband = tx_filter(tx_symbols); - tx_fdm = [tx_fdm real(fdm_upconvert(tx_baseband))]; - end - - tx_fdm *= gain; - fout = fopen(rawfilename,"wb"); - fwrite(fout, tx_fdm, "short"); - fclose(fout); -endfunction diff --git a/codec2/octave/fdmdv_sweep.m b/codec2/octave/fdmdv_sweep.m deleted file mode 100644 index fd617431..00000000 --- a/codec2/octave/fdmdv_sweep.m +++ /dev/null @@ -1,30 +0,0 @@ -% fdmdv_sweep.m -% David Rowe Feb 2013 -% Produces a raw file that sweeps between 1000 and 2000 Hz to test freq -% response of transmitters. - -secs=10; -fmin=1000; -fmax=2000; -Fs=8000; -rms = 4200; % roughly RMS value of fdmdv signal -amp = sqrt(2)*rms; -nsamples=Fs*secs; -theta = 0; -s=zeros(1,nsamples); - -for i=1:nsamples - f(i) = fmin + i*(fmax-fmin)/nsamples; - w = 2*pi*f(i)/Fs; - theta += w; - theta -= 2*pi*floor(theta/(2*pi)); - s(i) = amp*cos(theta); -end - -figure(1) -clf -plot(s(1:100)); -fout = fopen("1k_2k_sweep.raw", "wb"); -fwrite(fout, s, "short"); -fclose(fout); - diff --git a/codec2/octave/fdmdv_ut.m b/codec2/octave/fdmdv_ut.m deleted file mode 100644 index 6021c77c..00000000 --- a/codec2/octave/fdmdv_ut.m +++ /dev/null @@ -1,346 +0,0 @@ -% fdmdv_ut.m -% -% Unit Test program for FDMDV modem. Useful for general development as it has -% both tx and rx sides, and basic AWGN channel simulation. -% -% Copyright David Rowe 2012 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% - -fdmdv; % load modem code - -% Simulation Parameters -------------------------------------- - -frames = 100; -EbNo_dB = 7.3; -Foff_hz = 0; -modulation = 'dqpsk'; -hpa_clip = 150; - -% ------------------------------------------------------------ - -tx_filt = zeros(Nc,M); -rx_symbols_log = []; -rx_phase_log = 0; -rx_timing_log = 0; -tx_pwr = 0; -noise_pwr = 0; -rx_fdm_log = []; -rx_baseband_log = []; -rx_bits_offset = zeros(Nc*Nb*2); -prev_tx_symbols = ones(Nc+1,1); -prev_rx_symbols = ones(Nc+1,1); -ferr = 0; -foff = 0; -foff_log = []; -tx_baseband_log = []; -tx_fdm_log = []; - -% BER stats - -total_bit_errors = 0; -total_bits = 0; -bit_errors_log = []; -sync_log = []; -test_frame_sync_log = []; -test_frame_sync_state = 0; - -% SNR estimation states - -sig_est = zeros(Nc+1,1); -noise_est = zeros(Nc+1,1); - -% fixed delay simuation - -Ndelay = M+20; -rx_fdm_delay = zeros(Ndelay,1); - -% --------------------------------------------------------------------- -% Eb/No calculations. We need to work out Eb/No for each FDM carrier. -% Total power is sum of power in all FDM carriers -% --------------------------------------------------------------------- - -C = 1; % power of each FDM carrier (energy/sample). Total Carrier power should = Nc*C = Nc -N = 1; % total noise power (energy/sample) of noise source across entire bandwidth - -% Eb = Carrier power * symbol time / (bits/symbol) -% = C *(1/Rs) / Nb -Eb_dB = 10*log10(C) - 10*log10(Rs) - 10*log10(Nb); - -No_dBHz = Eb_dB - EbNo_dB; - -% Noise power = Noise spectral density * bandwidth -% Noise power = Noise spectral density * Fs/2 for real signals -N_dB = No_dBHz + 10*log10(Fs/2); -Ngain_dB = N_dB - 10*log10(N); -Ngain = 10^(Ngain_dB/20); - -% C/No = Carrier Power/noise spectral density -% = power per carrier*number of carriers / noise spectral density -CNo_dB = 10*log10(C) + 10*log10(Nc) - No_dBHz; - -% SNR in equivalent 3000 Hz SSB channel - -B = 3000; -SNR = CNo_dB - 10*log10(B); - -% freq offset simulation states - -phase_offset = 1; -freq_offset = exp(j*2*pi*Foff_hz/Fs); -foff_phase = 1; -t = 0; -foff = 0; -fest_state = 0; -bad_sync = 0; -track = 0; -track_log = []; - -snr_log = []; - -Nspec=1024; -spec_mem=zeros(1,Nspec); -SdB = zeros(1,Nspec); - -% --------------------------------------------------------------------- -% Main loop -% --------------------------------------------------------------------- - -for f=1:frames - - % ------------------- - % Modulator - % ------------------- - - tx_bits = get_test_bits(Nc*Nb); - tx_symbols = bits_to_psk(prev_tx_symbols, tx_bits, modulation); - prev_tx_symbols = tx_symbols; - tx_baseband = tx_filter(tx_symbols); - tx_baseband_log = [tx_baseband_log tx_baseband]; - tx_fdm = fdm_upconvert(tx_baseband); - tx_pwr = 0.9*tx_pwr + 0.1*real(tx_fdm)*real(tx_fdm)'/(M); - - % ------------------- - % Channel simulation - % ------------------- - - % frequency offset - - %Foff_hz += 1/Rs; - Foff = Foff_hz; - for i=1:M - % Time varying freq offset - %Foff = Foff_hz + 100*sin(t*2*pi/(300*Fs)); - %t++; - freq_offset = exp(j*2*pi*Foff/Fs); - phase_offset *= freq_offset; - tx_fdm(i) = phase_offset*tx_fdm(i); - end - - tx_fdm = real(tx_fdm); - - % HPA non-linearity - - tx_fdm(find(abs(tx_fdm) > hpa_clip)) = hpa_clip; - tx_fdm_log = [tx_fdm_log tx_fdm]; - - rx_fdm = tx_fdm; - - % AWGN noise - - noise = Ngain*randn(1,M); - noise_pwr = 0.9*noise_pwr + 0.1*noise*noise'/M; - rx_fdm += noise; - rx_fdm_log = [rx_fdm_log rx_fdm]; - - % update spectrum - - l=length(rx_fdm); - spec_mem(1:Nspec-l) = spec_mem(l+1:Nspec); - spec_mem(Nspec-l+1:Nspec) = rx_fdm; - S=fft(spec_mem.*hanning(Nspec)',Nspec); - SdB = 0.9*SdB + 0.1*20*log10(abs(S)); - - % Delay - - rx_fdm_delay(1:Ndelay-M) = rx_fdm_delay(M+1:Ndelay); - rx_fdm_delay(Ndelay-M+1:Ndelay) = rx_fdm; - %rx_fdm_delay = rx_fdm; - - % ------------------- - % Demodulator - % ------------------- - - % frequency offset estimation and correction, need to call rx_est_freq_offset even in track - % mode to keep states updated - - [pilot prev_pilot pilot_lut_index prev_pilot_lut_index] = get_pilot(pilot_lut_index, prev_pilot_lut_index, M); - [foff_course S1 S2] = rx_est_freq_offset(rx_fdm_delay, pilot, prev_pilot, M); - if track == 0 - foff = foff_course; - end - foff_log = [ foff_log foff ]; - foff_rect = exp(j*2*pi*foff/Fs); - - for i=1:M - foff_phase *= foff_rect'; - rx_fdm_delay(i) = rx_fdm_delay(i)*foff_phase; - end - - % baseband processing - - rx_baseband = fdm_downconvert(rx_fdm_delay(1:M), M); - rx_baseband_log = [rx_baseband_log rx_baseband]; - rx_filt = rx_filter(rx_baseband, M); - - [rx_symbols rx_timing] = rx_est_timing(rx_filt, rx_baseband, M); - rx_timing_log = [rx_timing_log rx_timing]; - - %rx_phase = rx_est_phase(rx_symbols); - %rx_phase_log = [rx_phase_log rx_phase]; - %rx_symbols = rx_symbols*exp(j*rx_phase); - - [rx_bits sync foff_fine pd] = psk_to_bits(prev_rx_symbols, rx_symbols, modulation); - if strcmp(modulation,'dqpsk') - rx_symbols_log = [rx_symbols_log pd]; - else - rx_symbols_log = [rx_symbols_log rx_symbols]; - endif - foff -= 0.5*ferr; - prev_rx_symbols = rx_symbols; - sync_log = [sync_log sync]; - - % freq est state machine - - [track fest_state bad_sync] = freq_state(sync, fest_state, bad_sync); - track_log = [track_log track]; - - % Update SNR est - - [sig_est noise_est] = snr_update(sig_est, noise_est, pd); - snr_log = [snr_log calc_snr(sig_est, noise_est)]; - - % count bit errors if we find a test frame - % Allow 15 frames for filter memories to fill and time est to settle - - [test_frame_sync bit_errors] = put_test_bits(test_bits, rx_bits); - - if test_frame_sync == 1 - total_bit_errors = total_bit_errors + bit_errors; - total_bits = total_bits + Ntest_bits; - bit_errors_log = [bit_errors_log bit_errors]; - else - bit_errors_log = [bit_errors_log 0]; - end - - % test frame sync state machine, just for more informative plots - - next_test_frame_sync_state = test_frame_sync_state; - if (test_frame_sync_state == 0) - if (test_frame_sync == 1) - next_test_frame_sync_state = 1; - test_frame_count = 0; - end - end - - if (test_frame_sync_state == 1) - % we only expect another test_frame_sync pulse every 4 symbols - test_frame_count++; - if (test_frame_count == 4) - test_frame_count = 0; - if ((test_frame_sync == 0)) - next_test_frame_sync_state = 0; - end - end - end - test_frame_sync_state = next_test_frame_sync_state; - test_frame_sync_log = [test_frame_sync_log test_frame_sync_state]; -end - -% --------------------------------------------------------------------- -% Print Stats -% --------------------------------------------------------------------- - -ber = total_bit_errors / total_bits; - -% Peak to Average Power Ratio calcs from http://www.dsplog.com - -papr = max(tx_fdm_log.*conj(tx_fdm_log)) / mean(tx_fdm_log.*conj(tx_fdm_log)); -papr_dB = 10*log10(papr); - -% Note Eb/No set point is for Nc data carriers only, excluding pilot. -% This is convenient for testing BER versus Eb/No. Measured SNR & -% Eb/No includes power of pilot. Similar for SNR, first number is SNR -% excluding pilot pwr for Eb/No set point, 2nd value is measured SNR -% which will be a little higher as pilot power is included. Note current SNR -% est algorithm only works for QPSK, gives silly values for 8PSK. - -printf("Bits/symbol.: %d\n", Nb); -printf("Num carriers: %d\n", Nc); -printf("Bit Rate....: %d bits/s\n", Rb); -printf("Eb/No (meas): %2.2f (%2.2f) dB\n", EbNo_dB, 10*log10(0.25*tx_pwr*Fs/(Rs*Nc*noise_pwr))); -printf("bits........: %d\n", total_bits); -printf("errors......: %d\n", total_bit_errors); -printf("BER.........: %1.4f\n", ber); -printf("PAPR........: %1.2f dB\n", papr_dB); -printf("SNR...(meas): %2.2f (%2.2f) dB\n", SNR, calc_snr(sig_est, noise_est)); - -% --------------------------------------------------------------------- -% Plots -% --------------------------------------------------------------------- - -figure(1) -clf; -[n m] = size(rx_symbols_log); -plot(real(rx_symbols_log(1:Nc+1,15:m)),imag(rx_symbols_log(1:Nc+1,15:m)),'+') -axis([-3 3 -3 3]); -title('Scatter Diagram'); - -figure(2) -clf; -subplot(211) -plot(rx_timing_log) -title('timing offset (samples)'); -subplot(212) -plot(foff_log, '-;freq offset;') -hold on; -plot(track_log*75, 'r;course-fine;'); -hold off; -title('Freq offset (Hz)'); - -figure(3) -clf; -subplot(211) -plot(real(tx_fdm_log)); -title('FDM Tx Signal'); -subplot(212) -plot((0:Nspec/2-1)*Fs/Nspec, SdB(1:Nspec/2) - 20*log10(Nspec/2)) -axis([0 Fs/2 -40 0]) -grid -title('FDM Rx Spectrum'); - -figure(4) -clf; -subplot(311) -stem(sync_log) -axis([0 frames 0 1.5]); -title('BPSK Sync') -subplot(312) -stem(bit_errors_log); -title('Bit Errors for test frames') -subplot(313) -plot(test_frame_sync_log); -axis([0 frames 0 1.5]); -title('Test Frame Sync') - -figure(5) -clf -subplot(211) -plot(snr_log) -subplot(212) -%plot(20*log10(sig_est(1:Nc))-20*log10(sig_est(Nc+1))+6) -%axis([1 Nc -6 6]); -sdB_pc = 20*log10(sig_est(1:Nc+1)); -bar(sdB_pc(1:Nc) - mean(sdB_pc(1:Nc))) -axis([0 Nc+1 -3 3]); diff --git a/codec2/octave/fdmdv_ut_coh.m b/codec2/octave/fdmdv_ut_coh.m deleted file mode 100644 index a1598878..00000000 --- a/codec2/octave/fdmdv_ut_coh.m +++ /dev/null @@ -1,341 +0,0 @@ -% fdmdv_ut_coh.m -% - -% Unit Test program for coherent version of FDMDV modem. Used to -% build up the ability to test coherent demodulation of FDMDV -% signals sampled off air. These signals are differentially encoded -% but we can treat the symbols after the diff encoder as PSK symbols. -% -% We keep most of the existing DPSK modem to handle acquisition, frame sync, -% and just the the PSK demo in parallel. The goal here is to measure the BER -% of the test data using coherent PSK, it's not actually a practical modem. - -% Copyright David Rowe 2012 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% - -fdmdv; % load modem code - -% Simulation Parameters -------------------------------------- - -frames = 200; -EbNo_dB = 7; -Foff_hz = -100; -hpa_clip = 150; - -% ------------------------------------------------------------ - -tx_filt = zeros(Nc,M); -rx_symbols_log = []; -rx_phase_log = 0; -rx_timing_log = 0; -tx_pwr = 0; -noise_pwr = 0; -rx_fdm_log = []; -rx_baseband_log = []; -rx_bits_offset = zeros(Nc*Nb*2); -prev_tx_symbols = ones(Nc+1,1); -prev_rx_symbols = ones(Nc+1,1); -ferr = 0; -foff = 0; -foff_log = []; -tx_baseband_log = []; -tx_fdm_log = []; - -% BER stats - -total_bit_errors = 0; -total_bits = 0; -bit_errors_log = []; -sync_log = []; -test_frame_sync_log = []; -test_frame_sync_state = 0; - -% SNR estimation states - -sig_est = zeros(Nc+1,1); -noise_est = zeros(Nc+1,1); - -% fixed delay simuation - -Ndelay = M+20; -rx_fdm_delay = zeros(Ndelay,1); - -% --------------------------------------------------------------------- -% Eb/No calculations. We need to work out Eb/No for each FDM carrier. -% Total power is sum of power in all FDM carriers -% --------------------------------------------------------------------- - -C = 1; % power of each FDM carrier (energy/sample). Total Carrier power should = Nc*C = Nc -N = 1; % total noise power (energy/sample) of noise source across entire bandwidth - -% Eb = Carrier power * symbol time / (bits/symbol) -% = C *(1/Rs) / 2 -Eb_dB = 10*log10(C) - 10*log10(Rs) - 10*log10(2); - -No_dBHz = Eb_dB - EbNo_dB; - -% Noise power = Noise spectral density * bandwidth -% Noise power = Noise spectral density * Fs/2 for real signals -N_dB = No_dBHz + 10*log10(Fs/2); -Ngain_dB = N_dB - 10*log10(N); -Ngain = 10^(Ngain_dB/20); - -% C/No = Carrier Power/noise spectral density -% = power per carrier*number of carriers / noise spectral density -CNo_dB = 10*log10(C) + 10*log10(Nc) - No_dBHz; - -% SNR in equivalent 3000 Hz SSB channel - -B = 3000; -SNR = CNo_dB - 10*log10(B); - -% freq offset simulation states - -phase_offset = exp(j*0); -freq_offset = exp(j*2*pi*Foff_hz/Fs); -foff_phase = 1; -t = 0; -foff = 0; -fest_state = 0; -track = 0; -track_log = []; - -snr_log = []; - -rx_symbols_ph_log = []; -prev_rx_symbols_ph = ones(Nc+1,1); -rx_phase_offsets_log = []; -phase_amb_log = []; - -% --------------------------------------------------------------------- -% Main loop -% --------------------------------------------------------------------- - -for f=1:frames - - % ------------------- - % Modulator - % ------------------- - - tx_bits = get_test_bits(Nc*Nb); - tx_symbols = bits_to_qpsk(prev_tx_symbols, tx_bits, 'dqpsk'); - prev_tx_symbols = tx_symbols; - tx_baseband = tx_filter(tx_symbols); - tx_baseband_log = [tx_baseband_log tx_baseband]; - tx_fdm = fdm_upconvert(tx_baseband); - tx_pwr = 0.9*tx_pwr + 0.1*real(tx_fdm)*real(tx_fdm)'/(M); - - % ------------------- - % Channel simulation - % ------------------- - - % frequency offset - - %Foff_hz += 1/Rs; - Foff = Foff_hz; - for i=1:M - % Time varying freq offset - %Foff = Foff_hz + 100*sin(t*2*pi/(300*Fs)); - %t++; - freq_offset = exp(j*2*pi*Foff/Fs); - phase_offset *= freq_offset; - tx_fdm(i) = phase_offset*tx_fdm(i); - end - - tx_fdm = real(tx_fdm); - - % HPA non-linearity - - tx_fdm(find(abs(tx_fdm) > hpa_clip)) = hpa_clip; - tx_fdm_log = [tx_fdm_log tx_fdm]; - - rx_fdm = tx_fdm; - - % AWGN noise - - noise = Ngain*randn(1,M); - noise_pwr = 0.9*noise_pwr + 0.1*noise*noise'/M; - rx_fdm += noise; - rx_fdm_log = [rx_fdm_log rx_fdm]; - - % Delay - - %rx_fdm_delay(1:Ndelay-M) = rx_fdm_delay(M+1:Ndelay); - %rx_fdm_delay(Ndelay-M+1:Ndelay) = rx_fdm; - rx_fdm_delay = rx_fdm; - - % ------------------- - % Demodulator - % ------------------- - - % frequency offset estimation and correction, need to call - % rx_est_freq_offset even in track mode to keep states updated - - [pilot prev_pilot pilot_lut_index prev_pilot_lut_index] = get_pilot(pilot_lut_index, prev_pilot_lut_index, M); - [foff_course S1 S2] = rx_est_freq_offset(rx_fdm_delay, pilot, prev_pilot, M); - if track == 0 - foff = foff_course; - end - - %foff = 0; % disable for now - - foff_log = [ foff_log foff ]; - foff_rect = exp(j*2*pi*foff/Fs); - - for i=1:M - foff_phase *= foff_rect'; - rx_fdm_delay(i) = rx_fdm_delay(i)*foff_phase; - end - - % baseband processing - - rx_baseband = fdm_downconvert(rx_fdm_delay(1:M), M); - rx_baseband_log = [rx_baseband_log rx_baseband]; - rx_filt = rx_filter(rx_baseband, M); - - [rx_symbols rx_timing] = rx_est_timing(rx_filt, rx_baseband, M); - rx_symbols_log = [rx_symbols_log rx_symbols.*(conj(prev_rx_symbols)./abs(prev_rx_symbols))*exp(j*pi/4)]; - rx_timing_log = [rx_timing_log rx_timing]; - - % coherent phase offset estimation ------------------------------------ - - [rx_phase_offsets ferr] = rx_est_phase(rx_symbols); - rx_phase_offsets_log = [rx_phase_offsets_log rx_phase_offsets]; - phase_amb_log = [phase_amb_log phase_amb]; - rx_symbols_ph = rx_symbols_mem(:,floor(Nph/2)+1) .* exp(-j*(rx_phase_offsets + phase_amb)); - rx_symbols_ph_log = [rx_symbols_ph_log rx_symbols_ph .* exp(j*pi/4)]; - rx_symbols_ph = -1 + 2*(real(rx_symbols_ph .* exp(j*pi/4)) > 0) + j*(-1 + 2*(imag(rx_symbols_ph .* exp(j*pi/4)) > 0)); - - % Std differential (used for freq offset est and BPSK sync) and psuedo coherent detection ----------------------- - - [rx_bits_unused sync ferr pd] = qpsk_to_bits(prev_rx_symbols, rx_symbols, 'dqpsk'); - [rx_bits sync_unused ferr_unused pd] = qpsk_to_bits(prev_rx_symbols_ph, rx_symbols_ph, 'dqpsk'); - - %---------------------------------------------------------------------- - - foff -= 0.5*ferr; - prev_rx_symbols = rx_symbols; - prev_rx_symbols_ph = rx_symbols_ph; - sync_log = [sync_log sync]; - - % freq est state machine - - [track fest_state] = freq_state(sync, fest_state); - track_log = [track_log track]; - - % Update SNR est - - [sig_est noise_est] = snr_update(sig_est, noise_est, pd); - snr_log = [snr_log calc_snr(sig_est, noise_est)]; - - % count bit errors if we find a test frame - - [test_frame_sync bit_errors] = put_test_bits(test_bits, rx_bits); - - if (test_frame_sync == 1) && (f > 15) - total_bit_errors = total_bit_errors + bit_errors; - total_bits = total_bits + Ntest_bits; - bit_errors_log = [bit_errors_log bit_errors]; - else - bit_errors_log = [bit_errors_log 0]; - end - - % test frame sync state machine, just for more informative plots - - next_test_frame_sync_state = test_frame_sync_state; - if (test_frame_sync_state == 0) - if (test_frame_sync == 1) - next_test_frame_sync_state = 1; - test_frame_count = 0; - end - end - - if (test_frame_sync_state == 1) - % we only expect another test_frame_sync pulse every 4 symbols - test_frame_count++; - if (test_frame_count == 4) - test_frame_count = 0; - if ((test_frame_sync == 0)) - next_test_frame_sync_state = 0; - end - end - end - test_frame_sync_state = next_test_frame_sync_state; - test_frame_sync_log = [test_frame_sync_log test_frame_sync_state]; -end - -% --------------------------------------------------------------------- -% Print Stats -% --------------------------------------------------------------------- - -ber = total_bit_errors / total_bits; - -% Note Eb/No set point is for Nc data carriers only, excluding pilot. -% This is convenient for testing BER versus Eb/No. Measured Eb/No -% includes power of pilot. Similar for SNR, first number is SNR excluding -% pilot pwr for Eb/No set point, 2nd value is measured SNR which will be a little -% higher as pilot power is included. - -printf("\n"); -printf("Eb/No (meas): %2.2f (%2.2f) dB\n", EbNo_dB, 10*log10(0.25*tx_pwr*Fs/(Rs*Nc*noise_pwr))); -printf("SNR...(meas): %2.2f (%2.2f) dB\n", SNR, calc_snr(sig_est, noise_est)); -printf("\nDPSK\n"); -printf(" bits......: %d\n", total_bits); -printf(" errors....: %d\n", total_bit_errors); -printf(" BER.......: %1.4f\n", ber); - -% --------------------------------------------------------------------- -% Plots -% --------------------------------------------------------------------- - -figure(1) -clf; -[n m] = size(rx_symbols_log); -plot(real(rx_symbols_log(1:Nc+1,15:m)),imag(rx_symbols_log(1:Nc+1,15:m)),'+') -%plot(real(rx_symbols_log(2,15:m)),imag(rx_symbols_log(2,15:m)),'+') -axis([-3 3 -3 3]); -title('Scatter Diagram'); - -figure(2) -clf; -subplot(211) -plot(rx_timing_log) -title('timing offset (samples)'); -subplot(212) -plot(foff_log, '-;freq offset;') -hold on; -plot(track_log*75, 'r;course-fine;'); -hold off; -title('Freq offset (Hz)'); - -figure(3) -clf; -subplot(311) -stem(sync_log) -axis([0 frames 0 1.5]); -title('BPSK Sync') -subplot(312) -stem(bit_errors_log); -title('Bit Errors for test frames') -subplot(313) -plot(test_frame_sync_log); -axis([0 frames 0 1.5]); -title('Test Frame Sync') - -figure(4) -clf; -[n m] = size(rx_symbols_ph_log); -plot(real(rx_symbols_ph_log(1:Nc+1,15:m)),imag(rx_symbols_ph_log(1:Nc+1,15:m)),'+') -%plot(real(rx_symbols_ph_log(2,15:m)),imag(rx_symbols_ph_log(2,15:m)),'+') -axis([-3 3 -3 3]); -title('Scatter Diagram - after phase correction'); - -figure(5) -clf; -subplot(211) -plot(rx_phase_offsets_log(1,:)) -subplot(212) -plot(phase_amb_log(1,:)) -title('Rx Phase Offset Est') diff --git a/codec2/octave/fuzzy_gray.m b/codec2/octave/fuzzy_gray.m deleted file mode 100644 index 425f8d7c..00000000 --- a/codec2/octave/fuzzy_gray.m +++ /dev/null @@ -1,586 +0,0 @@ -% fuzzy_gray.m -% David Rowe -% 10 April 2014 -% -% Various experiments in fuzzy gray codes and quantising and -% transmitting scalars. - -1; - -% fuzzy gray coding idea: use an extra parity bit, if we get a single -% bit error the value will be "close: to the original, so effect of -% error will be soft. Unlike data we don't need 0 bit errors. I -% struggled to extend this to larger m. - -function three_bit_code - m=4; - log2_m=2; - value_to_codeword = ["000"; "001"; "101"; "111"]; - codeword_to_value = [0 1 1 2 1 2 2 3 3]; - - printf("tx_value tx_codeword rx_codeword rx_value distance\n"); - for i=1:m - tx_codeword = bin2dec(value_to_codeword(i,:)); - tx_codeword_bin = value_to_codeword(i,:); - rx_value = codeword_to_value(tx_codeword+1); - distance = abs((i-1) - rx_value); - printf("%8d %11s %11s %8d %8d\n", i-1, tx_codeword_bin, tx_codeword_bin, ... - rx_value, distance ); - end - printf("\n"); - for i=1:m - tx_codeword = bin2dec(value_to_codeword(i,:)); - tx_codeword_bin = value_to_codeword(i,:); - for j=1:(log2_m+1) - rx_codeword = bitxor(tx_codeword, bitset(0,j)); - rx_codeword_bin = dec2bin(rx_codeword, 3); - rx_value = codeword_to_value(rx_codeword+1); - distance = abs((i-1) - rx_value); - printf("%8d %11s %11s %8d %8d\n", i-1, tx_codeword_bin, rx_codeword_bin, ... - rx_value, distance ); - end - end -endfunction - -% regular natural binary quantiser - -function index = quantise_value(value, min_value, max_value, num_levels) - norm = (value - min_value)/(max_value - min_value); - index = floor(num_levels * norm + 0.5); - if (index < 0 ) - index = 0; - end - if (index > (num_levels-1)) - index = num_levels-1; - end -endfunction - -function value = unquantise_value(index, min_value, max_value, num_levels) - step = (max_value - min_value)/num_levels; - value = min_value + step*(index); -endfunction - -% converting natural binary to gray - -function gray = binary_to_gray(natural) - gray = bitxor(bitshift(natural,-1),natural); -endfunction - -function natural = gray_to_binary(gray) - for i=1:length(gray) - mask = bitshift(gray(i),-1); - num = gray(i); - while(mask) - num = bitxor(num, mask); - mask = bitshift(mask,-1); - end - natural(i) = num; - end -endfunction - -function sim_out = test_baseline_uncoded(Ebvec, Nbits, Ntrials, enable_error_log, enable_gray) - Nlevels = 2.^ Nbits; powersOfTwo = 2 .^ fliplr(0:(Nbits-1)); - Nsymb = Nbits; - - sim_out.qnoise_log = zeros(length(Ebvec),Ntrials); - sim_out.error_log = []; - - for ne = 1:length(Ebvec) - EbNodB = Ebvec(ne); - EbNo = 10^(EbNodB/10); - - variance = 1/EbNo; - - Terrs = 0; Tbits = 0; - qsignal = qnoise = 0; - - for nn = 1:Ntrials - - tx_value = rand(1,1); - tx_index = quantise_value(tx_value, 0, 1, Nlevels); - if enable_gray - tx_index = binary_to_gray(tx_index); - end - tx_bits = dec2bin(tx_index, Nbits) - '0'; - tx_symbols = -1 + 2*tx_bits; - - % AWGN noise and phase/freq offset channel simulation - % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im - - noise = sqrt(variance*0.5)*(randn(1,Nsymb) + j*randn(1,Nsymb)); - rx_symbols = tx_symbols + noise; - - rx_bits = rx_symbols > 0; - - error_positions = xor(rx_bits, tx_bits); - Nerrs = sum(error_positions); - Terrs += Nerrs; - Tbits += length(tx_bits); - if enable_error_log - sim_out.error_log = [sim_out.error_log error_positions]; - end - - rx_index = (powersOfTwo * rx_bits'); - if enable_gray - rx_index = gray_to_binary(rx_index); - end - rx_value = unquantise_value(rx_index, 0, 1, Nlevels); - - qsignal += tx_value*tx_value; - qnoise += (tx_value - rx_value) .^ 2; - sim_out.qnoise_log(ne,nn) = tx_value - rx_value; - end - - sim_out.TERvec(ne) = Terrs; - sim_out.BERvec(ne) = Terrs/Tbits; - sim_out.QSNRvec(ne) = 10*log10(qsignal/qnoise); - printf("EbNo (dB): %3.2f Terrs: %6d BER %1.4f QSNR (dB): %3.2f\n", - EbNodB, Terrs, Terrs/Tbits, 10*log10(qsignal/qnoise)); - end - -endfunction - -function sim_out = test_varpower(Ebvec, Nbits, Ntrials, amps, enable_error_log) - Nlevels = 2.^ Nbits; powersOfTwo = 2 .^ fliplr(0:(Nbits-1)); - Nsymb = Nbits; - - sim_out.qnoise_log = zeros(length(Ebvec), Ntrials); - sim_out.error_log = []; - - for ne = 1:length(Ebvec) - EbNodB = Ebvec(ne); - EbNo = 10^(EbNodB/10); - - variance = 1/EbNo; - - Terrs = 0; Tbits = 0; - qsignal = qnoise = 0; - - for nn = 1:Ntrials - - tx_value = rand(1,1); - tx_index = quantise_value(tx_value, 0, 1, Nlevels); - tx_bits = dec2bin(tx_index, Nbits) - '0'; - tx_symbols = (-1 + 2*tx_bits) .* amps; - - % AWGN noise and phase/freq offset channel simulation - % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im - - noise = sqrt(variance*0.5)*(randn(1,Nsymb) + j*randn(1,Nsymb)); - rx_symbols = tx_symbols + noise; - - rx_bits = rx_symbols > 0; - - error_positions = xor(rx_bits, tx_bits); - if enable_error_log - sim_out.error_log = [sim_out.error_log error_positions]; - end - Nerrs = sum(error_positions); - Terrs += Nerrs; - Tbits += length(tx_bits); - - rx_index = (powersOfTwo * rx_bits'); - rx_value = unquantise_value(rx_index, 0, 1, Nlevels); - - qsignal += tx_value*tx_value; - qnoise += (tx_value - rx_value) .^ 2; - sim_out.qnoise_log(ne,nn) = tx_value - rx_value; - end - - sim_out.TERvec(ne) = Terrs; - sim_out.BERvec(ne) = Terrs/Tbits; - sim_out.QSNRvec(ne) = 10*log10(qsignal/qnoise); - printf("EbNo (dB): %3.2f Terrs: %6d BER %1.4f QSNR (dB): %3.2f\n", - EbNodB, Terrs, Terrs/Tbits, 10*log10(qsignal/qnoise)); - end - -endfunction - -% gray codes with specified number of data and parity bits. Soft -% decision decoding. Didn't really work out. - -function valid_codewords = fuzzy_code_create(ndata,nparity) - Nbits = ndata + nparity; - Nvalid = 2 .^ ndata; - codewords = binary_to_gray(0:(2 .^ Nbits)-1); - valid_codewords = dec2bin(codewords(1:2:(2 .^ Nbits)), Nbits) - '0'; - - % check all valid codewords have a hamming distance of at least 2^nparity - - bad_distance = 0; - for i=1:Nvalid - for k=i+1:Nvalid - distance = sum(bitxor(valid_codewords(i,:), valid_codewords(k,:))); - if distance < 2 - bad_distance++; - end - end - end - if bad_distance != 0 - printf("Error: Nvalid: %d bad_distance: %d\n", Nvalid, bad_distance); - return; - end - -endfunction - -function tx_codeword = fuzzy_code_encode(codewords, value) - tx_codeword = codewords(value+1,:); -endfunction - -function [value, best_codeword] = fuzzy_code_decode(codewords, rx_symbols) - max_corr = 0; - value = 0; - [rows,cols] = size(codewords); - for i=1:rows - corr = (-1 + 2*codewords(i,:)) * transpose(rx_symbols); - if (corr > max_corr) - max_corr = corr; - value = i-1; - best_codeword = codewords(i,:); - end - end -endfunction - - -function sim_out = test_fuzzy_code(Ebvec, Ndata, Nparity, Ntrials) - Nbits = Ndata + Nparity; - Nlevels = 2 .^ Ndata; - Nsymb = Nbits; - powersOfTwo = 2 .^ fliplr(0:(Nbits-1)); - - codewords = fuzzy_code_create(Ndata,Nparity); - sim_out.qnoise_log = zeros(length(Ebvec), Ntrials); - - for ne = 1:length(Ebvec) - EbNodB = Ebvec(ne); - EbNo = 10^(EbNodB/10); - - variance = 1/EbNo; - - Terrs = 0; Terrs_coded = 0; Tbits = 0; - Nsingle = Nsingle_corrected = 0; - qsignal = qnoise = 0; - - for nn = 1:Ntrials - - tx_value = rand(1,1); - tx_index = quantise_value(tx_value, 0, 1, Nlevels); - tx_codeword = fuzzy_code_encode(codewords, tx_index); - tx_symbols = -1 + 2*tx_codeword; - - % AWGN noise and phase/freq offset channel simulation - % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im - - noise = sqrt(variance*0.5)*(randn(1,Nsymb) + j*randn(1,Nsymb)); - rx_symbols = tx_symbols + noise; - - % uncoded BER - - rx_bits = rx_symbols > 0; - error_positions = xor(rx_bits(1:Ndata), tx_codeword(1:Ndata)); - Nerrs = sum(error_positions); - Terrs += Nerrs; - Tbits += Ndata; - - % decode and determine QSNR - - [rx_index, rx_codeword] = fuzzy_code_decode(codewords, rx_symbols); - rx_value = unquantise_value(rx_index, 0, 1, Nlevels); - qsignal += tx_value*tx_value; - qnoise += (tx_value - rx_value) .^ 2; - sim_out.qnoise_log(ne,nn) = tx_value - rx_value; - - % coded BER - - error_positions = xor(rx_codeword(1:Ndata), tx_codeword(1:Ndata)); - Nerrs_coded = sum(error_positions); - if Nerrs == 1 - Nsingle++; - if Nerrs_coded == 0 - Nsingle_corrected++; - end - end - Terrs_coded += Nerrs_coded; - - end - - sim_out.BERvec(ne) = Terrs/Tbits; - sim_out.BERvec_coded(ne) = Terrs_coded/Tbits; - sim_out.Nsingle(ne) = Nsingle; - sim_out.Nsingle_corrected(ne) = Nsingle_corrected; - - sim_out.QSNRvec(ne) = 10*log10(qsignal/qnoise); - printf("EbNo (dB): %3.2f Terrs: %6d BER %1.4f Terrs_coded: %6d BER_coded %1.4f QSNR (dB): %3.2f", - EbNodB, Terrs, Terrs/Tbits, Terrs_coded, Terrs_coded/Tbits, sim_out.QSNRvec(ne)); - printf(" Nsingle: %d Nsingle_corrected: %d corrected: %3.1f\n", Nsingle, Nsingle_corrected, Nsingle_corrected*100/Nsingle); - end -endfunction - -function compare_baseline_fuzzy - Ebvec = 0:3; - Ntrials = 5000; - Nbits = 4; Nparity = 1; - - baseline = test_baseline_uncoded(Ebvec, Nbits, Ntrials, 0, 0); - fuzzy = test_fuzzy_code(Ebvec, Nbits, Nparity, Ntrials); - - figure(1); - clf; - semilogy(Ebvec, baseline.BERvec) - xlabel('Eb/N0') - ylabel('BER') - grid("minor") - - figure(2); - clf; - plot(Ebvec, baseline.QSNRvec,'b;baseline;') - hold on; - plot(Ebvec, fuzzy.QSNRvec,'r;fuzzy;') - hold off; - xlabel('Eb/N0') - ylabel('SNR') - grid("minor") - - figure(3); - subplot(211) - hist(baseline.qnoise_log(4,:),50); - subplot(212) - hist(fuzzy.qnoise_log(4,:),50); - - figure(4) - subplot(211) - plot(baseline.qnoise_log(4,1:250),'b;baseline;') - subplot(212) - plot(fuzzy.qnoise_log(4,1:250),'r;fuzzy;') -endfunction - -% compare baseline and variable power schemes and make plots - -function compare_baseline_varpower_plot - Ebvec = -2:5; - Ntrials = 5000; - Nbits = 5; - - baseline = test_baseline_uncoded(Ebvec, Nbits, Ntrials, 0, 0); - amps = [2 1.5 1.0 0.5 0.5]; - av_pwr = (amps*amps')/length(amps); - amps_norm = amps/sqrt(av_pwr); - varpower = test_varpower(Ebvec, Nbits, Ntrials, amps_norm, 0); - - figure(1); - clf; - semilogy(Ebvec, baseline.BERvec) - xlabel('Eb/No (dB)') - ylabel('BER') - grid("minor") - title('BER versus Eb/No') - - figure(2); - clf; - plot(Ebvec, baseline.QSNRvec,'b;baseline;') - hold on; - plot(Ebvec, varpower.QSNRvec,'r;varpower;') - hold off; - xlabel('Eb/No (dB)') - ylabel('SNR (dB)') - grid("minor") - title('Quantiser SNR versus Eb/No') - - figure(3); - subplot(211) - hist(baseline.qnoise_log(1,:),50); - title('Baseline and Variable Power Error Histograms') - subplot(212) - hist(varpower.qnoise_log(1,:),50); - - figure(4) - subplot(211) - plot(baseline.qnoise_log(1,1:250),'b;baseline;') - title('Baseline and Variable Power Error plots for Eb/No = -2dB') - subplot(212) - plot(varpower.qnoise_log(1,1:250),'r;varpower;') -endfunction - -% Compare baseline and variable power schemes and make error pattern -% files for inserting into codec bit stream so we can listen to -% result. - -function compare_baseline_varpower_error_files - Ebvec = -2; - Fs = 25; % number of samples per second - Nsec = 15; % seconds to simulate - Ntrials = Fs*Nsec; - Nbits = 5; - bits_per_frame = 52; - bits_per_frame_rounded = ceil(bits_per_frame/8)*8; % c2enc uses integer number of bytes/frame - start_bit = 12; % first energy bit (after 4 voicing, 7 Wo bits) - - baseline = test_baseline_uncoded(Ebvec, Nbits, Ntrials, 1, 0); - amps = [2 1.5 1.0 0.5 0.5]; - av_pwr = (amps*amps')/length(amps); - amps_norm = amps/sqrt(av_pwr); - varpower = test_varpower(Ebvec, Nbits, Ntrials, amps_norm, 1); - - % construct error patterns to apply to c2enc bit stream - - baseline_errors = []; - for i=1:Ntrials - error_positions = baseline.error_log(Nbits*(i-1)+1:Nbits*i); - baseline_errors = [baseline_errors zeros(1,start_bit-1) error_positions ... - zeros(1, bits_per_frame_rounded - Nbits - (start_bit-1))]; - end - - varpower_errors = []; - for i=1:Ntrials - error_positions = varpower.error_log(Nbits*(i-1)+1:Nbits*i); - varpower_errors = [varpower_errors zeros(1,start_bit-1) error_positions ... - zeros(1, bits_per_frame_rounded - Nbits - (start_bit-1))]; - end - - % save error patterns - - fep=fopen("energy_errors_baseline.bin","wb"); fwrite(fep, baseline_errors, "short"); fclose(fep); - fep=fopen("energy_errors_varpower.bin","wb"); fwrite(fep, varpower_errors, "short"); fclose(fep); -endfunction - -% compare natural and gray coding and make plots - -function compare_natural_gray_plot - Ebvec = -2:10; - Ntrials = 5000; - Nbits = 7; - - natural = test_baseline_uncoded(Ebvec, Nbits, Ntrials, 0, 0); - gray = test_baseline_uncoded(Ebvec, Nbits, Ntrials, 0, 1); - - figure(1); - clf; - semilogy(Ebvec, natural.BERvec) - xlabel('Eb/No (dB)') - ylabel('BER') - grid("minor") - title('BER versus Eb/No') - - figure(2); - clf; - plot(Ebvec, natural.QSNRvec,'b;natural;') - hold on; - plot(Ebvec, gray.QSNRvec,'r;gray;') - hold off; - xlabel('Eb/No (dB)') - ylabel('SNR (dB)') - grid("minor") - title('Quantiser SNR versus Eb/No') - - figure(3); - subplot(211) - hist(natural.qnoise_log(1,:),50); - title('Natural and Gray coded Error Histograms') - subplot(212) - hist(gray.qnoise_log(1,:),50); - - figure(4) - subplot(211) - plot(natural.qnoise_log(1,1:250),'b;natural;') - axis([0 250 -1 1]) - title('Natural and Gray coded Error plots for Eb/No = -2dB') - subplot(212) - plot(gray.qnoise_log(1,1:250),'r;gray;') - axis([0 250 -1 1]) -endfunction - -% compare natural at different Eb/No and Nbitsmake plots - -function compare_natural_nbit_plot - Ebvec = -2:10; - Ntrials = 5000; - - figure(1); - clf; - for n = 2:7 - natural = test_baseline_uncoded(Ebvec, n, Ntrials, 0, 0); - plot(Ebvec, natural.QSNRvec) - if n == 2 - hold on; - end - end - hold off; - - xlabel('Eb/No (dB)') - ylabel('SNR (dB)') - grid("minor") - title('Quantiser SNR versus Eb/No') -endfunction - -function generate_varpower_error_files(EbNo, start_bit, end_bit, amps, error_file_name) - Fs = 25; % number of samples per second - Nsec = 3; % seconds to simulate - Ntrials = Fs*Nsec; - Nbits = end_bit - start_bit + 1; - bits_per_frame = 52; - bits_per_frame_rounded = ceil(bits_per_frame/8)*8; % c2enc uses integer number of bytes/frame - % first energy bit (after 4 voicing, 7 Wo bits) - - % normalise powers and run test - - av_pwr = (amps*amps')/length(amps); - amps_norm = amps/sqrt(av_pwr); - av_pwr2 = (amps_norm*amps_norm')/length(amps_norm) - varpower = test_varpower(EbNo, Nbits, Ntrials, amps_norm, 1); - - % construct error patterns to apply to c2enc bit stream - - varpower_errors = []; - for i=1:Ntrials - error_positions = varpower.error_log(Nbits*(i-1)+1:Nbits*i); - - if 0 - % reset single errors to tes effect of ideal single bit error correcting code - for i=1:7 - st = 4*(i-1)+1 - en = 4*i - if sum(error_positions(st:en)) == 1 - error_positions(st:en) = 0; - end - end - for i=1:2 - st = 7*4+3*(i-1)+1 - en = 7*4+3*i - if sum(error_positions(st:en)) == 1 - error_positions(st:en) = 0; - end - end - st = 7*4+3*2+1 - en = 7*4+3*2+2 - if sum(error_positions(st:en)) == 1 - error_positions(st:en) = 0; - end - end - - num_errors(i) = sum(error_positions); - varpower_errors = [varpower_errors zeros(1,start_bit-1) error_positions ... - zeros(1, bits_per_frame_rounded - Nbits - (start_bit-1))]; - end - - % save error pattern to file - - fep=fopen(error_file_name,"wb"); fwrite(fep, varpower_errors, "short"); fclose(fep); - - figure(1) - clf - hist(num_errors) -endfunction - -more off; - -%generate_varpower_error_files(0, 17, 52, ones(1,36), "lsp_baseline_errors_0dB.bin") -%amps = [1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 ]; -%generate_varpower_error_files(0, 17, 52, amps, "lsp_varpower_errors_0dB.bin") - -%compare_natural_nbit_plot -%compare_natural_gray_plot -%compare_baseline_varpower_plot -%compare_baseline_varpower_error_files - -compare_baseline_fuzzy -%fuzzy_code_create(3,1) diff --git a/codec2/octave/gen_rn_coeffs.m b/codec2/octave/gen_rn_coeffs.m deleted file mode 100644 index bfc214e0..00000000 --- a/codec2/octave/gen_rn_coeffs.m +++ /dev/null @@ -1,40 +0,0 @@ -% gen_rn_coeffs.m -% David Rowe 13 april 2012 -% -% Generate root raised cosine (Root Nyquist) filter coefficients -% thanks http://www.dsplog.com/db-install/wp-content/uploads/2008/05/raised_cosine_filter.m - -function coeffs = gen_rn_coeffs(alpha, T, Rs, Nsym, M) - - Ts = 1/Rs; - - n = -Nsym*Ts/2:T:Nsym*Ts/2; - Nfilter = Nsym*M; - Nfiltertiming = M+Nfilter+M; - - sincNum = sin(pi*n/Ts); % numerator of the sinc function - sincDen = (pi*n/Ts); % denominator of the sinc function - sincDenZero = find(abs(sincDen) < 10^-10); - sincOp = sincNum./sincDen; - sincOp(sincDenZero) = 1; % sin(pix/(pix) =1 for x =0 - - cosNum = cos(alpha*pi*n/Ts); - cosDen = (1-(2*alpha*n/Ts).^2); - cosDenZero = find(abs(cosDen)<10^-10); - cosOp = cosNum./cosDen; - cosOp(cosDenZero) = pi/4; - gt_alpha5 = sincOp.*cosOp; - Nfft = 4096; - GF_alpha5 = fft(gt_alpha5,Nfft)/M; - - % sqrt causes stop band to be amplified, this hack pushes it down again - - for i=1:Nfft - if (abs(GF_alpha5(i)) < 0.02) - GF_alpha5(i) *= 0.001; - endif - end - GF_alpha5_root = sqrt(abs(GF_alpha5)) .* exp(j*angle(GF_alpha5)); - ifft_GF_alpha5_root = ifft(GF_alpha5_root); - coeffs = real((ifft_GF_alpha5_root(1:Nfilter))); -endfunction diff --git a/codec2/octave/glottal.m b/codec2/octave/glottal.m deleted file mode 100644 index 46675e7d..00000000 --- a/codec2/octave/glottal.m +++ /dev/null @@ -1,29 +0,0 @@ -% glottal.m -% David Rowe 12 Sep 2009 -% Matlab script to generate the phase spectra of a glottal pulse - -% lpc10 pulse from spandsp. When the file glottal.c was used as a part of the -% excitation phase component in phase.c, phase_synth_zero_order(), no difference -% in speech quality was apparent. So left out of code for now. - -sh=12 -kexc = [ 8, -16, 26, -48, 86, -162, 294, -502, 718, -728, 184 672, -610, -672, 184, 728, 718, 502, 294, 162, 86, 48, 26, 16, 8]; -kexc = shift(kexc,sh); -kexc = [kexc(1:sh) zeros(1,512-25) kexc(sh+1:25)]; -figure(1) -clf -plot(kexc) -figure(2) -G = fft(kexc); -subplot(211) -plot((1:256)*(4000/256),unwrap(angle(G(1:256)))) -subplot(212) -plot(20*log10(abs(G))) - -f=fopen("glottal.c","wt"); -fprintf(f,"const float glottal[]={\n"); -for m=1:255 - fprintf(f," %f,\n",angle(G(m))); -endfor -fprintf(f," %f};\n",angle(G(256))); -fclose(f); diff --git a/codec2/octave/hf_sim.m b/codec2/octave/hf_sim.m deleted file mode 100644 index 90458283..00000000 --- a/codec2/octave/hf_sim.m +++ /dev/null @@ -1,74 +0,0 @@ -% hf_sim.m -% David Rowe March 2014 -% -% HF channel simulation. - -function sim_out = hf_sim(sim_in, snr3kHz) - - % Init HF channel model from stored sample files of spreading signal ---------------------------------- - - % convert "spreading" samples from 1kHz carrier at Fs to complex - % baseband, generated by passing a 1kHz sine wave through PathSim - % with the ccir-poor model, enabling one path at a time. - - Fc = 1000; Fs=8000; - fspread = fopen("../raw/sine1k_2Hz_spread.raw","rb"); - spread1k = fread(fspread, "int16")/10000; - fclose(fspread); - fspread = fopen("../raw/sine1k_2ms_delay_2Hz_spread.raw","rb"); - spread1k_2ms = fread(fspread, "int16")/10000; - fclose(fspread); - - % down convert to complex baseband - spreadbb = spread1k.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k))'); - spreadbb_2ms = spread1k_2ms.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k_2ms))'); - - % remove -2000 Hz image - b = fir1(50, 5/Fs); - spread = filter(b,1,spreadbb); - spread_2ms = filter(b,1,spreadbb_2ms); - - % discard first 1000 samples as these were near 0, probably as - % PathSim states were ramping up - - spread = spread(1000:length(spread)); - spread_2ms = spread_2ms(1000:length(spread_2ms)); - - hf_gain = 1.0/sqrt(var(spread)+var(spread_2ms)); - - % 300 - 3000 Hz filter - - b = fir1(100,[300/4000, 3000/4000], 'pass'); - - % det power of unit variance noise passed through this filter - - filter_var = var(filter(b,1,randn(1000,1))); - - % Start simulation - - s = hilbert(filter(b,1,sim_in)); - n1 = length(s); n2 = length(spread); - n = min(n1,n2); - path1 = s(1:n) .* spread(1:n); - path2 = s(1:n) .* spread_2ms(1:n); - delay = floor(0.002*Fs); - - combined = path1(delay+1:n) + path2(1:n-delay); - - snr = 10 .^ (snr3kHz/10); - variance = (combined'*combined)/(snr*n); - noise = sqrt(variance*0.5/filter_var)*(randn(n-delay,1) + j*randn(n-delay,1)); - filtered_noise = filter(b,1,noise); - - sim_out = real(combined+filtered_noise); - printf("measured SNR: %3.2fdB\n", 10*log10(var(real(combined))/var(real(filtered_noise)))); - - figure(1); - plot(s); - figure(2) - plot(real(combined)) - figure(2) - plot(sim_out) - -endfunction - diff --git a/codec2/octave/hfper.m b/codec2/octave/hfper.m deleted file mode 100644 index b3396342..00000000 --- a/codec2/octave/hfper.m +++ /dev/null @@ -1,57 +0,0 @@ -% hfper.m -% David Rowe 2 June 2014 -% Quick and dirty HF PER calculator/simulator - -function hfper(ber, nbits, ntrials) - - % Raw PER with no FEC -------------------------------------- - - nper = 0; - for i=1:ntrials - nerr = sum(rand(1,nbits) < ber); - if nerr >0 - nper++; - end - end - printf("Raw PER..................: %0.3f\n", nper/ntrials); - - % Half rate block code, e.g. Golay (23,12) with 3 bit error - % correcting capability - - % Golay (23,12) that can correct 3 errors (fails at 4) ------ - - ncodeword = 23; - ncorrect = 3; - nper = 0; - for i=1:ntrials - nerr = sum(rand(1,ncodeword) < ber); - if nerr > ncorrect - nper++; - end - end - printf("One Golay codeword.......: %0.3f\n", nper/ntrials); - - % Several Golay codewords concatenated ---------------------- - - m = floor(nbits/12); % number of codewords - - nper = 0; - for i=1:ntrials - - % test each codeword in packet, if any of the codewords has > 4 - % errors, entire packet is a dud - - no_errors = 1; - for k=1:m - nerr = sum(rand(1,ncodeword) < ber); - if (nerr > ncorrect) && no_errors - nper++; - no_errors = 0; - end - end - - end - printf("Packet protected by Golay: %0.3f\n", nper/ntrials); - -endfunction - diff --git a/codec2/octave/hp_filt.m b/codec2/octave/hp_filt.m deleted file mode 100644 index 1087bb91..00000000 --- a/codec2/octave/hp_filt.m +++ /dev/null @@ -1,12 +0,0 @@ -% hp_filt.m -% David Rowe 20 Feb 2012 - -function hp_filt(in_file, out_file) - fin = fopen(in_file,"rb"); - s = fread(fin,Inf,"short"); - b = fir1(256, 300/4000, "high"); - freqz(b); - s_hpf = filter(b,1,s); - fout = fopen(out_file,"wb"); - fwrite(fout, s_hpf, "short"); -endfunction diff --git a/codec2/octave/ldpc.m b/codec2/octave/ldpc.m deleted file mode 100644 index 7ce4a87a..00000000 --- a/codec2/octave/ldpc.m +++ /dev/null @@ -1,209 +0,0 @@ -% ldpc.m -% LDPC functions - -1; - - -function code_param = ldpc_init(rate, framesize, modulation, mod_order, mapping) - [code_param.H_rows, code_param.H_cols, code_param.P_matrix] = InitializeWiMaxLDPC( rate, framesize, 0 ); - code_param.data_bits_per_frame = length(code_param.H_cols) - length( code_param.P_matrix ); - code_param.S_matrix = CreateConstellation( modulation, mod_order, mapping ); - code_param.bits_per_symbol = log2(mod_order); -endfunction - - -% Gray coded QPSK modulation function - -function symbol = qpsk_mod(two_bits) - two_bits_decimal = sum(two_bits .* [2 1]); - switch(two_bits_decimal) - case (0) symbol = 1; - case (1) symbol = j; - case (2) symbol = -j; - case (3) symbol = -1; - endswitch -endfunction - - -% Gray coded QPSK demodulation function - -function two_bits = qpsk_demod(symbol) - bit0 = real(symbol*exp(j*pi/4)) < 0; - bit1 = imag(symbol*exp(j*pi/4)) < 0; - two_bits = [bit1 bit0]; -endfunction - - -% inserts a unique word into a frame of bits. The UW bits are spread -% throughout the input frame 2 bits at a time. - -function frameout = insert_uw(framein, uw) - - luw = length(uw); - lframein = length(framein); - spacing = 2*lframein/luw; - - frameout = []; - - pin = 1; pout = 1; puw = 1; - while (luw) - %printf("pin %d pout %d puw %d luw %d\n", pin, pout, puw, luw); - frameout(pout:pout+spacing-1) = framein(pin:pin+spacing-1); - pin += spacing; - pout += spacing; - frameout(pout:pout+1) = uw(puw:puw+1); - puw += 2; - pout += 2; - luw -= 2; - end -endfunction - -% removes a unique word from a frame of bits. The UW bits are spread -% throughout the input frame 2 bits at a time. - -function frameout = remove_uw(framein, lvd, luw) - - spacing = 2*lvd/luw; - - frameout = []; - - pin = 1; pout = 1; - while (luw) - %printf("pin %d pout %d luw %d ", pin, pout, luw); - %printf("pin+spacing-1 %d lvd %d lframein: %d\n", pin+spacing-1, lvd, length(framein)); - frameout(pout:pout+spacing-1) = framein(pin:pin+spacing-1); - pin += spacing + 2; - pout += spacing; - luw -= 2; - end - -endfunction - - -% removes a unique word from a frame of symbols. The UW symbols are spread -% throughout the input frame 1 symbol at a time. - -function framesymbolsout = remove_uw_symbols(framesymbolsin, ldatasymbols, luwsymbols) - - spacing = ldatasymbols/luwsymbols; - - framesymbolsout = []; - - pin = 1; pout = 1; - while (luwsymbols) - %printf("pin %d pout %d luw %d ", pin, pout, luwsymbols); - %printf("pin+spacing-1 %d ldatasymbols %d lframein: %d\n", pin+spacing-1, ldatasymbols, length(framesymbolsin)); - framesymbolsout(pout:pout+spacing-1) = framesymbolsin(pin:pin+spacing-1); - pin += spacing + 1; - pout += spacing; - luwsymbols--; - end - -endfunction - - - -% builds up a sparse QPSK modulated version version of the UW for use -% in UW sync at the rx - -function mod_uw = build_mod_uw(uw, spacing) - luw = length(uw); - - mod_uw = []; - - pout = 1; puw = 1; - while (luw) - %printf("pin %d pout %d puw %d luw %d\n", pin, pout, puw, luw); - pout += spacing/2; - mod_uw(pout) = qpsk_mod(uw(puw:puw+1)); - puw += 2; - pout += 1; - luw -= 2; - end -endfunction - - -% Uses the UW to determine when we have a full codeword ready for decoding - -function [found_uw corr] = look_for_uw(mem_rx_symbols, mod_uw) - sparse_mem_rx_symbols = mem_rx_symbols(find(mod_uw)); - - % correlate with ref UW - - num = (mem_rx_symbols * mod_uw') .^ 2; - den = (sparse_mem_rx_symbols * sparse_mem_rx_symbols') * (mod_uw * mod_uw'); - - corr = abs(num/(den+1E-6)); - found_uw = corr > 0.8; -endfunction - - -function [codeword s] = ldpc_enc(data, code_param) - codeword = LdpcEncode( data, code_param.H_rows, code_param.P_matrix ); - s = Modulate( codeword, code_param.S_matrix ); -endfunction - - -function detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, r, EsNo, fading) - symbol_likelihood = Demod2D( r, code_param.S_matrix, EsNo, fading); - - % initialize the extrinsic decoder input - input_somap_c = zeros(1, code_param.code_bits_per_frame ); - bit_likelihood = Somap( symbol_likelihood, demod_type, input_somap_c ); - - input_decoder_c = bit_likelihood(1:code_param.code_bits_per_frame); - - x_hat= MpDecode( -input_decoder_c, code_param.H_rows, code_param.H_cols, ... - max_iterations, decoder_type, 1, 1); - detected_data = x_hat(max_iterations,:); -endfunction - - -% Packs a binary array into an array of 8 bit bytes, MSB first - -function packed = packmsb(unpacked) - packed = zeros(1,floor(length(unpacked)+7)/8); - bit = 7; byte = 1; - for i=1:length(unpacked) - packed(byte) = bitor(packed(byte), bitshift(unpacked(i),bit)); - bit--; - if (bit < 0) - bit = 7; - byte++; - end - end -endfunction - - -% unpacks an array of 8 bit bytes into a binary array of unpacked bits, MSB first - -function unpacked = unpackmsb(packed) - bit = 7; byte = 1; - for i=1:length(packed)*8 - unpacked(i) = bitand(bitshift(packed(byte), -bit), 1); - bit--; - if (bit < 0) - bit = 7; - byte++; - end - end -endfunction - - -% symbol interleaver that acts on bits 2 at a time - -function y = interleave_bits(interleaver, x) - y = zeros(1,length(x)); - for i = 1:length(interleaver) - dst = interleaver(i); - y(2*(dst-1)+1:2*dst) = x(2*(i-1)+1:2*(i)); - end -endfunction - -% symbol de-interleaver - -function x = deinterleave_symbols(interleaver, y) - for i = 1:length(interleaver) - x(i) = y(interleaver(i)); - end -endfunction diff --git a/codec2/octave/ldpcdec.m b/codec2/octave/ldpcdec.m deleted file mode 100644 index 6f71f832..00000000 --- a/codec2/octave/ldpcdec.m +++ /dev/null @@ -1,300 +0,0 @@ -% ldpcdec.m -% David Rowe 31 Dec 2013 -% -% LDPC decoder test program, given a file of QPSK symbols (IQIQ floats), -% performs frame sync, decodes, and measures BER. - -function ldpcdec(filename, Eprob) - - % Start CML library - - currentdir = pwd; - addpath '/home/david/tmp/cml/mat' % assume the source files stored here - cd /home/david/tmp/cml - CmlStartup % note that this is not in the cml path! - cd(currentdir) - - % Our LDPC library - - ldpc; - - % Start simulation - - rand('state',1); - - rate = 3/4; - framesize = 576; - - mod_order = 4; - modulation = 'QPSK'; - mapping = 'gray'; - - demod_type = 0; - decoder_type = 0; - max_iterations = 100; - EsNo = 4; - if (nargin == 1) - Eprob = 0.0; - end - - nbitspervocoderframe = 52; - nvocoderframes = 8; - nbitspermodemframe = 72; - - code_param = ldpc_init(rate, framesize, modulation, mod_order, mapping); - code_param.code_bits_per_frame = 576; - - data = []; - r = []; - load interleaver.txt - interleaver = interleaver + 1; - - Nframes = 100; - uw = [1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0]; - - Nc = 18; - - % repeat same simulated vocoder data to ease testing - - vd = round( rand( 1, nbitspervocoderframe*nvocoderframes) ); - - % Decoder: Sync with LDPC frames, de-interleave, LDPC decode, strip off UW, measure BER ------- - - mcwfilename = strcat(filename,"_modcodeword.bin"); - fm=fopen(mcwfilename,"rb"); - etfilename = strcat(filename,"_modcodeword_et.bin"); - fet=fopen(etfilename ,"rb"); - epfilename = strcat(filename,".err"); - fep=fopen(epfilename ,"wb"); - printf("Input QPSK symbols: %s\n", mcwfilename); - if (fet == -1) - printf("Input entered track file: none\n"); - else - printf("Input entered track file: %s\n", etfilename); - end - printf("Output error pattern file: %s\n", epfilename); - - mod_uw = build_mod_uw(uw, 2*length(vd)/length(uw)); - - mod_codeword = zeros(1, code_param.code_bits_per_frame/2); - lmod_codeword = code_param.code_bits_per_frame/2; - - Terrs = 0; Trawerrs = 0; Ferrs = 0; Tbits = 0; Tframes = 0; nerr = []; nrawerr = []; - corr = []; n = 0; - sync_state = 0; sync_count = 0; - mod_unpackedmodem_log = []; - sync_state_log = []; - entered_track_log = []; - sig_pwr_log = []; - - symbols = erasures = 0; - - [mod_unpackedmodem_float32, count] = fread(fm,nbitspermodemframe, "float32"); - if (fet == -1) - entered_track = 0; - else - entered_track = fread(fet, 1, "int"); - end - - while (count == nbitspermodemframe) - n++; - - mod_unpackedmodem = mod_unpackedmodem_float32(1:2:nbitspermodemframe) + j*mod_unpackedmodem_float32(2:2:nbitspermodemframe); - mod_unpackedmodem_log = [mod_unpackedmodem_log mod_unpackedmodem]; - %erasures = rand(1,length(mod_unpackedmodem)) < Eprob; - %mod_unpackedmodem(erasures) = 0; - - % keep buffer of one entire codeword - - mod_codeword(1:lmod_codeword-length(mod_unpackedmodem)) = mod_codeword(length(mod_unpackedmodem)+1:lmod_codeword); - mod_codeword(lmod_codeword-length(mod_unpackedmodem)+1:lmod_codeword) = mod_unpackedmodem; - - [uw_sync corr(n)] = look_for_uw(mod_codeword(1:length(mod_uw)), mod_uw); - - next_sync_state = sync_state; - if ((sync_state == 0) && (uw_sync == 1)) - next_sync_state = 1; - sync_count = 0; - end - if ((sync_state == 1) && (entered_track != 0)) - next_sync_state = 0; - end - sync_state = next_sync_state; - sync_state_log = [sync_state_log sync_state]; - entered_track_log = [entered_track_log entered_track]; - - if (sync_state && (sync_count == 0)) - Tframes++; - - % remove UW symbols - - mod_codeword_no_uw = remove_uw_symbols(mod_codeword, code_param.data_bits_per_frame/2 - length(uw)/2, length(uw)/2); - mod_codeword_no_uw = [mod_codeword_no_uw mod_codeword((code_param.data_bits_per_frame/2+1):code_param.code_bits_per_frame/2)]; - - % de-interleave - - tmp = deinterleave_symbols(interleaver, mod_codeword_no_uw); - - % insert known symbols at end of data - - mod_codeword_deinter = [ tmp(1:(code_param.data_bits_per_frame/2 - length(uw)/2)) ... - ones(1,length(uw)/2) * qpsk_mod([0 0]) ... - tmp((code_param.data_bits_per_frame/2 - length(uw)/2+1):length(tmp)) ]; - - % determine BER stats of raw data before decoding - - raw_bits = zeros(1, code_param.data_bits_per_frame - length(uw)); - for i=1:(code_param.data_bits_per_frame - length(uw))/2 - raw_bits(2*(i-1)+1:2*i) = qpsk_demod(mod_codeword_deinter(i)); - end - error_positions = xor(vd, raw_bits); - Nerrs = sum(error_positions); - Trawerrs += Nerrs; - nrawerr(Tframes) = Nerrs; - - % Determine Es/N for each carrier. For this codeword we assume - % across codeword (currently 320ms) signal is stationary. - % So for each carrier signal level is constant, so we can - % average across all symols of that carrier to get a better - % estimate of the carrier power. The spectral noise density - % No will be the same for the bandwidth of each carrier. So - % we can use noise samples from all symbols together to get - % a better estimate of the noise power. - - sig_pwr(Tframes,:) = zeros(1,Nc); - noise_samples = []; - for n=1:Nc - - % extract a vector of one carrier's symbols for this codeword - % rotate so that decision boundaries are now real and imag axis - - r = mod_codeword(n:Nc:length(mod_codeword)) .* exp(j*pi/4); - - sig_est = mean(abs(r)); - - % The noise is the variance of symbols (samples) about the actual symbol position - % we reflect all symbols into the first quadrant to simplify things, as the actual - % received symbol isn't matter, just the noise around it. We model the received - % symbol based on the estimated signal level. - - refl_symbols = abs(real(r)) + j*abs(imag(r)); - est_symbols = exp(j*pi/4)*sig_est*ones(1,length(r)); - noise_samples = [ noise_samples (est_symbols - refl_symbols)]; - - sig_pwr(Tframes,n) = sig_est .^ 2; - end - noise_pwr(Tframes) = var(noise_samples); - %plot(real(refl_symbols), imag(refl_symbols), '+'); - %hold on; - %plot(real(exp(j*pi/4)*sig_est*ones(1,length(r))), imag(exp(j*pi/4)*sig_est*ones(1,length(r))), 'r+'); - %hold off; - %printf("SNR: %f\n", 10*log10(sig_est*sig_est/noise_pwr(Tframes))); - - % Set erasures for carrier beneath a certain Es/N - - for n=1:Nc - symbols++; - EsN(n) = 10*log10(sig_pwr(Tframes,n)/noise_pwr(Tframes)); - if (EsN(n) < 1) - %mod_codeword(n:Nc:length(mod_codeword)) = 0; - %printf("Tframes: %d n: %d EsN = %3.2fdB\n", Tframes, n, EsN(n)); - erasures++; - end - end - - % De-interleave again with erasures set ---------------------- - - % remove UW symbols - - mod_codeword_no_uw = remove_uw_symbols(mod_codeword, code_param.data_bits_per_frame/2 - length(uw)/2, length(uw)/2); - mod_codeword_no_uw = [mod_codeword_no_uw mod_codeword((code_param.data_bits_per_frame/2+1):code_param.code_bits_per_frame/2)]; - - tmp = deinterleave_symbols(interleaver, mod_codeword_no_uw); - - % insert known symbols at end of data - - mod_codeword_deinter = [ tmp(1:(code_param.data_bits_per_frame/2 - length(uw)/2)) ... - ones(1,length(uw)/2) * qpsk_mod([0 0]) ... - tmp((code_param.data_bits_per_frame/2 - length(uw)/2+1):length(tmp)) ]; - - % LDPC decode ------------------------------------------------ - - detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, mod_codeword_deinter, EsNo); - - % unpack payload data, removing UW - - vd_rx = detected_data(1:(code_param.data_bits_per_frame - length(uw))); - - % measure coded BER - - error_positions = xor(vd, vd_rx); - Nerrs = sum(error_positions); - if Nerrs>0, fprintf(1,'x'); Ferrs++; , else fprintf(1,'.'), end - Tbits += length(vd); - Terrs += Nerrs; - nerr(Tframes) = Nerrs; - - % save error patterns is simulated vocoder data to disk - - fwrite(fep, error_positions, "short"); - - end - - if (sync_state) - sync_count++; - if (sync_count == 8) - sync_count = 0; - end - end - - % read in one modulated modem frame at a time - - [mod_unpackedmodem_float32, count] = fread(fm, nbitspermodemframe, "float32"); - if (fet == -1) - entered_track = 0; - else - entered_track = fread(fet, 1, "int"); - end - end - - fclose(fep); - - printf("\nFrames: %d bits: %d errors: %d Raw BER = %f Coded BER = %f FER = %f\n", Tframes, Tbits, Terrs, Trawerrs/Tbits, Terrs/Tbits, Ferrs/Tframes); - printf("Symbols: %d Erasures: %d %f\n", symbols, erasures, erasures/symbols); - figure(8) - clf; - [n m] = size(mod_unpackedmodem_log); - plot( real(mod_unpackedmodem_log), imag(mod_unpackedmodem_log), '+') - axis([-2 2 -2 2]); - title('Scatter Diagram'); - - figure(9) - subplot(311) - plot(sync_state_log); - subplot(312) - plot(nrawerr); - subplot(313) - plot(nerr); - - figure(10); - plot(10*log10(sig_pwr(:,3)./noise_pwr(:)),'b'); - hold on; - plot(10+10*log10(noise_pwr(:))); - plot(10+10*log10(sig_pwr(:,3)),'r'); -% for n=2:Nc -% plot(n*10+10*log10(sig_pwr(:,n)./noise_pwr(:,n))); -% plot(n*10+10*log10(sig_pwr(:,n)),'r'); -% end - hold off; - - y = 1:Tframes; - x = 1:Nc; - z = 10*log10(sig_pwr(:,:)./((noise_pwr(:)*ones(1, Nc)))); - %printf("mean SNR = %3.2fdB\n", mean(z)); - figure(11); - imagesc(x,y,z); - figure(12); - mesh(x,y,z); - axis([1 Nc 1 Tframes 5 15]); - -endfunction diff --git a/codec2/octave/ldpcenc.m b/codec2/octave/ldpcenc.m deleted file mode 100644 index 023c5172..00000000 --- a/codec2/octave/ldpcenc.m +++ /dev/null @@ -1,125 +0,0 @@ -% ldpcenc.m -% David Rowe 20 Dec 2013 -% -% LDPC encoder function. Takes a random data pattern, LDPC Encodes and -% inserts Unique Word (UW) sync bits and ouputs this as a packed -% binary file suitable for the Nc=18 carrier FDMDV modulator, -% fdmdv_mod. Also produces a "modulated" output file of QPSK -% symbols, suitable for feeding into ldpcdec for testing. - -function ldpcenc(filename) - - % Start CML library - - currentdir = pwd; - addpath '/home/david/tmp/cml/mat' % assume the source files stored here - cd /home/david/tmp/cml - CmlStartup % note that this is not in the cml path! - cd(currentdir) - - % Our LDPC library - - ldpc; - - % Start simulation - - rand('state',1); - - rate = 3/4; - framesize = 576; - - mod_order = 4; - modulation = 'QPSK'; - mapping = 'gray'; - - demod_type = 0; - decoder_type = 0; - max_iterations = 100; - - nbitspervocoderframe = 52; - nvocoderframes = 8; - nbitspermodemframe = 72; - - code_param = ldpc_init(rate, framesize, modulation, mod_order, mapping); - - data = []; - r = []; - load interleaver.txt - interleaver = interleaver + 1; - - % Encoder: Generate simulated vocoder data - % LPDC encode - % interleave - % insert UW bits - - Nframes = 100; - uw = [1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0]; - - % repeat same simulated vocoder data to ease testing - - vd = round( rand( 1, nbitspervocoderframe*nvocoderframes) ); - - % pad data with zeros the size of UW - - vdpad = [vd zeros(1, length(uw))]; - - % LDPC encode - - [codewordpad, s] = ldpc_enc(vdpad, code_param); - code_param.code_bits_per_frame = length(codewordpad); - code_param.symbols_per_frame = length(s); - - % remove padded zeros after encoding to leave room for UW bits (code - % is systematic) - - codeword = [ codewordpad(1:length(vd)) codewordpad((length(vd)+length(uw)+1):length(codewordpad)) ]; - - % interleave, insert UW bits, and pack bits (as C modulator likes packed bits) - - codeword_interleaved = interleave_bits(interleaver, codeword); - codeword_interleaved_uw = [insert_uw(codeword_interleaved(1:length(vd)), uw) codeword_interleaved(length(vd)+1:length(codeword_interleaved)) ]; - packedcodeword = packmsb(codeword_interleaved_uw); - - cwfilename = strcat(filename,"_codeword.bin"); - fc=fopen(cwfilename,"wb"); - for nn = 1: Nframes - fwrite(fc,packedcodeword,"uchar"); - end - fclose(fc); - - %printf("framesize: %d data_bits_per_frame: %d code_bits_per_frame: %d\n", ... - % framesize, code_param.data_bits_per_frame, code_param.code_bits_per_frame); - - printf("Encoded %d LDPC codewords, saved in packed file: %s\n", Nframes, cwfilename); - - % Modulator: Modulate to QPSK symbols ------------------------------------------ - - nbytespackedcodeword=length(packedcodeword); - fc=fopen(cwfilename,"rb"); - mcwfilename = strcat(filename,"_modcodeword.bin"); - fm=fopen(mcwfilename,"wb"); - nbytespackedmodemframe = nbitspermodemframe/8; - n = 0; - - [packedmodem, count] = fread(fc,nbytespackedmodemframe,"uchar"); - while (count == nbytespackedmodemframe) - n++; - unpackedmodem = unpackmsb(packedmodem); - - ii = 1; - for i=1:2:length(unpackedmodem) - mod_unpackedmodem(ii) = qpsk_mod(unpackedmodem(i:i+1)); - mod_unpackedmodem_float32(i) = real(mod_unpackedmodem(ii)); - mod_unpackedmodem_float32(i+1) = imag(mod_unpackedmodem(ii)); - ii += 1; - end - - fwrite(fm, mod_unpackedmodem_float32, "float32"); - [packedmodem, count] = fread(fc,nbytespackedmodemframe,"uchar"); - end - fclose(fc); - fclose(fm); - printf("Modulated %d modem frames to file: %s\n", n, mcwfilename); -endfunction - - diff --git a/codec2/octave/ldpcut.m b/codec2/octave/ldpcut.m deleted file mode 100644 index 80142ba6..00000000 --- a/codec2/octave/ldpcut.m +++ /dev/null @@ -1,69 +0,0 @@ -% LDPC unit test script -% David Rowe 18 Dec 2013 -% Based on siulation by Bill Cowley - -% Start CML library - -currentdir = pwd; -addpath '/home/david/tmp/cml/mat' % assume the source files stored here -cd /home/david/tmp/cml -CmlStartup % note that this is not in the cml path! -cd(currentdir) - -% Our LDPC library - -ldpc; - -% Start simulation - -rate = 3/4; -framesize = 576; - -mod_order = 4; -modulation = 'QPSK'; -mapping = 'gray'; - -demod_type = 0; -decoder_type = 0; -max_iterations = 100; - -code_param = ldpc_init(rate, framesize, modulation, mod_order, mapping); - -Ntrials = 84; -EsNo=10; - -Tbits = Terrs = Ferrs = 0; - -data = []; -r = []; - -% Encode a bunch of frames - -for nn = 1: Ntrials - d = round( rand( 1, code_param.data_bits_per_frame ) ); - data = [data d]; - [codeword, s] = ldpc_enc(d, code_param); - code_param.code_bits_per_frame = length(codeword); - code_param.symbols_per_frame = length(s); - r = [r s]; -end - -% Decode a bunch of frames - -for nn = 1: Ntrials - st = (nn-1)*code_param.symbols_per_frame + 1; - en = (nn)*code_param.symbols_per_frame; - detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, r(st:en), EsNo); - st = (nn-1)*code_param.data_bits_per_frame + 1; - en = (nn)*code_param.data_bits_per_frame; - error_positions = xor( detected_data(1:code_param.data_bits_per_frame), data(st:en) ); - Nerrs = sum( error_positions); - - if Nerrs>0, fprintf(1,'x'), else fprintf(1,'.'), end - if (rem(nn, 50)==0), fprintf(1,'\n'), end - if Nerrs>0, Ferrs = Ferrs +1; end - Terrs = Terrs + Nerrs; - Tbits = Tbits + code_param.data_bits_per_frame; -end -fprintf(1,'\n') - diff --git a/codec2/octave/load_raw.m b/codec2/octave/load_raw.m deleted file mode 100644 index 1f7868d4..00000000 --- a/codec2/octave/load_raw.m +++ /dev/null @@ -1,8 +0,0 @@ -% load_raw.m -% David Rowe 7 Oct 2009 - -function s = load_raw(fn) - fs=fopen(fn,"rb"); - s = fread(fs,Inf,"short"); - plot(s) -endfunction diff --git a/codec2/octave/lpcpf.m b/codec2/octave/lpcpf.m deleted file mode 100644 index f1e0982c..00000000 --- a/codec2/octave/lpcpf.m +++ /dev/null @@ -1,46 +0,0 @@ -% lpcpf.m -% David Rowe Aug 27 2012 -% Experiments with LPC post filtering - -function lpcpf(ak_filename, f) - aks = load(ak_filename); - - ak = aks(f,:); - [tmp p] = size(ak); - p -= 1; - - A = freqz(1,ak, 4000); - AdB = 20*log10(abs(A)); - - gamma = 0.5; - gammas = gamma .^ (0:p); - W = freqz(ak .* gammas,1, 4000); - WdB = 20*log10(abs(W)); - - beta = 0.2; - R = abs(freqz(ak .* gammas, ak, 4000)); - %P = (R/max(R)) .^ beta; - P = R .^ beta; - AP = abs(A) .* P; - - eA = sum(abs(A) .^ 2); - eAP = sum(AP .^ 2); - gain = sqrt(eA/eAP) - AP *= gain; - - PdB = 20*log10(P); - - APdB = 20*log10(AP); - 10*log10(sum(AP .^ 2))/10*log10(sum(abs(A) .^ 2)) - - figure(1); - clf; - plot(AdB); - hold on; - plot(WdB,'g'); - plot(PdB,'r'); - plot(APdB,'b.'); - hold off; - -endfunction - diff --git a/codec2/octave/lsp_pdf.m b/codec2/octave/lsp_pdf.m deleted file mode 100644 index 4fc1359a..00000000 --- a/codec2/octave/lsp_pdf.m +++ /dev/null @@ -1,91 +0,0 @@ -% lsp_pdf.m -% David Rowe 2 Oct 2009 -% Plots histograms (PDF estimates) of LSP training data - -function lsp_pdf(lsp) - [r,c] = size(lsp); - - % LSPs - - figure(1); - clf; - [x,y] = hist(lsp(:,1),100); - plot(y*4000/pi,x,"+;1;"); - hold on; - for i=2:5 - [x,y] = hist(lsp(:,i),100); - legend = sprintf("+%d;%d;",i,i); - plot(y*4000/pi,x,legend); - endfor - for i=6:c - [x,y] = hist(lsp(:,i),100); - legend = sprintf("+%d;%d;",i-5,i); - plot(y*4000/pi,x,legend); - endfor - hold off; - grid; - - % LSP differences - - figure(2); - clf; - subplot(211) - [x,y] = hist(lsp(:,1),100); - plot(y*4000/pi,x,"1;1;"); - hold on; - for i=2:5 - [x,y] = hist(lsp(:,i) - lsp(:,i-1),100); - legend = sprintf("%d;%d;",i,i); - plot(y*4000/pi,x,legend); - endfor - hold off; - grid; - - subplot(212) - [x,y] = hist(lsp(:,6)-lsp(:,5),100); - plot(y*4000/pi,x,"1;6;"); - hold on; - for i=7:c - [x,y] = hist(lsp(:,i) - lsp(:,i-1),100); - legend = sprintf("%d;%d;",i-5,i); - plot(y*4000/pi,x,legend); - endfor - hold off; - grid; - - % LSP differences delta from last frame - - lspd(:,1) = lsp(:,1); - lspd(:,2:10) = lsp(:,2:10) - lsp(:,1:9); - - [m,n] = size(lspd); - lspdd = lspd(5:m,:) - lspd(1:m-4,:); - - figure(3); - clf; - subplot(211) - for i=1:5 - [x,y] = hist(lspdd(:,i),100); - legend = sprintf("%d;%d;",i,i); - plot(y*4000/pi,x,legend); - hold on; - endfor - hold off; - grid; - axis([-200 200 0 35000]); - - subplot(212) - for i=6:10 - [x,y] = hist(lspdd(:,i),100); - legend = sprintf("%d;%d;",i-5,i); - plot(y*4000/pi,x,legend); - hold on; - endfor - hold off; - grid; - axis([-200 200 0 16000]); - - figure(4); - clf; - plot((4000/pi)*(lsp(2:r,3)-lsp(1:r-1,3))) -endfunction diff --git a/codec2/octave/lspwarp.m b/codec2/octave/lspwarp.m deleted file mode 100644 index 2d2f2c99..00000000 --- a/codec2/octave/lspwarp.m +++ /dev/null @@ -1,40 +0,0 @@ -% lspwarp.m -% David Rowe Sep 2012 -% -% Experimenting with non-linear LSP frequency axis for LSP quantisation -% Plots a scaled mel axis. - -1; - -function mel = freq2mel(f) - mel = 70*log10(1 + f/700); -endfunction - -function freq = mel2freq(m) - freq = 700*(10 ^ (m/70) - 1); -endfunction - -x = []; y = []; - -for freq = 100:25:4000 - mel = freq2mel(freq); - x = [x freq]; - y = [y mel]; -end - -plot(x,y) -grid - -mel_start = floor(freq2mel(100)); -mel_end = floor(freq2mel(4000)); - -x = []; y = []; -for mel=mel_start:mel_end - freq = mel2freq(mel); - x = [x freq]; - y = [y mel]; -end - -hold on; -plot(x,y, '+') -hold off; diff --git a/codec2/octave/phase.m b/codec2/octave/phase.m deleted file mode 100644 index f9735903..00000000 --- a/codec2/octave/phase.m +++ /dev/null @@ -1,56 +0,0 @@ -% phase.m -% David Rowe August 2009 -% experiments with phase for sinusoidal codecs - -function phase(samname, F0, png) - Wo=2*pi*F0/8000; - P=2*pi/Wo; - L = floor(pi/Wo); - Nsam = 16000; - N = 80; - F = Nsam/N; - A = 10000/L; - phi = zeros(1,L); - s = zeros(1,Nsam); - - for m=floor(L/2):L - phi_off(m) = -m*Wo*8; - end - - for f=1:F - phi(1) = phi(1) + Wo*N; - phi(1) = mod(phi(1),2*pi); - - for m=1:L - phi(m) = m*phi(1); - end - - x = zeros(1,N); - for m=1:L - x = x + A*cos(m*Wo*(0:(N-1)) + phi(m)); - endfor - s((f-1)*N+1:f*N) = x; - endfor - - figure(1); - clf; - plot(s(1:250)); - - fs=fopen(samname,"wb"); - fwrite(fs,s,"short"); - fclose(fs); - - if (nargin == 3) - % small image to fit blog - - __gnuplot_set__ terminal png size 450,300 - ss = sprintf("__gnuplot_set__ output \"%s.png\"", samname); - eval(ss) - replot; - - % for some reason I need this to stop large plot getting wiped - __gnuplot_set__ output "/dev/null" - endif - -endfunction - diff --git a/codec2/octave/phase2.m b/codec2/octave/phase2.m deleted file mode 100644 index 5c148f38..00000000 --- a/codec2/octave/phase2.m +++ /dev/null @@ -1,57 +0,0 @@ -% phase2.m -% David Rowe Sep 2009 -% experiments with phase for sinusoidal codecs, looking at phase -% of excitation with real Am samples from hts1 - -function phase2(samname, png) - N = 16000; - - f=43; - model = load("../src/hts1a_phase_model.txt"); - phase = load("../src/hts1a_phase_phase.txt"); - Wo = model(f,1); - P=2*pi/Wo; - L = model(f,2); - A = model(f,3:(L+2)); - phi = phase(f,1:L); - phi = zeros(1,L); - phi(3) = -pi/2; - phi(4) = -pi/4; - phi(5) = pi/2; - - s = zeros(1,N); - - for m=3:5 - s_m = A(m)*cos(m*Wo*(0:(N-1)) + phi(m)); - s = s + s_m; - endfor - - figure(1); - clf; - plot(s(1:250)); - - figure(2); - clf; - subplot(211) - plot((1:L)*Wo*4000/pi, 20*log10(A),'+'); - subplot(212) - plot((1:L)*Wo*4000/pi, phi,'+'); - - fs=fopen(samname,"wb"); - fwrite(fs,s,"short"); - fclose(fs); - - if (nargin == 2) - % small image to fit blog - - __gnuplot_set__ terminal png size 450,300 - ss = sprintf("__gnuplot_set__ output \"%s.png\"", samname); - eval(ss) - replot; - - % for some reason I need this to stop large plot getting wiped - __gnuplot_set__ output "/dev/null" - endif - -endfunction - diff --git a/codec2/octave/phasesecord.m b/codec2/octave/phasesecord.m deleted file mode 100644 index a3cf2516..00000000 --- a/codec2/octave/phasesecord.m +++ /dev/null @@ -1,47 +0,0 @@ -% phasesecord.m -% David Rowe Aug 2012 -% Used to experiment with aproximations of phase of 2nd order systems - -function phasesecord(w,beta) - - a = [1 -2*cos(w)*beta beta*beta]; - b = 1; - - [h w1] = freqz(b,a); - - figure(1) - subplot(211) - plot(abs(h)) - subplot(212) - plot(angle(h)) - - % for beta close to 1, we approximate 3 dB points as 1-beta above - % and below the resonance freq. Note this fails if w=0 as there is a - % double pole. Lets sample the freq response at the 3dB points and - % w: - - ws = [w-(1-beta) w w+(1-beta)]; - [h w1] = freqz(b,a,ws); - - % gain as a fraction of max, should be 3dB. Within 1.3 dB or for w > pi/8, - % gets innacurate near w=0 due to 2nd pole - - printf("mag measured...:"); printf("% 4.3f ", abs(h)/max(abs(h))); - - % measured angle, 45 deg from angle at w - - printf("\nangle measured.: "); printf("% 5.3f ", angle(h)); - - % Our estimate of angle, (pi+w) is phase at resonance, at lower 3dB - % phase is pi/4 ahead, at upper 3B pi/4 behind. -pi/2 is contribution of - % other pole at at -w to phase - - ph_lower = (pi+w) + pi/4 - pi/2; - ph_res =(pi+w) - pi/2; - ph_upper = (pi+w) - pi/4 - pi/2; - ph_ests = [ph_lower ph_res ph_upper]; - ph_ests = ph_ests - 2*pi*(floor(ph_ests/(2*pi)) + 0.5); - printf("\nangle estimated:"); printf("% 5.3f ", ph_ests); - printf("\n"); -endfunction - diff --git a/codec2/octave/pitch_test.m b/codec2/octave/pitch_test.m deleted file mode 100644 index 3fe0d1ad..00000000 --- a/codec2/octave/pitch_test.m +++ /dev/null @@ -1,39 +0,0 @@ -% pitch_test.m -% David Rowe Sep 2009 -% Constructs a sequence to test the pitch estimator - -function pitch_test(samname) - M=320; - F=200; - - fs=fopen(samname,"wb"); - - f0 = 100; - for f=1:200 - Wo=2*pi*f0/8000; - P=2*pi/Wo; - L = floor(pi/Wo); - A = 10000/L; - phi = zeros(1,L); - s = zeros(1,M); - - for m=1:L - s = s + A*cos(m*Wo*(0:(M-1)) + phi(m)); - endfor - - figure(1); - clf; - plot(s); - - fwrite(fs,s,"short"); - - f0 = f0 + 5; - if (f0 > 400) - f0 = 100; - endif - endfor - - fclose(fs); - -endfunction - diff --git a/codec2/octave/pl.m b/codec2/octave/pl.m deleted file mode 100644 index 0d547882..00000000 --- a/codec2/octave/pl.m +++ /dev/null @@ -1,45 +0,0 @@ -% Copyright David Rowe 2009 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% -% Plots a raw speech sample file, you can optionally specify the start and end -% samples and create a large and small PNGs - -function pl(samname1, start_sam, end_sam, pngname) - - fs=fopen(samname1,"rb"); - s=fread(fs,Inf,"short"); - - st = 1; - en = length(s); - if (nargin >= 2) - st = start_sam; - endif - if (nargin >= 3) - en = end_sam; - endif - - figure(1); - clf; - plot(s(st:en)); - axis([1 en-st 1.1*min(s) 1.1*max(s)]); - - if (nargin == 4) - - % small image - - __gnuplot_set__ terminal png size 420,300 - ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname); - eval(ss) - replot; - - % larger image - - __gnuplot_set__ terminal png size 800,600 - ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname); - eval(ss) - replot; - - endif - -endfunction diff --git a/codec2/octave/pl2.m b/codec2/octave/pl2.m deleted file mode 100644 index 17671c08..00000000 --- a/codec2/octave/pl2.m +++ /dev/null @@ -1,41 +0,0 @@ -% Copyright David Rowe 2009 -% This program is distributed under the terms of the GNU General Public License -% Version 2 - -function pl2(samname1, samname2, start_sam, end_sam, offset) - - fs1=fopen(samname1,"rb"); - s1=fread(fs1,Inf,"short"); - fs2=fopen(samname2,"rb"); - s2=fread(fs2,Inf,"short"); - - st1 = st2 = 1; - en1 = en2 = length(s1); - if (nargin >= 3) - st1 = st2 = start_sam; - endif - if (nargin >= 4) - en1 = en2 = end_sam; - endif - - if (nargin == 5) - st2 += offset - en2 += offset - endif - - figure(1); - clf; - subplot(211); - l1 = strcat("r;",samname1,";"); - plot(s1(st1:en1), l1); - axis([1 en1-st1 min(s1(st1:en1)) max(s1(st1:en1))]); - subplot(212); - l2 = strcat("r;",samname2,";"); - plot(s2(st2:en2),l2); - axis([1 en2-st2 min(s1(st2:en2)) max(s1(st2:en2))]); - - figure(2) - plot(s1(st1:en1)-s2(st2:en2)); - - -endfunction diff --git a/codec2/octave/plamp.m b/codec2/octave/plamp.m deleted file mode 100644 index 62b6893a..00000000 --- a/codec2/octave/plamp.m +++ /dev/null @@ -1,197 +0,0 @@ -% Copyright David Rowe 2009 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% -% Plot ampltiude modelling information from dump files. - -function plamp(samname, f, samname2) - - % switch some stuff off to unclutter display - - plot_lsp = 0; - plot_snr = 0; - plot_vsnr = 0; - plot_sw = 0; - plot_pw = 0; - - sn_name = strcat(samname,"_sn.txt"); - Sn = load(sn_name); - - sw_name = strcat(samname,"_sw.txt"); - Sw = load(sw_name); - - sw__name = strcat(samname,"_sw_.txt"); - if (file_in_path(".",sw__name)) - Sw_ = load(sw__name); - endif - - ew_name = strcat(samname,"_ew.txt"); - if (file_in_path(".",ew_name)) - Ew = load(ew_name); - endif - - rk_name = strcat(samname,"_rk.txt"); - if (file_in_path(".",rk_name)) - Rk = load(rk_name); - endif - - model_name = strcat(samname,"_model.txt"); - model = load(model_name); - - modelq_name = strcat(samname,"_qmodel.txt"); - if (file_in_path(".",modelq_name)) - modelq = load(modelq_name); - endif - - pw_name = strcat(samname,"_pw.txt"); - if (file_in_path(".",pw_name)) - Pw = load(pw_name); - endif - - lsp_name = strcat(samname,"_lsp.txt"); - if (file_in_path(".",lsp_name)) - lsp = load(lsp_name); - endif - - phase_name = strcat(samname,"_phase.txt"); - if (file_in_path(".",phase_name)) - phase = load(phase_name); - endif - - phase_name_ = strcat(samname,"_phase_.txt"); - if (file_in_path(".",phase_name_)) - phase_ = load(phase_name_); - endif - - snr_name = strcat(samname,"_snr.txt"); - if (file_in_path(".",snr_name)) - snr = load(snr_name); - endif - - % optional second file, for exploring post filter - - model2q_name = " "; - if nargin == 3 - model2q_name = strcat(samname2,"_qmodel.txt"); - if file_in_path(".",modelq_name) - model2q = load(model2q_name); - end - end - - Ew_on = 1; - k = ' '; - do - figure(1); - clf; -% s = [ Sn(2*(f-2)-1,:) Sn(2*(f-2),:) ]; - s = [ Sn(2*f-1,:) Sn(2*f,:) ]; - size(s); - plot(s); - axis([1 length(s) -20000 20000]); - - figure(2); - Wo = model(f,1); - L = model(f,2); - Am = model(f,3:(L+2)); - plot((1:L)*Wo*4000/pi, 20*log10(Am),";Am;r"); - axis([1 4000 -10 80]); - hold on; - if plot_sw - plot((0:255)*4000/256, Sw(f,:),";Sw;"); - end - - if (file_in_path(".",modelq_name)) - Amq = modelq(f,3:(L+2)); - plot((1:L)*Wo*4000/pi, 20*log10(Amq),";Amq;g" ); - if (file_in_path(".",pw_name) && plot_pw) - plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;c"); - endif - signal = Am * Am'; - noise = (Am-Amq) * (Am-Amq)'; - snr1 = 10*log10(signal/noise); - Am_err_label = sprintf(";Am error SNR %4.2f dB;m",snr1); - plot((1:L)*Wo*4000/pi, 20*log10(Amq) - 20*log10(Am), Am_err_label); - endif - - if file_in_path(".",model2q_name) - Amq2 = model2q(f,3:(L+2)); - plot((1:L)*Wo*4000/pi, 20*log10(Amq2),";Amq2;m" ); - end - - if (file_in_path(".",snr_name) && plot_vsnr) - snr_label = sprintf(";Voicing SNR %4.2f dB;",snr(f)); - plot(1,1,snr_label); - endif - - % phase model - determine SNR and error spectrum for phase model 1 - - if (file_in_path(".",phase_name_)) - orig = Am.*exp(j*phase(f,1:L)); - synth = Am.*exp(j*phase_(f,1:L)); - signal = orig * orig'; - noise = (orig-synth) * (orig-synth)'; - snr_phase = 10*log10(signal/noise); - - %phase_err_label = sprintf(";phase_err SNR %4.2f dB;",snr_phase); - %plot((1:L)*Wo*4000/pi, 20*log10(orig-synth), phase_err_label); - endif - - if (file_in_path(".",lsp_name) && plot_lsp) - for l=1:10 - plot([lsp(f,l)*4000/pi lsp(f,l)*4000/pi], [60 80], 'r'); - endfor - endif - - hold off; - - %if (file_in_path(".",phase_name)) - %figure(3); - %plot((1:L)*Wo*4000/pi, phase(f,1:L), ";phase;"); - %axis; - %if (file_in_path(".",phase_name_)) - %hold on; - %plot((1:L)*Wo*4000/pi, phase_(f,1:L), ";phase_;"); - %hold off; - %endif - %figure(2); - %endif - - % interactive menu - - printf("\rframe: %d menu: n-next b-back p-png q-quit e-toggle Ew", f); - fflush(stdout); - k = kbhit(); - if (k == 'n') - f = f + 1; - endif - if (k == 'b') - f = f - 1; - endif - if (k == 'e') - if (Ew_on == 1) - Ew_on = 0; - else - Ew_on = 1; - endif - endif - - % optional print to PNG - - if (k == 'p') - figure(1); - pngname = sprintf("%s_%d_sn.png",samname,f); - print(pngname, '-dpng', "-S500,500") - pngname = sprintf("%s_%d_sn_large.png",samname,f); - print(pngname, '-dpng', "-S800,600") - - figure(2); - pngname = sprintf("%s_%d_sw.png",samname,f); - print(pngname, '-dpng', "-S500,500") - pngname = sprintf("%s_%d_sw_large.png",samname,f); - print(pngname, '-dpng', "-S1200,800") - endif - - until (k == 'q') - printf("\n"); - -endfunction diff --git a/codec2/octave/plinterp.m b/codec2/octave/plinterp.m deleted file mode 100644 index 794a0853..00000000 --- a/codec2/octave/plinterp.m +++ /dev/null @@ -1,11 +0,0 @@ -load ../unittest/tinterp_prev.txt; -load ../unittest/tinterp_interp.txt; -load ../unittest/tinterp_next.txt; - -clf; -plot(tinterp_prev(:,1), 20.0*log10(tinterp_prev(:,2)),";prev;") -hold on; -plot(tinterp_interp(:,1), 20.0*log10(tinterp_interp(:,2)),'g+-;interp;') -plot(tinterp_next(:,1), 20.0*log10(tinterp_next(:,2)),'ro-;next;') -hold off; -axis([0 pi 0 80]) diff --git a/codec2/octave/pllpcpf.m b/codec2/octave/pllpcpf.m deleted file mode 100644 index 924e045a..00000000 --- a/codec2/octave/pllpcpf.m +++ /dev/null @@ -1,150 +0,0 @@ -% Copyright David Rowe 2012 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% -% Plot amplitude modelling information from dump files to test and develop -% LPC post filter. - -function pllpcpf(samname, f) - - % switch some stuff off to unclutter display - - plot_Am = 0; - plot_Amq = 0; - plot_err = 0; - plot_lsp = 0; - plot_snr = 0; - plot_vsnr = 0; - plot_sw = 0; - plot_pw = 1; - plot_pwb = 1; - plot_rw = 1; - - sn_name = strcat(samname,"_sn.txt"); - Sn = load(sn_name); - - sw_name = strcat(samname,"_sw.txt"); - Sw = load(sw_name); - - sw__name = strcat(samname,"_sw_.txt"); - if (file_in_path(".",sw__name)) - Sw_ = load(sw__name); - endif - - model_name = strcat(samname,"_model.txt"); - model = load(model_name); - - modelq_name = strcat(samname,"_qmodel.txt"); - if (file_in_path(".",modelq_name)) - modelq = load(modelq_name); - endif - - % Pw (LPC synth filter spectrum) before post filter - - pwb_name = strcat(samname,"_pwb.txt"); - if (file_in_path(".",pwb_name)) - Pwb = load(pwb_name); - endif - - % Rw (Post filter spectrum) - - rw_name = strcat(samname,"_rw.txt"); - if (file_in_path(".",rw_name)) - Rw = load(rw_name); - endif - - % Pw (LPC synth filter spectrum) after post filter - - pw_name = strcat(samname,"_pw.txt"); - if (file_in_path(".",pw_name)) - Pw = load(pw_name); - endif - - - Ew_on = 1; - k = ' '; - do - figure(1); - clf; - s = [ Sn(2*f-1,:) Sn(2*f,:) ]; - size(s); - plot(s); - axis([1 length(s) -20000 20000]); - - figure(2); - clf; - Wo = model(f,1); - L = model(f,2); - Am = model(f,3:(L+2)); - if plot_Am - plot((1:L)*Wo*4000/pi, 20*log10(Am),";Am;r"); - end - axis([1 4000 -10 80]); - hold on; - if plot_sw - plot((0:255)*4000/256, Sw(f,:),";Sw;"); - end - - if (file_in_path(".",modelq_name)) - - Amq = modelq(f,3:(L+2)); - if plot_Amq - plot((1:L)*Wo*4000/pi, 20*log10(Amq),";Amq;g" ); - end - - if (file_in_path(".",pwb_name) && plot_pwb) - plot((0:255)*4000/256, 10*log10(Pwb(f,:)),";Pwb;r"); - endif - - if (file_in_path(".",rw_name) && plot_rw) - plot((0:255)*4000/256, 10*log10(Rw(f,:)),";Rw;b"); - endif - - if (file_in_path(".",pw_name) && plot_pw) - plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;g."); - endif - - signal = Am * Am'; - noise = (Am-Amq) * (Am-Amq)'; - snr1 = 10*log10(signal/noise); - Am_err_label = sprintf(";Am error SNR %4.2f dB;m",snr1); - if plot_err - plot((1:L)*Wo*4000/pi, 20*log10(Amq) - 20*log10(Am), Am_err_label); - end - endif - - - hold off; - - % interactive menu - - printf("\rframe: %d menu: n-next b-back p-png q-quit", f); - fflush(stdout); - k = kbhit(); - if (k == 'n') - f = f + 1; - endif - if (k == 'b') - f = f - 1; - endif - - % optional print to PNG - - if (k == 'p') - figure(1); - pngname = sprintf("%s_%d_sn.png",samname,f); - print(pngname, '-dpng', "-S500,500") - pngname = sprintf("%s_%d_sn_large.png",samname,f); - print(pngname, '-dpng', "-S800,600") - - figure(2); - pngname = sprintf("%s_%d_sw.png",samname,f); - print(pngname, '-dpng', "-S500,500") - pngname = sprintf("%s_%d_sw_large.png",samname,f); - print(pngname, '-dpng', "-S1200,800") - endif - - until (k == 'q') - printf("\n"); - -endfunction diff --git a/codec2/octave/pllsp.m b/codec2/octave/pllsp.m deleted file mode 100644 index 0606d3ca..00000000 --- a/codec2/octave/pllsp.m +++ /dev/null @@ -1,46 +0,0 @@ -% Copyright David Rowe 2010 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% -% Plots a bunch of information related to LSP quantisation: -% - speech file -% - LSPs before and after quantisation -% - SNR for each frame -% -% Note: there is a 160 sample (two frame delay) from the when a sample -% enters the input buffer until it is at the centre of the analysis window - -function pllsp(rawfile, - dumpfile_prefix_lpc_only, - dumpfile_prefix_lsp, - start_f, end_f) - - fs=fopen(rawfile,"rb"); - s=fread(fs,Inf,"short"); - - lpc_snr_name = strcat(dumpfile_prefix_lpc_only,"_lpc_snr.txt"); - lpc10_snr = load(lpc_snr_name); - lpc_snr_name = strcat(dumpfile_prefix_lsp,"_lpc_snr.txt"); - lsp_snr = load(lpc_snr_name); - - lsp_name = strcat(dumpfile_prefix_lsp,"_lsp.txt"); - lsps = load(lsp_name); - [m,n]=size(lsps); - lsp = lsps(1:2:m,:); - lsp_ = lsps(2:2:m,:); - - figure(1); - clf; - subplot(211); - sp = s((start_f-2)*80:(end_f-2)*80); - plot(sp); - - subplot(212); - plot(lpc10_snr((start_f+1):end_f)-lsp_snr((start_f+1):end_f)); - - figure(2); - plot((4000/pi)*lsp((start_f+1):end_f,:)); - hold on; - plot((4000/pi)*lsp_((start_f+1):end_f,:),'+-'); - hold off; -endfunction diff --git a/codec2/octave/pllspdt.m b/codec2/octave/pllspdt.m deleted file mode 100644 index c711aa46..00000000 --- a/codec2/octave/pllspdt.m +++ /dev/null @@ -1,27 +0,0 @@ -% pllspdt.m -% Copyright David Rowe 2010 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% -% Test script to plot differences in LSps between frames - -function pllspdt(rawfile,dumpfile_prefix_lsp,lspn, start_f, end_f) - - fs=fopen(rawfile,"rb"); - s=fread(fs,Inf,"short"); - - lsp_name = strcat(dumpfile_prefix_lsp,"_lsp.txt"); - lsps = load(lsp_name); - [m,n]=size(lsps); - lsp = lsps(1:2:m,:); - lsp_ = lsps(2:2:m,:); - lspdt = lsp(2:m/2,:) - lsp(1:m/2-1,:); - - figure(1); - clf; - sp = s((start_f-2)*80:(end_f-2)*80); - plot(sp); - - figure(2); - plot((4000/pi)*lspdt((start_f+1):end_f,lspn)); -endfunction diff --git a/codec2/octave/plnlp.m b/codec2/octave/plnlp.m deleted file mode 100644 index 01b49311..00000000 --- a/codec2/octave/plnlp.m +++ /dev/null @@ -1,134 +0,0 @@ -% Copyright David Rowe 2009 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% -% Plot NLP states from dump files. - -function plnlp(samname, f) - - sn_name = strcat(samname,"_sn.txt"); - Sn = load(sn_name); - - sw_name = strcat(samname,"_sw.txt"); - Sw = load(sw_name); - - fw_name = strcat(samname,"_fw.txt"); - if (file_in_path(".",fw_name)) - fw = load(fw_name); - endif - - e_name = strcat(samname,"_e.txt"); - if (file_in_path(".",e_name)) - e = load(e_name); - endif - - p_name = strcat(samname,".p"); - if (file_in_path(".",p_name)) - p = load(p_name); - endif - - sq_name = strcat(samname,"_sq.txt"); - if (file_in_path(".",sq_name)) - sq = load(sq_name); - endif - - dec_name = strcat(samname,"_dec.txt"); - if (file_in_path(".",dec_name)) - dec = load(dec_name); - endif - - do - figure(1); - clf; - s = [ Sn(2*f-1,:) Sn(2*f,:) ]; - plot(s, ";Sn;"); - grid - axis([1 length(s) -20000 20000]); - - figure(2); - plot((0:255)*4000/256, Sw(f,:),";Sw;"); - grid - axis([1 4000 -10 80]); - hold on; - - f0 = 8000/p(f); - Wo = 2*pi/p(f); - L = floor(pi/Wo); - f0_label = sprintf("b;P=%3.1f F0=%3.0f;",p(f),f0); - for m=1:L-1 - plot([ m*Wo*4000/pi m*Wo*4000/pi], [10 60], 'b'); - endfor - plot([ L*Wo*4000/pi L*Wo*4000/pi], [10 60], f0_label); - - hold off; - - if (file_in_path(".",fw_name)) - figure(3); - if (file_in_path(".",e_name)) - subplot(211); - endif - plot((0:255)*800/256, fw(f,:)/max(fw(f,:)), ";Fw;"); - axis([1 400 0 1]); - if (file_in_path(".",e_name)) - subplot(212); - e_concat = [ e(2*f-1,:) e(2*f,:) ]; - plot(e_concat(1:400)/max(e_concat(1:400)), "+;MBE E(f);"); - axis([1 400 0 1]); - endif - endif - - if (file_in_path(".",sq_name)) - figure(4); - sq_concat = [ sq(2*f-1,:) sq(2*f,:) ]; - axis - plot(sq_concat, ";sq;"); - endif - - if (file_in_path(".",dec_name)) - figure(5); - plot(dec(f,:), ";dec;"); - endif - - figure(2); - - % interactive menu - - printf("\rframe: %d menu: n-next b-back p-png q-quit ", f); - fflush(stdout); - k = kbhit(); - if (k == 'n') - f = f + 1; - endif - if (k == 'b') - f = f - 1; - endif - - % optional print to PNG - - if (k == 'p') - - pngname = sprintf("%s_%d",samname,f); - - % small image - - __gnuplot_set__ terminal png size 420,300 - ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname); - eval(ss) - replot; - - % larger image - - __gnuplot_set__ terminal png size 800,600 - ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname); - eval(ss) - replot; - - % for some reason I need this to stop large plot getting wiped - __gnuplot_set__ output "/dev/null" - - endif - - until (k == 'q') - printf("\n"); - -endfunction diff --git a/codec2/octave/plphase.m b/codec2/octave/plphase.m deleted file mode 100644 index c12422ea..00000000 --- a/codec2/octave/plphase.m +++ /dev/null @@ -1,198 +0,0 @@ -% Copyright David Rowe 2009 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% -% Plot phase modelling information from dump files. - -function plphase(samname, f) - - sn_name = strcat(samname,"_sn.txt"); - Sn = load(sn_name); - - sw_name = strcat(samname,"_sw.txt"); - Sw = load(sw_name); - - model_name = strcat(samname,"_model.txt"); - model = load(model_name); - - sw__name = strcat(samname,"_sw_.txt"); - if (file_in_path(".",sw__name)) - Sw_ = load(sw__name); - endif - - pw_name = strcat(samname,"_pw.txt"); - if (file_in_path(".",pw_name)) - Pw = load(pw_name); - endif - - ak_name = strcat(samname,"_ak.txt"); - if (file_in_path(".",ak_name)) - ak = load(ak_name); - endif - - phase_name = strcat(samname,"_phase.txt"); - if (file_in_path(".",phase_name)) - phase = load(phase_name); - endif - - phase_name_ = strcat(samname,"_phase_.txt"); - if (file_in_path(".",phase_name_)) - phase_ = load(phase_name_); - endif - - snr_name = strcat(samname,"_snr.txt"); - if (file_in_path(".",snr_name)) - snr = load(snr_name); - endif - - sn_name_ = strcat(samname,".raw"); - if (file_in_path(".",sn_name_)) - fs_ = fopen(sn_name_,"rb"); - sn_ = fread(fs_,Inf,"short"); - endif - - k = ' '; - do - figure(1); - clf; - s = [ Sn(2*f-1,:) Sn(2*f,:) ]; - plot(s); - grid; - axis([1 length(s) -20000 20000]); - if (k == 'p') - pngname = sprintf("%s_%d_sn",samname,f); - png(pngname); - endif - - figure(2); - Wo = model(f,1); - L = model(f,2); - Am = model(f,3:(L+2)); - plot((1:L)*Wo*4000/pi, 20*log10(Am),"r;Am;"); - axis([1 4000 -10 80]); - hold on; - plot((0:255)*4000/256, Sw(f,:),";Sw;"); - grid; - - if (file_in_path(".",sw__name)) - plot((0:255)*4000/256, Sw_(f,:),"g;Sw_;"); - endif - - if (file_in_path(".",pw_name)) - plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;"); - endif - - if (file_in_path(".",snr_name)) - snr_label = sprintf(";phase SNR %4.2f dB;",snr(f)); - plot(1,1,snr_label); - endif - - % phase model - determine SNR and error spectrum for phase model 1 - - if (file_in_path(".",phase_name_)) - orig = Am.*exp(j*phase(f,1:L)); - synth = Am.*exp(j*phase_(f,1:L)); - signal = orig * orig'; - noise = (orig-synth) * (orig-synth)'; - snr_phase = 10*log10(signal/noise); - - phase_err_label = sprintf("g;phase_err SNR %4.2f dB;",snr_phase); - plot((1:L)*Wo*4000/pi, 20*log10(orig-synth), phase_err_label); - endif - - hold off; - if (k == 'p') - pngname = sprintf("%s_%d_sw",samname,f); - png(pngname); - endif - - if (file_in_path(".",phase_name)) - figure(3); - plot((1:L)*Wo*4000/pi, phase(f,1:L)*180/pi, "-o;phase;"); - axis; - if (file_in_path(".", phase_name_)) - hold on; - plot((1:L)*Wo*4000/pi, phase_(f,1:L)*180/pi, "g;phase after;"); - grid - hold off; - endif - if (k == 'p') - pngname = sprintf("%s_%d_phase",samname,f); - png(pngname); - endif - endif - - % synthesised speech - - if (file_in_path(".",sn_name_)) - figure(4); - s_ = sn_((f-3)*80+1:(f+1)*80); - plot(s_); - axis([1 length(s_) -20000 20000]); - if (k == 'p') - pngname = sprintf("%s_%d_sn_",samname,f) - png(pngname); - endif - endif - - if (file_in_path(".",ak_name)) - figure(5); - axis; - akw = ak(f,:); - weight = 1.0 .^ (0:length(akw)-1); - akw = akw .* weight; - H = 1./fft(akw,8000); - subplot(211); - plot(20*log10(abs(H(1:4000))),";LPC mag spec;"); - grid; - subplot(212); - plot(angle(H(1:4000))*180/pi,";LPC phase spec;"); - grid; - if (k == 'p') - % stops multimode errors from gnuplot, I know not why... - figure(2); - figure(5); - - pngname = sprintf("%s_%d_lpc",samname,f); - png(pngname); - endif - endif - - - % autocorrelation function to research voicing est - - %M = length(s); - %sw = s .* hanning(M)'; - %for k=0:159 - % R(k+1) = sw(1:320-k) * sw(1+k:320)'; - %endfor - %figure(4); - %R_label = sprintf(";R(k) %3.2f;",max(R(20:159))/R(1)); - %plot(R/R(1),R_label); - %grid - - figure(2); - - % interactive menu - - printf("\rframe: %d menu: n-next b-back p-png q-quit ", f); - fflush(stdout); - k = kbhit(); - if (k == 'n') - f = f + 1; - endif - if (k == 'b') - f = f - 1; - endif - - % optional print to PNG - - if (k == 'p') - pngname = sprintf("%s_%d",samname,f); - png(pngname); - endif - - until (k == 'q') - printf("\n"); - -endfunction diff --git a/codec2/octave/plpitch.m b/codec2/octave/plpitch.m deleted file mode 100644 index 69ad5338..00000000 --- a/codec2/octave/plpitch.m +++ /dev/null @@ -1,36 +0,0 @@ -% Copyright David Rowe 2009 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% -% plpitch.m -% Plots two pitch tracks on top of each other, used for comparing pitch -% estimators - -function plpitch(pitch1_name, pitch2_name, start_fr, end_fr) - - pitch1 = load(pitch1_name); - pitch2 = load(pitch2_name); - - st = 1; - en = length(pitch1); - if (nargin >= 3) - st = start_fr; - endif - if (nargin >= 4) - en = end_fr; - endif - - figure(1); - clf; - l1 = strcat("r;",pitch1_name,";") - l1 - st - en - plot(pitch1(st:en), l1); - axis([1 en-st 20 160]); - l2 = strcat("g;",pitch2_name,";"); - hold on; - plot(pitch2(st:en),l2); - hold off; -endfunction - diff --git a/codec2/octave/plppe.m b/codec2/octave/plppe.m deleted file mode 100644 index cbc5b562..00000000 --- a/codec2/octave/plppe.m +++ /dev/null @@ -1,65 +0,0 @@ -% Copyright David Rowe 2009 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% -% Plot two sparse phase prediction error text files. -% Generate data from print_pred_error, print_pred_error_sparse_wo_correction1 etc - -function plppe(ppe1_file, ppe2_file, f) - - ppe1 = load(ppe1_file); - ppe2 = load(ppe2_file); - - std1 = std(nonzeros(ppe1(:,40:80))); - std2 = std(nonzeros(ppe2(:,40:80))); - - printf("std dev for %s is %4.3f\n", ppe1_file, std1); - printf("std dev for %s is %4.3f\n", ppe2_file, std2); - - figure(1); - clf; - subplot(211) - hist(nonzeros(ppe1(:,40:80)),20); - subplot(212) - hist(nonzeros(ppe2(:,40:80)),20); - - k = ' '; - do - figure(2); - clf; - subplot(211) - L = length(nonzeros(ppe1(f,:))); - x = (1:L)*4000/L; - std1 = std(nonzeros(ppe1(f,:))); - legend = sprintf(";std dev %4.3f;", std1); - plot(x, nonzeros(ppe1(f,:)),legend); - axis([0 4000 -pi pi]); - subplot(212) - std2 = std(nonzeros(ppe2(f,:))); - legend = sprintf(";std dev %4.3f;", std2); - plot(x, nonzeros(ppe2(f,:)),legend); - axis([0 4000 -pi pi]); - - % interactive menu - - printf("\rframe: %d menu: n-next b-back p-png q-quit ", f); - fflush(stdout); - k = kbhit(); - if (k == 'n') - f = f + 1; - endif - if (k == 'b') - f = f - 1; - endif - - % optional print to PNG - - if (k == 'p') - pngname = sprintf("%s_%d",samname,f); - png(pngname); - endif - - until (k == 'q') - printf("\n"); - -endfunction diff --git a/codec2/octave/plsub.m b/codec2/octave/plsub.m deleted file mode 100644 index 6e2bc1ea..00000000 --- a/codec2/octave/plsub.m +++ /dev/null @@ -1,35 +0,0 @@ -% Copyright David Rowe 2010 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% plots the difference of two files - -function plsub(samname1, samname2, start_sam, end_sam, pngname) - - fs1=fopen(samname1,"rb"); - s1=fread(fs1,Inf,"short"); - fs2=fopen(samname2,"rb"); - s2=fread(fs2,Inf,"short"); - - st = 1; - en = length(s1); - if (nargin >= 3) - st = start_sam; - endif - if (nargin >= 4) - en = end_sam; - endif - - figure(1); - clf; - l1 = strcat("r;",samname1,";"); - plot(s1(st:en) - s2(st:en), l1); - %axis([1 en-st min(s1(st:en)) max(s1(st:en))]); - - if (nargin == 5) - pngname = sprintf("%s.png",pngname); - print(pngname, '-dpng', "-S500,500") - pngname = sprintf("%s_large.png",pngname); - print(pngname, '-dpng', "-S800,600") - endif - -endfunction diff --git a/codec2/octave/plvoicing.m b/codec2/octave/plvoicing.m deleted file mode 100644 index a5317476..00000000 --- a/codec2/octave/plvoicing.m +++ /dev/null @@ -1,89 +0,0 @@ -% Copyright David Rowe 2009 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% -% Plot voicing information from sample and dump files. -% -% samfilename is the raw source file, e.g. "../raw/hts1a.raw" -% samname is the dumpfile prefix, e.g. "../src/hts1a" -% -% There is a 160 sample (two frame delay) from the when a sample -% enters the input buffer until it is at the centre of the analysis window - -function plvoicing(samfilename, samname, start_f, end_f, pngname) - - fs=fopen(samfilename,"rb"); - s=fread(fs,Inf,"short"); - - snr_name = strcat(samname,"_snr.txt"); - snr = load(snr_name); - model_name = strcat(samname,"_model.txt"); - model = load(model_name); - - Wo = model((start_f+1):end_f,1); - F0 = Wo*4000/pi; - dF0 = F0(1:length(Wo)-1) - F0(2:length(Wo)); - - % work out LP and HP energy - - for f=(start_f+1):end_f - L = model(f,2); - Am = model(f,3:(L+2)); - L2 = floor(L/2); - elow = Am(1:L2) * Am(1:L2)'; - ehigh = Am(L2:L) * Am(L2:L)'; - erat(f-(start_f+1)+1) = 10*log10(elow/ehigh); - endfor - - figure(1); - clf; - sp = s((start_f-2)*80:(end_f-2)*80); - plot(sp); - hold on; - vhigh = snr((start_f+1):end_f) > 7; - vlow = snr((start_f+1):end_f) > 4; - - % test correction based on erat - - vlowadj = vlow; - - for f=1:length(erat)-1 - if (vlow(f) == 0) - if (erat(f) > 10) - vlowadj(f) = 1; - endif - endif - if (vlow(f) == 1) - if (erat(f) < -10) - vlowadj(f) = 0; - endif - if (abs(dF0(f)) > 15) - vlowadj(f) = 0; - endif - endif - endfor - - x = 1:(end_f-start_f); - plot(x*80,snr((start_f+1):end_f)*1000,';SNRdB x 1000;g+'); - plot(x*80,-8000 + vhigh*2000,';7dB thresh;g'); - plot(x*80,-11000 + vlowadj*2000,';vlow with corr;g'); - plot(x*80,erat*1000,';elow/ehigh in dB;r'); - plot(x*80,-14000 + vlow*2000,';4dB thresh;r'); - hold off; - grid - if (nargin == 5) - print(pngname, "-dpng", "-S500,500") - endif - - figure(2) - Wo = model((start_f+1):end_f,1); - F0 = Wo*4000/pi; - dF0 = F0(1:length(Wo)-1) - F0(2:length(Wo)); - %plot(dF0,'+--') - %hold on; - %plot([ 1 length(dF0) ], [10 10] ,'r') - %plot([ 1 length(dF0) ], [-10 -10] ,'r') - %axis([1 length(dF0) -50 50]) - %hold off; - plot(F0,'+--') -endfunction diff --git a/codec2/octave/png.m b/codec2/octave/png.m deleted file mode 100644 index 09a79968..00000000 --- a/codec2/octave/png.m +++ /dev/null @@ -1,25 +0,0 @@ -% Copyright David Rowe 2009 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% -% Replot current plot as a png, generates small and large versions - -function png(pngname) - % small image - - __gnuplot_set__ terminal png size 420,300 - ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname); - eval(ss) - replot; - - % larger image - - __gnuplot_set__ terminal png size 800,600 - ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname); - eval(ss) - replot; - - % for some reason I need this to stop large plot getting wiped - __gnuplot_set__ output "/dev/null" - -endfunction diff --git a/codec2/octave/postfilter.m b/codec2/octave/postfilter.m deleted file mode 100644 index 84f7dfc7..00000000 --- a/codec2/octave/postfilter.m +++ /dev/null @@ -1,24 +0,0 @@ -% Copyright David Rowe 2009 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% -% Plot postfilter doing its thing - -function postfilter(samname) - p = load(samname); - figure(1); - plot(p(:,1),";energy;"); - hold on; - plot(p(:,2),";bg_est;"); - hold off; - grid; - pngname=sprintf("%s_postfilter_1", samname); - png(pngname); - - figure(2); - plot(p(:,3),";% unvoiced;"); - grid; - pngname=sprintf("%s_postfilter_2", samname); - png(pngname); -endfunction - diff --git a/codec2/octave/pulse.m b/codec2/octave/pulse.m deleted file mode 100644 index 223389e7..00000000 --- a/codec2/octave/pulse.m +++ /dev/null @@ -1,37 +0,0 @@ -% pulse.m -% David Rowe August 2009 -% -% Experiments with human pulse perception for sinusoidal codecs - -function pulse(samname) - - A = 1000; - K = 16000; - N = 80; - frames = K/N; - s = zeros(1,K); - - for f=1:frames - % lets try placing np random pulses in every frame - - P = 20 + (160-20)*rand(1,1); - Wo = 2*pi/P; - L = floor(pi/Wo); - sf = zeros(1,N); - for m=1:L/2:L - pos = floor(rand(1,1)*N)+1; - %pos = 50; - for l=m:m+L/2-1 - sf = sf + A*cos(l*Wo*((f-1)*N+1:f*N) - pos*l*Wo); - endfor - endfor - s((f-1)*N+1:f*N) = sf; - endfor - - plot(s(1:250)); - - fs=fopen(samname,"wb"); - fwrite(fs,s,"short"); - fclose(fs); -endfunction - diff --git a/codec2/octave/sd.m b/codec2/octave/sd.m deleted file mode 100644 index efff9061..00000000 --- a/codec2/octave/sd.m +++ /dev/null @@ -1,99 +0,0 @@ -% sd.m -% David Rowe Aug 2012 -% Plots the spectal distorion between twofiles of LPCs. Used for LSP -% quantisation tuning. - -function sd(raw_filename, dump_file_prefix, f) - - ak1_filename = sprintf("%s_ak.txt", dump_file_prefix); - ak2_filename = sprintf("%s_ak_.txt", dump_file_prefix); - ak1 = load(ak1_filename); - ak2 = load(ak2_filename); - - [ak1_r, ak1_c] = size(ak1); - [ak2_r, ak2_c] = size(ak1); - - frames = max([ak1_r ak2_r]); - sd = zeros(1,frames); - Ndft = 512; - A1 = zeros(frames, Ndft); - A2 = zeros(frames, Ndft); - - % initial helicopter view of all frames - - for i = 1:frames - A1(i,:) = -20*log10(abs(fft(ak1(i,:),Ndft))); - A2(i,:) = -20*log10(abs(fft(ak2(i,:),Ndft))); - sd(i) = sum((A1(i,:) - A2(i,:)).^2)/Ndft; - end - printf("sd av %3.2f dB*dB\n", sum(sd)/frames); - - figure(1); - clf; - subplot(211) - fs=fopen(raw_filename,"rb"); - s = fread(fs,Inf,"short"); - plot(s); - subplot(212) - plot(sd); - - lsp1_filename = sprintf("%s_lsp.txt", dump_file_prefix); - lsp2_filename = sprintf("%s_lsp_.txt", dump_file_prefix); - lsp1 = load(lsp1_filename); - lsp2 = load(lsp2_filename); - - weights_filename = sprintf("%s_weights.txt", dump_file_prefix); - if file_in_path(".",weights_filename) - weights = load(weights_filename); - end - - % now enter single step mode so we can analyse each frame - k = ' '; - do - figure(2); - clf; - plot((4000/pi)*lsp1((f-2:f+2),:)); - hold on; - plot((4000/pi)*lsp2((f-2:f+2),:),'+-'); - hold off; - - figure(3); - clf; - - plot((1:Ndft/2)*4000/(Ndft/2), A1(f,1:(Ndft/2)),";A1;r"); - axis([1 4000 -20 40]); - hold on; - plot((1:Ndft/2)*4000/(Ndft/2), A2(f,1:(Ndft/2)),";A2;"); - if file_in_path(".",weights_filename) - plot(lsp1(f,:)*4000/pi, weights(f,:),";weights;g+"); - end - - for l=1:10 - plot([lsp1(f,l)*4000/pi lsp1(f,l)*4000/pi], [0 -10], 'r'); - plot([lsp2(f,l)*4000/pi lsp2(f,l)*4000/pi], [-10 -20], 'b'); - endfor - - plot(0,0,';lsp1;r'); - plot(0,0,';lsp2;b'); - sd_str = sprintf(";sd %3.2f dB*dB;", sd(f)); - plot(0,0,sd_str); - - hold off; - - % interactive menu - - printf("\rframe: %d menu: n-next b-back q-quit", f); - fflush(stdout); - k = kbhit(); - if (k == 'n') - f = f + 1; - endif - if (k == 'b') - f = f - 1; - endif - - until (k == 'q') - printf("\n"); - -endfunction - diff --git a/codec2/octave/spec.m b/codec2/octave/spec.m deleted file mode 100644 index d556b906..00000000 --- a/codec2/octave/spec.m +++ /dev/null @@ -1,86 +0,0 @@ -% spec.m -% Jean Marc Valin -% -% Spectrogram function for Octave -% -% Copyright (c) John-Marc Valin 2012 -% -% Redistribution and use in source and binary forms, with or without -% modification, are permitted provided that the following conditions -% are met: -% -% - Redistributions of source code must retain the above copyright -% notice, this list of conditions and the following disclaimer. -% -% - Redistributions in binary form must reproduce the above copyright -% notice, this list of conditions and the following disclaimer in the -% documentation and/or other materials provided with the distribution. -% -% - Neither the name of Jean Marc Valin nor the names of its -% contributors may be used to endorse or promote products derived from -% this software without specific prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -% ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -% A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR -% CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -% PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -function X = spec(x, Fs, framesize, start, stop) - - -gr=[zeros(1024,1),[0:1023]'/1023,.68*[0:1023]'/1023]; - -%gr=[.4*[0:1023]'/1023,[0:1023]'/1023,.68*[0:1023]'/1023]; - -%t=[0:1023]'/1023; -%t=(1+.25*t-cos(pi*t))/2.25; -%gr = [zeros(1024,1),t,.68*t]; - - -%colormap(gr); - -if nargin < 2 || isempty(Fs) - Fs = 44100; -end - -if nargin < 3 || isempty(framesize) - framesize = 2048; -endif - -offset = framesize/8; - -X = 20*log10(abs(specgram(x, framesize, 48000, blackmanharris(framesize)', framesize-offset))); - -XM=max(max(X)); -X = max(XM-30,X); -%size(X) -F = -[framesize/2-1:-1:0]/framesize*Fs; -%F = [0:127]/128*24000; -T=[1:size(X,2)]/Fs*offset; -%imagesc(X(end:-1:1,:)); - -if nargin < 4 || isempty(start) - istart=1; -else - istart = round(start*Fs/offset); -end - -if nargin < 5 || isempty(stop) - istop = size(X,2); -else - istop = round(stop*Fs/offset); -endif - -istart = max(1,istart); -istop = min(istop, size(X,2)); - -imagesc(T(1+istart:istop), F, X(end:-1:1,1+istart:istop)); - -X = X(:,1+istart:istop); diff --git a/codec2/octave/test_dqpsk.m b/codec2/octave/test_dqpsk.m deleted file mode 100644 index 76beaf9c..00000000 --- a/codec2/octave/test_dqpsk.m +++ /dev/null @@ -1,394 +0,0 @@ -% test_dqpsk.m -% David Rowe March 2014 -% -% Single sample/symbol DQPSK modem simulation to test modulating modem -% tx power based on speech energy. - -1; - -% main test function - -function sim_out = ber_test(sim_in) - Fs = 8000; - - verbose = sim_in.verbose; - framesize = sim_in.framesize; - Ntrials = sim_in.Ntrials; - Esvec = sim_in.Esvec; - phase_offset = sim_in.phase_offset; - w_offset = sim_in.w_offset; - plot_scatter = sim_in.plot_scatter; - Rs = sim_in.Rs; - hf_sim = sim_in.hf_sim; - nhfdelay = sim_in.hf_delay_ms*Rs/1000; - hf_phase_only = sim_in.hf_phase_only; - hf_mag_only = sim_in.hf_mag_only; - Nc = sim_in.Nc; - symbol_amp = sim_in.symbol_amp; - - bps = 2; - Nsymb = framesize/bps; - for k=1:Nc - prev_sym_tx(k) = qpsk_mod([0 0]); - prev_sym_rx(k) = qpsk_mod([0 0]); - end - - rate = 1; - - % Init HF channel model from stored sample files of spreading signal ---------------------------------- - - % convert "spreading" samples from 1kHz carrier at Fs to complex - % baseband, generated by passing a 1kHz sine wave through PathSim - % with the ccir-poor model, enabling one path at a time. - - Fc = 1000; M = Fs/Rs; - fspread = fopen("../raw/sine1k_2Hz_spread.raw","rb"); - spread1k = fread(fspread, "int16")/10000; - fclose(fspread); - fspread = fopen("../raw/sine1k_2ms_delay_2Hz_spread.raw","rb"); - spread1k_2ms = fread(fspread, "int16")/10000; - fclose(fspread); - - % down convert to complex baseband - spreadbb = spread1k.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k))'); - spreadbb_2ms = spread1k_2ms.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k_2ms))'); - - % remove -2000 Hz image - b = fir1(50, 5/Fs); - spread = filter(b,1,spreadbb); - spread_2ms = filter(b,1,spreadbb_2ms); - - % discard first 1000 samples as these were near 0, probably as - % PathSim states were ramping up - - spread = spread(1000:length(spread)); - spread_2ms = spread_2ms(1000:length(spread_2ms)); - - % decimate down to Rs - - spread = spread(1:M:length(spread)); - spread_2ms = spread_2ms(1:M:length(spread_2ms)); - - % Determine "gain" of HF channel model, so we can normalise - % carrier power during HF channel sim to calibrate SNR. I imagine - % different implementations of ccir-poor would do this in - % different ways, leading to different BER results. Oh Well! - - hf_gain = 1.0/sqrt(var(spread)+var(spread_2ms)); - - % Start Simulation ---------------------------------------------------------------- - - for ne = 1:length(Esvec) - EsNodB = Esvec(ne); - EsNo = 10^(EsNodB/10); - - variance = 1/EsNo; - if verbose > 1 - printf("EsNo (dB): %f EsNo: %f variance: %f\n", EsNodB, EsNo, variance); - end - - Terrs = 0; Tbits = 0; - - tx_symb_log = []; - rx_symb_log = []; - noise_log = []; - sim_out.errors_log = []; - - % init HF channel - - hf_n = 1; - hf_angle_log = []; - hf_fading = ones(1,Nsymb); % default input for ldpc dec - hf_model = ones(Ntrials*Nsymb/Nc, Nc); % defaults for plotting surface - - sim_out.errors_log = []; - sim_out.Nerrs = []; - sim_out.snr_log = []; - sim_out.hf_model_pwr = []; - - symbol_amp_index = 1; - - for nn = 1: Ntrials - - tx_bits = round( rand( 1, framesize*rate ) ); - - % modulate -------------------------------------------- - - s = zeros(1, Nsymb); - for i=1:Nc:Nsymb - for k=1:Nc - tx_symb = qpsk_mod(tx_bits(2*(i-1+k-1)+1:2*(i+k-1))); - tx_symb *= prev_sym_tx(k); - prev_sym_tx(k) = tx_symb; - s(i+k-1) = symbol_amp(symbol_amp_index)*tx_symb; - end - end - s_ch = s; - symbol_amp_index++; - - % HF channel simulation ------------------------------------ - - if hf_sim - - % separation between carriers. Note this is - % effectively under samples at Rs, I dont think this - % matters. Equivalent to doing freq shift at Fs, then - % decimating to Rs. - - wsep = 2*pi*(1+0.5); % e.g. 75Hz spacing at Rs=50Hz, alpha=0.5 filters - - if Nsymb/Nc != floor(Nsymb/Nc) - printf("Error: Nsymb/Nc must be an integrer\n") - return; - end - - % arrange symbols in Nsymb/Nc by Nc matrix - - for i=1:Nc:Nsymb - - % Determine HF channel at each carrier for this symbol - - for k=1:Nc - hf_model(hf_n, k) = hf_gain*(spread(hf_n) + exp(-j*k*wsep*nhfdelay)*spread_2ms(hf_n)); - hf_fading(i+k-1) = abs(hf_model(hf_n, k)); - if hf_mag_only - s_ch(i+k-1) *= abs(hf_model(hf_n, k)); - else - s_ch(i+k-1) *= hf_model(hf_n, k); - end - end - hf_n++; - end - end - - tx_symb_log = [tx_symb_log s_ch]; - - % "genie" SNR estimate - - snr = (s_ch*s_ch')/(Nsymb*variance); - sim_out.snr_log = [sim_out.snr_log snr]; - sim_out.hf_model_pwr = [sim_out.hf_model_pwr mean(hf_fading.^2)]; - - % AWGN noise and phase/freq offset channel simulation - % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im - - noise = sqrt(variance*0.5)*(randn(1,Nsymb) + j*randn(1,Nsymb)); - noise_log = [noise_log noise]; - - % organise into carriers to apply frequency and phase offset - - for i=1:Nc:Nsymb - for k=1:Nc - s_ch(i+k-1) = s_ch(i+k-1)*exp(j*phase_offset) + noise(i+k-1); - end - phase_offset += w_offset; - end - - % de-modulate - - rx_bits = zeros(1, framesize); - for i=1:Nc:Nsymb - for k=1:Nc - rx_symb = s_ch(i+k-1); - tmp = rx_symb; - rx_symb *= conj(prev_sym_rx(k)/abs(prev_sym_rx(k))); - prev_sym_rx(k) = tmp; - rx_bits((2*(i-1+k-1)+1):(2*(i+k-1))) = qpsk_demod(rx_symb); - rx_symb_log = [rx_symb_log rx_symb]; - end - end - - error_positions = xor(rx_bits, tx_bits); - Nerrs = sum(error_positions); - sim_out.Nerrs = [sim_out.Nerrs Nerrs]; - Terrs += Nerrs; - Tbits += length(tx_bits); - - sim_out.errors_log = [sim_out.errors_log error_positions]; - end - - TERvec(ne) = Terrs; - BERvec(ne) = Terrs/Tbits; - - if verbose - printf("EsNo (dB): %f Terrs: %d BER %f ", EsNodB, Terrs, Terrs/Tbits); - printf("\n"); - end - if verbose > 1 - printf("Terrs: %d BER %f C %f N %f Es %f No %f Es/No %f\n\n", Terrs, - Terrs/Tbits, var(tx_symb_log), var(noise_log), - var(tx_symb_log), var(noise_log), var(tx_symb_log)/var(noise_log)); - end - end - - Ebvec = Esvec - 10*log10(bps); - - sim_out.BERvec = BERvec; - sim_out.Ebvec = Ebvec; - sim_out.TERvec = TERvec; - - if plot_scatter - figure(2); - clf; - scat = rx_symb_log .* exp(j*pi/4); - plot(real(scat), imag(scat),'+'); - title('Scatter plot'); - - figure(3); - clf; - y = 1:Rs*2; - x = 1:Nc; - EsNodBSurface = 20*log10(abs(hf_model(y,:))) - 10*log10(variance); - mesh(x,y,EsNodBSurface); - grid - title('HF Channel Es/No'); - - if 0 - figure(4); - clf; - subplot(211) - plot(y,abs(hf_model(y,1))) - title('HF Channel Carrier 1 Mag'); - subplot(212) - plot(y,angle(hf_model(y,1))) - title('HF Channel Carrier 1 Phase'); - end - end - -endfunction - -% Gray coded QPSK modulation function - -function symbol = qpsk_mod(two_bits) - two_bits_decimal = sum(two_bits .* [2 1]); - switch(two_bits_decimal) - case (0) symbol = 1; - case (1) symbol = j; - case (2) symbol = -j; - case (3) symbol = -1; - endswitch -endfunction - -% Gray coded QPSK demodulation function - -function two_bits = qpsk_demod(symbol) - if isscalar(symbol) == 0 - printf("only works with scalars\n"); - return; - end - bit0 = real(symbol*exp(j*pi/4)) < 0; - bit1 = imag(symbol*exp(j*pi/4)) < 0; - two_bits = [bit1 bit0]; -endfunction - -function sim_in = standard_init - sim_in.verbose = 1; - sim_in.plot_scatter = 0; - - sim_in.Esvec = 5:15; - sim_in.Ntrials = 100; - sim_in.framesize = 64; - sim_in.Rs = 100; - sim_in.Nc = 8; - - sim_in.phase_offset = 0; - sim_in.w_offset = 0; - sim_in.phase_noise_amp = 0; - - sim_in.hf_delay_ms = 2; - sim_in.hf_sim = 0; - sim_in.hf_phase_only = 0; - sim_in.hf_mag_only = 0; -endfunction - -function awgn_hf_ber_curves() - sim_in = standard_init(); - - Ebvec = sim_in.Esvec - 10*log10(2); - BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10))); - - dpsk_awgn = ber_test(sim_in); - sim_in.hf_sim = 1; - dpsk_hf = ber_test(sim_in); - - figure(1); - clf; - semilogy(Ebvec, BER_theory,'r;QPSK theory;') - hold on; - semilogy(dpsk_awgn.Ebvec, dpsk_awgn.BERvec,'g;DQPSK;') - semilogy(dpsk_hf.Ebvec, dpsk_hf.BERvec,'g;DQPSK HF;') - hold off; - xlabel('Eb/N0') - ylabel('BER') - grid("minor") - axis([min(Ebvec) max(Ebvec) 1E-3 1]) -end - -sim_in = standard_init(); - -% energy file sampled every 10ms - -load ../src/ve9qrp.txt -pdB=10*log10(ve9qrp); -for i=1:length(pdB) - if pdB(i) < 0 - pdB(i) = 0; - end -end - -% Down sample to 40ms rate used for 1300 bit/s codec, every 4th sample is transmitted - -pdB = pdB(4:4:length(pdB)); - -% Use linear mapping function in dB domain to map to symbol power - -power_map_x = [ 0 20 24 40 50 ]; -power_map_y = [-6 -6 0 6 6]; -mapped_pdB = interp1(power_map_x, power_map_y, pdB); - -%sim_in.symbol_amp = 10 .^ (mapped_pdB/20); -sim_in.symbol_amp = ones(1,length(pdB)); -sim_in.plot_scatter = 1; -sim_in.verbose = 2; -sim_in.hf_sim = 1; -sim_in.Esvec = 10; -sim_in.Ntrials = 400; - -dqpsk_pwr_hf = ber_test(sim_in); - -% note: need way to test that power is aligned with speech - -figure(4) -clf; -plot((1:sim_in.Ntrials)*80*4, pdB(1:sim_in.Ntrials)); -hold on; -plot((1:sim_in.Ntrials)*80*4, mapped_pdB(1:sim_in.Ntrials),'r'); -hold off; - -figure(5) -clf; - -s = load_raw("../raw/ve9qrp.raw"); -M=320; M_on_2 = M/2; % processing delay between input speech and centre of analysis window -plot(M_on_2:(M_on_2-1+sim_in.Ntrials*M),s(1:sim_in.Ntrials*M)) -hold on; -plot((1:sim_in.Ntrials)*M, 5000*sim_in.symbol_amp(1:sim_in.Ntrials),'r'); -hold off; -axis([1 sim_in.Ntrials*M -3E4 3E4]); - -figure(6) -clf; -plot((1:sim_in.Ntrials)*M, 20*log10(sim_in.symbol_amp(1:sim_in.Ntrials)),'b;Es (dB);'); -hold on; -plot((1:sim_in.Ntrials)*M, 10*log10(dqpsk_pwr_hf.hf_model_pwr),'g;Fading (dB);'); -plot((1:sim_in.Ntrials)*M, 10*log10(dqpsk_pwr_hf.snr_log),'r;Es/No (dB);'); - -ber = dqpsk_pwr_hf.Nerrs/sim_in.framesize; -ber_clip = ber; -ber_clip(find(ber > 0.2)) = 0.2; -plot((1:sim_in.Ntrials)*M, -20+100*ber_clip,'k;BER (0-20%);'); -hold off; -axis([1 sim_in.Ntrials*M -20 20]) - -fep=fopen("dqpsk_errors_pwr.bin","wb"); fwrite(fep, dqpsk_pwr_hf.errors_log, "short"); fclose(fep); -fber=fopen("ber.bin","wb"); fwrite(fber, ber, "float"); fclose(fber); diff --git a/codec2/octave/test_dqpsk2.m b/codec2/octave/test_dqpsk2.m deleted file mode 100644 index 01f45677..00000000 --- a/codec2/octave/test_dqpsk2.m +++ /dev/null @@ -1,463 +0,0 @@ -% test_dqpsk2.m -% David Rowe April 2014 -% -% DQPSK modem simulation inclduing filtering to test modulating modem -% tx power based on speech energy. Unlike test_dpsk runs at sample -% rate Fs. - -1; - -% main test function - -function sim_out = ber_test(sim_in) - Fs = 8000; - - verbose = sim_in.verbose; - framesize = sim_in.framesize; - Ntrials = sim_in.Ntrials; - Esvec = sim_in.Esvec; - phase_offset = sim_in.phase_offset; - w_offset = sim_in.w_offset; - plot_scatter = sim_in.plot_scatter; - Rs = sim_in.Rs; - hf_sim = sim_in.hf_sim; - Nhfdelay = floor(sim_in.hf_delay_ms*Fs/1000); - Nc = sim_in.Nc; - symbol_amp = sim_in.symbol_amp; - - bps = 2; - Nsymb = framesize/bps; - for k=1:Nc - prev_sym_tx(k) = qpsk_mod([0 0]); - prev_sym_rx(k) = qpsk_mod([0 0]); - end - - % design root nyquist (root raised cosine) filter and init tx and rx filter states - - alpha = 0.5; T=1/Fs; Nfiltsym=7; M=Fs/Rs; - if floor(Fs/Rs) != Fs/Rs - printf("oversampling ratio must be an integer\n"); - return; - end - hrn = gen_rn_coeffs(alpha, T, Rs, Nfiltsym, M); - Nfilter = length(hrn); - - % convert "spreading" samples from 1kHz carrier at Fs to complex - % baseband, generated by passing a 1kHz sine wave through PathSim - % with the ccir-poor model, enabling one path at a time. - - Fc = 1000; - fspread = fopen("../raw/sine1k_2Hz_spread.raw","rb"); - spread1k = fread(fspread, "int16")/10000; - fclose(fspread); - fspread = fopen("../raw/sine1k_2ms_delay_2Hz_spread.raw","rb"); - spread1k_2ms = fread(fspread, "int16")/10000; - fclose(fspread); - - % down convert to complex baseband - spreadbb = spread1k.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k))'); - spreadbb_2ms = spread1k_2ms.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k_2ms))'); - - % remove -2000 Hz image - b = fir1(50, 5/Fs); - spread = filter(b,1,spreadbb); - spread_2ms = filter(b,1,spreadbb_2ms); - - % discard first 1000 samples as these were near 0, probably as - % PathSim states were ramping up. Transpose for convenience - - spread = transpose(spread(1000:length(spread))); - spread_2ms = transpose(spread_2ms(1000:length(spread_2ms))); - - % Determine "gain" of HF channel model, so we can normalise - % carrier power during HF channel sim to calibrate SNR. I imagine - % different implementations of ccir-poor would do this in - % different ways, leading to different BER results. Oh Well! - - hf_gain = 1.0/sqrt(var(spread)+var(spread_2ms)); - - % Start Simulation ---------------------------------------------------------------- - - for ne = 1:length(Esvec) - EsNodB = Esvec(ne); - EsNo = 10^(EsNodB/10); - - variance = Fs/(Rs*EsNo); - if verbose > 1 - printf("EsNo (dB): %f EsNo: %f variance: %f\n", EsNodB, EsNo, variance); - end - - Terrs = 0; Tbits = 0; - - tx_symb_log = []; - rx_symb_log = []; - noise_log = []; - sim_out.errors_log = []; - sim_out.tx_baseband_log = []; - sim_out.rx_filt_log = []; - symbol_amp_index = 1; - - % init filter memories and LOs - - tx_filter_memory = zeros(Nc, Nfilter); - rx_filter_memory = zeros(Nc, Nfilter); - s_delay_line_filt = zeros(Nc, Nfiltsym); - phase_tx = ones(1,Nc); - phase_rx = ones(1,Nc); - Fcentre = 1500; Fsep = (1+alpha)*Rs; - freq = Fcentre + Fsep*((-Nc/2+0.5):(Nc/2-0.5)); - freq = exp(j*freq*2*pi/Fs); - - % init HF channel - - sc = 1; hf_n = 1; - hf_sim_delay_line = zeros(1,M+Nhfdelay); - freq_sample_hz = Fcentre + ((Fsep*(-Nc/2)):50:(Fsep*(Nc/2))); - freq_sample_rads = (2*pi/Fs)*freq_sample_hz; - hf_model = ones(Ntrials*Nsymb/Nc, length(freq_sample_rads)); % defaults for plotting surface - - % bunch of outputs we log for graphing - - sim_out.errors_log = []; - sim_out.Nerrs = []; - sim_out.snr_log = []; - sim_out.hf_model_pwr = []; - sim_out.tx_fdm_log = []; - C_log = []; - - for nn = 1: Ntrials - - tx_bits = round( rand( 1, framesize ) ); - - % modulate -------------------------------------------- - - s = zeros(1, Nsymb); - for i=1:Nc:Nsymb - for k=1:Nc - tx_symb = qpsk_mod(tx_bits(2*(i-1+k-1)+1:2*(i+k-1))); - s_qpsk(i+k-1) = tx_symb; - tx_symb *= prev_sym_tx(k); - prev_sym_tx(k) = tx_symb; - s(i+k-1) = symbol_amp(symbol_amp_index)*tx_symb; - end - end - symbol_amp_index++; - s_ch = s; - - % Now we start processing frame Nc symbols at a time to model parallel carriers - - tx_fdm_sym_log = []; - for i=1:Nc:Nsymb - - % Delay tx symbols to match delay due to filters. qpsk - % (rather than dqpsk) symbols used for convenience as - % it's easy to shift symbols than pairs of bits - - s_delay_line_filt(:,1:Nfiltsym-1) = s_delay_line_filt(:,2:Nfiltsym); - s_delay_line_filt(:,Nfiltsym) = s_qpsk(i:i+Nc-1); - s_qpsk(i:i+Nc-1) = s_delay_line_filt(:,1); - for k=1:Nc - tx_bits(2*(i-1+k-1)+1:2*(i+k-1)) = qpsk_demod(s_qpsk(i+k-1)); - end - - % tx filter - - tx_baseband = zeros(Nc,M); - - % tx filter each symbol, generate M filtered output samples for each symbol. - % Efficient polyphase filter techniques used as tx_filter_memory is sparse - - tx_filter_memory(:,Nfilter) = s(i:i+Nc-1); - - for k=1:M - tx_baseband(:,k) = M*tx_filter_memory(:,M:M:Nfilter) * hrn(M-k+1:M:Nfilter)'; - end - tx_filter_memory(:,1:Nfilter-M) = tx_filter_memory(:,M+1:Nfilter); - tx_filter_memory(:,Nfilter-M+1:Nfilter) = zeros(Nc,M); - - sim_out.tx_baseband_log = [sim_out.tx_baseband_log tx_baseband]; - - % upconvert - - tx_fdm = zeros(1,M); - - for c=1:Nc - for k=1:M - phase_tx(c) = phase_tx(c) * freq(c); - tx_fdm(k) = tx_fdm(k) + tx_baseband(c,k)*phase_tx(c); - end - end - - sim_out.tx_fdm_log = [sim_out.tx_fdm_log tx_fdm]; - - % HF channel - - if hf_sim - hf_sim_delay_line(1:Nhfdelay) = hf_sim_delay_line(M+1:M+Nhfdelay); - hf_sim_delay_line(Nhfdelay+1:M+Nhfdelay) = tx_fdm; - - tx_fdm = tx_fdm.*spread(sc:sc+M-1) + hf_sim_delay_line(1:M).*spread_2ms(sc:sc+M-1); - tx_fdm *= hf_gain; - - % sample HF channel spectrum in middle of this symbol for plotting - - hf_model(hf_n,:) = hf_gain*(spread(sc+M/2) + exp(-j*freq_sample_rads*Nhfdelay)*spread_2ms(sc+M/2)); - - sc += M; - hf_n++; - end - - tx_fdm_sym_log = [tx_fdm_sym_log tx_fdm ]; - - % AWGN noise and phase/freq offset channel simulation - % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im - - noise = sqrt(variance*0.5)*(randn(1,M) + j*randn(1,M)); - noise_log = [noise_log noise]; - - % apply frequency and phase offset and noise - - for k=1:M - rx_fdm(k) = tx_fdm(k)*exp(j*phase_offset) + noise(k); - phase_offset += w_offset; - end - - % downconvert - - rx_baseband = zeros(Nc,M); - for c=1:Nc - for k=1:M - phase_rx(c) = phase_rx(c) * freq(c); - rx_baseband(c,k) = rx_fdm(k)*phase_rx(c)'; - end - end - - % rx filter - - rx_filter_memory(:,Nfilter-M+1:Nfilter) = rx_baseband; - rx_filt = rx_filter_memory * hrn'; - rx_filter_memory(:,1:Nfilter-M) = rx_filter_memory(:,1+M:Nfilter); - sim_out.rx_filt_log = [sim_out.rx_filt_log rx_filt]; - - s_ch(i:i+Nc-1) = rx_filt; - end - - % est HF model power for entire code frame (which could be several symbols) - - if hf_sim - frame_hf_model = reshape(hf_model(hf_n-Nsymb/Nc:hf_n-1,:),1,(Nsymb/Nc)*length(freq_sample_hz)); - sim_out.hf_model_pwr = [sim_out.hf_model_pwr mean(abs(frame_hf_model).^2)]; - else - sim_out.hf_model_pwr = [sim_out.hf_model_pwr 1]; - end - - % "genie" SNR estimate - - snr = (tx_fdm_sym_log*tx_fdm_sym_log')/(M*variance); - sim_out.snr_log = [sim_out.snr_log snr]; - - % de-modulate - - rx_bits = zeros(1, framesize); - for i=1:Nc:Nsymb - for k=1:Nc - rx_symb = s_ch(i+k-1); - tmp = rx_symb; - rx_symb *= conj(prev_sym_rx(k)/abs(prev_sym_rx(k))); - prev_sym_rx(k) = tmp; - rx_bits((2*(i-1+k-1)+1):(2*(i+k-1))) = qpsk_demod(rx_symb); - rx_symb_log = [rx_symb_log rx_symb]; - end - end - - % ignore data until we have enough frames to fill filter memory - % then count errors - - if nn > ceil(Nfiltsym/(Nsymb/Nc)) - error_positions = xor(rx_bits, tx_bits); - sim_out.errors_log = [sim_out.errors_log error_positions]; - Nerrs = sum(error_positions); - sim_out.Nerrs = [sim_out.Nerrs Nerrs]; - Terrs += Nerrs; - Tbits += length(tx_bits); - end - - end - - TERvec(ne) = Terrs; - BERvec(ne) = Terrs/Tbits; - - if verbose - printf("EsNo (dB): %f Terrs: %d BER %f ", EsNodB, Terrs, Terrs/Tbits); - printf("\n"); - end - if verbose > 1 - printf("Terrs: %d BER %f C %f N %f Es %f No %f Es/No %f\n\n", Terrs, - Terrs/Tbits, var(sim_out.tx_fdm_log), var(noise_log), - var(sim_out.tx_fdm_log)/(Nc*Rs), var(noise_log)/Fs, (var(sim_out.tx_fdm_log)/(Nc*Rs))/(var(noise_log)/Fs)); - end - end - - Ebvec = Esvec - 10*log10(bps); - - sim_out.BERvec = BERvec; - sim_out.Ebvec = Ebvec; - sim_out.TERvec = TERvec; - - if plot_scatter - figure(2); - clf; - scat = rx_symb_log(Nfiltsym*Nc:length(rx_symb_log)) .* exp(j*pi/4); - plot(real(scat), imag(scat),'+'); - title('Scatter plot'); - - figure(3); - clf; - y = 1:Rs*2; - EsNodBSurface = 20*log10(abs(hf_model(y,:))) + EsNodB; - mesh(1:length(freq_sample_hz),y,EsNodBSurface); - grid - title('HF Channel Es/No'); - end - -endfunction - -% Gray coded QPSK modulation function - -function symbol = qpsk_mod(two_bits) - two_bits_decimal = sum(two_bits .* [2 1]); - switch(two_bits_decimal) - case (0) symbol = 1; - case (1) symbol = j; - case (2) symbol = -j; - case (3) symbol = -1; - endswitch -endfunction - -% Gray coded QPSK demodulation function - -function two_bits = qpsk_demod(symbol) - if isscalar(symbol) == 0 - printf("only works with scalars\n"); - return; - end - bit0 = real(symbol*exp(j*pi/4)) < 0; - bit1 = imag(symbol*exp(j*pi/4)) < 0; - two_bits = [bit1 bit0]; -endfunction - -function sim_in = standard_init - sim_in.verbose = 1; - sim_in.plot_scatter = 0; - - sim_in.Esvec = 5:15; - sim_in.Ntrials = 100; - sim_in.framesize = 64; - sim_in.Rs = 100; - sim_in.Nc = 8; - - sim_in.phase_offset = 0; - sim_in.w_offset = 0; - sim_in.phase_noise_amp = 0; - - sim_in.hf_delay_ms = 2; - sim_in.hf_sim = 0; - sim_in.hf_phase_only = 0; - sim_in.hf_mag_only = 0; -endfunction - -function awgn_hf_ber_curves() - sim_in = standard_init(); - - Ebvec = sim_in.Esvec - 10*log10(2); - BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10))); - - dpsk_awgn = ber_test(sim_in); - sim_in.hf_sim = 1; - dpsk_hf = ber_test(sim_in); - - figure(1); - clf; - semilogy(Ebvec, BER_theory,'r;QPSK theory;') - hold on; - semilogy(dpsk_awgn.Ebvec, dpsk_awgn.BERvec,'g;DQPSK;') - semilogy(dpsk_hf.Ebvec, dpsk_hf.BERvec,'g;DQPSK HF;') - hold off; - xlabel('Eb/N0') - ylabel('BER') - grid("minor") - axis([min(Ebvec) max(Ebvec) 1E-3 1]) -end - -sim_in = standard_init(); - -% energy file sampled every 10ms - -load ../src/ve9qrp.txt -pdB=10*log10(ve9qrp); -for i=1:length(pdB) - if pdB(i) < 0 - pdB(i) = 0; - end -end - -% Down sample to 40ms rate used for 1300 bit/s codec, every 4th sample is transmitted - -pdB = pdB(4:4:length(pdB)); - -% Use linear mapping function in dB domain to map to symbol power - -power_map_x = [ 0 20 24 40 50 ]; -power_map_y = [-6 -6 0 6 6]; -mapped_pdB = interp1(power_map_x, power_map_y, pdB); - -sim_in.symbol_amp = 10 .^ (mapped_pdB/20); -%sim_in.symbol_amp = ones(1,length(pdB)); -sim_in.plot_scatter = 1; -sim_in.verbose = 2; -sim_in.hf_delay_ms = 2; -sim_in.hf_sim = 1; -sim_in.Esvec = 10; -sim_in.Ntrials = 400; - -dqpsk_pwr_hf = ber_test(sim_in); - -% note: need way to test that power is aligned with speech - -figure(4) -clf; -plot((1:sim_in.Ntrials)*80*4, pdB(1:sim_in.Ntrials)); -hold on; -plot((1:sim_in.Ntrials)*80*4, mapped_pdB(1:sim_in.Ntrials),'r'); -hold off; - -figure(5) -clf; -s = load_raw("../raw/ve9qrp.raw"); -M=320; M_on_2 = M/2; % processing delay between input speech and centre of analysis window -subplot(211) -plot(M_on_2:(M_on_2-1+sim_in.Ntrials*M),s(1:sim_in.Ntrials*M)) -hold on; -plot((1:sim_in.Ntrials)*M, 5000*sim_in.symbol_amp(1:sim_in.Ntrials),'r'); -hold off; -axis([1 sim_in.Ntrials*M -3E4 3E4]); -subplot(212) -plot(real(dqpsk_pwr_hf.tx_fdm_log)); - - -figure(6) -clf; -plot((1:sim_in.Ntrials)*M, 20*log10(sim_in.symbol_amp(1:sim_in.Ntrials)),'b;Es (dB);'); -hold on; -plot((1:sim_in.Ntrials)*M, 10*log10(dqpsk_pwr_hf.hf_model_pwr),'g;Fading (dB);'); -plot((1:sim_in.Ntrials)*M, 10*log10(dqpsk_pwr_hf.snr_log),'r;Es/No (dB);'); - -ber = dqpsk_pwr_hf.Nerrs/sim_in.framesize; -ber_clip = ber; -ber_clip(find(ber > 0.2)) = 0.2; -plot((1:length(ber_clip))*M, -20+100*ber_clip,'k;BER (0-20%);'); -hold off; -axis([1 sim_in.Ntrials*M -20 20]) - -fep=fopen("dqpsk_errors_pwr.bin","wb"); fwrite(fep, dqpsk_pwr_hf.errors_log, "short"); fclose(fep); -fber=fopen("ber.bin","wb"); fwrite(fber, ber, "float"); fclose(fber); diff --git a/codec2/octave/test_qpsk.m b/codec2/octave/test_qpsk.m deleted file mode 100644 index 987841cf..00000000 --- a/codec2/octave/test_qpsk.m +++ /dev/null @@ -1,516 +0,0 @@ -% test_qpsk.m -% David Rowe Feb 2014 -% -% QPSK modem simulation, initially based on code by Bill Cowley -% Generates curves BER versus E/No curves for different modems. -% Design to test coherent demodulation ideas on HF channels without -% building a full blown modem. Uses 'genie provided' estimates for -% timing estimation, frame sync. - -1; - -% main test function - -function sim_out = ber_test(sim_in, modulation) - Fs = 8000; - - verbose = sim_in.verbose; - framesize = sim_in.framesize; - Ntrials = sim_in.Ntrials; - Esvec = sim_in.Esvec; - phase_offset = sim_in.phase_offset; - phase_est = sim_in.phase_est; - w_offset = sim_in.w_offset; - plot_scatter = sim_in.plot_scatter; - Rs = sim_in.Rs; - hf_sim = sim_in.hf_sim; - Nhfdelay = floor(sim_in.hf_delay_ms*1000/Fs); - hf_phase_only = sim_in.hf_phase_only; - hf_mag_only = sim_in.hf_mag_only; - - bps = 2; - Nsymb = framesize/bps; - prev_sym_tx = qpsk_mod([0 0]); - prev_sym_rx = qpsk_mod([0 0]); - rx_symb_log = []; - - Np = sim_in.Np; % number of pilot symbols to use in phase est - Ns = sim_in.Ns; % spacing of pilot symbols, so (Nps-1) data symbols between every pilot - Nps = Np*Ns; - r_delay_line = zeros(1,Nps+1); - s_delay_line = zeros(1,Nps+1); - spread_main_phi = 0; - spread_delay_phi = 0; - spread_main_phi_log = []; - - ldpc_code = sim_in.ldpc_code; - - if ldpc_code - % Start CML library - - currentdir = pwd; - addpath '/home/david/tmp/cml/mat' % assume the source files stored here - cd /home/david/tmp/cml - CmlStartup % note that this is not in the cml path! - cd(currentdir) - - % Our LDPC library - - ldpc; - - rate = 3/4; - mod_order = 4; - modulation = 'QPSK'; - mapping = 'gray'; - - demod_type = 0; - decoder_type = 0; - max_iterations = 100; - - code_param = ldpc_init(rate, framesize, modulation, mod_order, mapping); - code_param.code_bits_per_frame = framesize; - code_param.symbols_per_frame = framesize/bps; - else - rate = 1; - end - - % convert "spreading" samples from 1kHz carrier at Fs to complex - % baseband, generated by passing a 1kHz sine wave through PathSim - % with the ccir-poor model, enabling one path at a time. - - Fc = 1000; - fspread = fopen("../raw/sine1k_2Hz_spread.raw","rb"); - spread1k = fread(fspread, "int16")/10000; - fclose(fspread); - fspread = fopen("../raw/sine1k_2ms_delay_2Hz_spread.raw","rb"); - spread1k_2ms = fread(fspread, "int16")/10000; - fclose(fspread); - - % down convert to complex baseband - spreadbb = spread1k.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k))'); - spreadbb_2ms = spread1k_2ms.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k_2ms))'); - - % remove -2000 Hz image - b = fir1(50, 5/Fs); - spread = filter(b,1,spreadbb); - spread_2ms = filter(b,1,spreadbb_2ms); - - % discard first 1000 samples as these were near 0, probably as - % PathSim states were ramping up - - spread = spread(1000:length(spread)); - spread_2ms = spread_2ms(1000:length(spread_2ms)); - - % Determine "gain" of HF channel model, so we can normalise - % carrier power during HF channel sim to calibrate SNR. I imagine - % different implementations of ccir-poor would do this in - % different ways, leading to different BER results. Oh Well! - - hf_gain = 1.0/sqrt(var(spread)+var(spread_2ms)); - - % design root nyquist (root raised cosine) filter and init tx and rx filter states - - alpha = 0.5; T=1/Fs; Nfiltsym=7; M=Fs/Rs; - if floor(Fs/Rs) != Fs/Rs - printf("oversampling ratio must be an integer\n"); - return; - end - hrn = gen_rn_coeffs(alpha, T, Rs, Nfiltsym, M); - Nfilter = length(hrn); - tx_filter_memory = zeros(1, Nfilter); - rx_filter_memory = zeros(1, Nfilter); - s_delay_line_filt = zeros(1,Nfiltsym); - tx_bits_delay_line_filt = zeros(1,Nfiltsym*bps); - hf_sim_delay_line = zeros(1,M+Nhfdelay); - - for ne = 1:length(Esvec) - Es = Esvec(ne); - EsNo = 10^(Es/10); - - % Given Es/No, determine the variance of a normal noise source: - % - % Es = C/Rs where C is carrier power (energy per unit time) and Rs is the symbole rate - % N = NoB where N is the total noise power, No is the Noise spectral density is W/Hz - % and B is the bandwidth of the noise which is Fs - % No = N/Fs - % - % equating Es/No we get: - % - % Es/No = (C/Rs)/(No/Fs) - % No = CFs/(Rs(Es/No)) - - variance = Fs/(Rs*EsNo); - Terrs = 0; Tbits = 0; Terrsldpc = 0; Tbitsldpc = 0; Ferrsldpc = 0; - if verbose > 1 - printf("EsNo (dB): %f EsNo: %f variance: %f\n", Es, EsNo, variance); - end - - % init HF channel - sc = 1; - - tx_filt_log = []; - rx_filt_log = []; - rx_baseband_log = []; - tx_baseband_log = []; - noise_log = []; - hf_angle_log = []; - tx_phase = rx_phase = 0; - tx_data_buffer = zeros(1,2*framesize); - s_data_buffer = zeros(1,2*Nsymb); - C_log = []; - - for nn = 1: Ntrials - - tx_bits = round( rand( 1, framesize*rate ) ); - %tx_bits = [1 0 zeros(1,framesize*rate-2)]; - - % modulate - - if ldpc_code - [tx_bits, s] = ldpc_enc(tx_bits, code_param); - t2 = tx_bits; - s2 = s; - else - s = zeros(1, Nsymb); - for i=1:Nsymb - tx_symb = qpsk_mod(tx_bits(2*(i-1)+1:2*i)); - %printf("shift: %f prev_sym: %f ", tx_symb, prev_sym_tx); - if strcmp(modulation,'dqpsk') - tx_symb *= prev_sym_tx; - %printf("tx_symb: %f\n", tx_symb); - prev_sym_tx = tx_symb; - end - s(i) = tx_symb; - end - end - s_ch = s; - - % root nyquist filter symbols - - for k=1:Nsymb - - % tx filter symbols - - tx_filt = zeros(1,M); - - % tx filter each symbol, generate M filtered output samples for each symbol. - % Efficient polyphase filter techniques used as tx_filter_memory is sparse - - tx_filter_memory(Nfilter) = s_ch(k); - - for i=1:M - tx_filt(i) = M*tx_filter_memory(M:M:Nfilter) * hrn(M-i+1:M:Nfilter)'; - end - tx_filter_memory(1:Nfilter-M) = tx_filter_memory(M+1:Nfilter); - tx_filter_memory(Nfilter-M+1:Nfilter) = zeros(1,M); - - % HF channel simulation - - if hf_sim - - hf_sim_delay_line(1:Nhfdelay) = hf_sim_delay_line(M+1:M+Nhfdelay); - hf_sim_delay_line(Nhfdelay+1:M+Nhfdelay) = tx_filt; - - % disable as a wrap around will cause a nasty phase jump. Best to generate - % longer files - %if ((sc+M) > length(spread)) || ((sc+M) > length(spread_2ms)) - % sc =1 ; - %end - comb = conj(spread(sc:sc+M-1))' + conj(spread_2ms(sc:sc+M-1))'; - if hf_phase_only - tx_filt = tx_filt.*exp(j*angle(comb)); - hf_angle_log = [hf_angle_log angle(comb)]; - else - if hf_mag_only - comb = conj(spread(sc:sc+M-1))' + conj(spread_2ms(sc:sc+M-1))'; - tx_filt = tx_filt.*abs(comb); - else - % regular HF channel sim - tx_filt = tx_filt.*conj(spread(sc:sc+M-1))' + hf_sim_delay_line(1:M).*conj(spread_2ms(sc:sc+M-1))'; - end - end - sc += M; - - % normalise so average HF power C=1 - - if hf_phase_only == 0 % C already 1 if we are just tweaking phase - tx_filt *= hf_gain; - end - C_log = [C_log abs(comb)*hf_gain]; - end - tx_filt_log = [tx_filt_log tx_filt]; - - % AWGN noise and phase/freq offset channel simulation - % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im - - noise = sqrt(variance*0.5)*( randn(1,M) + j*randn(1,M) ); - noise_log = [noise_log noise]; - rx_baseband = tx_filt.*exp(j*phase_offset) + noise; - phase_offset += w_offset; - - % rx filter symbol - - rx_filter_memory(Nfilter-M+1:Nfilter) = rx_baseband; - rx_filt = rx_filter_memory * hrn'; - rx_filter_memory(1:Nfilter-M) = rx_filter_memory(1+M:Nfilter); - rx_filt_log = [rx_filt_log rx_filt]; - - % delay in tx symbols to compensate for filtering - % delay, as tx symbols are used as pilot symbols input - % to phase est - - s_delay_line_filt(1:Nfiltsym-1) = s_delay_line_filt(2:Nfiltsym); - s_delay_line_filt(Nfiltsym) = s(k); - s(k) = s_delay_line_filt(1); - - % delay in tx bits to compensate for filtering delay - - tx_bits_delay_line_filt(1:(Nfiltsym-1)*bps) = tx_bits_delay_line_filt(bps+1:Nfiltsym*bps); - tx_bits_delay_line_filt((Nfiltsym-1)*bps+1:Nfiltsym*bps) = tx_bits((k-1)*bps+1:k*bps); - tx_bits((k-1)*bps+1:k*bps) = tx_bits_delay_line_filt(1:bps); - - s_ch(k) = rx_filt; - end - - % coherent demod phase estimation and correction using pilot symbols - % cheating a bit here, we use fact that all tx-ed symbols are known - - if phase_est - for i=1:Nsymb - - % delay line for phase est window - - r_delay_line(1:Nps-1) = r_delay_line(2:Nps); - r_delay_line(Nps) = s_ch(i); - - % delay in tx data to compensate data for phase est window - - s_delay_line(1:Nps-1) = s_delay_line(2:Nps); - s_delay_line(Nps) = s(i); - tx_bits(2*(i-1)+1:2*i) = qpsk_demod(s_delay_line(floor(Nps/2)+1)); - - % estimate phase from surrounding known pilot symbols and correct - - corr = 0; centre = floor(Nps/2)+1; - for k=1:Ns:(Nps+1) - if (k != centre) - corr += s_delay_line(k) * r_delay_line(k)'; - end - end - s_ch(i) = r_delay_line(centre).*exp(j*angle(corr)); - end - %printf("corr: %f angle: %f\n", corr, angle(corr)); - end - - % de-modulate - - rx_bits = zeros(1, framesize); - for i=1:Nsymb - rx_symb = s_ch(i); - if strcmp(modulation,'dqpsk') - tmp = rx_symb; - rx_symb *= conj(prev_sym_rx/abs(prev_sym_rx)); - prev_sym_rx = tmp; - end - rx_bits((2*(i-1)+1):(2*i)) = qpsk_demod(rx_symb); - rx_symb_log = [rx_symb_log rx_symb]; - end - - % Measure BER - - % discard bits from first 2*Nfiltsym+Nps+1 symbols as tx - % and rx filter and phase est memories not full - - skip = bps*(2*Nfiltsym+1+Nps+1); - if nn == 1 - tx_bits_tmp = tx_bits(skip:length(tx_bits)); - rx_bits_tmp = rx_bits(skip:length(rx_bits)); - else - tx_bits_tmp = tx_bits; - rx_bits_tmp = rx_bits; - end - - error_positions = xor( rx_bits_tmp, tx_bits_tmp ); - Nerrs = sum(error_positions); - Terrs += Nerrs; - Tbits += length(tx_bits_tmp); - - % Optionally LDPC decode - - if ldpc_code - % filter memories etc screw up frame alignment so we need to buffer a frame - - tx_data_buffer(1:framesize) = tx_data_buffer(framesize+1:2*framesize); - s_data_buffer(1:Nsymb) = s_data_buffer(Nsymb+1:2*Nsymb); - tx_data_buffer(framesize+1:2*framesize) = tx_bits; - s_data_buffer(Nsymb+1:2*Nsymb) = s_ch; - - offset = Nfiltsym-1; - if (phase_est) - offset += floor(Nps/2); - end - st_tx = offset*bps+1; - st_s = offset; - - detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, ... - s_data_buffer(st_s+1:st_s+Nsymb), min(100,EsNo)); - - % ignore first frame as filter, phase est memories filling up - if nn != 1 - error_positions = xor( detected_data(1:framesize*rate), ... - tx_data_buffer(st_tx:st_tx+framesize*rate-1) ); - Nerrs = sum(error_positions); - if Nerrs - Ferrsldpc++; - end - Terrsldpc += Nerrs; - Tbitsldpc += framesize*rate; - end - end - - end - - TERvec(ne) = Terrs; - BERvec(ne) = Terrs/Tbits; - if ldpc_code - TERldpcvec(ne) = Terrsldpc; - FERldpcvec(ne) = Ferrsldpc; - BERldpcvec(ne) = Terrsldpc/Tbitsldpc; - end - - if verbose - printf("EsNo (dB): %f Terrs: %d BER %f BER theory %f", Es, Terrs, - Terrs/Tbits, 0.5*erfc(sqrt(EsNo/2))); - if ldpc_code - printf(" LDPC: Terrs: %d BER: %f Ferrs: %d FER: %f", - Terrsldpc, Terrsldpc/Tbitsldpc, Ferrsldpc, Ferrsldpc/(Ntrials-1)); - end - printf("\n"); - end - if verbose > 1 - printf("Terrs: %d BER %f BER theory %f C %f N %f Es %f No %f Es/No %f\n\n", Terrs, - Terrs/Tbits, 0.5*erfc(sqrt(EsNo/2)), var(tx_filt_log), var(noise_log), - var(tx_filt_log)/Rs, var(noise_log)/Fs, (var(tx_filt_log)/Rs)/(var(noise_log)/Fs)); - end - end - - Ebvec = Esvec - 10*log10(bps); - sim_out.BERvec = BERvec; - sim_out.Ebvec = Ebvec; - sim_out.TERvec = TERvec; - if ldpc_code - sim_out.BERldpcvec = BERldpcvec; - sim_out.TERldpcvec = TERldpcvec; - sim_out.FERldpcvec = FERldpcvec; - end - - if plot_scatter - figure(2); - clf; - scat = rx_symb_log(2*Nfiltsym:length(rx_symb_log)) .* exp(j*pi/4); - plot(real(scat), imag(scat),'+'); - - figure(3); - clf; - - if hf_phase_only - plot(hf_angle_log); - axis([1 10000 min(hf_angle_log) max(hf_angle_log)]) - else - plot(C_log); - end - end -endfunction - -% Gray coded QPSK modulation function - -function symbol = qpsk_mod(two_bits) - two_bits_decimal = sum(two_bits .* [2 1]); - switch(two_bits_decimal) - case (0) symbol = 1; - case (1) symbol = j; - case (2) symbol = -j; - case (3) symbol = -1; - endswitch -endfunction - -% Gray coded QPSK demodulation function - -function two_bits = qpsk_demod(symbol) - if isscalar(symbol) == 0 - printf("only works with scalars\n"); - return; - end - bit0 = real(symbol*exp(j*pi/4)) < 0; - bit1 = imag(symbol*exp(j*pi/4)) < 0; - two_bits = [bit1 bit0]; -endfunction - -% Start simulations --------------------------------------- - -more off; -sim_in.verbose = 2; - -sim_in.Esvec = 5; -sim_in.Ntrials = 100; -sim_in.framesize = 100; -sim_in.Rs = 400; -sim_in.phase_offset = 0; -sim_in.phase_est = 0; -sim_in.w_offset = 0; -sim_in.plot_scatter = 1; -sim_in.hf_delay_ms = 2; -sim_in.hf_sim = 1; -sim_in.Np = 6; -sim_in.Ns = 5; -sim_in.hf_phase_only = 0; -sim_in.hf_mag_only = 1; -sim_in.ldpc_code = 0; - -Ebvec = sim_in.Esvec - 10*log10(2); -BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10))); - -sim_qpsk = ber_test(sim_in, 'qpsk'); - -figure(1); -clf; -semilogy(Ebvec, BER_theory,'r;QPSK theory;') -hold on; -semilogy(sim_qpsk.Ebvec, sim_qpsk.BERvec,'g;QPSK;') -hold off; -xlabel('Eb/N0') -ylabel('BER') -grid("minor") - - -if 0 -sim_in.hf_mag_only = 1; -sim_qpsk_mag = ber_test(sim_in, 'qpsk'); - -sim_in.hf_mag_only = 0; -sim_in.hf_phase_only = 1; -sim_in.phase_est = 1; -sim_qpsk_phase = ber_test(sim_in, 'qpsk'); - -sim_in.hf_phase_only = 0; -sim_qpsk_coh_6_5 = ber_test(sim_in, 'qpsk'); - -sim_in.phase_est = 0; -sim_dqpsk = ber_test(sim_in, 'dqpsk'); - -figure(1); -clf; -semilogy(Ebvec, BER_theory,'r;QPSK theory;') -hold on; -semilogy(sim_qpsk_mag.Ebvec, sim_qpsk_mag.BERvec,'g;QPSK CCIR poor mag;') -semilogy(sim_qpsk_phase.Ebvec, sim_qpsk_phase.BERvec,'k;QPSK CCIR poor phase;') -semilogy(sim_qpsk_coh_6_5.Ebvec, sim_qpsk_coh_6_5.BERvec,'c;QPSK CCIR poor Np=6 Ns=5;') -semilogy(sim_dqpsk.Ebvec, sim_dqpsk.BERvec,'b;DQPSK CCIR poor;') -%semilogy(sim_qpsk_coh_5_24.Ebvec, sim_qpsk_coh_5_24.BERvec,'k;QPSK Ns=5 Np=24;') -%semilogy(sim_qpsk_coh_2_12.Ebvec, sim_qpsk_coh_2_12.BERvec,'c;QPSK Ns=2 Np=12;') -hold off; -xlabel('Eb/N0') -ylabel('BER') -grid("minor") -axis([min(Ebvec)-1 max(Ebvec)+1 1E-2 1]) -end diff --git a/codec2/octave/test_qpsk2.m b/codec2/octave/test_qpsk2.m deleted file mode 100644 index a17e1ee4..00000000 --- a/codec2/octave/test_qpsk2.m +++ /dev/null @@ -1,639 +0,0 @@ -% test_qps2k.m -% David Rowe Feb 2014 -% -% QPSK modem simulation, version 2. Simplifed version of -% test_qpsk. initially based on code by Bill Cowley Generates curves -% BER versus E/No curves for different modems. Design to test -% coherent demodulation ideas on HF channels without building a full -% blown modem. Uses 'genie provided' estimates for timing estimation, -% frame sync. - -1; - -% main test function - -function sim_out = ber_test(sim_in, modulation) - Fs = 8000; - - verbose = sim_in.verbose; - framesize = sim_in.framesize; - Ntrials = sim_in.Ntrials; - Esvec = sim_in.Esvec; - phase_offset = sim_in.phase_offset; - phase_est = sim_in.phase_est; - w_offset = sim_in.w_offset; - plot_scatter = sim_in.plot_scatter; - Rs = sim_in.Rs; - hf_sim = sim_in.hf_sim; - nhfdelay = sim_in.hf_delay_ms*Rs/1000; - hf_phase_only = sim_in.hf_phase_only; - hf_mag_only = sim_in.hf_mag_only; - Nc = sim_in.Nc; - - bps = 2; - Nsymb = framesize/bps; - prev_sym_tx = qpsk_mod([0 0]); - prev_sym_rx = qpsk_mod([0 0]); - - phase_est_method = sim_in.phase_est_method; - if phase_est_method == 1 - Nps = sim_in.Np; - else - Np = sim_in.Np; - Ns = sim_in.Ns; - if Np/2 == floor(Np/2) - printf("Np must be odd\n"); - return; - end - Nps = (Np-1)*Ns+1; - end - r_delay_line = zeros(Nc, Nps); - s_delay_line = zeros(Nc, Nps); - ph_est_log = []; - - phase_noise_amp = sim_in.phase_noise_amp; - - ldpc_code = sim_in.ldpc_code; - - tx_bits_buf = zeros(1,2*framesize); - rx_bits_buf = zeros(1,2*framesize); - rx_symb_buf = zeros(1,2*Nsymb); - - % Init LDPC -------------------------------------------------------------------- - - if ldpc_code - % Start CML library - - currentdir = pwd; - addpath '/home/david/tmp/cml/mat' % assume the source files stored here - cd /home/david/tmp/cml - CmlStartup % note that this is not in the cml path! - cd(currentdir) - - % Our LDPC library - - ldpc; - - rate = sim_in.ldpc_code_rate; - mod_order = 4; - modulation = 'QPSK'; - mapping = 'gray'; - - demod_type = 0; - decoder_type = 0; - max_iterations = 100; - - code_param = ldpc_init(rate, framesize, modulation, mod_order, mapping); - code_param.code_bits_per_frame = framesize; - code_param.symbols_per_frame = framesize/bps; - else - rate = 1; - end - - % Init HF channel model from stored sample files of spreading signal ---------------------------------- - - % convert "spreading" samples from 1kHz carrier at Fs to complex - % baseband, generated by passing a 1kHz sine wave through PathSim - % with the ccir-poor model, enabling one path at a time. - - Fc = 1000; M = Fs/Rs; - fspread = fopen("../raw/sine1k_2Hz_spread.raw","rb"); - spread1k = fread(fspread, "int16")/10000; - fclose(fspread); - fspread = fopen("../raw/sine1k_2ms_delay_2Hz_spread.raw","rb"); - spread1k_2ms = fread(fspread, "int16")/10000; - fclose(fspread); - - % down convert to complex baseband - spreadbb = spread1k.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k))'); - spreadbb_2ms = spread1k_2ms.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k_2ms))'); - - % remove -2000 Hz image - b = fir1(50, 5/Fs); - spread = filter(b,1,spreadbb); - spread_2ms = filter(b,1,spreadbb_2ms); - - % discard first 1000 samples as these were near 0, probably as - % PathSim states were ramping up - - spread = spread(1000:length(spread)); - spread_2ms = spread_2ms(1000:length(spread_2ms)); - - % decimate down to Rs - - spread = spread(1:M:length(spread)); - spread_2ms = spread_2ms(1:M:length(spread_2ms)); - - % Determine "gain" of HF channel model, so we can normalise - % carrier power during HF channel sim to calibrate SNR. I imagine - % different implementations of ccir-poor would do this in - % different ways, leading to different BER results. Oh Well! - - hf_gain = 1.0/sqrt(var(spread)+var(spread_2ms)); - - % Start Simulation ---------------------------------------------------------------- - - for ne = 1:length(Esvec) - EsNodB = Esvec(ne); - EsNo = 10^(EsNodB/10); - - variance = 1/EsNo; - if verbose > 1 - printf("EsNo (dB): %f EsNo: %f variance: %f\n", EsNodB, EsNo, variance); - end - - Terrs = 0; Tbits = 0; Terrsldpc = 0; Tbitsldpc = 0; Ferrsldpc = 0; - - tx_symb_log = []; - rx_symb_log = []; - noise_log = []; - mod_strip_log = []; - - % init HF channel - - hf_n = 1; - hf_angle_log = []; - hf_fading = ones(1,Nsymb); % default input for ldpc dec - hf_model = ones(Ntrials*Nsymb/Nc, Nc); % defaults for plotting surface - - for nn = 1: Ntrials - - tx_bits = round( rand( 1, framesize*rate ) ); - - % modulate -------------------------------------------- - - if ldpc_code - [tx_bits, s] = ldpc_enc(tx_bits, code_param); - else - s = zeros(1, Nsymb); - for i=1:Nsymb - tx_symb = qpsk_mod(tx_bits(2*(i-1)+1:2*i)); - if strcmp(modulation,'dqpsk') - tx_symb *= prev_sym_tx; - prev_sym_tx = tx_symb; - end - s(i) = tx_symb; - end - end - tx_bits_buf(1:framesize) = tx_bits_buf(framesize+1:2*framesize); - tx_bits_buf(framesize+1:2*framesize) = tx_bits; - s_ch = s; - - % HF channel simulation ------------------------------------ - - if hf_sim - - % separation between carriers. Note this is - % effectively under samples at Rs, I dont think this - % matters. Equivalent to doing freq shift at Fs, then - % decimating to Rs. - - wsep = 2*pi*(1+0.5); % e.g. 75Hz spacing at Rs=50Hz, alpha=0.5 filters - - if Nsymb/Nc != floor(Nsymb/Nc) - printf("Error: Nsymb/Nc must be an integrer\n") - return; - end - - % arrange symbols in Nsymb/Nc by Nc matrix - - for i=1:Nc:Nsymb - - % Determine HF channel at each carrier for this symbol - - for k=1:Nc - hf_model(hf_n, k) = hf_gain*(spread(hf_n) + exp(-j*k*wsep*nhfdelay)*spread_2ms(hf_n)); - hf_fading(i+k-1) = abs(hf_model(hf_n, k)); - if hf_mag_only - s_ch(i+k-1) *= abs(hf_model(hf_n, k)); - else - s_ch(i+k-1) *= hf_model(hf_n, k); - end - end - hf_n++; - end - end - - tx_symb_log = [tx_symb_log s_ch]; - - % AWGN noise and phase/freq offset channel simulation - % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im - - noise = sqrt(variance*0.5)*(randn(1,Nsymb) + j*randn(1,Nsymb)); - noise_log = [noise_log noise]; - phase_noise = phase_noise_amp*(2.0*rand(1,Nsymb)-1.0); - - % organise into carriers to apply frequency and phase offset - - for i=1:Nc:Nsymb - for k=1:Nc - s_ch(i+k-1) = s_ch(i+k-1)*exp(j*(phase_offset+phase_noise(i+k-1))) + noise(i+k-1); - end - phase_offset += w_offset; - end - - % phase estimation - - ph_est = zeros(Nc,1); - - if phase_est - - % organise into carriers - - for i=1:Nc:Nsymb - - for k=1:Nc - centre = floor(Nps/2)+1; - - % delay line for phase est window - - r_delay_line(k,1:Nps-1) = r_delay_line(k,2:Nps); - r_delay_line(k,Nps) = s_ch(i+k-1); - - % delay in tx data to compensate data for phase est window - - s_delay_line(k,1:Nps-1) = s_delay_line(k,2:Nps); - s_delay_line(k,Nps) = s(i+k-1); - %tx_bits(2*(i+k-1-1)+1:2*(i+k-1)) = qpsk_demod(s_delay_line(k,centre)); - - if phase_est_method == 1 - % QPSK modulation strip and phase est - - mod_strip_pol = angle(r_delay_line(k,:)) * 4; - mod_strip_rect = exp(j*mod_strip_pol); - - ph_est_pol = atan2(sum(imag(mod_strip_rect)),sum(real(mod_strip_rect)))/4; - ph_est(k) = exp(j*ph_est_pol); - - s_ch(i+k-1) = r_delay_line(k,centre).*exp(-j*ph_est_pol); - else - - % estimate phase from surrounding known pilot symbols and correct - - corr = 0; - for m=1:Ns:Nps - if (m != centre) - corr += s_delay_line(k,m) * r_delay_line(k,m)'; - end - end - ph_est(k) = conj(corr/(1E-6+abs(corr))); - s_ch(i+k-1) = r_delay_line(k,centre).*exp(j*angle(corr)); - end - - end - - ph_est_log = [ph_est_log ph_est]; - end - %printf("corr: %f angle: %f\n", corr, angle(corr)); - end - - % de-modulate - - rx_bits = zeros(1, framesize); - for i=1:Nsymb - rx_symb = s_ch(i); - if strcmp(modulation,'dqpsk') - tmp = rx_symb; - rx_symb *= conj(prev_sym_rx/abs(prev_sym_rx)); - prev_sym_rx = tmp; - end - rx_bits((2*(i-1)+1):(2*i)) = qpsk_demod(rx_symb); - rx_symb_log = [rx_symb_log rx_symb]; - end - - rx_bits_buf(1:framesize) = rx_bits_buf(framesize+1:2*framesize); - rx_bits_buf(framesize+1:2*framesize) = rx_bits; - rx_symb_buf(1:Nsymb) = rx_symb_buf(Nsymb+1:2*Nsymb); - rx_symb_buf(Nsymb+1:2*Nsymb) = s_ch; - - % determine location of start and end of frame depending on processing delays - - if phase_est - st_rx_bits = 1+(floor(Nps/2)+1-1)*Nc*2; - st_rx_symb = 1+(floor(Nps/2)+1-1)*Nc; - else - st_rx_bits = 1; - st_rx_symb = 1; - end - en_rx_bits = st_rx_bits+framesize-1; - en_rx_symb = st_rx_symb+Nsymb-1; - - if nn > 1 - % Measure BER - - %printf("nn: %d centre: %d\n", nn, floor(Nps/2)+1); - %tx_bits_buf(1:20) - %rx_bits_buf(st_rx_bits:st_rx_bits+20-1) - error_positions = xor(rx_bits_buf(st_rx_bits:en_rx_bits), tx_bits_buf(1:framesize)); - Nerrs = sum(error_positions); - Terrs += Nerrs; - Tbits += length(tx_bits); - - % Optionally LDPC decode - - if ldpc_code - detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, rx_symb_buf(st_rx_symb:en_rx_symb), min(100,EsNo), hf_fading); - %for m=1:20 - % printf("%f ", qpsk_demod(rx_symb_buf(m))); - %end - %detected_data(1:19) - error_positions = xor( detected_data(1:framesize*rate), tx_bits_buf(1:framesize*rate) ); - Nerrs = sum(error_positions); - if Nerrs - Ferrsldpc++; - end - Terrsldpc += Nerrs; - Tbitsldpc += framesize*rate; - end - end - end - - TERvec(ne) = Terrs; - BERvec(ne) = Terrs/Tbits; - if ldpc_code - TERldpcvec(ne) = Terrsldpc; - FERldpcvec(ne) = Ferrsldpc; - BERldpcvec(ne) = Terrsldpc/Tbitsldpc; - end - - if verbose - printf("EsNo (dB): %f Terrs: %d BER %f BER theory %f", EsNodB, Terrs, - Terrs/Tbits, 0.5*erfc(sqrt(EsNo/2))); - if ldpc_code - printf(" LDPC: Terrs: %d BER: %f Ferrs: %d FER: %f", - Terrsldpc, Terrsldpc/Tbitsldpc, Ferrsldpc, Ferrsldpc/(Ntrials-1)); - end - printf("\n"); - end - if verbose > 1 - printf("Terrs: %d BER %f BER theory %f C %f N %f Es %f No %f Es/No %f\n\n", Terrs, - Terrs/Tbits, 0.5*erfc(sqrt(EsNo/2)), var(tx_symb_log), var(noise_log), - var(tx_symb_log), var(noise_log), var(tx_symb_log)/var(noise_log)); - end - end - - Ebvec = Esvec - 10*log10(bps); - sim_out.BERvec = BERvec; - sim_out.Ebvec = Ebvec; - sim_out.TERvec = TERvec; - if ldpc_code - sim_out.BERldpcvec = BERldpcvec; - sim_out.TERldpcvec = TERldpcvec; - sim_out.FERldpcvec = FERldpcvec; - end - - if plot_scatter - figure(2); - clf; - scat = rx_symb_log .* exp(j*pi/4); - plot(real(scat(Nps*Nc:length(scat))), imag(scat(Nps*Nc:length(scat))),'+'); - title('Scatter plot'); - - figure(3); - clf; - - y = 1:Rs*2; - x = 1:Nc; - EsNodBSurface = 20*log10(abs(hf_model(y,:))) - 10*log10(variance); - mesh(x,y,EsNodBSurface); - grid - %axis([1 Nc 1 Rs*2 -10 10]) - title('HF Channel Es/No'); - - figure(4); - clf; - %mesh(x,y,unwrap(angle(hf_model(y,:)))); - subplot(211) - plot(y,abs(hf_model(y,1))) - title('HF Channel Carrier 1 Mag'); - subplot(212) - plot(y,angle(hf_model(y,1))) - title('HF Channel Carrier 1 Phase'); - - if phase_est - scat = ph_est_log(1,floor(Nps/2):Rs*2+floor(Nps/2)-1); - hold on; - plot(angle(scat),'r'); - hold off; - - figure(5) - clf; - scat = ph_est_log(1,y); - plot(real(scat), imag(scat),'+'); - title('Carrier 1 Phase Est'); - axis([-1 1 -1 1]) - end -if 0 - figure(5); - clf; - subplot(211) - plot(real(spread)); - hold on; - plot(imag(spread),'g'); - hold off; - subplot(212) - plot(real(spread_2ms)); - hold on; - plot(imag(spread_2ms),'g'); - hold off; - - figure(6) - tmp = []; - for i = 1:hf_n-1 - tmp = [tmp abs(hf_model(i,:))]; - end - hist(tmp); -end - end - -endfunction - -% Gray coded QPSK modulation function - -function symbol = qpsk_mod(two_bits) - two_bits_decimal = sum(two_bits .* [2 1]); - switch(two_bits_decimal) - case (0) symbol = 1; - case (1) symbol = j; - case (2) symbol = -j; - case (3) symbol = -1; - endswitch -endfunction - -% Gray coded QPSK demodulation function - -function two_bits = qpsk_demod(symbol) - if isscalar(symbol) == 0 - printf("only works with scalars\n"); - return; - end - bit0 = real(symbol*exp(j*pi/4)) < 0; - bit1 = imag(symbol*exp(j*pi/4)) < 0; - two_bits = [bit1 bit0]; -endfunction - -function sim_in = standard_init - sim_in.verbose = 1; - sim_in.plot_scatter = 0; - - sim_in.Esvec = 5; - sim_in.Ntrials = 30; - sim_in.framesize = 576; - sim_in.Rs = 100; - sim_in.Nc = 8; - - sim_in.phase_offset = 0; - sim_in.w_offset = 0; - sim_in.phase_noise_amp = 0; - - sim_in.hf_delay_ms = 2; - sim_in.hf_sim = 0; - sim_in.hf_phase_only = 0; - sim_in.hf_mag_only = 1; - - sim_in.phase_est = 0; - sim_in.phase_est_method = 1; - sim_in.Np = 5; - sim_in.Ns = 5; - - sim_in.ldpc_code_rate = 1/2; - sim_in.ldpc_code = 1; -endfunction - -function ideal - - sim_in = standard_init(); - - sim_in.verbose = 1; - sim_in.plot_scatter = 1; - - sim_in.Esvec = 5; - sim_in.hf_sim = 1; - sim_in.Ntrials = 30; - - sim_qpsk_hf = ber_test(sim_in, 'qpsk'); - - sim_in.hf_sim = 0; - sim_in.plot_scatter = 0; - sim_in.Esvec = 2:15; - sim_in.ldpc_code = 0; - Ebvec = sim_in.Esvec - 10*log10(2); - BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10))); - sim_qpsk = ber_test(sim_in, 'qpsk'); - sim_dqpsk = ber_test(sim_in, 'dqpsk'); - - sim_in.hf_sim = 1; - sim_in.Esvec = 2:15; - sim_qpsk_hf = ber_test(sim_in, 'qpsk'); - sim_dqpsk_hf = ber_test(sim_in, 'dqpsk'); - sim_in.ldpc_code = 1; - sim_qpsk_hf_ldpc1 = ber_test(sim_in, 'qpsk'); - sim_in.ldpc_code_rate = 1/2; - sim_qpsk_hf_ldpc2 = ber_test(sim_in, 'qpsk'); - sim_in.ldpc_code_rate = 3/4; - sim_in.hf_sim = 0; - sim_qpsk_awgn_ldpc = ber_test(sim_in, 'qpsk'); - - figure(1); - clf; - semilogy(Ebvec, BER_theory,'r;QPSK theory;') - hold on; - semilogy(sim_qpsk.Ebvec, sim_qpsk.BERvec,'g;QPSK AWGN;') - semilogy(sim_qpsk_hf.Ebvec, sim_qpsk_hf.BERvec,'r;QPSK HF;') - semilogy(sim_dqpsk.Ebvec, sim_dqpsk.BERvec,'c;DQPSK AWGN;') - semilogy(sim_dqpsk_hf.Ebvec, sim_dqpsk_hf.BERvec,'m;DQPSK HF;') - semilogy(sim_qpsk_hf_ldpc1.Ebvec, sim_qpsk_hf_ldpc1.BERldpcvec,'k;QPSK HF LDPC 3/4;') - semilogy(sim_qpsk_hf_ldpc2.Ebvec, sim_qpsk_hf_ldpc2.BERldpcvec,'b;QPSK HF LDPC 1/2;') - semilogy(sim_qpsk_awgn_ldpc.Ebvec, sim_qpsk_awgn_ldpc.BERldpcvec,'k;QPSK AWGN LDPC 3/4;') - - hold off; - xlabel('Eb/N0') - ylabel('BER') - grid("minor") - axis([min(Ebvec) max(Ebvec) 1E-3 1]) -endfunction - -function phase_noise - sim_in = standard_init(); - - sim_in.verbose = 1; - sim_in.plot_scatter = 1; - - sim_in.Esvec = 100; - sim_in.Ntrials = 30; - - sim_in.ldpc_code_rate = 1/2; - sim_in.ldpc_code = 1; - - sim_in.phase_noise_amp = pi/16; - tmp = ber_test(sim_in, 'qpsk'); - - sim_in.plot_scatter = 0; - sim_in.Esvec = 2:8; - sim_qpsk_hf = ber_test(sim_in, 'qpsk'); - - Ebvec = sim_in.Esvec - 10*log10(2); - BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10))); - - sim_in.phase_noise_amp = 0; - sim_qpsk = ber_test(sim_in, 'qpsk'); - sim_in.phase_noise_amp = pi/8; - sim_qpsk_pn8 = ber_test(sim_in, 'qpsk'); - sim_in.phase_noise_amp = pi/16; - sim_qpsk_pn16 = ber_test(sim_in, 'qpsk'); - sim_in.phase_noise_amp = pi/32; - sim_qpsk_pn32 = ber_test(sim_in, 'qpsk'); - - figure(1); - clf; - semilogy(sim_qpsk.Ebvec, sim_qpsk.BERvec,'g;QPSK phase noise 0;') - hold on; - semilogy(sim_qpsk_pn8.Ebvec, sim_qpsk_pn8.BERvec,'c;QPSK phase noise +/- pi/8;') - semilogy(sim_qpsk_pn16.Ebvec, sim_qpsk_pn16.BERvec,'b;QPSK phase noise +/- pi/16;') - semilogy(sim_qpsk_pn32.Ebvec, sim_qpsk_pn32.BERvec,'k;QPSK phase noise +/- pi/32;') - - semilogy(sim_qpsk.Ebvec, sim_qpsk.BERldpcvec,'g;QPSK phase noise 0 ldpc;') - semilogy(sim_qpsk_pn8.Ebvec, sim_qpsk_pn8.BERldpcvec,'c;QPSK phase noise +/- pi/8 ldpc;') - semilogy(sim_qpsk_pn16.Ebvec, sim_qpsk_pn16.BERldpcvec,'b;QPSK phase noise +/- pi/16 ldpc;') - semilogy(sim_qpsk_pn32.Ebvec, sim_qpsk_pn32.BERldpcvec,'k;QPSK phase noise +/- pi/32 ldpc;') - - hold off; - xlabel('Eb/N0') - ylabel('BER') - grid("minor") - axis([min(Ebvec) max(Ebvec) 1E-2 1]) -endfunction - -function test_phase_est - sim_in = standard_init(); - - sim_in.Rs = 100; - sim_in.Nc = 8; - - sim_in.verbose = 1; - sim_in.plot_scatter = 1; - - sim_in.Esvec = 5; - sim_in.Ntrials = 30; - - sim_in.ldpc_code_rate = 1/2; - sim_in.ldpc_code = 1; - - sim_in.phase_est = 1; - sim_in.phase_est_method = 2; - sim_in.Np = 3; - sim_in.phase_offset = 0; - sim_in.w_offset = 0; - - sim_in.hf_sim = 1; - sim_in.hf_mag_only = 0; - - tmp = ber_test(sim_in, 'qpsk'); - -endfunction - -% Start simulations --------------------------------------- - -more off; - -test_phase_est(); diff --git a/codec2/octave/test_qpsk3.m b/codec2/octave/test_qpsk3.m deleted file mode 100644 index 37efad87..00000000 --- a/codec2/octave/test_qpsk3.m +++ /dev/null @@ -1,955 +0,0 @@ -% test_qps3k.m -% David Rowe March 2014 -% -% QPSK modem simulation, version 2. Simplifed version of -% test_qpsk. Initially based on code by Bill Cowley Generates curves -% BER versus E/No curves for different modems. Design to test -% coherent demodulation ideas on HF channels without building a full -% blown modem. Uses 'genie provided' estimates for timing estimation, -% frame sync. -% -% Compared to test_qsk2.m this version supports phase estimation -% (coherent demod) - -1; - -% main test function - -function sim_out = ber_test(sim_in, modulation) - Fs = 8000; - - newldpc = sim_in.newldpc; - verbose = sim_in.verbose; - framesize = sim_in.framesize; - Ntrials = sim_in.Ntrials; - Esvec = sim_in.Esvec; - phase_offset = sim_in.phase_offset; - phase_est = sim_in.phase_est; - w_offset = sim_in.w_offset; - plot_scatter = sim_in.plot_scatter; - Rs = sim_in.Rs; - hf_sim = sim_in.hf_sim; - nhfdelay = sim_in.hf_delay_ms*Rs/1000; - hf_phase_only = sim_in.hf_phase_only; - hf_mag_only = sim_in.hf_mag_only; - Nc = sim_in.Nc; - sim_coh_dpsk = sim_in.sim_coh_dpsk; - - bps = 2; - Nsymb = framesize/bps; - for k=1:Nc - prev_sym_tx(k) = qpsk_mod([0 0]); - prev_sym_rx(k) = qpsk_mod([0 0]); - end - - phase_est_method = sim_in.phase_est_method; - if phase_est_method == 2 - Np = sim_in.Np; - Ns = sim_in.Ns; - if Np/2 == floor(Np/2) - printf("Np must be odd\n"); - return; - end - Nps = (Np-1)*Ns+1; - else - Nps = sim_in.Np; - end - r_delay_line = zeros(Nc, Nps); - s_delay_line = zeros(Nc, Nps); - ph_est_log = []; - - phase_noise_amp = sim_in.phase_noise_amp; - - ldpc_code = sim_in.ldpc_code; - - tx_bits_buf = zeros(1,2*framesize); - rx_bits_buf = zeros(1,2*framesize); - rx_symb_buf = zeros(1,2*Nsymb); - hf_fading_buf = zeros(1,2*Nsymb); - - % Init LDPC -------------------------------------------------------------------- - - if ldpc_code - % Start CML library - - currentdir = pwd; - addpath '/home/david/tmp/cml/mat' % assume the source files stored here - cd /home/david/tmp/cml - CmlStartup % note that this is not in the cml path! - cd(currentdir) - - % Our LDPC library - - ldpc; - - rate = sim_in.ldpc_code_rate; - mod_order = 4; - modulation2 = 'QPSK'; - mapping = 'gray'; - - demod_type = 0; - decoder_type = 0; - max_iterations = 100; - - code_param = ldpc_init(rate, framesize, modulation2, mod_order, mapping); - code_param.code_bits_per_frame = framesize; - code_param.symbols_per_frame = framesize/bps; - else - rate = 1; - end - - % Init HF channel model from stored sample files of spreading signal ---------------------------------- - - % convert "spreading" samples from 1kHz carrier at Fs to complex - % baseband, generated by passing a 1kHz sine wave through PathSim - % with the ccir-poor model, enabling one path at a time. - - Fc = 1000; M = Fs/Rs; - fspread = fopen("../raw/sine1k_2Hz_spread.raw","rb"); - spread1k = fread(fspread, "int16")/10000; - fclose(fspread); - fspread = fopen("../raw/sine1k_2ms_delay_2Hz_spread.raw","rb"); - spread1k_2ms = fread(fspread, "int16")/10000; - fclose(fspread); - - % down convert to complex baseband - spreadbb = spread1k.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k))'); - spreadbb_2ms = spread1k_2ms.*exp(-j*(2*pi*Fc/Fs)*(1:length(spread1k_2ms))'); - - % remove -2000 Hz image - b = fir1(50, 5/Fs); - spread = filter(b,1,spreadbb); - spread_2ms = filter(b,1,spreadbb_2ms); - - % discard first 1000 samples as these were near 0, probably as - % PathSim states were ramping up - - spread = spread(1000:length(spread)); - spread_2ms = spread_2ms(1000:length(spread_2ms)); - - % decimate down to Rs - - spread = spread(1:M:length(spread)); - spread_2ms = spread_2ms(1:M:length(spread_2ms)); - - % Determine "gain" of HF channel model, so we can normalise - % carrier power during HF channel sim to calibrate SNR. I imagine - % different implementations of ccir-poor would do this in - % different ways, leading to different BER results. Oh Well! - - hf_gain = 1.0/sqrt(var(spread)+var(spread_2ms)); - - % Start Simulation ---------------------------------------------------------------- - - for ne = 1:length(Esvec) - EsNodB = Esvec(ne); - EsNo = 10^(EsNodB/10); - - variance = 1/EsNo; - if verbose > 1 - printf("EsNo (dB): %f EsNo: %f variance: %f\n", EsNodB, EsNo, variance); - end - - Terrs = 0; Tbits = 0; Terrsldpc = 0; Tbitsldpc = 0; Ferrsldpc = 0; - - tx_symb_log = []; - rx_symb_log = []; - noise_log = []; - mod_strip_log = []; - - % init HF channel - - hf_n = 1; - hf_angle_log = []; - hf_fading = ones(1,Nsymb); % default input for ldpc dec - hf_model = ones(Ntrials*Nsymb/Nc, Nc); % defaults for plotting surface - - sim_out.errors_log = []; - sim_out.ldpc_errors_log = []; - - for nn = 1: Ntrials - - tx_bits = round( rand( 1, framesize*rate ) ); - - % modulate -------------------------------------------- - - if ldpc_code - [tx_bits, s] = ldpc_enc(tx_bits, code_param); - end - s = zeros(1, Nsymb); - for i=1:Nc:Nsymb - for k=1:Nc - tx_symb = qpsk_mod(tx_bits(2*(i-1+k-1)+1:2*(i+k-1))); - if strcmp(modulation,'dqpsk') - tx_symb *= prev_sym_tx(k); - prev_sym_tx(k) = tx_symb; - end - s(i+k-1) = tx_symb; - end - end - tx_bits_buf(1:framesize) = tx_bits_buf(framesize+1:2*framesize); - tx_bits_buf(framesize+1:2*framesize) = tx_bits; - s_ch = s; - - % HF channel simulation ------------------------------------ - - if hf_sim - - % separation between carriers. Note this is - % effectively under samples at Rs, I dont think this - % matters. Equivalent to doing freq shift at Fs, then - % decimating to Rs. - - wsep = 2*pi*(1+0.5); % e.g. 75Hz spacing at Rs=50Hz, alpha=0.5 filters - - if Nsymb/Nc != floor(Nsymb/Nc) - printf("Error: Nsymb/Nc must be an integrer\n") - return; - end - - % arrange symbols in Nsymb/Nc by Nc matrix - - for i=1:Nc:Nsymb - - % Determine HF channel at each carrier for this symbol - - for k=1:Nc - hf_model(hf_n, k) = hf_gain*(spread(hf_n) + exp(-j*k*wsep*nhfdelay)*spread_2ms(hf_n)); - hf_fading(i+k-1) = abs(hf_model(hf_n, k)); - if hf_mag_only - s_ch(i+k-1) *= abs(hf_model(hf_n, k)); - else - s_ch(i+k-1) *= hf_model(hf_n, k); - end - end - hf_n++; - end - end - - tx_symb_log = [tx_symb_log s_ch]; - - % AWGN noise and phase/freq offset channel simulation - % 0.5 factor ensures var(noise) == variance , i.e. splits power between Re & Im - - noise = sqrt(variance*0.5)*(randn(1,Nsymb) + j*randn(1,Nsymb)); - noise_log = [noise_log noise]; - phase_noise = phase_noise_amp*(2.0*rand(1,Nsymb)-1.0); - - % organise into carriers to apply frequency and phase offset - - for i=1:Nc:Nsymb - for k=1:Nc - s_ch(i+k-1) = s_ch(i+k-1)*exp(j*(phase_offset+phase_noise(i+k-1))) + noise(i+k-1); - end - phase_offset += w_offset; - end - - % phase estimation - - ph_est = zeros(Nc,1); - - if phase_est - - % organise into carriers - - for i=1:Nc:Nsymb - - for k=1:Nc - centre = floor(Nps/2)+1; - - % delay line for phase est window - - r_delay_line(k,1:Nps-1) = r_delay_line(k,2:Nps); - r_delay_line(k,Nps) = s_ch(i+k-1); - - % delay in tx data to compensate data for phase est window - - s_delay_line(k,1:Nps-1) = s_delay_line(k,2:Nps); - s_delay_line(k,Nps) = s(i+k-1); - - if phase_est_method == 1 - % QPSK modulation strip and phase est - - mod_strip_pol = angle(r_delay_line(k,:)) * 4; - mod_strip_rect = exp(j*mod_strip_pol); - - ph_est_pol = atan2(sum(imag(mod_strip_rect)),sum(real(mod_strip_rect)))/4; - ph_est(k) = exp(j*ph_est_pol); - - s_ch(i+k-1) = r_delay_line(k,centre).*exp(-j*ph_est_pol); - % s_ch(i+k-1) = r_delay_line(k,centre); - end - - if phase_est_method == 3 - % QPSK modulation strip and phase est with original symbol mags - - mod_strip_pol = angle(r_delay_line(k,:)) * 4; - mod_strip_rect = abs(r_delay_line(k,:)) .* exp(j*mod_strip_pol); - - ph_est_pol = atan2(sum(imag(mod_strip_rect)),sum(real(mod_strip_rect)))/4; - ph_est(k) = exp(j*ph_est_pol); - - s_ch(i+k-1) = r_delay_line(k,centre).*exp(-j*ph_est_pol); - % s_ch(i+k-1) = r_delay_line(k,centre); - end - - if phase_est_method == 2 - - % estimate phase from surrounding known pilot symbols and correct - - corr = 0; - for m=1:Ns:Nps - if (m != centre) - corr += s_delay_line(k,m) * r_delay_line(k,m)'; - end - end - ph_est(k) = conj(corr/(1E-6+abs(corr))); - s_ch(i+k-1) = r_delay_line(k,centre).*exp(j*angle(corr)); - %s_ch(i+k-1) = r_delay_line(k,centre); - end - - end - - ph_est_log = [ph_est_log ph_est]; - end - %printf("corr: %f angle: %f\n", corr, angle(corr)); - end - - % de-modulate - - rx_bits = zeros(1, framesize); - for i=1:Nc:Nsymb - for k=1:Nc - rx_symb = s_ch(i+k-1); - if strcmp(modulation,'dqpsk') - tmp = rx_symb; - rx_symb *= conj(prev_sym_rx(k)/abs(prev_sym_rx(k))); - if sim_coh_dpsk - prev_sym_rx(k) = qpsk_mod(qpsk_demod(tmp)); - else - prev_sym_rx(k) = tmp; - end - s_ch(i+k-1) = rx_symb; - end - rx_bits((2*(i-1+k-1)+1):(2*(i+k-1))) = qpsk_demod(rx_symb); - rx_symb_log = [rx_symb_log rx_symb]; - end - end - -if newldpc - rx_bits_buf(1:framesize) = rx_bits_buf(framesize+1:2*framesize); - rx_bits_buf(framesize+1:2*framesize) = rx_bits; - rx_symb_buf(1:Nsymb) = rx_symb_buf(Nsymb+1:2*Nsymb); - rx_symb_buf(Nsymb+1:2*Nsymb) = s_ch; - hf_fading_buf(1:Nsymb) = hf_fading_buf(Nsymb+1:2*Nsymb); - hf_fading_buf(Nsymb+1:2*Nsymb) = hf_fading; - - % determine location of start and end of frame depending on processing delays - - if phase_est - st_rx_bits = 1+(floor(Nps/2)+1-1)*Nc*2; - st_rx_symb = 1+(floor(Nps/2)+1-1)*Nc; - else - st_rx_bits = 1; - st_rx_symb = 1; - end - en_rx_bits = st_rx_bits+framesize-1; - en_rx_symb = st_rx_symb+Nsymb-1; - - if nn > 1 - % Measure BER - - %printf("nn: %d centre: %d\n", nn, floor(Nps/2)+1); - %tx_bits_buf(1:20) - %rx_bits_buf(st_rx_bits:st_rx_bits+20-1) - error_positions = xor(rx_bits_buf(st_rx_bits:en_rx_bits), tx_bits_buf(1:framesize)); - Nerrs = sum(error_positions); - sim_out.errors_log = [sim_out.errors_log error_positions]; - Terrs += Nerrs; - Tbits += length(tx_bits); - - % Optionally LDPC decode - - if ldpc_code - detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, ... - rx_symb_buf(st_rx_symb:en_rx_symb), min(100,EsNo), hf_fading_buf(1:Nsymb)); - error_positions = xor( detected_data(1:framesize*rate), tx_bits_buf(1:framesize*rate) ); - %detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, s_ch, min(100,EsNo), hf_fading); - %error_positions = xor( detected_data(1:framesize*rate), tx_bits(1:framesize*rate) ); - Nerrs = sum(error_positions); - sim_out.ldpc_errors_log = [sim_out.ldpc_errors_log error_positions]; - if Nerrs - Ferrsldpc++; - end - Terrsldpc += Nerrs; - Tbitsldpc += framesize*rate; - end - end - -else - error_positions = xor(rx_bits, tx_bits); - Nerrs = sum(error_positions); - Terrs += Nerrs; - Tbits += length(tx_bits); - - % Optionally LDPC decode - - if ldpc_code - detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, s_ch, min(100,EsNo), hf_fading); - error_positions = xor( detected_data(1:framesize*rate), tx_bits(1:framesize*rate) ); - Nerrs = sum(error_positions); - if Nerrs - Ferrsldpc++; - end - Terrsldpc += Nerrs; - Tbitsldpc += framesize*rate; - - end - end -end - - TERvec(ne) = Terrs; - BERvec(ne) = Terrs/Tbits; - if ldpc_code - TERldpcvec(ne) = Terrsldpc; - FERldpcvec(ne) = Ferrsldpc; - BERldpcvec(ne) = Terrsldpc/Tbitsldpc; - end - - if verbose - printf("EsNo (dB): %f Terrs: %d BER %f BER theory %f", EsNodB, Terrs, - Terrs/Tbits, 0.5*erfc(sqrt(EsNo/2))); - if ldpc_code - printf(" LDPC: Terrs: %d BER: %f Ferrs: %d FER: %f", - Terrsldpc, Terrsldpc/Tbitsldpc, Ferrsldpc, Ferrsldpc/(Ntrials-1)); - end - printf("\n"); - end - if verbose > 1 - printf("Terrs: %d BER %f BER theory %f C %f N %f Es %f No %f Es/No %f\n\n", Terrs, - Terrs/Tbits, 0.5*erfc(sqrt(EsNo/2)), var(tx_symb_log), var(noise_log), - var(tx_symb_log), var(noise_log), var(tx_symb_log)/var(noise_log)); - end - end - - Ebvec = Esvec - 10*log10(bps); - - % account for extra power rqd for pilot symbols - - if (phase_est_method == 2) && (phase_est) - Ebvec += 10*log10(Ns/(Ns-1)); - end - - sim_out.BERvec = BERvec; - sim_out.Ebvec = Ebvec; - sim_out.TERvec = TERvec; - if ldpc_code - sim_out.BERldpcvec = BERldpcvec; - sim_out.TERldpcvec = TERldpcvec; - sim_out.FERldpcvec = FERldpcvec; - end - - if plot_scatter - figure(2); - clf; - scat = rx_symb_log .* exp(j*pi/4); - plot(real(scat(Nps*Nc:length(scat))), imag(scat(Nps*Nc:length(scat))),'+'); - title('Scatter plot'); - - figure(3); - clf; - - y = 1:Rs*2; - x = 1:Nc; - EsNodBSurface = 20*log10(abs(hf_model(y,:))) - 10*log10(variance); - mesh(x,y,EsNodBSurface); - grid - %axis([1 Nc 1 Rs*2 -10 10]) - title('HF Channel Es/No'); - - figure(4); - clf; - %mesh(x,y,unwrap(angle(hf_model(y,:)))); - subplot(211) - plot(y,abs(hf_model(y,1))) - title('HF Channel Carrier 1 Mag'); - subplot(212) - plot(y,angle(hf_model(y,1))) - title('HF Channel Carrier 1 Phase'); - - if phase_est - scat = ph_est_log(1,floor(Nps/2):Rs*2+floor(Nps/2)-1); - hold on; - plot(angle(scat),'r'); - hold off; - - figure(5) - clf; - scat = ph_est_log(1,y); - plot(real(scat), imag(scat),'+'); - title('Carrier 1 Phase Est'); - axis([-1 1 -1 1]) - end -if 0 - figure(5); - clf; - subplot(211) - plot(real(spread)); - hold on; - plot(imag(spread),'g'); - hold off; - subplot(212) - plot(real(spread_2ms)); - hold on; - plot(imag(spread_2ms),'g'); - hold off; - - figure(6) - tmp = []; - for i = 1:hf_n-1 - tmp = [tmp abs(hf_model(i,:))]; - end - hist(tmp); -end - end - -size(sim_out.errors_log) - -endfunction - -% Gray coded QPSK modulation function - -function symbol = qpsk_mod(two_bits) - two_bits_decimal = sum(two_bits .* [2 1]); - switch(two_bits_decimal) - case (0) symbol = 1; - case (1) symbol = j; - case (2) symbol = -j; - case (3) symbol = -1; - endswitch -endfunction - -% Gray coded QPSK demodulation function - -function two_bits = qpsk_demod(symbol) - if isscalar(symbol) == 0 - printf("only works with scalars\n"); - return; - end - bit0 = real(symbol*exp(j*pi/4)) < 0; - bit1 = imag(symbol*exp(j*pi/4)) < 0; - two_bits = [bit1 bit0]; -endfunction - -function sim_in = standard_init - sim_in.verbose = 1; - sim_in.plot_scatter = 0; - - sim_in.Esvec = 5; - sim_in.Ntrials = 30; - sim_in.framesize = 576; - sim_in.Rs = 100; - sim_in.Nc = 8; - - sim_in.phase_offset = 0; - sim_in.w_offset = 0; - sim_in.phase_noise_amp = 0; - - sim_in.hf_delay_ms = 2; - sim_in.hf_sim = 0; - sim_in.hf_phase_only = 0; - sim_in.hf_mag_only = 1; - - sim_in.phase_est = 0; - sim_in.phase_est_method = 1; - sim_in.Np = 5; - sim_in.Ns = 5; - - sim_in.ldpc_code_rate = 1/2; - sim_in.ldpc_code = 1; -endfunction - -function ideal - - sim_in = standard_init(); - - sim_in.verbose = 1; - sim_in.plot_scatter = 1; - - sim_in.Esvec = 5; - sim_in.hf_sim = 1; - sim_in.Ntrials = 100; - - sim_qpsk_hf = ber_test(sim_in, 'qpsk'); - - sim_in.hf_sim = 0; - sim_in.plot_scatter = 0; - sim_in.Esvec = 2:15; - sim_in.ldpc_code = 0; - Ebvec = sim_in.Esvec - 10*log10(2); - BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10))); - sim_qpsk = ber_test(sim_in, 'qpsk'); - sim_dqpsk = ber_test(sim_in, 'dqpsk'); - - sim_in.hf_sim = 1; - sim_in.Esvec = 2:15; - sim_qpsk_hf = ber_test(sim_in, 'qpsk'); - sim_dqpsk_hf = ber_test(sim_in, 'dqpsk'); - sim_in.ldpc_code = 1; - sim_in.ldpc_code_rate = 3/4; - sim_qpsk_hf_ldpc1 = ber_test(sim_in, 'qpsk'); - sim_in.ldpc_code_rate = 1/2; - sim_qpsk_hf_ldpc2 = ber_test(sim_in, 'qpsk'); - sim_in.ldpc_code_rate = 3/4; - sim_in.hf_sim = 0; - sim_qpsk_awgn_ldpc = ber_test(sim_in, 'qpsk'); - - figure(1); - clf; - semilogy(Ebvec, BER_theory,'r;QPSK theory;') - hold on; - semilogy(sim_qpsk.Ebvec, sim_qpsk.BERvec,'g;QPSK AWGN;') - semilogy(sim_qpsk_hf.Ebvec, sim_qpsk_hf.BERvec,'r;QPSK HF;') - semilogy(sim_dqpsk.Ebvec, sim_dqpsk.BERvec,'c;DQPSK AWGN;') - semilogy(sim_dqpsk_hf.Ebvec, sim_dqpsk_hf.BERvec,'m;DQPSK HF;') - semilogy(sim_qpsk_hf_ldpc1.Ebvec, sim_qpsk_hf_ldpc1.BERldpcvec,'k;QPSK HF LDPC 3/4;') - semilogy(sim_qpsk_hf_ldpc2.Ebvec, sim_qpsk_hf_ldpc2.BERldpcvec,'b;QPSK HF LDPC 1/2;') - semilogy(sim_qpsk_awgn_ldpc.Ebvec, sim_qpsk_awgn_ldpc.BERldpcvec,'k;QPSK AWGN LDPC 3/4;') - - hold off; - xlabel('Eb/N0') - ylabel('BER') - grid("minor") - axis([min(Ebvec) max(Ebvec) 1E-3 1]) -endfunction - -function phase_noise - sim_in = standard_init(); - - sim_in.verbose = 1; - sim_in.plot_scatter = 1; - - sim_in.Esvec = 100; - sim_in.Ntrials = 100; - - sim_in.ldpc_code_rate = 1/2; - sim_in.ldpc_code = 1; - - sim_in.phase_noise_amp = pi/16; - tmp = ber_test(sim_in, 'qpsk'); - - sim_in.plot_scatter = 0; - sim_in.Esvec = 2:8; - sim_qpsk_hf = ber_test(sim_in, 'qpsk'); - - Ebvec = sim_in.Esvec - 10*log10(2); - BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10))); - - sim_in.phase_noise_amp = 0; - sim_qpsk = ber_test(sim_in, 'qpsk'); - sim_in.phase_noise_amp = pi/8; - sim_qpsk_pn8 = ber_test(sim_in, 'qpsk'); - sim_in.phase_noise_amp = pi/16; - sim_qpsk_pn16 = ber_test(sim_in, 'qpsk'); - sim_in.phase_noise_amp = pi/32; - sim_qpsk_pn32 = ber_test(sim_in, 'qpsk'); - - figure(1); - clf; - semilogy(sim_qpsk.Ebvec, sim_qpsk.BERvec,'g;QPSK phase noise 0;') - hold on; - semilogy(sim_qpsk_pn8.Ebvec, sim_qpsk_pn8.BERvec,'c;QPSK phase noise +/- pi/8;') - semilogy(sim_qpsk_pn16.Ebvec, sim_qpsk_pn16.BERvec,'b;QPSK phase noise +/- pi/16;') - semilogy(sim_qpsk_pn32.Ebvec, sim_qpsk_pn32.BERvec,'k;QPSK phase noise +/- pi/32;') - - semilogy(sim_qpsk.Ebvec, sim_qpsk.BERldpcvec,'g;QPSK phase noise 0 ldpc;') - semilogy(sim_qpsk_pn8.Ebvec, sim_qpsk_pn8.BERldpcvec,'c;QPSK phase noise +/- pi/8 ldpc;') - semilogy(sim_qpsk_pn16.Ebvec, sim_qpsk_pn16.BERldpcvec,'b;QPSK phase noise +/- pi/16 ldpc;') - semilogy(sim_qpsk_pn32.Ebvec, sim_qpsk_pn32.BERldpcvec,'k;QPSK phase noise +/- pi/32 ldpc;') - - hold off; - xlabel('Eb/N0') - ylabel('BER') - grid("minor") - axis([min(Ebvec) max(Ebvec) 1E-2 1]) -endfunction - -function phase_est_hf - sim_in = standard_init(); - - sim_in.Rs = 100; - sim_in.Nc = 8; - - sim_in.verbose = 1; - sim_in.plot_scatter = 0; - - sim_in.Esvec = 5:15; - sim_in.Ntrials = 100; - - sim_in.newldpc = 1; - sim_in.ldpc_code_rate = 1/2; - sim_in.ldpc_code = 1; - - sim_in.phase_est = 0; - sim_in.sim_coh_dpsk = 0; - sim_in.phase_est_method = 2; - sim_in.Np = 3; - sim_in.phase_offset = 0; - sim_in.w_offset = 0; - - sim_in.hf_sim = 1; - sim_in.hf_mag_only = 1; - - Ebvec = sim_in.Esvec - 10*log10(2); - - baseline = ber_test(sim_in, 'qpsk'); - - sim_in.hf_mag_only = 0; - sim_in.phase_est_method = 2; - sim_in.phase_est = 1; - sim_in.Np = 3; - pilot_3 = ber_test(sim_in, 'qpsk'); - sim_in.Np = 5; - pilot_5 = ber_test(sim_in, 'qpsk'); - sim_in.Np = 7; - pilot_7 = ber_test(sim_in, 'qpsk'); - -if 1 - sim_in.phase_est = 0; - dqpsk = ber_test(sim_in, 'dqpsk'); - - figure(1); - clf; - semilogy(baseline.Ebvec, baseline.BERvec,'r;QPSK CCIR poor;') - hold on; - semilogy(baseline.Ebvec, baseline.BERldpcvec,'r;QPSK CCIR poor ldpc;') - semilogy(pilot_3.Ebvec, pilot_3.BERvec,'b;QPSK CCIR poor ldpc pilot 3;') - semilogy(pilot_3.Ebvec, pilot_3.BERldpcvec,'b;QPSK CCIR poor ldpc pilot 3;') - semilogy(pilot_5.Ebvec, pilot_5.BERvec,'g;QPSK CCIR poor ldpc pilot 5;') - semilogy(pilot_5.Ebvec, pilot_5.BERldpcvec,'g;QPSK CCIR poor ldpc pilot 5;') - semilogy(pilot_7.Ebvec, pilot_7.BERvec,'m;QPSK CCIR poor ldpc pilot 7;') - semilogy(pilot_7.Ebvec, pilot_7.BERldpcvec,'m;QPSK CCIR poor ldpc pilot 7;') - semilogy(dqpsk.Ebvec, dqpsk.BERvec,'k;DQPSK CCIR poor ldpc;') - semilogy(dqpsk.Ebvec, dqpsk.BERldpcvec,'k;DQPSK CCIR poor ldpc;') - - hold off; - xlabel('Eb/N0') - ylabel('BER') - grid("minor") - axis([min(Ebvec) max(Ebvec) 1E-2 1]) -end -endfunction - -function phase_est_awgn - sim_in = standard_init(); - - sim_in.Rs = 100; - sim_in.Nc = 8; - - sim_in.verbose = 1; - sim_in.plot_scatter = 0; - - sim_in.Esvec = 0:0.5:3; - sim_in.Ntrials = 30; - - sim_in.newldpc = 1; - sim_in.ldpc_code_rate = 1/2; - sim_in.ldpc_code = 1; - - sim_in.phase_est = 0; - sim_in.phase_est_method = 1; - sim_in.Np = 3; - sim_in.phase_offset = 0; - sim_in.w_offset = 0; - - sim_in.hf_sim = 0; - sim_in.hf_mag_only = 1; - - ideal = ber_test(sim_in, 'qpsk'); - - sim_in.phase_est = 1; - sim_in.Np = 21; - sim_in.phase_est_method = 3; - strip_21_mag = ber_test(sim_in, 'qpsk'); - - sim_in.Np = 41; - strip_41_mag = ber_test(sim_in, 'qpsk'); - - sim_in.phase_est_method = 1; - sim_in.Np = 21; - strip_21 = ber_test(sim_in, 'qpsk'); - - sim_in.Np = 41; - strip_41 = ber_test(sim_in, 'qpsk'); - - sim_in.Np = 7; - sim_in.phase_est_method = 2; - pilot_7 = ber_test(sim_in, 'qpsk'); - - Ebvec = sim_in.Esvec - 10*log10(2); - - figure(1); - clf; - semilogy(ideal.Ebvec, ideal.BERvec,'r;QPSK;') - hold on; - semilogy(ideal.Ebvec, ideal.BERldpcvec,'r;QPSK LDPC;') - semilogy(strip_21.Ebvec, strip_21.BERvec,'g;QPSK strip 21;') - semilogy(strip_21.Ebvec, strip_21.BERldpcvec,'g;QPSK LDPC strip 21;') - semilogy(strip_41.Ebvec, strip_41.BERvec,'b;QPSK strip 41;') - semilogy(strip_41.Ebvec, strip_41.BERldpcvec,'b;QPSK LDPC strip 41;') - semilogy(strip_21_mag.Ebvec, strip_21_mag.BERvec,'m;QPSK strip 21 mag;') - semilogy(strip_21_mag.Ebvec, strip_21_mag.BERldpcvec,'m;QPSK LDPC strip 21 mag;') - semilogy(strip_41_mag.Ebvec, strip_41_mag.BERvec,'c;QPSK strip 41 mag;') - semilogy(strip_41_mag.Ebvec, strip_41_mag.BERldpcvec,'c;QPSK LDPC strip 41 mag;') - semilogy(pilot_7.Ebvec, pilot_7.BERvec,'k;QPSK pilot 7;') - semilogy(pilot_7.Ebvec, pilot_7.BERldpcvec,'k;QPSK LDPC pilot 7;') - - hold off; - xlabel('Eb/N0') - ylabel('BER') - grid("minor") - axis([min(Ebvec) max(Ebvec) 1E-2 1]) -endfunction - -function test_dpsk - sim_in = standard_init(); - - sim_in.Rs = 100; - sim_in.Nc = 8; - - sim_in.verbose = 1; - sim_in.plot_scatter = 0; - - sim_in.Esvec = 5; - sim_in.Ntrials = 30; - - sim_in.newldpc = 1; - sim_in.ldpc_code_rate = 1/2; - sim_in.ldpc_code = 1; - - sim_in.phase_est = 0; - sim_in.phase_est_method = 3; - sim_in.Np = 41; - sim_in.phase_offset = 0; - sim_in.w_offset = 0; - sim_in.sim_coh_dpsk = 0; - - sim_in.hf_sim = 0; - sim_in.hf_mag_only = 1; - - Ebvec = sim_in.Esvec - 10*log10(2); - - baseline = ber_test(sim_in, 'qpsk'); - sim_in.phase_est = 0; - dqpsk = ber_test(sim_in, 'dqpsk'); - - sim_in.phase_est = 1; - sim_in.phase_est_method = 3; - sim_in.sim_coh_dpsk = 1; - sim_in.Np = 41; - dqpsk_strip_41 = ber_test(sim_in, 'dqpsk'); - - figure(1); - clf; - semilogy(baseline.Ebvec, baseline.BERvec,'r;QPSK CCIR poor;') - hold on; - semilogy(baseline.Ebvec, baseline.BERldpcvec,'r;QPSK CCIR poor ldpc;') - semilogy(dqpsk.Ebvec, dqpsk.BERvec,'c;DQPSK CCIR poor ldpc;') - semilogy(dqpsk.Ebvec, dqpsk.BERldpcvec,'c;DQPSK CCIR poor ldpc;') - semilogy(dqpsk_strip_41.Ebvec, dqpsk_strip_41.BERvec,'m;DQPSK CCIR poor ldpc strip 41;') - semilogy(dqpsk_strip_41.Ebvec, dqpsk_strip_41.BERldpcvec,'m;DQPSK CCIR poor ldpc strip 41;') - - hold off; - xlabel('Eb/N0') - ylabel('BER') - grid("minor") - axis([min(Ebvec) max(Ebvec) 1E-2 1]) - -endfunction - -function gen_error_pattern_qpsk() - sim_in = standard_init(); - - % model codec and uncoded streams as 1000 bit/s each - - sim_in.Rs = 100; - sim_in.Nc = 4; - - sim_in.verbose = 1; - sim_in.plot_scatter = 0; - - sim_in.Esvec = 10; % Eb/No=2dB - sim_in.Ntrials = 30; - - sim_in.newldpc = 1; - sim_in.ldpc_code_rate = 1/2; - sim_in.ldpc_code = 1; - - sim_in.phase_est = 1; - sim_in.phase_est_method = 2; - sim_in.Np = 5; - sim_in.phase_offset = 0; - sim_in.w_offset = 0; - sim_in.sim_coh_dpsk = 0; - - sim_in.hf_sim = 1; - sim_in.hf_mag_only = 0; - - qpsk = ber_test(sim_in, 'qpsk'); - - length(qpsk.errors_log) - length(qpsk.ldpc_errors_log) - % multiplex errors into prot and unprot halves of 52 bit codec frames - - error_pattern = []; - for i=1:26:length(qpsk.ldpc_errors_log)-52 - error_pattern = [error_pattern qpsk.ldpc_errors_log(i:i+25) qpsk.errors_log(i:i+25) zeros(1,4)]; - %error_pattern = [error_pattern qpsk.ldpc_errors_log(i:i+25) zeros(1,26) zeros(1,4)]; - %error_pattern = [error_pattern zeros(1,26) qpsk.errors_log(i:i+25) zeros(1,4)]; - end - - fep=fopen("qpsk_errors_2dB.bin","wb"); fwrite(fep, error_pattern, "short"); fclose(fep); - -endfunction - -function gen_error_pattern_dpsk() - sim_in = standard_init(); - - sim_in.Rs = 50; - sim_in.Nc = 16; - - sim_in.verbose = 1; - sim_in.plot_scatter = 1; - - sim_in.Esvec = 10; % Eb/No=Es/No-3 - sim_in.Ntrials = 30; - - sim_in.newldpc = 1; - sim_in.ldpc_code_rate = 1/2; - sim_in.ldpc_code = 0; - - sim_in.phase_est = 0; - sim_in.phase_est_method = 3; - sim_in.Np = 41; - sim_in.phase_offset = 0; - sim_in.w_offset = 0; - sim_in.sim_coh_dpsk = 0; - - sim_in.hf_sim = 1; - sim_in.hf_mag_only = 1; - - dqpsk = ber_test(sim_in, 'dqpsk'); - - fep=fopen("dqpsk_errors_12dB.bin","wb"); fwrite(fep, dqpsk.errors_log, "short"); fclose(fep); - -endfunction - -% Start simulations --------------------------------------- - -more off; - -%ideal(); -%phase_est_hf(); -%phase_est_awgn(); -%test_dpsk(); -gen_error_pattern_qpsk diff --git a/codec2/octave/tfdmdv.m b/codec2/octave/tfdmdv.m deleted file mode 100644 index 41e68c88..00000000 --- a/codec2/octave/tfdmdv.m +++ /dev/null @@ -1,306 +0,0 @@ -% tfdmdv.m -% -% Octave script that tests the C port of the FDMDV modem. This script loads -% the output of unittest/tfdmdv.c and compares it to the output of the -% reference versions of the same functions written in Octave. -% -% Copyright David Rowe 2012 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% - -fdmdv; % load modem code - -% Generate reference vectors using Octave implementation of FDMDV modem - -global passes; -global fails; -passes = fails = 0; -frames = 25; -prev_tx_symbols = ones(Nc+1,1); -prev_rx_symbols = ones(Nc+1,1); -foff_phase_rect = 1; -coarse_fine = 0; -fest_state = 0; -channel = []; -channel_count = 0; -next_nin = M; -sig_est = zeros(Nc+1,1); -noise_est = zeros(Nc+1,1); - -% Octave outputs we want to collect for comparison to C version - -tx_bits_log = []; -tx_symbols_log = []; -tx_baseband_log = []; -tx_fdm_log = []; -pilot_baseband1_log = []; -pilot_baseband2_log = []; -pilot_lpf1_log = []; -pilot_lpf2_log = []; -S1_log = []; -S2_log = []; -foff_coarse_log = []; -foff_fine_log = []; -foff_log = []; -rx_baseband_log = []; -rx_filt_log = []; -env_log = []; -rx_timing_log = []; -rx_symbols_log = []; -rx_bits_log = []; -sync_bit_log = []; -coarse_fine_log = []; -nin_log = []; -sig_est_log = []; -noise_est_log = []; - -for f=1:frames - - % modulator - - tx_bits = get_test_bits(Nc*Nb); - tx_bits_log = [tx_bits_log tx_bits]; - tx_symbols = bits_to_qpsk(prev_tx_symbols, tx_bits, 'dqpsk'); - prev_tx_symbols = tx_symbols; - tx_symbols_log = [tx_symbols_log tx_symbols]; - tx_baseband = tx_filter(tx_symbols); - tx_baseband_log = [tx_baseband_log tx_baseband]; - tx_fdm = fdm_upconvert(tx_baseband); - tx_fdm_log = [tx_fdm_log tx_fdm]; - - % channel - - nin = next_nin; - %nin = 120; - %nin = M; - %if (f == 3) - % nin = 120; - %elseif (f == 4) - % nin = 200; - %else - % nin = M; - %end - channel = [channel real(tx_fdm)]; - channel_count += M; - rx_fdm = channel(1:nin); - channel = channel(nin+1:channel_count); - channel_count -= nin; - - % demodulator - - [pilot prev_pilot pilot_lut_index prev_pilot_lut_index] = get_pilot(pilot_lut_index, prev_pilot_lut_index, nin); - - [foff_coarse S1 S2] = rx_est_freq_offset(rx_fdm, pilot, prev_pilot, nin); - if coarse_fine == 0 - foff = foff_coarse; - end - foff_coarse_log = [foff_coarse_log foff_coarse]; - - pilot_baseband1_log = [pilot_baseband1_log pilot_baseband1]; - pilot_baseband2_log = [pilot_baseband2_log pilot_baseband2]; - pilot_lpf1_log = [pilot_lpf1_log pilot_lpf1]; - pilot_lpf2_log = [pilot_lpf2_log pilot_lpf2]; - S1_log = [S1_log S1]; - S2_log = [S2_log S2]; - - foff_rect = exp(j*2*pi*foff/Fs); - - for i=1:nin - foff_phase_rect *= foff_rect'; - rx_fdm_fcorr(i) = rx_fdm(i)*foff_phase_rect; - end - - rx_baseband = fdm_downconvert(rx_fdm_fcorr, nin); - rx_baseband_log = [rx_baseband_log rx_baseband]; - - rx_filt = rx_filter(rx_baseband, nin); - rx_filt_log = [rx_filt_log rx_filt]; - - [rx_symbols rx_timing env] = rx_est_timing(rx_filt, rx_baseband, nin); - env_log = [env_log env]; - - rx_timing_log = [rx_timing_log rx_timing]; - rx_symbols_log = [rx_symbols_log rx_symbols]; - - next_nin = M; - if rx_timing > 2*M/P - next_nin += M/P; - end - if rx_timing < 0; - next_nin -= M/P; - end - nin_log = [nin_log nin]; - - [rx_bits sync_bit foff_fine pd] = qpsk_to_bits(prev_rx_symbols, rx_symbols, 'dqpsk'); - - [sig_est noise_est] = snr_update(sig_est, noise_est, pd); - sig_est_log = [sig_est_log sig_est]; - noise_est_log = [noise_est_log noise_est]; - - prev_rx_symbols = rx_symbols; - rx_bits_log = [rx_bits_log rx_bits]; - foff_fine_log = [foff_fine_log foff_fine]; - sync_bit_log = [sync_bit_log sync_bit]; - foff -= 0.5*foff_fine; - foff_log = [foff_log foff]; - - % freq est state machine - - [coarse_fine fest_state] = freq_state(sync_bit, fest_state); - coarse_fine_log = [coarse_fine_log coarse_fine]; -end - -% Compare to the output from the C version - -load ../unittest/tfdmdv_out.txt - -% Helper functions to plot output of C verson and difference between Octave and C versions - -function stem_sig_and_error(plotnum, subplotnum, sig, error, titlestr, axisvec) - figure(plotnum) - subplot(subplotnum) - stem(sig); - hold on; - stem(error,'g'); - hold off; - if nargin == 6 - axis(axisvec); - end - title(titlestr); -endfunction - -function plot_sig_and_error(plotnum, subplotnum, sig, error, titlestr, axisvec) - figure(plotnum) - subplot(subplotnum) - plot(sig); - hold on; - plot(error,'g'); - hold off; - if nargin == 6 - axis(axisvec); - end - title(titlestr); -endfunction - -% --------------------------------------------------------------------------------------- -% Plot output and test each C function -% --------------------------------------------------------------------------------------- - -% fdmdv_get_test_bits() & bits_to_dqpsk_symbols() - -n = 28; -stem_sig_and_error(1, 211, tx_bits_log_c(1:n), tx_bits_log(1:n) - tx_bits_log_c(1:n), 'tx bits', [1 n -1.5 1.5]) -stem_sig_and_error(1, 212, real(tx_symbols_log_c(1:n/2)), real(tx_symbols_log(1:n/2) - tx_symbols_log_c(1:n/2)), 'tx symbols real', [1 n/2 -1.5 1.5]) - -% tx_filter() - -diff = tx_baseband_log - tx_baseband_log_c; -c=15; -plot_sig_and_error(2, 211, real(tx_baseband_log_c(c,:)), real(sum(diff)), 'tx baseband real') -plot_sig_and_error(2, 212, imag(tx_baseband_log_c(c,:)), imag(sum(diff)), 'tx baseband imag') - -% fdm_upconvert() - -plot_sig_and_error(3, 211, real(tx_fdm_log_c), real(tx_fdm_log - tx_fdm_log_c), 'tx fdm real') -plot_sig_and_error(3, 212, imag(tx_fdm_log_c), imag(tx_fdm_log - tx_fdm_log_c), 'tx fdm imag') - -% generate_pilot_lut() - -plot_sig_and_error(4, 211, real(pilot_lut_c), real(pilot_lut - pilot_lut_c), 'pilot lut real') -plot_sig_and_error(4, 212, imag(pilot_lut_c), imag(pilot_lut - pilot_lut_c), 'pilot lut imag') - -% rx_est_freq_offset() - -st=1; en = 3*Npilotbaseband; -plot_sig_and_error(5, 211, real(pilot_baseband1_log(st:en)), real(pilot_baseband1_log(st:en) - pilot_baseband1_log_c(st:en)), 'pilot baseband1 real' ) -plot_sig_and_error(5, 212, real(pilot_baseband2_log(st:en)), real(pilot_baseband2_log(st:en) - pilot_baseband2_log_c(st:en)), 'pilot baseband2 real' ) - -st=1; en = 3*Npilotlpf; -plot_sig_and_error(6, 211, real(pilot_lpf1_log(st:en)), real(pilot_lpf1_log(st:en) - pilot_lpf1_log_c(st:en)), 'pilot lpf1 real' ) -plot_sig_and_error(6, 212, real(pilot_lpf2_log(st:en)), real(pilot_lpf2_log(st:en) - pilot_lpf2_log_c(st:en)), 'pilot lpf2 real' ) - -plot_sig_and_error(7, 211, real(S1_log), real(S1_log - S1_log_c), 'S1 real' ) -plot_sig_and_error(7, 212, imag(S1_log), imag(S1_log - S1_log_c), 'S1 imag' ) - -plot_sig_and_error(8, 211, real(S2_log), real(S2_log - S2_log_c), 'S2 real' ) -plot_sig_and_error(8, 212, imag(S2_log), imag(S2_log - S2_log_c), 'S2 imag' ) - -plot_sig_and_error(9, 211, foff_coarse_log, foff_coarse_log - foff_coarse_log_c, 'Coarse Freq Offset' ) -plot_sig_and_error(9, 212, foff_fine_log, foff_fine_log - foff_fine_log_c, 'Fine Freq Offset' ) - -plot_sig_and_error(10, 211, foff_log, foff_log - foff_log_c, 'Freq Offset' ) -plot_sig_and_error(10, 212, coarse_fine_log, coarse_fine_log - coarse_fine_log_c, 'Freq Est Coarse(0) Fine(1)', [1 frames -0.5 1.5] ) - -c=15; -plot_sig_and_error(11, 211, real(rx_baseband_log(c,:)), real(rx_baseband_log(c,:) - rx_baseband_log_c(c,:)), 'Rx baseband real' ) -plot_sig_and_error(11, 212, imag(rx_baseband_log(c,:)), imag(rx_baseband_log(c,:) - rx_baseband_log_c(c,:)), 'Rx baseband imag' ) - -plot_sig_and_error(12, 211, real(rx_filt_log(c,:)), real(rx_filt_log(c,:) - rx_filt_log_c(c,:)), 'Rx filt real' ) -plot_sig_and_error(12, 212, imag(rx_filt_log(c,:)), imag(rx_filt_log(c,:) - rx_filt_log_c(c,:)), 'Rx filt imag' ) - -st=1; en=3*Nt*P; -plot_sig_and_error(13, 211, env_log(st:en), env_log(st:en) - env_log_c(st:en), 'env' ) -stem_sig_and_error(13, 212, real(rx_symbols_log(c,:)), real(rx_symbols_log(c,:) - rx_symbols_log_c(c,:)), 'rx symbols' ) - -st=10*28; -en = 12*28; -plot_sig_and_error(14, 211, rx_timing_log, rx_timing_log - rx_timing_log_c, 'Rx Timing' ) -stem_sig_and_error(14, 212, sync_bit_log_c, sync_bit_log - sync_bit_log_c, 'Sync bit', [1 n -1.5 1.5]) - -stem_sig_and_error(15, 211, rx_bits_log_c(st:en), rx_bits_log(st:en) - rx_bits_log_c(st:en), 'RX bits', [1 en-st -1.5 1.5]) -stem_sig_and_error(15, 212, nin_log_c, nin_log - nin_log_c, 'nin') - -c = 1; -plot_sig_and_error(16, 211, sig_est_log(c,:), sig_est_log(c,:) - sig_est_log_c(c,:), 'sig est for SNR' ) -plot_sig_and_error(16, 212, noise_est_log(c,:), noise_est_log(c,:) - noise_est_log_c(c,:), 'noise est for SNR' ) - -% --------------------------------------------------------------------------------------- -% AUTOMATED CHECKS ------------------------------------------ -% --------------------------------------------------------------------------------------- - -function check(a, b, test_name) - global passes; - global fails; - - [m n] = size(a); - printf("%s", test_name); - for i=1:(25-length(test_name)) - printf("."); - end - printf(": "); - - if sum(abs(a - b))/n < 1E-3 - printf("OK\n"); - passes++; - else - printf("FAIL\n"); - fails++; - end -endfunction - -check(tx_bits_log, tx_bits_log_c, 'tx_bits'); -check(tx_symbols_log, tx_symbols_log_c, 'tx_symbols'); -check(tx_baseband_log, tx_baseband_log_c, 'tx_baseband'); -check(tx_fdm_log, tx_fdm_log_c, 'tx_fdm'); -check(pilot_lut, pilot_lut_c, 'pilot_lut'); -check(pilot_baseband1_log, pilot_baseband1_log_c, 'pilot lpf1'); -check(pilot_baseband2_log, pilot_baseband2_log_c, 'pilot lpf2'); -check(S1_log, S1_log_c, 'S1'); -check(S2_log, S2_log_c, 'S2'); -check(foff_coarse_log, foff_coarse_log_c, 'foff_coarse'); -check(foff_fine_log, foff_fine_log_c, 'foff_fine'); -check(foff_log, foff_log_c, 'foff'); -check(rx_baseband_log, rx_baseband_log_c, 'rx baseband'); -check(rx_filt_log, rx_filt_log_c, 'rx filt'); -check(env_log, env_log_c, 'env'); -check(rx_timing_log, rx_timing_log_c, 'rx_timing'); -check(rx_symbols_log, rx_symbols_log_c, 'rx_symbols'); -check(rx_bits_log, rx_bits_log_c, 'rx bits'); -check(sync_bit_log, sync_bit_log_c, 'sync bit'); -check(coarse_fine_log, coarse_fine_log_c, 'coarse_fine'); -check(nin_log, nin_log_c, 'nin'); -check(sig_est_log, sig_est_log_c, 'sig_est'); -check(noise_est_log, noise_est_log_c, 'noise_est'); - -printf("\npasses: %d fails: %d\n", passes, fails); diff --git a/codec2/octave/tget_spec.m b/codec2/octave/tget_spec.m deleted file mode 100644 index 593f2af2..00000000 --- a/codec2/octave/tget_spec.m +++ /dev/null @@ -1,49 +0,0 @@ -% tget-spec.m -% -% Used in conjunction with src/fdmdv_demod to test the -% fdmdv_get_rx_spectrum() function. -% -% codec2/src$ ./fdmdv_demod fdmdv_mod.raw tmp.c2 dump.txt -% octave:3> tget_spec("../src/dump.txt") -% -% Copyright David Rowe 2012 -% This program is distributed under the terms of the GNU General Public License -% Version 2 -% - -function tfft_log(dumpfilename) - - load(dumpfilename); - - [rows cols] = size(rx_spec_log_c); - Fs = 8000; low_freq = 0; high_freq = 2500; - res = (Fs/2)/cols; - st_bin = low_freq/res + 1; - en_bin = high_freq/res; - xaxis = (st_bin:en_bin)*res; - - f_start = 2; f_end = 100; - beta = 0.1; - - av = zeros(f_end, en_bin-st_bin+1); - for r=f_start:f_end - x = (1-beta)*av(r-1,:) + beta*rx_spec_log_c(r,st_bin:en_bin); - av(r,:) = x; - end - - % spectrogram (waterfall) - - figure(1) - clf; - imagesc(av,[-40 0]); - - % animated spectrum display - - figure(2) - clf; - for r=f_start:f_end - plot(xaxis, av(r,:)) - axis([ low_freq high_freq -40 0]) - sleep(0.1) - end -endfunction diff --git a/codec2/octave/twotone.m b/codec2/octave/twotone.m deleted file mode 100644 index a20c5c5a..00000000 --- a/codec2/octave/twotone.m +++ /dev/null @@ -1,52 +0,0 @@ -% twotone.m -% David Rowe Aug 2012 -% Used to experiment with combining phase of two tones - -function cbphase - - Wo = 100.0*pi/4000; - L = floor(pi/Wo); - phi = zeros(1,L); - - % two harmonics - - a = 20; b = 21; - - % set up phases to whatever - - phi(a) = -pi; - phi(b) = -pi/2; - - % synthesis the two-tone signal - - N = 16000; - Nplot = 250; - s = zeros(1,N); - - for m=a:b - s_m = cos(m*Wo*(0:(N-1)) + phi(m)); - s = s + s_m; - endfor - - % now our theory says that this signal should be the same perceptually - - phi_(a) = (phi(a) - phi(b))/2; - phi_(b) = (phi(b) - phi(a))/2; - - s_ = zeros(1,N); - for m=a:b - s_m = cos(m*Wo*(0:(N-1)) + phi_(m)); - s_ = s_ + s_m; - endfor - - % plot them and see if envelope has the same phase, but "carriers" - % have different phase - - figure(1); - clf; - subplot(211); - plot(s(1:Nplot)); - subplot(212); - plot(s_(1:Nplot),'r'); -endfunction - diff --git a/codec2/octave/twotone1.m b/codec2/octave/twotone1.m deleted file mode 100644 index 9f36c68d..00000000 --- a/codec2/octave/twotone1.m +++ /dev/null @@ -1,76 +0,0 @@ -% twotone1.m -% David Rowe Aug 17 2012 -% -% Used to experiment with combining phase of two tones. This version -% sets up a complete synthetic speech signal then tries to combine the -% phase of high frequency tones. Lets see if we can do this and keep perceptual -% nature of signal the same. - -function twotone1 - - % hts1a frame 47 - - Wo = 0.093168; - L = 33; - %A = [69.626907 460.218536 839.677429 2577.498047 972.647888 712.755066 489.048553 364.830536 409.230652 371.767487 489.112854 893.127014 2447.596680 752.878113 475.720520 234.452271 248.161606 232.171051 202.669891 323.914490 678.749451 362.958038 211.652512 170.764435 148.631790 169.261673 272.254150 176.872375 67.344391 99.022301 60.812035 34.319073 14.864757]; - A = zeros(1,L)*100; - phi = [1.560274 1.508063 -1.565184 1.289117 -2.547365 1.412528 -1.303992 3.121130 1.087573 -1.158161 -2.928007 0.995093 -2.614023 0.246136 -2.267406 2.143802 -0.273431 -2.266897 1.685171 -0.668712 2.699722 -1.151891 2.406379 -0.046192 -2.718611 0.761067 -2.305014 0.133172 -1.428978 1.492630 -1.668385 1.539734 -1.336615]; - %phi = zeros(1,L); - st = floor(L/2); - %st = 1; - - A(st:st+5) = 1000; - - % now set up phase of signal with phase of upper frequency harmonic - % pairs combined - - phi_ = phi; - for m=floor(L/2):2:L - phi_(m) = (phi(m) - phi(m+1))/2; - phi_(m+1) = (phi(m+1) - phi(m))/2; - %phi_(m+1) = 0; - end - - % synthesise the signals - - N = 16000; - Nplot = 250; - - s = zeros(1,N); - for m=st:L - s_m = A(m)*cos(m*Wo*(0:(N-1)) + phi(m)); - s = s + s_m; - endfor - - s_ = zeros(1,N); - for m=st:L - s_m = A(m)*cos(m*Wo*(0:(N-1)) + phi_(m)); - s_ = s_ + s_m; - endfor - - % plot them, expect to see similar time domain waveforms - - figure(1); - clf; - subplot(211); - plot(s(1:Nplot)); - subplot(212); - plot(s_(1:Nplot),'r'); - - figure(2); - clf; - subplot(211); - plot(s(1:Nplot)-s_(1:Nplot)); - - % save to disk - - gain = 1; - fs=fopen("twotone1_orig.raw","wb"); - fwrite(fs,gain*s,"short"); - fclose(fs); - fs=fopen("twotone1_comb.raw","wb"); - fwrite(fs,gain*s_,"short"); - fclose(fs); - -endfunction - diff --git a/codec2/octave/undersample.m b/codec2/octave/undersample.m deleted file mode 100644 index 1bfbf38b..00000000 --- a/codec2/octave/undersample.m +++ /dev/null @@ -1,26 +0,0 @@ -% undersample.m -% David Rowe 5 Nov 2012 -% Testing algorithms for plotting undersampled data for fdmdv2 waveform displays - -fs=fopen("../raw/hts1a.raw","rb"); -s = fread(fs,Inf,"short"); - -Fs1=8000; -Fs2=200; - -M=Fs1/Fs2; - -samples=length(s)/M; -s1=zeros(1,2*samples); -for b=1:samples - st = (b-1)*M + 1; - en = b*M; - s1(2*b-1) = max(s(st:en)); - s1(2*b) = min(s(st:en)); -end - -subplot(211) -plot(s) -subplot(212) -plot(s1); - diff --git a/codec2/portaudio/Makefile b/codec2/portaudio/Makefile deleted file mode 100644 index 39255b6c..00000000 --- a/codec2/portaudio/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -# Makefile for Portaudio test programs -# Requires Portaudio V19 - -CFLAGS = -g -Wall -I../src -LIBS = -lm -lportaudio -pthread -SRC = ../src/fdmdv.c ../src/kiss_fft.c ../src/fifo.c - -all: pa_rec pa_play pa_recplay pa_impresp - -pa_rec: Makefile pa_rec.c $(SRC) - gcc $(CFLAGS) pa_rec.c $(SRC) -o pa_rec $(LIBS) - -pa_play: Makefile pa_play.c $(SRC) - gcc $(CFLAGS) pa_play.c $(SRC) -o pa_play $(LIBS) - -pa_recplay: Makefile pa_recplay.c $(SRC) - gcc $(CFLAGS) pa_recplay.c $(SRC) -o pa_recplay $(LIBS) - -pa_impresp: Makefile pa_impresp.c $(SRC) - gcc $(CFLAGS) pa_impresp.c $(SRC) -o pa_impresp $(LIBS) - -clean: - rm -f pa_rec pa_play pa_recplay diff --git a/codec2/portaudio/pa_impresp.c b/codec2/portaudio/pa_impresp.c deleted file mode 100644 index 7317e07e..00000000 --- a/codec2/portaudio/pa_impresp.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - pa_impresp.c - David Rowe - August 29 2012 - - Measures the impulse reponse of the path between the speaker and - microphone. Used to explore why Codec audio quality is - different through a speaker and headphones. - - Modified from pa_playrec.c -*/ - -/* - * $Id: paex_record.c 1752 2011-09-08 03:21:55Z philburk $ - * - * This program uses the PortAudio Portable Audio Library. - * For more information see: http://www.portaudio.com - * Copyright (c) 1999-2000 Ross Bencina and Phil Burk - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files - * (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include -#include "portaudio.h" -#include "fdmdv.h" - -#define SAMPLE_RATE 48000 /* 48 kHz sampling rate rec. as we - can trust accuracy of sound - card */ -#define N8 160 /* processing buffer size at 8 kHz */ -#define N48 (N8*FDMDV_OS) /* processing buffer size at 48 kHz */ -#define MEM8 (FDMDV_OS_TAPS/FDMDV_OS) -#define NUM_CHANNELS 2 /* I think most sound cards prefer - stereo, we will convert to mono - as we sample */ - -#define IMPULSE_AMP 16384 /* amplitide of impulse */ -#define IMPULSE_PERIOD 0.1 /* period (dly between impulses) in secs */ - -/* state information passed to call back */ - -typedef struct { - float in48k[FDMDV_OS_TAPS + N48]; - float in8k[MEM8 + N8]; - FILE *fimp; - float *impulse_buf; - int impulse_buf_length; - int impulse_sample_count; - int framesLeft; -} paTestData; - - -/* - This routine will be called by the PortAudio engine when audio is - required. It may be called at interrupt level on some machines so - don't do anything that could mess up the system like calling - malloc() or free(). -*/ - -static int callback( const void *inputBuffer, void *outputBuffer, - unsigned long framesPerBuffer, - const PaStreamCallbackTimeInfo* timeInfo, - PaStreamCallbackFlags statusFlags, - void *userData ) -{ - paTestData *data = (paTestData*)userData; - int i; - short *rptr = (short*)inputBuffer; - short *wptr = (short*)outputBuffer; - float *in8k = data->in8k; - float *in48k = data->in48k; - float out8k[N8]; - float out48k[N48]; - short out48k_short[N48]; - short out8k_short[N8]; - - (void) timeInfo; - (void) statusFlags; - - assert(inputBuffer != NULL); - - /* just use left channel */ - - for(i=0; iin48k[i+FDMDV_OS_TAPS] = *rptr; - - /* downsample and update filter memory */ - - fdmdv_48_to_8(out8k, &in48k[FDMDV_OS_TAPS], N8); - for(i=0; ifimp); - - /* play side, read from impulse buffer */ - - for(i=0; iimpulse_buf[data->impulse_sample_count]; - data->impulse_sample_count++; - if (data->impulse_sample_count == data->impulse_buf_length) - data->impulse_sample_count = 0; - } - - /* upsample and update filter memory */ - - fdmdv_8_to_48(out48k, &in8k[MEM8], N8); - for(i=0; iframesLeft -= framesPerBuffer; - if (data->framesLeft > 0) - return paContinue; - else - return paComplete; -} - -int main(int argc, char *argv[]) -{ - PaStreamParameters inputParameters, outputParameters; - PaStream* stream; - PaError err = paNoError; - paTestData data; - int i, numSecs; - - if (argc != 3) { - printf("usage: %s impulseRawFile time(s)\n", argv[0]); - exit(0); - } - - data.fimp = fopen(argv[1], "wb"); - if (data.fimp == NULL) { - printf("Error opening impulse output file %s\n", argv[1]); - exit(1); - } - - numSecs = atoi(argv[2]); - data.framesLeft = numSecs * SAMPLE_RATE; - - /* init filter states */ - - for(i=0; idefaultLowInputLatency; - inputParameters.hostApiSpecificStreamInfo = NULL; - - outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */ - if (outputParameters.device == paNoDevice) { - fprintf(stderr,"Error: No default output device.\n"); - goto done; - } - outputParameters.channelCount = NUM_CHANNELS; /* stereo output */ - outputParameters.sampleFormat = paInt16; - outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; - outputParameters.hostApiSpecificStreamInfo = NULL; - - /* Play some audio --------------------------------------------- */ - - err = Pa_OpenStream( - &stream, - &inputParameters, - &outputParameters, - SAMPLE_RATE, - N48, - paClipOff, - callback, - &data ); - if( err != paNoError ) goto done; - - err = Pa_StartStream( stream ); - if( err != paNoError ) goto done; - - while( ( err = Pa_IsStreamActive( stream ) ) == 1 ) - { - Pa_Sleep(100); - } - if( err < 0 ) goto done; - - err = Pa_CloseStream( stream ); - if( err != paNoError ) goto done; - - -done: - Pa_Terminate(); - if( err != paNoError ) - { - fprintf( stderr, "An error occured while using the portaudio stream\n" ); - fprintf( stderr, "Error number: %d\n", err ); - fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); - err = 1; /* Always return 0 or 1, but no other return codes. */ - } - - fclose(data.fimp); - - return err; -} - diff --git a/codec2/portaudio/pa_play.c b/codec2/portaudio/pa_play.c deleted file mode 100644 index 00ea0868..00000000 --- a/codec2/portaudio/pa_play.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - pa_play.c - David Rowe - July 8 2012 - - Converts samples from a 16 bit short 8000 Hz rawfile to 480000Hz - sample rate and plays them using the default sound device. Used as - an intermediate step in Portaudio integration. - - Modified from paex_record.c Portaudio example. Original author - author Phil Burk http://www.softsynth.com -*/ - -/* - * $Id: paex_record.c 1752 2011-09-08 03:21:55Z philburk $ - * - * This program uses the PortAudio Portable Audio Library. - * For more information see: http://www.portaudio.com - * Copyright (c) 1999-2000 Ross Bencina and Phil Burk - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files - * (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include -#include "portaudio.h" -#include "fdmdv.h" - -#define SAMPLE_RATE 48000 /* 48 kHz sampling rate rec. as we - can trust accuracy of sound - card */ -#define N8 160 /* processing buffer size at 8 kHz */ -#define N48 (N8*FDMDV_OS) /* processing buffer size at 48 kHz */ -#define MEM8 (FDMDV_OS_TAPS/FDMDV_OS) -#define NUM_CHANNELS 2 /* I think most sound cards prefer - stereo, we will convert to mono - as we sample */ - -/* state information passed to call back */ - -typedef struct { - FILE *fin; - float in8k[MEM8 + N8]; -} paTestData; - - -/* - This routine will be called by the PortAudio engine when audio is - required. It may be called at interrupt level on some machines so - don't do anything that could mess up the system like calling - malloc() or free(). -*/ - -static int playCallback( const void *inputBuffer, void *outputBuffer, - unsigned long framesPerBuffer, - const PaStreamCallbackTimeInfo* timeInfo, - PaStreamCallbackFlags statusFlags, - void *userData ) -{ - paTestData *data = (paTestData*)userData; - FILE *fin = data->fin; - int i, nread; - int finished; - short *wptr = (short*)outputBuffer; - float *in8k = data->in8k; - float out48k[N48]; - short out48k_short[N48]; - short in8k_short[N8]; - - (void) outputBuffer; /* Prevent unused variable warnings. */ - (void) timeInfo; - (void) statusFlags; - (void) userData; - - /* note Portaudio docs recs. against making systems calls like - fwrite() in this callback but seems to work OK */ - - nread = fread(in8k_short, sizeof(short), N8, fin); - if (nread == N8) - finished = paContinue; - else - finished = paComplete; - - for(i=0; idefaultLowOutputLatency; - outputParameters.hostApiSpecificStreamInfo = NULL; - - /* Play some audio --------------------------------------------- */ - - err = Pa_OpenStream( - &stream, - NULL, - &outputParameters, - SAMPLE_RATE, - N48, - paClipOff, - playCallback, - &data ); - if( err != paNoError ) goto done; - - err = Pa_StartStream( stream ); - if( err != paNoError ) goto done; - - while( ( err = Pa_IsStreamActive( stream ) ) == 1 ) - { - Pa_Sleep(100); - } - if( err < 0 ) goto done; - - err = Pa_CloseStream( stream ); - if( err != paNoError ) goto done; - - fclose(data.fin); - - -done: - Pa_Terminate(); - if( err != paNoError ) - { - fprintf( stderr, "An error occured while using the portaudio stream\n" ); - fprintf( stderr, "Error number: %d\n", err ); - fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); - err = 1; /* Always return 0 or 1, but no other return codes. */ - } - return err; -} - diff --git a/codec2/portaudio/pa_rec.c b/codec2/portaudio/pa_rec.c deleted file mode 100644 index 00023b02..00000000 --- a/codec2/portaudio/pa_rec.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - pa_rec.c - David Rowe - July 6 2012 - - Records at 48000 Hz from default sound device, convertes to 8 kHz, - and saves to raw file. Used to get experience with Portaudio. - - Modified from paex_record.c Portaudio example. Original author - author Phil Burk http://www.softsynth.com - - To Build: - - gcc paex_rec.c -o paex_rec -lm -lrt -lportaudio -pthread -*/ - -/* - * $Id: paex_record.c 1752 2011-09-08 03:21:55Z philburk $ - * - * This program uses the PortAudio Portable Audio Library. - * For more information see: http://www.portaudio.com - * Copyright (c) 1999-2000 Ross Bencina and Phil Burk - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files - * (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include -#include "portaudio.h" -#include "fdmdv.h" - -#define SAMPLE_RATE 48000 /* 48 kHz sampling rate rec. as we - can trust accuracy of sound - card */ -#define N8 160 /* processing buffer size at 8 kHz */ -#define N48 (N8*FDMDV_OS) /* processing buffer size at 48 kHz */ -#define NUM_CHANNELS 2 /* I think most sound cards prefer - stereo, we will convert to mono - as we sample */ - -/* state information passed to call back */ - -typedef struct { - FILE *fout; - int framesLeft; - float in48k[FDMDV_OS_TAPS + N48]; -} paTestData; - - -/* - This routine will be called by the PortAudio engine when audio is - available. It may be called at interrupt level on some machines so - don't do anything that could mess up the system like calling - malloc() or free(). -*/ - -static int recordCallback( const void *inputBuffer, void *outputBuffer, - unsigned long framesPerBuffer, - const PaStreamCallbackTimeInfo* timeInfo, - PaStreamCallbackFlags statusFlags, - void *userData ) -{ - paTestData *data = (paTestData*)userData; - FILE *fout = data->fout; - int framesToCopy; - int i; - int finished; - short *rptr = (short*)inputBuffer; - float out8k[N8]; - short out8k_short[N8]; - - (void) outputBuffer; /* Prevent unused variable warnings. */ - (void) timeInfo; - (void) statusFlags; - (void) userData; - - if (data->framesLeft < framesPerBuffer) { - framesToCopy = data->framesLeft; - finished = paComplete; - } - else { - framesToCopy = framesPerBuffer; - finished = paContinue; - } - data->framesLeft -= framesToCopy; - - assert(inputBuffer != NULL); - - /* just use left channel */ - - for(i=0; iin48k[i+FDMDV_OS_TAPS] = *rptr; - - /* downsample and update filter memory */ - - fdmdv_48_to_8(out8k, &data->in48k[FDMDV_OS_TAPS], N8); - for(i=0; iin48k[i] = data->in48k[i+framesToCopy]; - - /* save 8k to disk */ - - for(i=0; idefaultLowInputLatency; - inputParameters.hostApiSpecificStreamInfo = NULL; - - /* Record some audio --------------------------------------------- */ - - err = Pa_OpenStream( - &stream, - &inputParameters, - NULL, /* &outputParameters, */ - SAMPLE_RATE, - N48, - paClipOff, /* we won't output out of range samples so don't bother clipping them */ - recordCallback, - &data ); - if( err != paNoError ) goto done; - - err = Pa_StartStream( stream ); - if( err != paNoError ) goto done; - - while( ( err = Pa_IsStreamActive( stream ) ) == 1 ) - { - Pa_Sleep(100); - } - if( err < 0 ) goto done; - - err = Pa_CloseStream( stream ); - if( err != paNoError ) goto done; - - fclose(data.fout); - - -done: - Pa_Terminate(); - if( err != paNoError ) - { - fprintf( stderr, "An error occured while using the portaudio stream\n" ); - fprintf( stderr, "Error number: %d\n", err ); - fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); - err = 1; /* Always return 0 or 1, but no other return codes. */ - } - return err; -} - diff --git a/codec2/portaudio/pa_recplay.c b/codec2/portaudio/pa_recplay.c deleted file mode 100644 index 6bfcd08b..00000000 --- a/codec2/portaudio/pa_recplay.c +++ /dev/null @@ -1,270 +0,0 @@ -/* - pa_recplay.c - David Rowe - July 8 2012 - - Echos audio from sound card input to sound card output. Samples at - 48 kHz, converts to 8 kHz, converts back to 48kHz, and plays using - the default sound device. Used as an intermediate step in - Portaudio integration. - - Modified from paex_record.c Portaudio example. Original author - author Phil Burk http://www.softsynth.com -*/ - -/* - * $Id: paex_record.c 1752 2011-09-08 03:21:55Z philburk $ - * - * This program uses the PortAudio Portable Audio Library. - * For more information see: http://www.portaudio.com - * Copyright (c) 1999-2000 Ross Bencina and Phil Burk - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files - * (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include -#include "portaudio.h" -#include "fdmdv.h" -#include "fifo.h" - -#define SAMPLE_RATE 48000 /* 48 kHz sampling rate rec. as we - can trust accuracy of sound - card */ -#define N8 160 /* processing buffer size at 8 kHz */ -#define N48 (N8*FDMDV_OS) /* processing buffer size at 48 kHz */ -#define MEM8 (FDMDV_OS_TAPS/FDMDV_OS) -#define NUM_CHANNELS 2 /* I think most sound cards prefer - stereo, we will convert to mono - as we sample */ -#define MAX_FPB 2048 /* maximum value of framesPerBuffer */ - -/* state information passed to call back */ - -typedef struct { - float in48k[FDMDV_OS_TAPS + N48]; - float in8k[MEM8 + N8]; - struct FIFO *infifo; - struct FIFO *outfifo; -} paTestData; - - -/* - This routine will be called by the PortAudio engine when audio is - required. It may be called at interrupt level on some machines so - don't do anything that could mess up the system like calling - malloc() or free(). -*/ - -static int callback( const void *inputBuffer, void *outputBuffer, - unsigned long framesPerBuffer, - const PaStreamCallbackTimeInfo* timeInfo, - PaStreamCallbackFlags statusFlags, - void *userData ) -{ - paTestData *data = (paTestData*)userData; - int i; - short *rptr = (short*)inputBuffer; - short *wptr = (short*)outputBuffer; - float *in8k = data->in8k; - float *in48k = data->in48k; - float out8k[N8]; - float out48k[N48]; - short out48k_short[N48]; - short in48k_short[N48]; - short indata[MAX_FPB]; - short outdata[MAX_FPB]; - - (void) timeInfo; - (void) statusFlags; - - assert(inputBuffer != NULL); - assert(outputBuffer != NULL); - - /* - framesPerBuffer is portaudio-speak for number of samples we - actually get from the record side and need to provide to the - play side. On Linux (at least) it was found that - framesPerBuffer may not always be what we ask for in the - framesPerBuffer field of Pa_OpenStream. For example a request - for 960 sample buffers lead to framesPerBuffer = 1024. - - To perform the 48 to 8 kHz conversion we need an integer - multiple of FDMDV_OS samples to support the interpolation and - decimation. As we can't guarantee the size of framesPerBuffer - we do a little FIFO buffering. - */ - - //printf("framesPerBuffer: %d N48 %d\n", framesPerBuffer, N48); - - /* assemble a mono buffer (just use left channel) and write to FIFO */ - - assert(framesPerBuffer < MAX_FPB); - for(i=0; iinfifo, indata, framesPerBuffer); - - /* while we have enough samples available ... */ - - //printf("infifo before: %d\n", fifo_n(data->infifo)); - while (fifo_read(data->infifo, in48k_short, N48) == 0) { - - /* convert to float */ - - for(i=0; ioutfifo, out48k_short, N48); - } - //printf("infifo after: %d\n", fifo_n(data->infifo)); - //printf("outfifo : %d\n", fifo_n(data->outfifo)); - - - /* OK now set up output samples */ - - if (fifo_read(data->outfifo, outdata, framesPerBuffer) == 0) { - - /* write signal to both channels */ - - for(i=0; idefaultLowInputLatency; - inputParameters.hostApiSpecificStreamInfo = NULL; - - outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */ - if (outputParameters.device == paNoDevice) { - fprintf(stderr,"Error: No default output device.\n"); - goto done; - } - outputParameters.channelCount = NUM_CHANNELS; /* stereo output */ - outputParameters.sampleFormat = paInt16; - outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; - outputParameters.hostApiSpecificStreamInfo = NULL; - - /* Play some audio --------------------------------------------- */ - - err = Pa_OpenStream( - &stream, - &inputParameters, - &outputParameters, - SAMPLE_RATE, - 512, - paClipOff, - callback, - &data ); - if( err != paNoError ) goto done; - - err = Pa_StartStream( stream ); - if( err != paNoError ) goto done; - - while( ( err = Pa_IsStreamActive( stream ) ) == 1 ) - { - Pa_Sleep(100); - } - if( err < 0 ) goto done; - - err = Pa_CloseStream( stream ); - if( err != paNoError ) goto done; - - -done: - Pa_Terminate(); - if( err != paNoError ) - { - fprintf( stderr, "An error occured while using the portaudio stream\n" ); - fprintf( stderr, "Error number: %d\n", err ); - fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); - err = 1; /* Always return 0 or 1, but no other return codes. */ - } - - fifo_destroy(data.infifo); - fifo_destroy(data.outfifo); - - return err; -} - diff --git a/codec2/raw/b0067.raw b/codec2/raw/b0067.raw deleted file mode 100644 index 3aea9cda..00000000 Binary files a/codec2/raw/b0067.raw and /dev/null differ diff --git a/codec2/raw/cq_ref.raw b/codec2/raw/cq_ref.raw deleted file mode 100644 index 485703d9..00000000 Binary files a/codec2/raw/cq_ref.raw and /dev/null differ diff --git a/codec2/raw/cross.raw b/codec2/raw/cross.raw deleted file mode 100644 index 1b2af6a9..00000000 Binary files a/codec2/raw/cross.raw and /dev/null differ diff --git a/codec2/raw/cross_melp2400.raw b/codec2/raw/cross_melp2400.raw deleted file mode 100644 index 439012ca..00000000 Binary files a/codec2/raw/cross_melp2400.raw and /dev/null differ diff --git a/codec2/raw/f2400.raw b/codec2/raw/f2400.raw deleted file mode 100644 index 5f4427f2..00000000 Binary files a/codec2/raw/f2400.raw and /dev/null differ diff --git a/codec2/raw/forig.raw b/codec2/raw/forig.raw deleted file mode 100644 index 4ba294d7..00000000 Binary files a/codec2/raw/forig.raw and /dev/null differ diff --git a/codec2/raw/forig_ambe2000.raw b/codec2/raw/forig_ambe2000.raw deleted file mode 100644 index 91143579..00000000 Binary files a/codec2/raw/forig_ambe2000.raw and /dev/null differ diff --git a/codec2/raw/forig_g729a.raw b/codec2/raw/forig_g729a.raw deleted file mode 100644 index fbca567b..00000000 Binary files a/codec2/raw/forig_g729a.raw and /dev/null differ diff --git a/codec2/raw/forig_gsm13k.raw b/codec2/raw/forig_gsm13k.raw deleted file mode 100644 index 71cbe6f6..00000000 Binary files a/codec2/raw/forig_gsm13k.raw and /dev/null differ diff --git a/codec2/raw/forig_speex_8k.raw b/codec2/raw/forig_speex_8k.raw deleted file mode 100644 index e95302ef..00000000 Binary files a/codec2/raw/forig_speex_8k.raw and /dev/null differ diff --git a/codec2/raw/g3plx.raw b/codec2/raw/g3plx.raw deleted file mode 100644 index 9970c3fb..00000000 Binary files a/codec2/raw/g3plx.raw and /dev/null differ diff --git a/codec2/raw/hts.raw b/codec2/raw/hts.raw deleted file mode 100644 index 79f869ad..00000000 Binary files a/codec2/raw/hts.raw and /dev/null differ diff --git a/codec2/raw/hts1.raw b/codec2/raw/hts1.raw deleted file mode 100644 index 3369387e..00000000 Binary files a/codec2/raw/hts1.raw and /dev/null differ diff --git a/codec2/raw/hts1a.raw b/codec2/raw/hts1a.raw deleted file mode 100644 index 7332f936..00000000 Binary files a/codec2/raw/hts1a.raw and /dev/null differ diff --git a/codec2/raw/hts1a_ambe2000.raw b/codec2/raw/hts1a_ambe2000.raw deleted file mode 100644 index ab72ba2f..00000000 Binary files a/codec2/raw/hts1a_ambe2000.raw and /dev/null differ diff --git a/codec2/raw/hts1a_g729a.raw b/codec2/raw/hts1a_g729a.raw deleted file mode 100644 index 130f1ddc..00000000 Binary files a/codec2/raw/hts1a_g729a.raw and /dev/null differ diff --git a/codec2/raw/hts1a_gsm13k.raw b/codec2/raw/hts1a_gsm13k.raw deleted file mode 100644 index dd102f59..00000000 Binary files a/codec2/raw/hts1a_gsm13k.raw and /dev/null differ diff --git a/codec2/raw/hts1a_melp.raw b/codec2/raw/hts1a_melp.raw deleted file mode 100644 index a4040d29..00000000 Binary files a/codec2/raw/hts1a_melp.raw and /dev/null differ diff --git a/codec2/raw/hts1a_speex_8k.raw b/codec2/raw/hts1a_speex_8k.raw deleted file mode 100644 index 9289e1c9..00000000 Binary files a/codec2/raw/hts1a_speex_8k.raw and /dev/null differ diff --git a/codec2/raw/hts2.raw b/codec2/raw/hts2.raw deleted file mode 100644 index 0bb9df10..00000000 Binary files a/codec2/raw/hts2.raw and /dev/null differ diff --git a/codec2/raw/hts2a.raw b/codec2/raw/hts2a.raw deleted file mode 100644 index 6d9cf17b..00000000 Binary files a/codec2/raw/hts2a.raw and /dev/null differ diff --git a/codec2/raw/hts2a_ambe2000.raw b/codec2/raw/hts2a_ambe2000.raw deleted file mode 100644 index 7225f60a..00000000 Binary files a/codec2/raw/hts2a_ambe2000.raw and /dev/null differ diff --git a/codec2/raw/hts2a_g729a.raw b/codec2/raw/hts2a_g729a.raw deleted file mode 100644 index 9199b0ad..00000000 Binary files a/codec2/raw/hts2a_g729a.raw and /dev/null differ diff --git a/codec2/raw/hts2a_gsm13k.raw b/codec2/raw/hts2a_gsm13k.raw deleted file mode 100644 index f0a58505..00000000 Binary files a/codec2/raw/hts2a_gsm13k.raw and /dev/null differ diff --git a/codec2/raw/hts2a_melp.raw b/codec2/raw/hts2a_melp.raw deleted file mode 100644 index 5138e494..00000000 Binary files a/codec2/raw/hts2a_melp.raw and /dev/null differ diff --git a/codec2/raw/hts2a_speex_8k.raw b/codec2/raw/hts2a_speex_8k.raw deleted file mode 100644 index c421bb4e..00000000 Binary files a/codec2/raw/hts2a_speex_8k.raw and /dev/null differ diff --git a/codec2/raw/k6hx.raw b/codec2/raw/k6hx.raw deleted file mode 100644 index 35e6df71..00000000 Binary files a/codec2/raw/k6hx.raw and /dev/null differ diff --git a/codec2/raw/kristoff.raw b/codec2/raw/kristoff.raw deleted file mode 100644 index 9b0b4655..00000000 Binary files a/codec2/raw/kristoff.raw and /dev/null differ diff --git a/codec2/raw/m2400.raw b/codec2/raw/m2400.raw deleted file mode 100644 index 1c0956da..00000000 Binary files a/codec2/raw/m2400.raw and /dev/null differ diff --git a/codec2/raw/mmt1.raw b/codec2/raw/mmt1.raw deleted file mode 100644 index 40638a5a..00000000 Binary files a/codec2/raw/mmt1.raw and /dev/null differ diff --git a/codec2/raw/mmt1_ambe2000.raw b/codec2/raw/mmt1_ambe2000.raw deleted file mode 100644 index e38955c3..00000000 Binary files a/codec2/raw/mmt1_ambe2000.raw and /dev/null differ diff --git a/codec2/raw/mmt1_g729a.raw b/codec2/raw/mmt1_g729a.raw deleted file mode 100644 index 196716e0..00000000 Binary files a/codec2/raw/mmt1_g729a.raw and /dev/null differ diff --git a/codec2/raw/mmt1_gsm13k.raw b/codec2/raw/mmt1_gsm13k.raw deleted file mode 100644 index a9965af3..00000000 Binary files a/codec2/raw/mmt1_gsm13k.raw and /dev/null differ diff --git a/codec2/raw/mmt1_speex_8k.raw b/codec2/raw/mmt1_speex_8k.raw deleted file mode 100644 index 769a49cd..00000000 Binary files a/codec2/raw/mmt1_speex_8k.raw and /dev/null differ diff --git a/codec2/raw/morig.raw b/codec2/raw/morig.raw deleted file mode 100644 index 4af0e8f9..00000000 Binary files a/codec2/raw/morig.raw and /dev/null differ diff --git a/codec2/raw/morig_ambe2000.raw b/codec2/raw/morig_ambe2000.raw deleted file mode 100644 index 99642756..00000000 Binary files a/codec2/raw/morig_ambe2000.raw and /dev/null differ diff --git a/codec2/raw/morig_g729a.raw b/codec2/raw/morig_g729a.raw deleted file mode 100644 index 636ecfdc..00000000 Binary files a/codec2/raw/morig_g729a.raw and /dev/null differ diff --git a/codec2/raw/morig_gsm13k.raw b/codec2/raw/morig_gsm13k.raw deleted file mode 100644 index 660368fe..00000000 Binary files a/codec2/raw/morig_gsm13k.raw and /dev/null differ diff --git a/codec2/raw/morig_speex_8k.raw b/codec2/raw/morig_speex_8k.raw deleted file mode 100644 index ab667a1b..00000000 Binary files a/codec2/raw/morig_speex_8k.raw and /dev/null differ diff --git a/codec2/raw/sine1k_2Hz_spread.raw b/codec2/raw/sine1k_2Hz_spread.raw deleted file mode 100644 index 2ab521fc..00000000 Binary files a/codec2/raw/sine1k_2Hz_spread.raw and /dev/null differ diff --git a/codec2/raw/sine1k_2ms_delay_2Hz_spread.raw b/codec2/raw/sine1k_2ms_delay_2Hz_spread.raw deleted file mode 100644 index d694d23f..00000000 Binary files a/codec2/raw/sine1k_2ms_delay_2Hz_spread.raw and /dev/null differ diff --git a/codec2/script/menu.sh b/codec2/script/menu.sh deleted file mode 100755 index c0335d27..00000000 --- a/codec2/script/menu.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# ./menu.sh -# -# David Rowe -# Created August 2009 -# -# Presents a menu of sound files, press 1 to play file1, 2 to play file2 etc -# -# The aim is to make comparing files with different processing easier than -# using up-arrow on the command line. Based on cdialog. -# -# usage: -# menu.sh file1.raw file2.raw ........ [-d playbackdevice] -# -# for example: -# -# ../script/menu.sh hts1a.raw hts1a_uq.raw -# -# or: -# -# ../script/menu.sh hts1a.raw hts1a_uq.raw -d /dev/dsp1 -# - -# Copyright (C) 2007 David Rowe -# -# All rights reserved. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2, as -# published by the Free Software Foundation. -# -# 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 . - -files=0 -items="Q-Quit\n" -while [ ! -z "$1" ] -do - case "$1" in - -d) dsp="${1} ${2}"; shift;; - *) files=`expr 1 + $files`; - new_file=$1; - file[$files]=$new_file; - items="${items} ${files}-${new_file}\n";; - esac - shift -done - -echo -n -e "\r" $items"- " -while true ; do - echo -n -e "\r -" - stty cbreak # or stty raw. Stty uses file descriptor 0, not /dev/tty. - readchar=`dd bs=1 count=1 2>/dev/null` - stty -cbreak - if [ -n "$readchar" ] ; then - if [ x$readchar == 'xq' -o x$readchar == 'xQ' ] ; then - echo - exit 0 - fi - if [ -z ${file[$readchar]} ] ; then - echo -n -e "\nUnknown input\n" $items"- " - continue - fi - if ( play --version ) >/dev/null 2>&1; then - play -r 8000 -s -2 ${file[$readchar]} $dsp 2> /dev/null - elif ( aplay --version ) > /dev/null 2>&1; then - aplay -r 8000 -f S16_LE ${file[$readchar]} 2> /dev/null - elif ( ossplay -f? ) > /dev/null 2>&1; then - ossplay -s8000 -fS16_LE ${file[$readchar]} 2> /dev/null - else - echo "could not find play, aplay or ossplay program" - fi - fi -done -echo diff --git a/codec2/script/playraw.sh b/codec2/script/playraw.sh deleted file mode 100755 index 683cbaa1..00000000 --- a/codec2/script/playraw.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# Plays a raw file -# usage: -# playraw file.raw -# playraw file.raw -d /dev/dsp1 (e.g. for USB headphones) -play -r 8000 -s -2 $1 $2 $3 diff --git a/codec2/script/raw2wav.sh b/codec2/script/raw2wav.sh deleted file mode 100755 index a05efb72..00000000 --- a/codec2/script/raw2wav.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Converts 16 bit signed short 8 kHz raw (headerless) files to wave -sox -r 8000 -s -2 $1 $2 diff --git a/codec2/script/wav2raw.sh b/codec2/script/wav2raw.sh deleted file mode 100755 index 39c0f1ae..00000000 --- a/codec2/script/wav2raw.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Converts wave files to raw (headerless) files -sox $1 -t raw $2 diff --git a/codec2/src/CMakeLists.txt b/codec2/src/CMakeLists.txt deleted file mode 100644 index 36ffc926..00000000 --- a/codec2/src/CMakeLists.txt +++ /dev/null @@ -1,267 +0,0 @@ -# -# Generated sources -# - -set(D ${CMAKE_CURRENT_SOURCE_DIR}/codebook) - -# lsp quantisers - -set(CODEBOOKS - ${D}/lsp1.txt - ${D}/lsp2.txt - ${D}/lsp3.txt - ${D}/lsp4.txt - ${D}/lsp5.txt - ${D}/lsp6.txt - ${D}/lsp7.txt - ${D}/lsp8.txt - ${D}/lsp9.txt - ${D}/lsp10.txt -) - -# lspd quantisers - -set(CODEBOOKSD - ${D}/dlsp1.txt - ${D}/dlsp2.txt - ${D}/dlsp3.txt - ${D}/dlsp4.txt - ${D}/dlsp5.txt - ${D}/dlsp6.txt - ${D}/dlsp7.txt - ${D}/dlsp8.txt - ${D}/dlsp9.txt - ${D}/dlsp10.txt -) - -# lspd VQ quantisers - -set(CODEBOOKSVQ - ${D}/lsp1.txt - ${D}/lsp2.txt - ${D}/lsp3.txt - ${D}/lsp4.txt - ${CMAKE_SOURCE_DIR}/unittest/lsp45678910.txt -) - -set(CODEBOOKSJND - ${D}/lsp1.txt - ${D}/lsp2.txt - ${D}/lsp3.txt - ${D}/lsp4.txt - ${CMAKE_SOURCE_DIR}/unittest/lspjnd5-10.txt -) - -set(CODEBOOKSDT - ${D}/lspdt1.txt - ${D}/lspdt2.txt - ${D}/lspdt3.txt - ${D}/lspdt4.txt - ${D}/lspdt5.txt - ${D}/lspdt6.txt - ${D}/lspdt7.txt - ${D}/lspdt8.txt - ${D}/lspdt9.txt - ${D}/lspdt10.txt -) - -set(CODEBOOKSJVM - ${D}/lspjvm1.txt - ${D}/lspjvm2.txt - ${D}/lspjvm3.txt -) - -set(CODEBOOKSVQANSSI - ${D}/lspvqanssi1.txt - ${D}/lspvqanssi2.txt - ${D}/lspvqanssi3.txt - ${D}/lspvqanssi4.txt -) - -set(CODEBOOKSGE ${D}/gecb.txt) - -# when crosscompiling import the executable targets from a file -if(CMAKE_CROSSCOMPILING) - set(IMPORT_EXECUTABLES "IMPORTFILE-NOTFOUND" CACHE FILEPATH "Point to the export file from a native build") - include(${IMPORT_EXECUTABLES}) -else(CMAKE_CROSSCOMPILING) -# Build code generator binaries. These do not get installed. - # generate_codebook - add_executable(generate_codebook generate_codebook.c) - target_link_libraries(generate_codebook ${CMAKE_REQUIRED_LIBRARIES}) - # genlspdtcb - add_executable(genlspdtcb genlspdtcb.c) - target_link_libraries(genlspdtcb ${CMAKE_REQUIRED_LIBRARIES}) - # Make native builds available for cross-compiling. - export(TARGETS generate_codebook genlspdtcb - FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake) -endif(CMAKE_CROSSCOMPILING) - - -# codebook.c -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebook.c - COMMAND generate_codebook lsp_cb ${CODEBOOKS} > ${CMAKE_CURRENT_BINARY_DIR}/codebook.c - DEPENDS generate_codebook ${CODEBOOKS} -) - -# codebookd.c -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebookd.c - COMMAND generate_codebook lsp_cbd ${CODEBOOKSD} > ${CMAKE_CURRENT_BINARY_DIR}/codebookd.c - DEPENDS generate_codebook ${CODEBOOKSD} -) - -# codebookdt.c -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebookdt.c - COMMAND generate_codebook lsp_cbdt ${CODEBOOKSDT} > ${CMAKE_CURRENT_BINARY_DIR}/codebookdt.c - DEPENDS generate_codebook ${CODEBOOKSDT} -) - -# codebookvq.c -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebookvq.c - COMMAND generate_codebook lsp_cbvq ${CODEBOOKSVQ} > ${CMAKE_CURRENT_BINARY_DIR}/codebookvq.c - DEPENDS generate_codebook ${CODEBOOKSVQ} -) - -# codebookjnd.c -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebookjnd.c - COMMAND generate_codebook lsp_cbjnd ${CODEBOOKSJND} > ${CMAKE_CURRENT_BINARY_DIR}/codebookjnd.c - DEPENDS generate_codebook ${CODEBOOKSJND} -) - -# codebookjvm.c -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebookjvm.c - COMMAND generate_codebook lsp_cbjvm ${CODEBOOKSJVM} > ${CMAKE_CURRENT_BINARY_DIR}/codebookjvm.c - DEPENDS generate_codebook ${CODEBOOKSJVM} -) - -# codebookvqanssi.c -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebookvqanssi.c - COMMAND generate_codebook lsp_cbvqanssi ${CODEBOOKSVQANSSI} > ${CMAKE_CURRENT_BINARY_DIR}/codebookvqanssi.c - DEPENDS generate_codebook ${CODEBOOKSVQANSSI} -) - -# codebookge.c -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codebookge.c - COMMAND generate_codebook ge_cb ${CODEBOOKSGE} > ${CMAKE_CURRENT_BINARY_DIR}/codebookge.c - DEPENDS generate_codebook ${CODEBOOKSGE} -) - -# -# codec2 library sources -# - -set(CODEC2_SRCS - dump.c - lpc.c - nlp.c - postfilter.c - sine.c - codec2.c - fifo.c - fdmdv.c - kiss_fft.c - interp.c - lsp.c - phase.c - quantise.c - pack.c - codebook.c - codebookd.c - codebookvq.c - codebookjnd.c - codebookjvm.c - codebookvqanssi.c - codebookdt.c - codebookge.c - golay23.c -) - -set(CODEC2_PUBLIC_HEADERS - golay23.h - codec2.h - codec2_fdmdv.h - codec2_fifo.h - comp.h -) - -# -# Setup the codec2 library -# -add_library(codec2 ${CODEC2_SRCS}) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(codec2 ${CMAKE_REQUIRED_LIBRARIES}) -set_target_properties(codec2 PROPERTIES - SOVERSION ${SOVERSION} - PUBLIC_HEADER "${CODEC2_PUBLIC_HEADERS}" -) - -add_executable(c2demo c2demo.c) -target_link_libraries(c2demo ${CMAKE_REQUIRED_LIBRARIES} codec2) - -add_executable(c2enc c2enc.c) -target_link_libraries(c2enc ${CMAKE_REQUIRED_LIBRARIES} codec2) - -add_executable(c2dec c2dec.c) -target_link_libraries(c2dec ${CMAKE_REQUIRED_LIBRARIES} codec2) - -add_executable(c2sim c2sim.c ampexp.c phaseexp.c) -target_link_libraries(c2sim ${CMAKE_REQUIRED_LIBRARIES} codec2) - -add_executable(fdmdv_get_test_bits fdmdv_get_test_bits.c fdmdv.c kiss_fft.c) -target_link_libraries(fdmdv_get_test_bits ${CMAKE_REQUIRED_LIBRARIES}) - -add_executable(fdmdv_mod fdmdv_mod.c fdmdv.c kiss_fft.c) -target_link_libraries(fdmdv_mod ${CMAKE_REQUIRED_LIBRARIES}) - -add_executable(fdmdv_demod fdmdv_demod.c fdmdv.c kiss_fft.c octave.c) -target_link_libraries(fdmdv_demod ${CMAKE_REQUIRED_LIBRARIES}) - -add_executable(fdmdv_put_test_bits fdmdv_put_test_bits.c fdmdv.c kiss_fft.c) -target_link_libraries(fdmdv_put_test_bits ${CMAKE_REQUIRED_LIBRARIES}) - -add_executable(fdmdv_interleave fdmdv_interleave.c) -target_link_libraries(fdmdv_interleave ${CMAKE_REQUIRED_LIBRARIES}) - -add_executable(insert_errors insert_errors.c) -target_link_libraries(insert_errors ${CMAKE_REQUIRED_LIBRARIES}) - -add_executable(fec_enc fec_enc.c golay23.c) -target_link_libraries(fec_enc ${CMAKE_REQUIRED_LIBRARIES} codec2) - -add_executable(fec_dec fec_dec.c golay23.c) -target_link_libraries(fec_dec ${CMAKE_REQUIRED_LIBRARIES} codec2) - -install(TARGETS codec2 EXPORT codec2-config - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/codec2 -) - -#install(EXPORT codec2-config -# DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/codec2 -#) - -install(TARGETS - c2demo - c2demo - c2enc - c2dec - c2sim - fdmdv_get_test_bits - fdmdv_mod fdmdv_demod - fdmdv_put_test_bits - fdmdv_interleave - insert_errors - fec_enc - fec_dec - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) diff --git a/codec2/src/_kiss_fft_guts.h b/codec2/src/_kiss_fft_guts.h deleted file mode 100644 index ba661444..00000000 --- a/codec2/src/_kiss_fft_guts.h +++ /dev/null @@ -1,164 +0,0 @@ -/* -Copyright (c) 2003-2010, Mark Borgerding - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* kiss_fft.h - defines kiss_fft_scalar as either short or a float type - and defines - typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */ -#include "kiss_fft.h" -#include - -#define MAXFACTORS 32 -/* e.g. an fft of length 128 has 4 factors - as far as kissfft is concerned - 4*4*4*2 - */ - -struct kiss_fft_state{ - int nfft; - int inverse; - int factors[2*MAXFACTORS]; - kiss_fft_cpx twiddles[1]; -}; - -/* - Explanation of macros dealing with complex math: - - C_MUL(m,a,b) : m = a*b - C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise - C_SUB( res, a,b) : res = a - b - C_SUBFROM( res , a) : res -= a - C_ADDTO( res , a) : res += a - * */ -#ifdef FIXED_POINT -#if (FIXED_POINT==32) -# define FRACBITS 31 -# define SAMPPROD int64_t -#define SAMP_MAX 2147483647 -#else -# define FRACBITS 15 -# define SAMPPROD int32_t -#define SAMP_MAX 32767 -#endif - -#define SAMP_MIN -SAMP_MAX - -#if defined(CHECK_OVERFLOW) -# define CHECK_OVERFLOW_OP(a,op,b) \ - if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \ - fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); } -#endif - - -# define smul(a,b) ( (SAMPPROD)(a)*(b) ) -# define sround( x ) (kiss_fft_scalar)( ( (x) + (1<<(FRACBITS-1)) ) >> FRACBITS ) - -# define S_MUL(a,b) sround( smul(a,b) ) - -# define C_MUL(m,a,b) \ - do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \ - (m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0) - -# define DIVSCALAR(x,k) \ - (x) = sround( smul( x, SAMP_MAX/k ) ) - -# define C_FIXDIV(c,div) \ - do { DIVSCALAR( (c).r , div); \ - DIVSCALAR( (c).i , div); }while (0) - -# define C_MULBYSCALAR( c, s ) \ - do{ (c).r = sround( smul( (c).r , s ) ) ;\ - (c).i = sround( smul( (c).i , s ) ) ; }while(0) - -#else /* not FIXED_POINT*/ - -# define S_MUL(a,b) ( (a)*(b) ) -#define C_MUL(m,a,b) \ - do{ (m).r = (a).r*(b).r - (a).i*(b).i;\ - (m).i = (a).r*(b).i + (a).i*(b).r; }while(0) -# define C_FIXDIV(c,div) /* NOOP */ -# define C_MULBYSCALAR( c, s ) \ - do{ (c).r *= (s);\ - (c).i *= (s); }while(0) -#endif - -#ifndef CHECK_OVERFLOW_OP -# define CHECK_OVERFLOW_OP(a,op,b) /* noop */ -#endif - -#define C_ADD( res, a,b)\ - do { \ - CHECK_OVERFLOW_OP((a).r,+,(b).r)\ - CHECK_OVERFLOW_OP((a).i,+,(b).i)\ - (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \ - }while(0) -#define C_SUB( res, a,b)\ - do { \ - CHECK_OVERFLOW_OP((a).r,-,(b).r)\ - CHECK_OVERFLOW_OP((a).i,-,(b).i)\ - (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \ - }while(0) -#define C_ADDTO( res , a)\ - do { \ - CHECK_OVERFLOW_OP((res).r,+,(a).r)\ - CHECK_OVERFLOW_OP((res).i,+,(a).i)\ - (res).r += (a).r; (res).i += (a).i;\ - }while(0) - -#define C_SUBFROM( res , a)\ - do {\ - CHECK_OVERFLOW_OP((res).r,-,(a).r)\ - CHECK_OVERFLOW_OP((res).i,-,(a).i)\ - (res).r -= (a).r; (res).i -= (a).i; \ - }while(0) - - -#ifdef FIXED_POINT -# define KISS_FFT_COS(phase) floor(.5+SAMP_MAX * cos (phase)) -# define KISS_FFT_SIN(phase) floor(.5+SAMP_MAX * sin (phase)) -# define HALF_OF(x) ((x)>>1) -#elif defined(USE_SIMD) -# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) ) -# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) ) -# define HALF_OF(x) ((x)*_mm_set1_ps(.5)) -#else -# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase) -# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase) -# define HALF_OF(x) ((x)*.5) -#endif - -#define kf_cexp(x,phase) \ - do{ \ - (x)->r = KISS_FFT_COS(phase);\ - (x)->i = KISS_FFT_SIN(phase);\ - }while(0) - - -/* a debugging function */ -#define pcpx(c)\ - fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) ) - - -#ifdef KISS_FFT_USE_ALLOCA -// define this to allow use of alloca instead of malloc for temporary buffers -// Temporary buffers are used in two case: -// 1. FFT sizes that have "bad" factors. i.e. not 2,3 and 5 -// 2. "in-place" FFTs. Notice the quotes, since kissfft does not really do an in-place transform. -#include -#define KISS_FFT_TMP_ALLOC(nbytes) alloca(nbytes) -#define KISS_FFT_TMP_FREE(ptr) -#else -#define KISS_FFT_TMP_ALLOC(nbytes) KISS_FFT_MALLOC(nbytes) -#define KISS_FFT_TMP_FREE(ptr) KISS_FFT_FREE(ptr) -#endif diff --git a/codec2/src/ampexp.c b/codec2/src/ampexp.c deleted file mode 100644 index 94e2184c..00000000 --- a/codec2/src/ampexp.c +++ /dev/null @@ -1,1093 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: ampexp.c - AUTHOR......: David Rowe - DATE CREATED: 7 August 2012 - - Functions for experimenting with amplitude quantisation. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2012 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not,see . -*/ - - -#include -#include -#include -#include -#include -#include - -#include "ampexp.h" - - -#define PRED_COEFF 0.9 - -/* states for amplitude experiments */ - -struct codebook { - unsigned int k; - unsigned int log2m; - unsigned int m; - float *cb; - unsigned int offset; -}; - -struct AEXP { - float A_prev[MAX_AMP]; - int frames; - float snr; - int snr_n; - float var; - int var_n; - float vq_var; - int vq_var_n; - struct codebook *vq1,*vq2,*vq3,*vq4,*vq5; - - int indexes[5][3]; - MODEL model[3]; - float mag[3]; - MODEL model_uq[3]; -}; - - -/*---------------------------------------------------------------------------*\ - - Bruce Perens' funcs to load codebook files - -\*---------------------------------------------------------------------------*/ - - -static const char format[] = -"The table format must be:\n" -"\tTwo integers describing the dimensions of the codebook.\n" -"\tThen, enough numbers to fill the specified dimensions.\n"; - -static float get_float(FILE * in, const char * name, char * * cursor, char * buffer, int size) -{ - for ( ; ; ) { - char * s = *cursor; - char c; - - while ( (c = *s) != '\0' && !isdigit(c) && c != '-' && c != '.' ) - s++; - - /* Comments start with "#" and continue to the end of the line. */ - if ( c != '\0' && c != '#' ) { - char * end = 0; - float f = 0; - - f = strtod(s, &end); - - if ( end != s ) - *cursor = end; - return f; - } - - if ( fgets(buffer, size, in) == NULL ) { - fprintf(stderr, "%s: Format error. %s\n", name, format); - exit(1); - } - *cursor = buffer; - } -} - -static struct codebook *load(const char * name) -{ - FILE *file; - char line[2048]; - char *cursor = line; - struct codebook *b = malloc(sizeof(struct codebook)); - int i; - int size; - - file = fopen(name, "rt"); - assert(file != NULL); - - *cursor = '\0'; - - b->k = (int)get_float(file, name, &cursor, line, sizeof(line)); - b->m = (int)get_float(file, name ,&cursor, line, sizeof(line)); - size = b->k * b->m; - - b->cb = (float *)malloc(size * sizeof(float)); - - for ( i = 0; i < size; i++ ) { - b->cb[i] = get_float(file, name, &cursor, line, sizeof(line)); - } - - fclose(file); - - return b; -} - - -/*---------------------------------------------------------------------------* \ - - amp_experiment_create() - - Inits states for amplitude quantisation experiments. - -\*---------------------------------------------------------------------------*/ - -struct AEXP *amp_experiment_create() { - struct AEXP *aexp; - int i,j,m; - - aexp = (struct AEXP *)malloc(sizeof(struct AEXP)); - assert (aexp != NULL); - - for(i=0; iA_prev[i] = 1.0; - aexp->frames = 0; - aexp->snr = 0.0; - aexp->snr_n = 0; - aexp->var = 0.0; - aexp->var_n = 0; - aexp->vq_var = 0.0; - aexp->vq_var_n = 0; - - //aexp->vq1 = load("amp_1_80_1024a.txt"); - //aexp->vq1 = load("../unittest/st1_10_1024.txt"); - //aexp->vq1 = load("../unittest/amp41_80_1024.txt"); - //aexp->vq1->offset = 40; - aexp->vq1 = load("../unittest/amp1_10_1024.txt"); - aexp->vq1->offset = 0; - aexp->vq2 = load("../unittest/amp11_20_1024.txt"); - aexp->vq2->offset = 10; - - aexp->vq3 = load("../unittest/amp21_40_1024.txt"); - aexp->vq3->offset = 20; - aexp->vq4 = load("../unittest/amp41_60_1024.txt"); - aexp->vq4->offset = 40; - aexp->vq5 = load("../unittest/amp61_80_256.txt"); - aexp->vq5->offset = 60; - - #ifdef CAND2_GS - //aexp->vq1 = load("../unittest/t1_amp1_20_1024.txt"); - //aexp->vq1 = load("../unittest/t2_amp1_20_1024.txt"); - aexp->vq1 = load("../unittest/amp1_20_1024.txt"); - aexp->vq1->offset = 0; - aexp->vq2 = load("../unittest/amp21_40_1024.txt"); - aexp->vq2->offset = 20; - aexp->vq3 = load("../unittest/amp41_60_1024.txt"); - aexp->vq3->offset = 40; - aexp->vq4 = load("../unittest/amp61_80_32.txt"); - aexp->vq4->offset = 60; - #endif - - //#define CAND2_GS - #ifdef CAND2_GS - aexp->vq1 = load("../unittest/amp1_20_1024.txt"); - aexp->vq2 = load("../unittest/amp21_40_1024.txt"); - aexp->vq3 = load("../unittest/amp41_80_1024.txt"); - aexp->vq4 = load("../unittest/amp61_80_32.txt"); - aexp->vq1->offset = 0; - aexp->vq2->offset = 20; - aexp->vq3->offset = 40; - aexp->vq4->offset = 60; - #endif - - //#define CAND1 - #ifdef CAND1 - aexp->vq1 = load("../unittest/amp1_10_128.txt"); - aexp->vq2 = load("../unittest/amp11_20_512.txt"); - aexp->vq3 = load("../unittest/amp21_40_1024.txt"); - aexp->vq4 = load("../unittest/amp41_60_1024.txt"); - aexp->vq5 = load("../unittest/amp61_80_32.txt"); - aexp->vq1->offset = 0; - aexp->vq2->offset = 10; - aexp->vq3->offset = 20; - aexp->vq4->offset = 40; - aexp->vq5->offset = 60; - #endif - - for(i=0; i<3; i++) { - for(j=0; j<5; j++) - aexp->indexes[j][i] = 0; - aexp->mag[i] = 1.0; - aexp->model[i].Wo = TWO_PI*100.0/8000.0; - aexp->model[i].L = floor(PI/aexp->model[i].Wo); - for(m=1; m<=MAX_AMP; m++) - aexp->model[i].A[m] = 10.0; - aexp->model_uq[i] = aexp->model[i]; - } - - return aexp; -} - - -/*---------------------------------------------------------------------------* \ - - amp_experiment_destroy() - -\*---------------------------------------------------------------------------*/ - -void amp_experiment_destroy(struct AEXP *aexp) { - assert(aexp != NULL); - if (aexp->snr != 0.0) - printf("snr: %4.2f dB\n", aexp->snr/aexp->snr_n); - if (aexp->var != 0.0) - printf("var...: %4.3f std dev...: %4.3f (%d amplitude samples)\n", - aexp->var/aexp->var_n, sqrt(aexp->var/aexp->var_n), aexp->var_n); - if (aexp->vq_var != 0.0) - printf("vq var: %4.3f std dev...: %4.3f (%d amplitude samples)\n", - aexp->vq_var/aexp->vq_var_n, sqrt(aexp->vq_var/aexp->vq_var_n), aexp->vq_var_n); - free(aexp); -} - - -/*---------------------------------------------------------------------------*\ - - Various test and experimental functions ................ - -\*---------------------------------------------------------------------------*/ - -/* - Quantisation noise simulation. Assume noise on amplitudes is a uniform - distribution, of +/- x dB. This means x = sqrt(3)*sigma. - - Note: for uniform distribution var = = sigma * sigma = (b-a)*(b-a)/12. -*/ - -static void add_quant_noise(struct AEXP *aexp, MODEL *model, int start, int end, float sigma_dB) -{ - int m; - float x_dB; - float noise_sam_dB; - float noise_sam_lin; - - x_dB = sqrt(3.0) * sigma_dB; - - for(m=start; m<=end; m++) { - noise_sam_dB = x_dB*(1.0 - 2.0*rand()/RAND_MAX); - //printf("%f\n", noise_sam_dB); - noise_sam_lin = pow(10.0, noise_sam_dB/20.0); - model->A[m] *= noise_sam_lin; - aexp->var += noise_sam_dB*noise_sam_dB; - aexp->var_n++; - } - -} - -/* - void print_sparse_pred_error() - - use to check pred error stats (e.g. of first 1kHz) in Octave: - - $ ./c2sim ../raw/hts1a.raw --ampexp > amppe.txt - - octave> load ../src/amppe.txt - octave> std(nonzeros(amppe(:,1:20))) - octave> hist(nonzeros(amppe(:,1:20)),20); - - */ - - -static void print_sparse_pred_error(struct AEXP *aexp, MODEL *model, float mag_thresh) -{ - int m, index; - float mag, error; - float sparse_pe[MAX_AMP]; - - mag = 0.0; - for(m=1; m<=model->L; m++) - mag += model->A[m]*model->A[m]; - mag = 10*log10(mag/model->L); - - if (mag > mag_thresh) { - for(m=0; mL; m++) { - assert(model->A[m] > 0.0); - error = PRED_COEFF*20.0*log10(aexp->A_prev[m]) - 20.0*log10(model->A[m]); - //error = 20.0*log10(model->A[m]) - mag; - - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - sparse_pe[index] = error; - } - - /* dump sparse amp vector */ - - for(m=0; mL; m++) - e += model->A[m]*model->A[m]; - edB = 10*log10(e); - - #define VER_E0 - - #ifdef VER_E0 - *enormdB = 10*log10(e/model->L); /* make high and low pitches have similar amps */ - #endif - - #ifdef VER_E1 - e = 0.0; - for(m=1; m<=model->L; m++) - e += 10*log10(model->A[m]*model->A[m]); - *enormdB = e; - #endif - - #ifdef VER_E2 - e = 0.0; - for(m=1; m<=model->L; m++) - e += 10*log10(model->A[m]*model->A[m]); - *enormdB = e/model->L; - #endif - //printf("%f\n", enormdB); - - return edB; -} - -static void print_sparse_amp_error(struct AEXP *aexp, MODEL *model, float edB_thresh) -{ - int m, index; - float edB, enormdB, error, dWo; - float sparse_pe[MAX_AMP]; - - edB = frame_energy(model, &enormdB); - //printf("%f\n", enormdB); - dWo = fabs((aexp->model_uq[2].Wo - aexp->model_uq[1].Wo)/aexp->model_uq[2].Wo); - - if ((edB > edB_thresh) && (dWo < 0.1)) { - for(m=0; mL; m++) { - assert(model->A[m] > 0.0); - error = 20.0*log10(model->A[m]) - enormdB; - - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - sparse_pe[index] = error; - } - - /* dump sparse amp vector */ - - for(m=0; mcb, &sparse_pe_in[vq->offset], &weights[vq->offset], vq->k, vq->m, &se); - printf("\n offset %d k %d m %d vq_ind %d j: ", vq->offset, vq->k, vq->m, vq_ind); - - non_zero = 0; - for(i=0, j=vq->offset; ik; i++,j++) { - if (sparse_pe_in[j] != 0.0) { - printf("%d ", j); - sparse_pe_in[j] -= vq->cb[vq->k * vq_ind + i]; - sparse_pe_out[j] += vq->cb[vq->k * vq_ind + i]; - non_zero++; - } - } - aexp->vq_var_n += non_zero; - return vq_ind; -} - - -static void sparse_vq_pred_error(struct AEXP *aexp, - MODEL *model -) -{ - int m, index; - float error, amp_dB, edB, enormdB; - float sparse_pe_in[MAX_AMP]; - float sparse_pe_out[MAX_AMP]; - float weights[MAX_AMP]; - - edB = frame_energy(model, &enormdB); - - for(m=0; mL; m++) { - assert(model->A[m] > 0.0); - error = PRED_COEFF*20.0*log10(aexp->A_prev[m]) - 20.0*log10(model->A[m]); - - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - sparse_pe_in[index] = error; - weights[index] = model->A[m]; - } - - /* vector quantise */ - - for(m=0; mvq1, weights, sparse_pe_in); - #else - for(m=aexp->vq->offset; mvq->offset+aexp->vq->k; m++) { - if (sparse_pe_in[m] != 0.0) { - float error = 8*(1.0 - 2.0*rand()/RAND_MAX); - aexp->vq_var += error*error; - aexp->vq_var_n++; - sparse_pe_out[m] = sparse_pe_in[m] + error; - } - } - #endif - - if (edB > -100.0) - for(m=0; mvq_var += pow(sparse_pe_out[m] - sparse_pe_in[m], 2.0); - } - - /* transform quantised amps back */ - - for(m=1; m<=model->L; m++) { - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - amp_dB = PRED_COEFF*20.0*log10(aexp->A_prev[m]) - sparse_pe_out[index]; - //printf("in: %f out: %f\n", sparse_pe_in[index], sparse_pe_out[index]); - //printf("amp_dB: %f A[m] (dB) %f\n", amp_dB, 20.0*log10(model->A[m])); - model->A[m] = pow(10.0, amp_dB/20.0); - } - //exit(0); -} - - -static void split_error(struct AEXP *aexp, struct codebook *vq, float sparse_pe_in[], int ind) -{ - int i, j; - - for(i=0, j=vq->offset; ik; i++,j++) { - if (sparse_pe_in[j] != 0.0) { - sparse_pe_in[j] -= vq->cb[vq->k * ind + i]; - } - } -} - - -static void sparse_vq_amp(struct AEXP *aexp, MODEL *model) -{ - int m, index; - float error, amp_dB, enormdB; - float sparse_pe_in[MAX_AMP]; - float sparse_pe_out[MAX_AMP]; - float weights[MAX_AMP]; - - frame_energy(model, &enormdB); - - aexp->mag[2] = enormdB; - - for(m=0; mL; m++) { - assert(model->A[m] > 0.0); - error = 20.0*log10(model->A[m]) - enormdB; - - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - sparse_pe_in[index] = error; - weights[index] = pow(model->A[m],0.8); - } - - /* vector quantise */ - - for(m=0; mindexes[0][2] = split_vq(sparse_pe_out, aexp, aexp->vq1, weights, sparse_pe_in); - - aexp->indexes[1][2] = split_vq(sparse_pe_out, aexp, aexp->vq2, weights, sparse_pe_in); - aexp->indexes[2][2] = split_vq(sparse_pe_out, aexp, aexp->vq3, weights, sparse_pe_in); - aexp->indexes[3][2] = split_vq(sparse_pe_out, aexp, aexp->vq4, weights, sparse_pe_in); - aexp->indexes[4][2] = split_vq(sparse_pe_out, aexp, aexp->vq5, weights, sparse_pe_in); - #endif - //#define MULTISTAGE - #ifdef MULTISTAGE - aexp->indexes[0][2] = split_vq(sparse_pe_out, aexp, aexp->vq1, weights, sparse_pe_in); - aexp->indexes[1][2] = split_vq(sparse_pe_out, aexp, aexp->vq2, weights, sparse_pe_in); - aexp->indexes[2][2] = split_vq(sparse_pe_out, aexp, aexp->vq3, weights, sparse_pe_in); - //aexp->indexes[3][2] = split_vq(sparse_pe_out, aexp, aexp->vq4, weights, sparse_pe_in); - #endif - - for(m=0; mvq_var += pow(sparse_pe_out[m] - sparse_pe_in[m], 2.0); - } - - /* transform quantised amps back */ - - for(m=1; m<=model->L; m++) { - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - amp_dB = sparse_pe_out[index] + enormdB; - model->A[m] = pow(10.0, amp_dB/20.0); - } - //exit(0); -} - - -static void update_snr_calc(struct AEXP *aexp, MODEL *m1, MODEL *m2) -{ - int m; - float signal, noise, signal_dB; - - assert(m1->L == m2->L); - - signal = 0.0; noise = 1E-32; - for(m=1; m<=m1->L; m++) { - signal += m1->A[m]*m1->A[m]; - noise += pow(m1->A[m] - m2->A[m], 2.0); - //printf("%f %f\n", before[m], model->phi[m]); - } - signal_dB = 10*log10(signal); - if (signal_dB > -100.0) { - aexp->snr += 10.0*log10(signal/noise); - aexp->snr_n++; - } -} - - -/* gain/shape vq search. Returns index of best gain. Gain is additive (as we use log quantisers) */ - -int gain_shape_vq_amp(float cb[], float vec[], float weights[], int d, int e, float *se, float *best_gain) -{ - float error; /* current error */ - int besti; /* best index so far */ - float best_error; /* best error so far */ - int i,j,m; - float diff, metric, best_metric, gain, sumAm, sumCb; - - besti = 0; - best_metric = best_error = 1E32; - for(j=0; jcb, &sparse_pe_in[vq->offset], &weights[vq->offset], vq->k, vq->m, &se, best_gain); - //printf("\n offset %d k %d m %d vq_ind %d gain: %4.2f j: ", vq->offset, vq->k, vq->m, vq_ind, *best_gain); - - non_zero = 0; - for(i=0, j=vq->offset; ik; i++,j++) { - if (sparse_pe_in[j] != 0.0) { - //printf("%d ", j); - sparse_pe_out[j] = vq->cb[vq->k * vq_ind + i] + *best_gain; - non_zero++; - } - } - aexp->vq_var_n += non_zero; -} - - -static void gain_shape_sparse_vq_amp(struct AEXP *aexp, MODEL *model) -{ - int m, index; - float amp_dB, best_gain; - float sparse_pe_in[MAX_AMP]; - float sparse_pe_out[MAX_AMP]; - float weights[MAX_AMP]; - - for(m=0; mL; m++) { - assert(model->A[m] > 0.0); - - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - sparse_pe_in[index] = 20.0*log10(model->A[m]); - weights[index] = model->A[m]; - } - - /* vector quantise */ - - for(m=0; mvq1, weights, sparse_pe_in, &best_gain); - gain_shape_split_vq(sparse_pe_out, aexp, aexp->vq2, weights, sparse_pe_in, &best_gain); - gain_shape_split_vq(sparse_pe_out, aexp, aexp->vq3, weights, sparse_pe_in, &best_gain); - gain_shape_split_vq(sparse_pe_out, aexp, aexp->vq4, weights, sparse_pe_in, &best_gain); - - for(m=0; mvq_var += pow(sparse_pe_out[m] - sparse_pe_in[m], 2.0); - } - - /* transform quantised amps back */ - - for(m=1; m<=model->L; m++) { - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - amp_dB = sparse_pe_out[index]; - model->A[m] = pow(10.0, amp_dB/20.0); - } - //exit(0); -} - - -static void interp_split_vq(float sparse_pe_out[], struct AEXP *aexp, struct codebook *vq, float sparse_pe_in[], int ind) -{ - int i, j; - float amp_dB; - - for(i=0, j=vq->offset; ik; i++,j++) { - if (sparse_pe_in[j] != 0.0) { - amp_dB = 0.5*(aexp->mag[0] + vq->cb[vq->k * aexp->indexes[ind][0] + i]); - amp_dB += 0.5*(aexp->mag[2] + vq->cb[vq->k * aexp->indexes[ind][2] + i]); - sparse_pe_out[j] = amp_dB; - } - } -} - - -static void vq_interp(struct AEXP *aexp, MODEL *model, int on) -{ - int i, j, m, index; - float amp_dB; - //struct codebook *vq = aexp->vq1; - float sparse_pe_in[MAX_AMP]; - float sparse_pe_out[MAX_AMP]; - - /* replace odd frames with interp */ - /* once we get an even input frame we can interpolate and output odd */ - /* using VQ to interpolate. This assumes some correlation in - adjacent VQ samples */ - - memcpy(&aexp->model[2], model, sizeof(MODEL)); - - /* once we get an even input frame we have enough information to - replace prev odd frame with interpolated version */ - - if (on && ((aexp->frames % 2) == 0)) { - - /* copy Wo, L, and phases */ - - memcpy(model, &aexp->model[1], sizeof(MODEL)); - //printf("mags: %4.2f %4.2f %4.2f Am: \n", aexp->mag[0], aexp->mag[1], aexp->mag[2]); - - /* now replace Am by interpolation, use similar design to VQ - to handle different bands */ - - for(m=1; m<=model->L; m++) { - assert(model->A[m] > 0.0); - - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - sparse_pe_in[index] = 20.0*log10(model->A[m]); - } - - /* this can be used for when just testing partial interpolation */ - - for(m=0; mvq1, sparse_pe_in, 0); - interp_split_vq(sparse_pe_out, aexp, aexp->vq2, sparse_pe_in, 1); - interp_split_vq(sparse_pe_out, aexp, aexp->vq3, sparse_pe_in, 2); - interp_split_vq(sparse_pe_out, aexp, aexp->vq4, sparse_pe_in, 3); - interp_split_vq(sparse_pe_out, aexp, aexp->vq5, sparse_pe_in, 4); - - for(m=1; m<=model->L; m++) { - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - amp_dB = sparse_pe_out[index]; - //printf(" %4.2f", 10.0*log10(model->A[m])); - model->A[m] = pow(10.0, amp_dB/20.0); - //printf(" %4.2f\n", 10.0*log10(model->A[m])); - } - - #ifdef INITIAL_VER - - for(m=1; m<=model->L; m++) { - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - - if (index < vq->k) { - amp_dB = 0.5*(aexp->mag[0] + vq->cb[vq->k * aexp->indexes[0] + index]); - amp_dB += 0.5*(aexp->mag[2] + vq->cb[vq->k * aexp->indexes[2] + index]); - //printf(" %4.2f", 10.0*log10(model->A[m])); - //amp_dB = 10; - model->A[m] = pow(10.0, amp_dB/20.0); - printf(" %4.2f\n", 10.0*log10(model->A[m])); - } - } - - #endif - } - else - memcpy(model, &aexp->model[1], sizeof(MODEL)); - - /* update memories */ - - for(i=0; i<2; i++) { - memcpy(&aexp->model[i], &aexp->model[i+1], sizeof(MODEL)); - for(j=0; j<5; j++) - aexp->indexes[j][i] = aexp->indexes[j][i+1]; - aexp->mag[i] = aexp->mag[i+1]; - } - -} - - -/* - This functions tests theory that some bands can be combined together - due to less frequency resolution at higher frequencies. This will - reduce the amount of information we need to encode. -*/ - -void smooth_samples(struct AEXP *aexp, MODEL *model, int mode) -{ - int m, i, j, index, step, nav, v, en; - float sparse_pe_in[MAX_AMP], av, amp_dB; - float sparse_pe_out[MAX_AMP]; - float smoothed[MAX_AMP], smoothed_out[MAX_AMP]; - float weights[MAX_AMP]; - float enormdB; - - frame_energy(model, &enormdB); - - for(m=0; mL; m++) { - assert(model->A[m] > 0.0); - - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - sparse_pe_out[index] = sparse_pe_in[index] = 20.0*log10(model->A[m]) - enormdB; - } - - /* now combine samples at high frequencies to reduce dimension */ - - step=4; - for(i=MAX_AMP/2,v=0; i (MAX_AMP-1)) - en = MAX_AMP-1; - for(j=i; jvq1, weights, smoothed); - for(i=0; i (MAX_AMP-1)) - en = MAX_AMP-1; - for(j=i; jL; m++) { - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - amp_dB = sparse_pe_out[index] + enormdB; - //printf("%d %4.2f %4.2f\n", m, 10.0*log10(model->A[m]), amp_dB); - model->A[m] = pow(10.0, amp_dB/20.0); - } - -} - -#define MAX_BINS 40 -static float bins[] = { - /*1000.0, 1200.0, 1400.0, 1600.0, 1800,*/ - 2000.0, 2400.0, 2800.0, - 3000.0, 3400.0, 3600.0, 4000.0}; - -void smooth_amp(struct AEXP *aexp, MODEL *model) { - int m, i; - int nbins; - int b; - float f; - float av[MAX_BINS]; - int nav[MAX_BINS]; - - nbins = sizeof(bins)/sizeof(float); - - /* clear all bins */ - - for(i=0; iL; m++) { - f = m*model->Wo*FS/TWO_PI; - if (f > bins[0]) { - - /* find bin */ - - for(i=0; i bins[i]) && (f <= bins[i+1])) - b = i; - assert(b < MAX_BINS); - - av[b] += model->A[m]*model->A[m]; - nav[b]++; - } - - } - - /* use averages to est amps */ - - for(m=1; m<=model->L; m++) { - f = m*model->Wo*FS/TWO_PI; - if (f > bins[0]) { - - /* find bin */ - - for(i=0; i bins[i]) && (f <= bins[i+1])) - b = i; - assert(b < MAX_BINS); - - /* add predicted phase error to this bin */ - - printf("L %d m %d f %4.f b %d\n", model->L, m, f, b); - - printf(" %d: %4.3f -> ", m, 20*log10(model->A[m])); - model->A[m] = sqrt(av[b]/nav[b]); - printf("%4.3f\n", 20*log10(model->A[m])); - } - } - printf("\n"); -} - -/*---------------------------------------------------------------------------* \ - - amp_experiment() - - Amplitude quantisation experiments. - -\*---------------------------------------------------------------------------*/ - -void amp_experiment(struct AEXP *aexp, MODEL *model, char *arg) { - int m,i; - - memcpy(&aexp->model_uq[2], model, sizeof(MODEL)); - - if (strcmp(arg, "qn") == 0) { - add_quant_noise(aexp, model, 1, model->L, 1); - update_snr_calc(aexp, &aexp->model_uq[2], model); - } - - /* print training samples that can be > train.txt for training VQ */ - - if (strcmp(arg, "train") == 0) - print_sparse_amp_error(aexp, model, 00.0); - - /* VQ of amplitudes, no interpolation (ie 10ms rate) */ - - if (strcmp(arg, "vq") == 0) { - sparse_vq_amp(aexp, model); - vq_interp(aexp, model, 0); - update_snr_calc(aexp, &aexp->model_uq[1], model); - } - - /* VQ of amplitudes, interpolation (ie 20ms rate) */ - - if (strcmp(arg, "vqi") == 0) { - sparse_vq_amp(aexp, model); - vq_interp(aexp, model, 1); - update_snr_calc(aexp, &aexp->model_uq[1], model); - } - - /* gain/shape VQ of amplitudes, 10ms rate (doesn't work that well) */ - - if (strcmp(arg, "gsvq") == 0) { - gain_shape_sparse_vq_amp(aexp, model); - vq_interp(aexp, model, 0); - update_snr_calc(aexp, &aexp->model_uq[1], model); - } - - if (strcmp(arg, "smooth") == 0) { - smooth_samples(aexp, model, 0); - update_snr_calc(aexp, &aexp->model_uq[2], model); - } - - if (strcmp(arg, "smoothtrain") == 0) { - smooth_samples(aexp, model, 1); - //update_snr_calc(aexp, &aexp->model_uq[2], model); - } - - if (strcmp(arg, "smoothvq") == 0) { - smooth_samples(aexp, model, 2); - update_snr_calc(aexp, &aexp->model_uq[2], model); - } - - if (strcmp(arg, "smoothamp") == 0) { - smooth_amp(aexp, model); - update_snr_calc(aexp, &aexp->model_uq[2], model); - } - - /* update states */ - - for(m=1; m<=model->L; m++) - aexp->A_prev[m] = model->A[m]; - aexp->frames++; - for(i=0; i<3; i++) - aexp->model_uq[i] = aexp->model_uq[i+1]; -} - diff --git a/codec2/src/ampexp.h b/codec2/src/ampexp.h deleted file mode 100644 index 313abb15..00000000 --- a/codec2/src/ampexp.h +++ /dev/null @@ -1,39 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: ampexp.h - AUTHOR......: David Rowe - DATE CREATED: & August 2012 - - Functions for experimenting with amplitude quantisation. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2012 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not,see . -*/ - -#ifndef __AMPEX__ -#define __AMPEXP__ - -#include "defines.h" - -struct AEXP; - -struct AEXP *amp_experiment_create(); -void amp_experiment_destroy(struct AEXP *aexp); -void amp_experiment(struct AEXP *aexp, MODEL *model, char *arg); - -#endif diff --git a/codec2/src/c2dec.c b/codec2/src/c2dec.c deleted file mode 100644 index 641e4019..00000000 --- a/codec2/src/c2dec.c +++ /dev/null @@ -1,291 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: c2dec.c - AUTHOR......: David Rowe - DATE CREATED: 23/8/2010 - - Decodes a file of bits to a file of raw speech samples using codec2. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2010 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include "codec2.h" -#include "dump.h" - -#include -#include -#include -#include -#include -#include - -#define NONE 0 /* no bit errors */ -#define UNIFORM 1 /* random bit errors */ -#define TWO_STATE 2 /* Two state error model */ -#define UNIFORM_RANGE 3 /* random bit errors over a certain range */ - -void print_help(const struct option *long_options, int num_opts, char* argv[]); - -int main(int argc, char *argv[]) -{ - int mode; - void *codec2; - FILE *fin; - FILE *fout; - FILE *fber = NULL; - short *buf; - unsigned char *bits, *prev_bits; - int nsam, nbit, nbyte, i, byte, frames, bits_proc, bit_errors, error_mode; - int nstart_bit, nend_bit, bit_rate; - int state, next_state; - float ber, r, burst_length, burst_period, burst_timer, ber_est; - unsigned char mask; - int natural, dump; - - char* opt_string = "h:"; - struct option long_options[] = { - { "ber", required_argument, NULL, 0 }, - { "startbit", required_argument, NULL, 0 }, - { "endbit", required_argument, NULL, 0 }, - { "berfile", required_argument, NULL, 0 }, - { "natural", no_argument, &natural, 1 }, - #ifdef DUMP - { "dump", required_argument, &dump, 1 }, - #endif - { "help", no_argument, NULL, 'h' }, - { NULL, no_argument, NULL, 0 } - }; - int num_opts=sizeof(long_options)/sizeof(struct option); - - if (argc < 4) - print_help(long_options, num_opts, argv); - - if (strcmp(argv[1],"3200") == 0) - mode = CODEC2_MODE_3200; - else if (strcmp(argv[1],"2400") == 0) - mode = CODEC2_MODE_2400; - else if (strcmp(argv[1],"1600") == 0) - mode = CODEC2_MODE_1600; - else if (strcmp(argv[1],"1400") == 0) - mode = CODEC2_MODE_1400; - else if (strcmp(argv[1],"1300") == 0) - mode = CODEC2_MODE_1300; - else if (strcmp(argv[1],"1200") == 0) - mode = CODEC2_MODE_1200; - else { - fprintf(stderr, "Error in mode: %s. Must be 3200, 2400, 1600, 1400, 1300 or 1200\n", argv[1]); - exit(1); - } - bit_rate = atoi(argv[1]); - - if (strcmp(argv[2], "-") == 0) fin = stdin; - else if ( (fin = fopen(argv[2],"rb")) == NULL ) { - fprintf(stderr, "Error opening input bit file: %s: %s.\n", - argv[2], strerror(errno)); - exit(1); - } - - if (strcmp(argv[3], "-") == 0) fout = stdout; - else if ( (fout = fopen(argv[3],"wb")) == NULL ) { - fprintf(stderr, "Error opening output speech file: %s: %s.\n", - argv[3], strerror(errno)); - exit(1); - } - - error_mode = NONE; - ber = 0.0; - burst_length = burst_period = 0.0; - burst_timer = 0.0; - dump = natural = 0; - - codec2 = codec2_create(mode); - nsam = codec2_samples_per_frame(codec2); - nbit = codec2_bits_per_frame(codec2); - buf = (short*)malloc(nsam*sizeof(short)); - nbyte = (nbit + 7) / 8; - bits = (unsigned char*)malloc(nbyte*sizeof(char)); - prev_bits = (unsigned char*)malloc(nbyte*sizeof(char)); - frames = bit_errors = bits_proc = 0; - nstart_bit = 0; - nend_bit = nbit-1; - - while(1) { - int option_index = 0; - int opt = getopt_long(argc, argv, opt_string, - long_options, &option_index); - if (opt == -1) - break; - - switch (opt) { - case 0: - if(strcmp(long_options[option_index].name, "ber") == 0) { - ber = atof(optarg); - error_mode = UNIFORM; - } else if(strcmp(long_options[option_index].name, "startbit") == 0) { - nstart_bit = atoi(optarg); - } else if(strcmp(long_options[option_index].name, "endbit") == 0) { - nend_bit = atoi(optarg); - } else if(strcmp(long_options[option_index].name, "berfile") == 0) { - if ((fber = fopen(optarg,"wt")) == NULL) { - fprintf(stderr, "Error opening BER file: %s %s.\n", - optarg, strerror(errno)); - exit(1); - } - - } - #ifdef DUMP - else if(strcmp(long_options[option_index].name, "dump") == 0) { - if (dump) - dump_on(optarg); - } - #endif - break; - - case 'h': - print_help(long_options, num_opts, argv); - break; - - default: - /* This will never be reached */ - break; - } - } - assert(nend_bit <= nbit); - codec2_set_natural_or_gray(codec2, !natural); - //printf("%d %d\n", nstart_bit, nend_bit); - - while(fread(bits, sizeof(char), nbyte, fin) == (size_t)nbyte) { - frames++; - - // apply bit errors, MSB of byte 0 is bit 0 in frame */ - - if ((error_mode == UNIFORM) || (error_mode == UNIFORM_RANGE)) { - for(i=nstart_bit; i (burst_period - burst_length)) - next_state = 1; - break; - - case 1: - - /* burst error state - 50% bit error rate */ - - for(i=nstart_bit; i burst_period) { - burst_timer = 0.0; - next_state = 0; - } - break; - - } - - state = next_state; - } - - if (fber != NULL) { - if (fread(&ber_est, sizeof(float), 1, fber) != 1) { - fprintf(stderr, "ran out of BER estimates!\n"); - exit(1); - } - //fprintf(stderr, "ber_est: %f\n", ber_est); - } - else - ber_est = 0.0; - - codec2_decode_ber(codec2, buf, bits, ber_est); - fwrite(buf, sizeof(short), nsam, fout); - //if this is in a pipeline, we probably don't want the usual - //buffering to occur - if (fout == stdout) fflush(stdout); - if (fin == stdin) fflush(stdin); - - memcpy(prev_bits, bits, nbyte); - } - - if (error_mode) - fprintf(stderr, "actual BER: %1.3f\n", (float)bit_errors/bits_proc); - - codec2_destroy(codec2); - - free(buf); - free(bits); - fclose(fin); - fclose(fout); - - return 0; -} - -void print_help(const struct option* long_options, int num_opts, char* argv[]) -{ - int i; - char *option_parameters; - fprintf(stderr, "\nc2dec - Codec 2 decoder and bit error simulation program\n" - "usage: %s 3200|2400|1400}1300|1200 InputFile OutputRawFile [OPTIONS]\n\n" - "Options:\n", argv[0]); - for(i=0; i. -*/ - -#include "codec2.h" -#include "sine.h" -#include "dump.h" - -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - struct CODEC2 *codec2; - FILE *fin; - FILE *fout; - short *buf; - unsigned char *bits; - int nsam, nbit, i, r; - - for(i=0; i<10; i++) { - r = codec2_rand(); - printf("[%d] r = %d\n", i, r); - } - - if (argc != 3) { - printf("usage: %s InputRawSpeechFile OutputRawSpeechFile\n", argv[0]); - exit(1); - } - - if ( (fin = fopen(argv[1],"rb")) == NULL ) { - fprintf(stderr, "Error opening input speech file: %s: %s.\n", - argv[1], strerror(errno)); - exit(1); - } - - if ( (fout = fopen(argv[2],"wb")) == NULL ) { - fprintf(stderr, "Error opening output speech file: %s: %s.\n", - argv[2], strerror(errno)); - exit(1); - } - - #ifdef DUMP - dump_on("c2demo"); - #endif - - /* Note only one set of Codec 2 states is required for an encoder - and decoder pair. */ - - codec2 = codec2_create(CODEC2_MODE_1300); - nsam = codec2_samples_per_frame(codec2); - buf = (short*)malloc(nsam*sizeof(short)); - nbit = codec2_bits_per_frame(codec2); - bits = (unsigned char*)malloc(nbit*sizeof(char)); - - while(fread(buf, sizeof(short), nsam, fin) == (size_t)nsam) { - codec2_encode(codec2, bits, buf); - codec2_decode(codec2, buf, bits); - fwrite(buf, sizeof(short), nsam, fout); - } - - free(buf); - free(bits); - codec2_destroy(codec2); - - fclose(fin); - fclose(fout); - - return 0; -} diff --git a/codec2/src/c2enc.c b/codec2/src/c2enc.c deleted file mode 100644 index f0d9bca1..00000000 --- a/codec2/src/c2enc.c +++ /dev/null @@ -1,117 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: c2enc.c - AUTHOR......: David Rowe - DATE CREATED: 23/8/2010 - - Encodes a file of raw speech samples using codec2 and outputs a file - of bits. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2010 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include "codec2.h" - -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - int mode; - void *codec2; - FILE *fin; - FILE *fout; - short *buf; - unsigned char *bits; - int nsam, nbit, nbyte, gray; - - if (argc < 4) { - printf("usage: c2enc 3200|2400|1600|1400|1300|1200 InputRawspeechFile OutputBitFile [--natural]\n"); - printf("e.g c2enc 1400 ../raw/hts1a.raw hts1a.c2\n"); - printf("e.g c2enc 1300 ../raw/hts1a.raw hts1a.c2 --natural\n"); - exit(1); - } - - if (strcmp(argv[1],"3200") == 0) - mode = CODEC2_MODE_3200; - else if (strcmp(argv[1],"2400") == 0) - mode = CODEC2_MODE_2400; - else if (strcmp(argv[1],"1600") == 0) - mode = CODEC2_MODE_1600; - else if (strcmp(argv[1],"1400") == 0) - mode = CODEC2_MODE_1400; - else if (strcmp(argv[1],"1300") == 0) - mode = CODEC2_MODE_1300; - else if (strcmp(argv[1],"1200") == 0) - mode = CODEC2_MODE_1200; - else { - fprintf(stderr, "Error in mode: %s. Must be 3200, 2400, 1600, 1400, 1300 or 1200\n", argv[1]); - exit(1); - } - - if (strcmp(argv[2], "-") == 0) fin = stdin; - else if ( (fin = fopen(argv[2],"rb")) == NULL ) { - fprintf(stderr, "Error opening input speech file: %s: %s.\n", - argv[2], strerror(errno)); - exit(1); - } - - if (strcmp(argv[3], "-") == 0) fout = stdout; - else if ( (fout = fopen(argv[3],"wb")) == NULL ) { - fprintf(stderr, "Error opening output compressed bit file: %s: %s.\n", - argv[3], strerror(errno)); - exit(1); - } - - codec2 = codec2_create(mode); - nsam = codec2_samples_per_frame(codec2); - nbit = codec2_bits_per_frame(codec2); - buf = (short*)malloc(nsam*sizeof(short)); - nbyte = (nbit + 7) / 8; - - bits = (unsigned char*)malloc(nbyte*sizeof(char)); - - if (argc == 5) { - if (strcmp(argv[4], "--natural") == 0) - gray = 0; - else - gray = 1; - codec2_set_natural_or_gray(codec2, gray); - } - - while(fread(buf, sizeof(short), nsam, fin) == (size_t)nsam) { - codec2_encode(codec2, bits, buf); - fwrite(bits, sizeof(char), nbyte, fout); - // if this is in a pipeline, we probably don't want the usual - // buffering to occur - if (fout == stdout) fflush(stdout); - if (fin == stdin) fflush(stdin); - } - - codec2_destroy(codec2); - - free(buf); - free(bits); - fclose(fin); - fclose(fout); - - return 0; -} diff --git a/codec2/src/c2sim.c b/codec2/src/c2sim.c deleted file mode 100644 index 9b3b8208..00000000 --- a/codec2/src/c2sim.c +++ /dev/null @@ -1,934 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: c2sim.c - AUTHOR......: David Rowe - DATE CREATED: 20/8/2010 - - Codec2 simulation. Combines encoder and decoder and allows - switching in and out various algorithms and quantisation steps. Used - for algorithm development. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2009 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "defines.h" -#include "sine.h" -#include "nlp.h" -#include "dump.h" -#include "lpc.h" -#include "lsp.h" -#include "quantise.h" -#include "phase.h" -#include "postfilter.h" -#include "interp.h" -#include "ampexp.h" -#include "phaseexp.h" - -void synth_one_frame(kiss_fft_cfg fft_inv_cfg, short buf[], MODEL *model, float Sn_[], float Pn[], int prede, float *de_mem, float gain); -void print_help(const struct option *long_options, int num_opts, char* argv[]); - - -/*---------------------------------------------------------------------------*\ - - MAIN - -\*---------------------------------------------------------------------------*/ - -int main(int argc, char *argv[]) -{ - FILE *fout = NULL; /* output speech file */ - FILE *fin; /* input speech file */ - short buf[N]; /* input/output buffer */ - float Sn[M]; /* float input speech samples */ - float Sn_pre[M]; /* pre-emphasised input speech samples */ - COMP Sw[FFT_ENC]; /* DFT of Sn[] */ - kiss_fft_cfg fft_fwd_cfg; - kiss_fft_cfg fft_inv_cfg; - float w[M]; /* time domain hamming window */ - COMP W[FFT_ENC]; /* DFT of w[] */ - MODEL model; - float Pn[2*N]; /* trapezoidal synthesis window */ - float Sn_[2*N]; /* synthesised speech */ - int i; /* loop variable */ - int frames; - float prev_Wo, prev__Wo, uq_Wo, prev_uq_Wo; - float pitch; - int voiced1 = 0; - char out_file[MAX_STR]; - char ampexp_arg[MAX_STR]; - char phaseexp_arg[MAX_STR]; - float snr; - float sum_snr; - - int lpc_model = 0, order = LPC_ORD; - int lsp = 0, lspd = 0, lspvq = 0; - int lspres = 0; - int lspdt = 0, lspdt_mode = LSPDT_ALL; - int dt = 0, lspjvm = 0, lspanssi = 0, lspjnd = 0, lspmel = 0; - int prede = 0; - float pre_mem = 0.0, de_mem = 0.0; - float ak[LPC_MAX]; - COMP Sw_[FFT_ENC]; - COMP Ew[FFT_ENC]; - - int phase0 = 0; - float ex_phase[MAX_AMP+1]; - - int postfilt; - float bg_est; - - int hand_voicing = 0, phaseexp = 0, ampexp = 0, hi = 0, simlpcpf = 0; - int lpcpf = 0; - FILE *fvoicing = 0; - - MODEL prev_model, interp_model; - int decimate = 0; - float lsps[LPC_MAX]; - float prev_lsps[LPC_MAX], prev_lsps_[LPC_MAX]; - float lsps__prev[LPC_MAX]; - float lsps__prev2[LPC_MAX]; - float e, prev_e; - float ak_interp[LPC_MAX]; - int lsp_indexes[LPC_MAX]; - float lsps_[LPC_MAX]; - float Woe_[2]; - - void *nlp_states; - float hpf_states[2]; - int scalar_quant_Wo_e = 0; - int vector_quant_Wo_e = 0; - int dump_pitch_e = 0; - FILE *fjvm = NULL; - #ifdef DUMP - int dump; - #endif - struct PEXP *pexp = NULL; - struct AEXP *aexp = NULL; - float gain = 1.0; - - char* opt_string = "ho:"; - struct option long_options[] = { - { "lpc", required_argument, &lpc_model, 1 }, - { "lspjnd", no_argument, &lspjnd, 1 }, - { "lspmel", no_argument, &lspmel, 1 }, - { "lsp", no_argument, &lsp, 1 }, - { "lspd", no_argument, &lspd, 1 }, - { "lspvq", no_argument, &lspvq, 1 }, - { "lspres", no_argument, &lspres, 1 }, - #ifdef __EXPERIMENTAL__ - { "lspdt", no_argument, &lspdt, 1 }, - { "lspdt_mode", required_argument, NULL, 0 }, - #endif - { "lspjvm", no_argument, &lspjvm, 1 }, - #ifdef __EXPERIMENTAL__ - { "lspanssi", no_argument, &lspanssi, 1 }, - #endif - { "phase0", no_argument, &phase0, 1 }, - { "phaseexp", required_argument, &phaseexp, 1 }, - { "ampexp", required_argument, &exp, 1 }, - { "postfilter", no_argument, &postfilt, 1 }, - { "hand_voicing", required_argument, &hand_voicing, 1 }, - { "dec", no_argument, &decimate, 1 }, - { "dt", no_argument, &dt, 1 }, - { "hi", no_argument, &hi, 1 }, - { "simlpcpf", no_argument, &simlpcpf, 1 }, - { "lpcpf", no_argument, &lpcpf, 1 }, - { "prede", no_argument, &prede, 1 }, - { "dump_pitch_e", required_argument, &dump_pitch_e, 1 }, - { "sq_pitch_e", no_argument, &scalar_quant_Wo_e, 1 }, - { "vq_pitch_e", no_argument, &vector_quant_Wo_e, 1 }, - { "rate", required_argument, NULL, 0 }, - { "gain", required_argument, NULL, 0 }, - #ifdef DUMP - { "dump", required_argument, &dump, 1 }, - #endif - { "help", no_argument, NULL, 'h' }, - { NULL, no_argument, NULL, 0 } - }; - int num_opts=sizeof(long_options)/sizeof(struct option); - - for(i=0; i 20)) { - fprintf(stderr, "Error in LPC order: %s\n", optarg); - exit(1); - } - #ifdef DUMP - } else if(strcmp(long_options[option_index].name, "dump") == 0) { - if (dump) - dump_on(optarg); - #endif - } else if(strcmp(long_options[option_index].name, "lsp") == 0 - || strcmp(long_options[option_index].name, "lspd") == 0 - || strcmp(long_options[option_index].name, "lspvq") == 0) { - assert(order == LPC_ORD); - } else if(strcmp(long_options[option_index].name, "lspdt_mode") == 0) { - if (strcmp(optarg,"all") == 0) - lspdt_mode = LSPDT_ALL; - else if (strcmp(optarg,"low") == 0) - lspdt_mode = LSPDT_LOW; - else if (strcmp(optarg,"high") == 0) - lspdt_mode = LSPDT_HIGH; - else { - fprintf(stderr, "Error in lspdt_mode: %s\n", optarg); - exit(1); - } - } else if(strcmp(long_options[option_index].name, "hand_voicing") == 0) { - if ((fvoicing = fopen(optarg,"rt")) == NULL) { - fprintf(stderr, "Error opening voicing file: %s: %s.\n", - optarg, strerror(errno)); - exit(1); - } - } else if(strcmp(long_options[option_index].name, "dump_pitch_e") == 0) { - if ((fjvm = fopen(optarg,"wt")) == NULL) { - fprintf(stderr, "Error opening pitch & energy dump file: %s: %s.\n", - optarg, strerror(errno)); - exit(1); - } - } else if(strcmp(long_options[option_index].name, "phaseexp") == 0) { - strcpy(phaseexp_arg, optarg); - } else if(strcmp(long_options[option_index].name, "ampexp") == 0) { - strcpy(ampexp_arg, optarg); - } else if(strcmp(long_options[option_index].name, "gain") == 0) { - gain = atof(optarg); - } else if(strcmp(long_options[option_index].name, "rate") == 0) { - if(strcmp(optarg,"3200") == 0) { - lpc_model = 1; order = 10; - scalar_quant_Wo_e = 1; - lspd = 1; - phase0 = 1; - postfilt = 1; - decimate = 1; - lpcpf = 1; - } else if(strcmp(optarg,"2400") == 0) { - lpc_model = 1; order = 10; - vector_quant_Wo_e = 1; - lsp = 1; - phase0 = 1; - postfilt = 1; - decimate = 1; - lpcpf = 1; - } else if(strcmp(optarg,"1400") == 0) { - lpc_model = 1; order = 10; - vector_quant_Wo_e = 1; - lsp = 1; lspdt = 1; - phase0 = 1; - postfilt = 1; - decimate = 1; - dt = 1; - lpcpf = 1; - } else if(strcmp(optarg,"1200") == 0) { - lpc_model = 1; order = 10; - scalar_quant_Wo_e = 1; - lspjvm = 1; lspdt = 1; - phase0 = 1; - postfilt = 1; - decimate = 1; - dt = 1; - lpcpf = 1; - } else { - fprintf(stderr, "Error: invalid output rate %s\n", optarg); - exit(1); - } - } - break; - - case 'h': - print_help(long_options, num_opts, argv); - break; - - case 'o': - if (strcmp(optarg, "-") == 0) fout = stdout; - else if ((fout = fopen(optarg,"wb")) == NULL) { - fprintf(stderr, "Error opening output speech file: %s: %s.\n", - optarg, strerror(errno)); - exit(1); - } - strcpy(out_file,optarg); - break; - - default: - /* This will never be reached */ - break; - } - } - - /* Input file */ - - if ((fin = fopen(argv[optind],"rb")) == NULL) { - fprintf(stderr, "Error opening input speech file: %s: %s.\n", - argv[optind], strerror(errno)); - exit(1); - } - - ex_phase[0] = 0; - bg_est = 0.0; - Woe_[0] = Woe_[1] = 1.0; - - /* - printf("lspd: %d lspdt: %d lspdt_mode: %d phase0: %d postfilt: %d " - "decimate: %d dt: %d\n",lspd,lspdt,lspdt_mode,phase0,postfilt, - decimate,dt); - */ - - /* Initialise ------------------------------------------------------------*/ - - fft_fwd_cfg = kiss_fft_alloc(FFT_ENC, 0, NULL, NULL); /* fwd FFT,used in several places */ - fft_inv_cfg = kiss_fft_alloc(FFT_DEC, 1, NULL, NULL); /* inverse FFT, used just for synth */ - make_analysis_window(fft_fwd_cfg, w, W); - make_synthesis_window(Pn); - quantise_init(); - if (phaseexp) - pexp = phase_experiment_create(); - if (ampexp) - aexp = amp_experiment_create(); - - /*----------------------------------------------------------------*\ - - Main Loop - - \*----------------------------------------------------------------*/ - - frames = 0; - sum_snr = 0; - while(fread(buf,sizeof(short),N,fin)) { - frames++; - //printf("frame: %d ", frames); - - /* Read input speech */ - - for(i=0; i 32767.0) - buf[i] = 32767; - else if (Sn_[i] < -32767.0) - buf[i] = -32767; - else - buf[i] = Sn_[i]; - } - -} - -void print_help(const struct option* long_options, int num_opts, char* argv[]) -{ - int i; - char *option_parameters; - - fprintf(stderr, "\nCodec2 - low bit rate speech codec - Simulation Program\n" - "\thttp://rowetel.com/codec2.html\n\n" - "usage: %s [OPTIONS] \n\n" - "Options:\n" - "\t-o \n", argv[0]); - for(i=0; i. -*/ - -#include -#include -#include -#include -#include - -#include "defines.h" -#include "sine.h" -#include "nlp.h" -#include "dump.h" -#include "lpc.h" -#include "quantise.h" -#include "phase.h" -#include "interp.h" -#include "postfilter.h" -#include "codec2.h" -#include "lsp.h" -#include "codec2_internal.h" -#include "machdep.h" - -/*---------------------------------------------------------------------------*\ - - FUNCTION HEADERS - -\*---------------------------------------------------------------------------*/ - -void analyse_one_frame(struct CODEC2 *c2, MODEL *model, short speech[]); -void synthesise_one_frame(struct CODEC2 *c2, short speech[], MODEL *model, - float ak[]); -void codec2_encode_3200(struct CODEC2 *c2, unsigned char * bits, short speech[]); -void codec2_decode_3200(struct CODEC2 *c2, short speech[], const unsigned char * bits); -void codec2_encode_2400(struct CODEC2 *c2, unsigned char * bits, short speech[]); -void codec2_decode_2400(struct CODEC2 *c2, short speech[], const unsigned char * bits); -void codec2_encode_1600(struct CODEC2 *c2, unsigned char * bits, short speech[]); -void codec2_decode_1600(struct CODEC2 *c2, short speech[], const unsigned char * bits); -void codec2_encode_1400(struct CODEC2 *c2, unsigned char * bits, short speech[]); -void codec2_decode_1400(struct CODEC2 *c2, short speech[], const unsigned char * bits); -void codec2_encode_1300(struct CODEC2 *c2, unsigned char * bits, short speech[]); -void codec2_decode_1300(struct CODEC2 *c2, short speech[], const unsigned char * bits, float ber_est); -void codec2_encode_1200(struct CODEC2 *c2, unsigned char * bits, short speech[]); -void codec2_decode_1200(struct CODEC2 *c2, short speech[], const unsigned char * bits); -static void ear_protection(float in_out[], int n); - -/*---------------------------------------------------------------------------*\ - - FUNCTIONS - -\*---------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: codec2_create - AUTHOR......: David Rowe - DATE CREATED: 21/8/2010 - - Create and initialise an instance of the codec. Returns a pointer - to the codec states or NULL on failure. One set of states is - sufficient for a full duuplex codec (i.e. an encoder and decoder). - You don't need separate states for encoders and decoders. See - c2enc.c and c2dec.c for examples. - -\*---------------------------------------------------------------------------*/ - -struct CODEC2 * CODEC2_WIN32SUPPORT codec2_create(int mode) -{ - struct CODEC2 *c2; - int i,l; - - c2 = (struct CODEC2*)malloc(sizeof(struct CODEC2)); - if (c2 == NULL) - return NULL; - - assert( - (mode == CODEC2_MODE_3200) || - (mode == CODEC2_MODE_2400) || - (mode == CODEC2_MODE_1600) || - (mode == CODEC2_MODE_1400) || - (mode == CODEC2_MODE_1300) || - (mode == CODEC2_MODE_1200) - ); - c2->mode = mode; - for(i=0; iSn[i] = 1.0; - c2->hpf_states[0] = c2->hpf_states[1] = 0.0; - for(i=0; i<2*N; i++) - c2->Sn_[i] = 0; - c2->fft_fwd_cfg = kiss_fft_alloc(FFT_ENC, 0, NULL, NULL); - make_analysis_window(c2->fft_fwd_cfg, c2->w,c2->W); - make_synthesis_window(c2->Pn); - c2->fft_inv_cfg = kiss_fft_alloc(FFT_DEC, 1, NULL, NULL); - quantise_init(); - c2->prev_Wo_enc = 0.0; - c2->bg_est = 0.0; - c2->ex_phase = 0.0; - - for(l=1; l<=MAX_AMP; l++) - c2->prev_model_dec.A[l] = 0.0; - c2->prev_model_dec.Wo = TWO_PI/P_MAX; - c2->prev_model_dec.L = PI/c2->prev_model_dec.Wo; - c2->prev_model_dec.voiced = 0; - - for(i=0; iprev_lsps_dec[i] = i*PI/(LPC_ORD+1); - } - c2->prev_e_dec = 1; - - c2->nlp = nlp_create(M); - if (c2->nlp == NULL) { - free (c2); - return NULL; - } - - c2->gray = 1; - - c2->lpc_pf = 1; c2->bass_boost = 1; c2->beta = LPCPF_BETA; c2->gamma = LPCPF_GAMMA; - - c2->xq_enc[0] = c2->xq_enc[1] = 0.0; - c2->xq_dec[0] = c2->xq_dec[1] = 0.0; - - c2->smoothing = 0; - - return c2; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: codec2_destroy - AUTHOR......: David Rowe - DATE CREATED: 21/8/2010 - - Destroy an instance of the codec. - -\*---------------------------------------------------------------------------*/ - -void CODEC2_WIN32SUPPORT codec2_destroy(struct CODEC2 *c2) -{ - assert(c2 != NULL); - nlp_destroy(c2->nlp); - KISS_FFT_FREE(c2->fft_fwd_cfg); - KISS_FFT_FREE(c2->fft_inv_cfg); - free(c2); -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: codec2_bits_per_frame - AUTHOR......: David Rowe - DATE CREATED: Nov 14 2011 - - Returns the number of bits per frame. - -\*---------------------------------------------------------------------------*/ - -int CODEC2_WIN32SUPPORT codec2_bits_per_frame(struct CODEC2 *c2) { - if (c2->mode == CODEC2_MODE_3200) - return 64; - if (c2->mode == CODEC2_MODE_2400) - return 48; - if (c2->mode == CODEC2_MODE_1600) - return 64; - if (c2->mode == CODEC2_MODE_1400) - return 56; - if (c2->mode == CODEC2_MODE_1300) - return 52; - if (c2->mode == CODEC2_MODE_1200) - return 48; - - return 0; /* shouldn't get here */ -} - - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: codec2_samples_per_frame - AUTHOR......: David Rowe - DATE CREATED: Nov 14 2011 - - Returns the number of bits per frame. - -\*---------------------------------------------------------------------------*/ - -int CODEC2_WIN32SUPPORT codec2_samples_per_frame(struct CODEC2 *c2) { - if (c2->mode == CODEC2_MODE_3200) - return 160; - if (c2->mode == CODEC2_MODE_2400) - return 160; - if (c2->mode == CODEC2_MODE_1600) - return 320; - if (c2->mode == CODEC2_MODE_1400) - return 320; - if (c2->mode == CODEC2_MODE_1300) - return 320; - if (c2->mode == CODEC2_MODE_1200) - return 320; - - return 0; /* shouldnt get here */ -} - -void CODEC2_WIN32SUPPORT codec2_encode(struct CODEC2 *c2, unsigned char *bits, short speech[]) -{ - assert(c2 != NULL); - assert( - (c2->mode == CODEC2_MODE_3200) || - (c2->mode == CODEC2_MODE_2400) || - (c2->mode == CODEC2_MODE_1600) || - (c2->mode == CODEC2_MODE_1400) || - (c2->mode == CODEC2_MODE_1300) || - (c2->mode == CODEC2_MODE_1200) - ); - - if (c2->mode == CODEC2_MODE_3200) - codec2_encode_3200(c2, bits, speech); - if (c2->mode == CODEC2_MODE_2400) - codec2_encode_2400(c2, bits, speech); - if (c2->mode == CODEC2_MODE_1600) - codec2_encode_1600(c2, bits, speech); - if (c2->mode == CODEC2_MODE_1400) - codec2_encode_1400(c2, bits, speech); - if (c2->mode == CODEC2_MODE_1300) - codec2_encode_1300(c2, bits, speech); - if (c2->mode == CODEC2_MODE_1200) - codec2_encode_1200(c2, bits, speech); -} - -void CODEC2_WIN32SUPPORT codec2_decode(struct CODEC2 *c2, short speech[], const unsigned char *bits) -{ - codec2_decode_ber(c2, speech, bits, 0.0); -} - -void CODEC2_WIN32SUPPORT codec2_decode_ber(struct CODEC2 *c2, short speech[], const unsigned char *bits, float ber_est) -{ - assert(c2 != NULL); - assert( - (c2->mode == CODEC2_MODE_3200) || - (c2->mode == CODEC2_MODE_2400) || - (c2->mode == CODEC2_MODE_1600) || - (c2->mode == CODEC2_MODE_1400) || - (c2->mode == CODEC2_MODE_1300) || - (c2->mode == CODEC2_MODE_1200) - ); - - if (c2->mode == CODEC2_MODE_3200) - codec2_decode_3200(c2, speech, bits); - if (c2->mode == CODEC2_MODE_2400) - codec2_decode_2400(c2, speech, bits); - if (c2->mode == CODEC2_MODE_1600) - codec2_decode_1600(c2, speech, bits); - if (c2->mode == CODEC2_MODE_1400) - codec2_decode_1400(c2, speech, bits); - if (c2->mode == CODEC2_MODE_1300) - codec2_decode_1300(c2, speech, bits, ber_est); - if (c2->mode == CODEC2_MODE_1200) - codec2_decode_1200(c2, speech, bits); -} - - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: codec2_encode_3200 - AUTHOR......: David Rowe - DATE CREATED: 13 Sep 2012 - - Encodes 160 speech samples (20ms of speech) into 64 bits. - - The codec2 algorithm actually operates internally on 10ms (80 - sample) frames, so we run the encoding algorithm twice. On the - first frame we just send the voicing bits. On the second frame we - send all model parameters. Compared to 2400 we use a larger number - of bits for the LSPs and non-VQ pitch and energy. - - The bit allocation is: - - Parameter bits/frame - -------------------------------------- - Harmonic magnitudes (LSPs) 50 - Pitch (Wo) 7 - Energy 5 - Voicing (10ms update) 2 - TOTAL 64 - -\*---------------------------------------------------------------------------*/ - -void codec2_encode_3200(struct CODEC2 *c2, unsigned char * bits, short speech[]) -{ - MODEL model; - float ak[LPC_ORD+1]; - float lsps[LPC_ORD]; - float e; - int Wo_index, e_index; - int lspd_indexes[LPC_ORD]; - int i; - unsigned int nbit = 0; - - assert(c2 != NULL); - - memset(bits, '\0', ((codec2_bits_per_frame(c2) + 7) / 8)); - - /* first 10ms analysis frame - we just want voicing */ - - analyse_one_frame(c2, &model, speech); - pack(bits, &nbit, model.voiced, 1); - - /* second 10ms analysis frame */ - - analyse_one_frame(c2, &model, &speech[N]); - pack(bits, &nbit, model.voiced, 1); - Wo_index = encode_Wo(model.Wo); - pack(bits, &nbit, Wo_index, WO_BITS); - - e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); - e_index = encode_energy(e); - pack(bits, &nbit, e_index, E_BITS); - - encode_lspds_scalar(lspd_indexes, lsps, LPC_ORD); - for(i=0; iprev_model_dec, &model[1]); - e[0] = interp_energy(c2->prev_e_dec, e[1]); - - /* LSPs are sampled every 20ms so we interpolate the frame in - between, then recover spectral amplitudes */ - - interpolate_lsp_ver2(&lsps[0][0], c2->prev_lsps_dec, &lsps[1][0], 0.5); - for(i=0; i<2; i++) { - lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD); - aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 0, 0, - c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma); - apply_lpc_correction(&model[i]); - } - - /* synthesise ------------------------------------------------*/ - - for(i=0; i<2; i++) - synthesise_one_frame(c2, &speech[N*i], &model[i], &ak[i][0]); - - /* update memories for next frame ----------------------------*/ - - c2->prev_model_dec = model[1]; - c2->prev_e_dec = e[1]; - for(i=0; iprev_lsps_dec[i] = lsps[1][i]; -} - - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: codec2_encode_2400 - AUTHOR......: David Rowe - DATE CREATED: 21/8/2010 - - Encodes 160 speech samples (20ms of speech) into 48 bits. - - The codec2 algorithm actually operates internally on 10ms (80 - sample) frames, so we run the encoding algorithm twice. On the - first frame we just send the voicing bit. On the second frame we - send all model parameters. - - The bit allocation is: - - Parameter bits/frame - -------------------------------------- - Harmonic magnitudes (LSPs) 36 - Joint VQ of Energy and Wo 8 - Voicing (10ms update) 2 - Spare 2 - TOTAL 48 - -\*---------------------------------------------------------------------------*/ - -void codec2_encode_2400(struct CODEC2 *c2, unsigned char * bits, short speech[]) -{ - MODEL model; - float ak[LPC_ORD+1]; - float lsps[LPC_ORD]; - float e; - int WoE_index; - int lsp_indexes[LPC_ORD]; - int i; - int spare = 0; - unsigned int nbit = 0; - - assert(c2 != NULL); - - memset(bits, '\0', ((codec2_bits_per_frame(c2) + 7) / 8)); - - /* first 10ms analysis frame - we just want voicing */ - - analyse_one_frame(c2, &model, speech); - pack(bits, &nbit, model.voiced, 1); - - /* second 10ms analysis frame */ - - analyse_one_frame(c2, &model, &speech[N]); - pack(bits, &nbit, model.voiced, 1); - - e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); - WoE_index = encode_WoE(&model, e, c2->xq_enc); - pack(bits, &nbit, WoE_index, WO_E_BITS); - - encode_lsps_scalar(lsp_indexes, lsps, LPC_ORD); - for(i=0; ixq_dec, WoE_index); - - for(i=0; iprev_model_dec, &model[1]); - e[0] = interp_energy(c2->prev_e_dec, e[1]); - - /* LSPs are sampled every 20ms so we interpolate the frame in - between, then recover spectral amplitudes */ - - interpolate_lsp_ver2(&lsps[0][0], c2->prev_lsps_dec, &lsps[1][0], 0.5); - for(i=0; i<2; i++) { - lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD); - aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 0, 0, - c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma); - apply_lpc_correction(&model[i]); - } - - /* synthesise ------------------------------------------------*/ - - for(i=0; i<2; i++) - synthesise_one_frame(c2, &speech[N*i], &model[i], &ak[i][0]); - - /* update memories for next frame ----------------------------*/ - - c2->prev_model_dec = model[1]; - c2->prev_e_dec = e[1]; - for(i=0; iprev_lsps_dec[i] = lsps[1][i]; -} - - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: codec2_encode_1600 - AUTHOR......: David Rowe - DATE CREATED: Feb 28 2013 - - Encodes 320 speech samples (40ms of speech) into 64 bits. - - The codec2 algorithm actually operates internally on 10ms (80 - sample) frames, so we run the encoding algorithm 4 times: - - frame 0: voicing bit - frame 1: voicing bit, Wo and E - frame 2: voicing bit - frame 3: voicing bit, Wo and E, scalar LSPs - - The bit allocation is: - - Parameter frame 2 frame 4 Total - ------------------------------------------------------- - Harmonic magnitudes (LSPs) 0 36 36 - Pitch (Wo) 7 7 14 - Energy 5 5 10 - Voicing (10ms update) 2 2 4 - TOTAL 14 50 64 - -\*---------------------------------------------------------------------------*/ - -void codec2_encode_1600(struct CODEC2 *c2, unsigned char * bits, short speech[]) -{ - MODEL model; - float lsps[LPC_ORD]; - float ak[LPC_ORD+1]; - float e; - int lsp_indexes[LPC_ORD]; - int Wo_index, e_index; - int i; - unsigned int nbit = 0; - - assert(c2 != NULL); - - memset(bits, '\0', ((codec2_bits_per_frame(c2) + 7) / 8)); - - /* frame 1: - voicing ---------------------------------------------*/ - - analyse_one_frame(c2, &model, speech); - pack(bits, &nbit, model.voiced, 1); - - /* frame 2: - voicing, scalar Wo & E -------------------------------*/ - - analyse_one_frame(c2, &model, &speech[N]); - pack(bits, &nbit, model.voiced, 1); - - Wo_index = encode_Wo(model.Wo); - pack(bits, &nbit, Wo_index, WO_BITS); - - /* need to run this just to get LPC energy */ - e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); - e_index = encode_energy(e); - pack(bits, &nbit, e_index, E_BITS); - - /* frame 3: - voicing ---------------------------------------------*/ - - analyse_one_frame(c2, &model, &speech[2*N]); - pack(bits, &nbit, model.voiced, 1); - - /* frame 4: - voicing, scalar Wo & E, scalar LSPs ------------------*/ - - analyse_one_frame(c2, &model, &speech[3*N]); - pack(bits, &nbit, model.voiced, 1); - - Wo_index = encode_Wo(model.Wo); - pack(bits, &nbit, Wo_index, WO_BITS); - - e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); - e_index = encode_energy(e); - pack(bits, &nbit, e_index, E_BITS); - - encode_lsps_scalar(lsp_indexes, lsps, LPC_ORD); - for(i=0; iprev_model_dec, &model[1]); - e[0] = interp_energy(c2->prev_e_dec, e[1]); - interp_Wo(&model[2], &model[1], &model[3]); - e[2] = interp_energy(e[1], e[3]); - - /* LSPs are sampled every 40ms so we interpolate the 3 frames in - between, then recover spectral amplitudes */ - - for(i=0, weight=0.25; i<3; i++, weight += 0.25) { - interpolate_lsp_ver2(&lsps[i][0], c2->prev_lsps_dec, &lsps[3][0], weight); - } - for(i=0; i<4; i++) { - lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD); - aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 0, 0, - c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma); - apply_lpc_correction(&model[i]); - } - - /* synthesise ------------------------------------------------*/ - - for(i=0; i<4; i++) - synthesise_one_frame(c2, &speech[N*i], &model[i], &ak[i][0]); - - /* update memories for next frame ----------------------------*/ - - c2->prev_model_dec = model[3]; - c2->prev_e_dec = e[3]; - for(i=0; iprev_lsps_dec[i] = lsps[3][i]; - -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: codec2_encode_1400 - AUTHOR......: David Rowe - DATE CREATED: May 11 2012 - - Encodes 320 speech samples (40ms of speech) into 56 bits. - - The codec2 algorithm actually operates internally on 10ms (80 - sample) frames, so we run the encoding algorithm 4 times: - - frame 0: voicing bit - frame 1: voicing bit, joint VQ of Wo and E - frame 2: voicing bit - frame 3: voicing bit, joint VQ of Wo and E, scalar LSPs - - The bit allocation is: - - Parameter frame 2 frame 4 Total - ------------------------------------------------------- - Harmonic magnitudes (LSPs) 0 36 36 - Energy+Wo 8 8 16 - Voicing (10ms update) 2 2 4 - TOTAL 10 46 56 - -\*---------------------------------------------------------------------------*/ - -void codec2_encode_1400(struct CODEC2 *c2, unsigned char * bits, short speech[]) -{ - MODEL model; - float lsps[LPC_ORD]; - float ak[LPC_ORD+1]; - float e; - int lsp_indexes[LPC_ORD]; - int WoE_index; - int i; - unsigned int nbit = 0; - - assert(c2 != NULL); - - memset(bits, '\0', ((codec2_bits_per_frame(c2) + 7) / 8)); - - /* frame 1: - voicing ---------------------------------------------*/ - - analyse_one_frame(c2, &model, speech); - pack(bits, &nbit, model.voiced, 1); - - /* frame 2: - voicing, joint Wo & E -------------------------------*/ - - analyse_one_frame(c2, &model, &speech[N]); - pack(bits, &nbit, model.voiced, 1); - - /* need to run this just to get LPC energy */ - e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); - - WoE_index = encode_WoE(&model, e, c2->xq_enc); - pack(bits, &nbit, WoE_index, WO_E_BITS); - - /* frame 3: - voicing ---------------------------------------------*/ - - analyse_one_frame(c2, &model, &speech[2*N]); - pack(bits, &nbit, model.voiced, 1); - - /* frame 4: - voicing, joint Wo & E, scalar LSPs ------------------*/ - - analyse_one_frame(c2, &model, &speech[3*N]); - pack(bits, &nbit, model.voiced, 1); - - e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); - WoE_index = encode_WoE(&model, e, c2->xq_enc); - pack(bits, &nbit, WoE_index, WO_E_BITS); - - encode_lsps_scalar(lsp_indexes, lsps, LPC_ORD); - for(i=0; ixq_dec, WoE_index); - - model[2].voiced = unpack(bits, &nbit, 1); - - model[3].voiced = unpack(bits, &nbit, 1); - WoE_index = unpack(bits, &nbit, WO_E_BITS); - decode_WoE(&model[3], &e[3], c2->xq_dec, WoE_index); - - for(i=0; iprev_model_dec, &model[1]); - e[0] = interp_energy(c2->prev_e_dec, e[1]); - interp_Wo(&model[2], &model[1], &model[3]); - e[2] = interp_energy(e[1], e[3]); - - /* LSPs are sampled every 40ms so we interpolate the 3 frames in - between, then recover spectral amplitudes */ - - for(i=0, weight=0.25; i<3; i++, weight += 0.25) { - interpolate_lsp_ver2(&lsps[i][0], c2->prev_lsps_dec, &lsps[3][0], weight); - } - for(i=0; i<4; i++) { - lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD); - aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 0, 0, - c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma); - apply_lpc_correction(&model[i]); - } - - /* synthesise ------------------------------------------------*/ - - for(i=0; i<4; i++) - synthesise_one_frame(c2, &speech[N*i], &model[i], &ak[i][0]); - - /* update memories for next frame ----------------------------*/ - - c2->prev_model_dec = model[3]; - c2->prev_e_dec = e[3]; - for(i=0; iprev_lsps_dec[i] = lsps[3][i]; - -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: codec2_encode_1300 - AUTHOR......: David Rowe - DATE CREATED: March 14 2013 - - Encodes 320 speech samples (40ms of speech) into 52 bits. - - The codec2 algorithm actually operates internally on 10ms (80 - sample) frames, so we run the encoding algorithm 4 times: - - frame 0: voicing bit - frame 1: voicing bit, - frame 2: voicing bit - frame 3: voicing bit, Wo and E, scalar LSPs - - The bit allocation is: - - Parameter frame 2 frame 4 Total - ------------------------------------------------------- - Harmonic magnitudes (LSPs) 0 36 36 - Pitch (Wo) 0 7 7 - Energy 0 5 5 - Voicing (10ms update) 2 2 4 - TOTAL 2 50 52 - -\*---------------------------------------------------------------------------*/ - -void codec2_encode_1300(struct CODEC2 *c2, unsigned char * bits, short speech[]) -{ - MODEL model; - float lsps[LPC_ORD]; - float ak[LPC_ORD+1]; - float e; - int lsp_indexes[LPC_ORD]; - int Wo_index, e_index; - int i; - unsigned int nbit = 0; - #ifdef TIMER - unsigned int quant_start; - #endif - - assert(c2 != NULL); - - memset(bits, '\0', ((codec2_bits_per_frame(c2) + 7) / 8)); - - /* frame 1: - voicing ---------------------------------------------*/ - - analyse_one_frame(c2, &model, speech); - pack_natural_or_gray(bits, &nbit, model.voiced, 1, c2->gray); - - /* frame 2: - voicing ---------------------------------------------*/ - - analyse_one_frame(c2, &model, &speech[N]); - pack_natural_or_gray(bits, &nbit, model.voiced, 1, c2->gray); - - /* frame 3: - voicing ---------------------------------------------*/ - - analyse_one_frame(c2, &model, &speech[2*N]); - pack_natural_or_gray(bits, &nbit, model.voiced, 1, c2->gray); - - /* frame 4: - voicing, scalar Wo & E, scalar LSPs ------------------*/ - - analyse_one_frame(c2, &model, &speech[3*N]); - pack_natural_or_gray(bits, &nbit, model.voiced, 1, c2->gray); - - Wo_index = encode_Wo(model.Wo); - pack_natural_or_gray(bits, &nbit, Wo_index, WO_BITS, c2->gray); - - #ifdef TIMER - quant_start = machdep_timer_sample(); - #endif - e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); - e_index = encode_energy(e); - pack_natural_or_gray(bits, &nbit, e_index, E_BITS, c2->gray); - - encode_lsps_scalar(lsp_indexes, lsps, LPC_ORD); - for(i=0; igray); - } - #ifdef TIMER - machdep_timer_sample_and_log(quant_start, " quant/packing"); - #endif - - assert(nbit == (unsigned)codec2_bits_per_frame(c2)); -} - - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: codec2_decode_1300 - AUTHOR......: David Rowe - DATE CREATED: 11 May 2012 - - Decodes frames of 52 bits into 320 samples (40ms) of speech. - -\*---------------------------------------------------------------------------*/ - -void codec2_decode_1300(struct CODEC2 *c2, short speech[], const unsigned char * bits, float ber_est) -{ - MODEL model[4]; - int lsp_indexes[LPC_ORD]; - float lsps[4][LPC_ORD]; - int Wo_index, e_index; - float e[4]; - float snr; - float ak[4][LPC_ORD+1]; - int i,j; - unsigned int nbit = 0; - float weight; - TIMER_VAR(recover_start); - - assert(c2 != NULL); - - /* only need to zero these out due to (unused) snr calculation */ - - for(i=0; i<4; i++) - for(j=1; j<=MAX_AMP; j++) - model[i].A[j] = 0.0; - - /* unpack bits from channel ------------------------------------*/ - - /* this will partially fill the model params for the 4 x 10ms - frames */ - - model[0].voiced = unpack_natural_or_gray(bits, &nbit, 1, c2->gray); - model[1].voiced = unpack_natural_or_gray(bits, &nbit, 1, c2->gray); - model[2].voiced = unpack_natural_or_gray(bits, &nbit, 1, c2->gray); - model[3].voiced = unpack_natural_or_gray(bits, &nbit, 1, c2->gray); - - Wo_index = unpack_natural_or_gray(bits, &nbit, WO_BITS, c2->gray); - model[3].Wo = decode_Wo(Wo_index); - model[3].L = PI/model[3].Wo; - - e_index = unpack_natural_or_gray(bits, &nbit, E_BITS, c2->gray); - e[3] = decode_energy(e_index); - - for(i=0; igray); - } - decode_lsps_scalar(&lsps[3][0], lsp_indexes, LPC_ORD); - check_lsp_order(&lsps[3][0], LPC_ORD); - bw_expand_lsps(&lsps[3][0], LPC_ORD, 50.0, 100.0); - - if (ber_est > 0.15) { - model[0].voiced = model[1].voiced = model[2].voiced = model[3].voiced = 0; - e[3] = decode_energy(10); - bw_expand_lsps(&lsps[3][0], LPC_ORD, 200.0, 200.0); - fprintf(stderr, "soft mute\n"); - } - - /* interpolate ------------------------------------------------*/ - - /* Wo, energy, and LSPs are sampled every 40ms so we interpolate - the 3 frames in between */ - - TIMER_SAMPLE(recover_start); - for(i=0, weight=0.25; i<3; i++, weight += 0.25) { - interpolate_lsp_ver2(&lsps[i][0], c2->prev_lsps_dec, &lsps[3][0], weight); - interp_Wo2(&model[i], &c2->prev_model_dec, &model[3], weight); - e[i] = interp_energy2(c2->prev_e_dec, e[3],weight); - } - - /* then recover spectral amplitudes */ - - for(i=0; i<4; i++) { - lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD); - aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 0, 0, - c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma); - apply_lpc_correction(&model[i]); - } - TIMER_SAMPLE_AND_LOG2(recover_start, " recover"); - #ifdef DUMP - dump_lsp_(&lsps[3][0]); - dump_ak_(&ak[3][0], LPC_ORD); - #endif - - /* synthesise ------------------------------------------------*/ - - for(i=0; i<4; i++) - synthesise_one_frame(c2, &speech[N*i], &model[i], &ak[i][0]); - - /* update memories for next frame ----------------------------*/ - - c2->prev_model_dec = model[3]; - c2->prev_e_dec = e[3]; - for(i=0; iprev_lsps_dec[i] = lsps[3][i]; - -} - - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: codec2_encode_1200 - AUTHOR......: David Rowe - DATE CREATED: Nov 14 2011 - - Encodes 320 speech samples (40ms of speech) into 48 bits. - - The codec2 algorithm actually operates internally on 10ms (80 - sample) frames, so we run the encoding algorithm four times: - - frame 0: voicing bit - frame 1: voicing bit, joint VQ of Wo and E - frame 2: voicing bit - frame 3: voicing bit, joint VQ of Wo and E, VQ LSPs - - The bit allocation is: - - Parameter frame 2 frame 4 Total - ------------------------------------------------------- - Harmonic magnitudes (LSPs) 0 27 27 - Energy+Wo 8 8 16 - Voicing (10ms update) 2 2 4 - Spare 0 1 1 - TOTAL 10 38 48 - -\*---------------------------------------------------------------------------*/ - -void codec2_encode_1200(struct CODEC2 *c2, unsigned char * bits, short speech[]) -{ - MODEL model; - float lsps[LPC_ORD]; - float lsps_[LPC_ORD]; - float ak[LPC_ORD+1]; - float e; - int lsp_indexes[LPC_ORD]; - int WoE_index; - int i; - int spare = 0; - unsigned int nbit = 0; - - assert(c2 != NULL); - - memset(bits, '\0', ((codec2_bits_per_frame(c2) + 7) / 8)); - - /* frame 1: - voicing ---------------------------------------------*/ - - analyse_one_frame(c2, &model, speech); - pack(bits, &nbit, model.voiced, 1); - - /* frame 2: - voicing, joint Wo & E -------------------------------*/ - - analyse_one_frame(c2, &model, &speech[N]); - pack(bits, &nbit, model.voiced, 1); - - /* need to run this just to get LPC energy */ - e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); - - WoE_index = encode_WoE(&model, e, c2->xq_enc); - pack(bits, &nbit, WoE_index, WO_E_BITS); - - /* frame 3: - voicing ---------------------------------------------*/ - - analyse_one_frame(c2, &model, &speech[2*N]); - pack(bits, &nbit, model.voiced, 1); - - /* frame 4: - voicing, joint Wo & E, scalar LSPs ------------------*/ - - analyse_one_frame(c2, &model, &speech[3*N]); - pack(bits, &nbit, model.voiced, 1); - - e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); - WoE_index = encode_WoE(&model, e, c2->xq_enc); - pack(bits, &nbit, WoE_index, WO_E_BITS); - - encode_lsps_vq(lsp_indexes, lsps, lsps_, LPC_ORD); - for(i=0; ixq_dec, WoE_index); - - model[2].voiced = unpack(bits, &nbit, 1); - - model[3].voiced = unpack(bits, &nbit, 1); - WoE_index = unpack(bits, &nbit, WO_E_BITS); - decode_WoE(&model[3], &e[3], c2->xq_dec, WoE_index); - - for(i=0; iprev_model_dec, &model[1]); - e[0] = interp_energy(c2->prev_e_dec, e[1]); - interp_Wo(&model[2], &model[1], &model[3]); - e[2] = interp_energy(e[1], e[3]); - - /* LSPs are sampled every 40ms so we interpolate the 3 frames in - between, then recover spectral amplitudes */ - - for(i=0, weight=0.25; i<3; i++, weight += 0.25) { - interpolate_lsp_ver2(&lsps[i][0], c2->prev_lsps_dec, &lsps[3][0], weight); - } - for(i=0; i<4; i++) { - lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD); - aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 0, 0, - c2->lpc_pf, c2->bass_boost, c2->beta, c2->gamma); - apply_lpc_correction(&model[i]); - } - - /* synthesise ------------------------------------------------*/ - - for(i=0; i<4; i++) - synthesise_one_frame(c2, &speech[N*i], &model[i], &ak[i][0]); - - /* update memories for next frame ----------------------------*/ - - c2->prev_model_dec = model[3]; - c2->prev_e_dec = e[3]; - for(i=0; iprev_lsps_dec[i] = lsps[3][i]; -} - - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: synthesise_one_frame() - AUTHOR......: David Rowe - DATE CREATED: 23/8/2010 - - Synthesise 80 speech samples (10ms) from model parameters. - -\*---------------------------------------------------------------------------*/ - -void synthesise_one_frame(struct CODEC2 *c2, short speech[], MODEL *model, float ak[]) -{ - int i; - TIMER_VAR(phase_start, pf_start, synth_start); - - #ifdef DUMP - dump_quantised_model(model); - #endif - - TIMER_SAMPLE(phase_start); - - phase_synth_zero_order(c2->fft_fwd_cfg, model, ak, &c2->ex_phase, LPC_ORD); - - TIMER_SAMPLE_AND_LOG(pf_start,phase_start, " phase_synth"); - - postfilter(model, &c2->bg_est); - - TIMER_SAMPLE_AND_LOG(synth_start, pf_start, " postfilter"); - - synthesise(c2->fft_inv_cfg, c2->Sn_, model, c2->Pn, 1); - - TIMER_SAMPLE_AND_LOG2(synth_start, " synth"); - - ear_protection(c2->Sn_, N); - - for(i=0; iSn_[i] > 32767.0) - speech[i] = 32767; - else if (c2->Sn_[i] < -32767.0) - speech[i] = -32767; - else - speech[i] = c2->Sn_[i]; - } - -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: analyse_one_frame() - AUTHOR......: David Rowe - DATE CREATED: 23/8/2010 - - Extract sinusoidal model parameters from 80 speech samples (10ms of - speech). - -\*---------------------------------------------------------------------------*/ - -void analyse_one_frame(struct CODEC2 *c2, MODEL *model, short speech[]) -{ - COMP Sw[FFT_ENC]; - COMP Sw_[FFT_ENC]; - COMP Ew[FFT_ENC]; - float pitch; - int i; - TIMER_VAR(dft_start, nlp_start, model_start, two_stage, estamps); - - /* Read input speech */ - - for(i=0; iSn[i] = c2->Sn[i+N]; - for(i=0; iSn[i+M-N] = speech[i]; - - TIMER_SAMPLE(dft_start); - dft_speech(c2->fft_fwd_cfg, Sw, c2->Sn, c2->w); - TIMER_SAMPLE_AND_LOG(nlp_start, dft_start, " dft_speech"); - - /* Estimate pitch */ - - nlp(c2->nlp,c2->Sn,N,P_MIN,P_MAX,&pitch,Sw, c2->W, &c2->prev_Wo_enc); - TIMER_SAMPLE_AND_LOG(model_start, nlp_start, " nlp"); - - model->Wo = TWO_PI/pitch; - model->L = PI/model->Wo; - - /* estimate model parameters */ - - two_stage_pitch_refinement(model, Sw); - TIMER_SAMPLE_AND_LOG(two_stage, model_start, " two_stage"); - estimate_amplitudes(model, Sw, c2->W, 0); - TIMER_SAMPLE_AND_LOG(estamps, two_stage, " est_amps"); - est_voicing_mbe(model, Sw, c2->W, Sw_, Ew, c2->prev_Wo_enc); - c2->prev_Wo_enc = model->Wo; - TIMER_SAMPLE_AND_LOG2(estamps, " est_voicing"); - #ifdef DUMP - dump_model(model); - #endif -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: ear_protection() - AUTHOR......: David Rowe - DATE CREATED: Nov 7 2012 - - Limits output level to protect ears when there are bit errors or the input - is overdriven. This doesn't correct or mask bit erros, just reduces the - worst of their damage. - -\*---------------------------------------------------------------------------*/ - -static void ear_protection(float in_out[], int n) { - float max_sample, over, gain; - int i; - - /* find maximum sample in frame */ - - max_sample = 0.0; - for(i=0; i max_sample) - max_sample = in_out[i]; - - /* determine how far above set point */ - - over = max_sample/30000.0; - - /* If we are x dB over set point we reduce level by 2x dB, this - attenuates major excursions in amplitude (likely to be caused - by bit errors) more than smaller ones */ - - if (over > 1.0) { - gain = 1.0/(over*over); - //fprintf(stderr, "gain: %f\n", gain); - for(i=0; i= 0.0) && (beta <= 1.0)); - assert((gamma >= 0.0) && (gamma <= 1.0)); - c2->lpc_pf = enable; - c2->bass_boost = bass_boost; - c2->beta = beta; - c2->gamma = gamma; -} - -/* - Allows optional stealing of one of the voicing bits for use as a - spare bit, only 1300 & 1400 & 1600 bit/s supported for now. - Experimental method of sending voice/data frames for FreeDV. -*/ - -int CODEC2_WIN32SUPPORT codec2_get_spare_bit_index(struct CODEC2 *c2) -{ - assert(c2 != NULL); - - switch(c2->mode) { - case CODEC2_MODE_1300: - return 2; // bit 2 (3th bit) is v2 (third voicing bit) - break; - case CODEC2_MODE_1400: - return 10; // bit 10 (11th bit) is v2 (third voicing bit) - break; - case CODEC2_MODE_1600: - return 15; // bit 15 (16th bit) is v2 (third voicing bit) - break; - } - - return -1; -} - -/* - Reconstructs the spare voicing bit. Note works on unpacked bits - for convenience. -*/ - -int CODEC2_WIN32SUPPORT codec2_rebuild_spare_bit(struct CODEC2 *c2, int unpacked_bits[]) -{ - int v1,v3; - - assert(c2 != NULL); - - v1 = unpacked_bits[1]; - - switch(c2->mode) { - case CODEC2_MODE_1300: - - v3 = unpacked_bits[1+1+1]; - - /* if either adjacent frame is voiced, make this one voiced */ - - unpacked_bits[2] = (v1 || v3); - - return 0; - - break; - - case CODEC2_MODE_1400: - - v3 = unpacked_bits[1+1+8+1]; - - /* if either adjacent frame is voiced, make this one voiced */ - - unpacked_bits[10] = (v1 || v3); - - return 0; - - break; - - case CODEC2_MODE_1600: - v3 = unpacked_bits[1+1+8+5+1]; - - /* if either adjacent frame is voiced, make this one voiced */ - - unpacked_bits[15] = (v1 || v3); - - return 0; - - break; - } - - return -1; -} - -void CODEC2_WIN32SUPPORT codec2_set_natural_or_gray(struct CODEC2 *c2, int gray) -{ - assert(c2 != NULL); - c2->gray = gray; -} - diff --git a/codec2/src/codec2.h b/codec2/src/codec2.h deleted file mode 100644 index ea007065..00000000 --- a/codec2/src/codec2.h +++ /dev/null @@ -1,76 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: codec2.h - AUTHOR......: David Rowe - DATE CREATED: 21 August 2010 - - Codec 2 fully quantised encoder and decoder functions. If you want use - Codec 2, these are the functions you need to call. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2010 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#ifdef __cplusplus - extern "C" { -#endif - -#ifndef __CODEC2__ -#define __CODEC2__ - -/* set up the calling convention for DLL function import/export for - WIN32 cross compiling */ - -#ifdef __CODEC2_WIN32__ -#ifdef __CODEC2_BUILDING_DLL__ -#define CODEC2_WIN32SUPPORT __declspec(dllexport) __stdcall -#else -#define CODEC2_WIN32SUPPORT __declspec(dllimport) __stdcall -#endif -#else -#define CODEC2_WIN32SUPPORT -#endif - -#define CODEC2_MODE_3200 0 -#define CODEC2_MODE_2400 1 -#define CODEC2_MODE_1600 2 -#define CODEC2_MODE_1400 3 -#define CODEC2_MODE_1300 4 -#define CODEC2_MODE_1200 5 - -struct CODEC2; - -struct CODEC2 * CODEC2_WIN32SUPPORT codec2_create(int mode); -void CODEC2_WIN32SUPPORT codec2_destroy(struct CODEC2 *codec2_state); -void CODEC2_WIN32SUPPORT codec2_encode(struct CODEC2 *codec2_state, unsigned char * bits, short speech_in[]); -void CODEC2_WIN32SUPPORT codec2_decode(struct CODEC2 *codec2_state, short speech_out[], const unsigned char *bits); -void CODEC2_WIN32SUPPORT codec2_decode_ber(struct CODEC2 *codec2_state, short speech_out[], const unsigned char *bits, float ber_est); -int CODEC2_WIN32SUPPORT codec2_samples_per_frame(struct CODEC2 *codec2_state); -int CODEC2_WIN32SUPPORT codec2_bits_per_frame(struct CODEC2 *codec2_state); - -void CODEC2_WIN32SUPPORT codec2_set_lpc_post_filter(struct CODEC2 *codec2_state, int enable, int bass_boost, float beta, float gamma); -int CODEC2_WIN32SUPPORT codec2_get_spare_bit_index(struct CODEC2 *codec2_state); -int CODEC2_WIN32SUPPORT codec2_rebuild_spare_bit(struct CODEC2 *codec2_state, int unpacked_bits[]); -void CODEC2_WIN32SUPPORT codec2_set_natural_or_gray(struct CODEC2 *codec2_state, int gray); - -#endif - -#ifdef __cplusplus -} -#endif - diff --git a/codec2/src/codec2_fdmdv.h b/codec2/src/codec2_fdmdv.h deleted file mode 100644 index 5938c642..00000000 --- a/codec2/src/codec2_fdmdv.h +++ /dev/null @@ -1,124 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: codec2_fdmdv.h - AUTHOR......: David Rowe - DATE CREATED: April 14 2012 - - A 1400 bit/s (nominal) Frequency Division Multiplexed Digital Voice - (FDMDV) modem. Used for digital audio over HF SSB. See - README_fdmdv.txt for more information, and fdmdv_mod.c and - fdmdv_demod.c for example usage. - - The name codec2_fdmdv.h is used to make it unique when "make - installed". - - References: - - [1] http://n1su.com/fdmdv/FDMDV_Docs_Rel_1_4b.pdf - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2012 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#ifndef __FDMDV__ -#define __FDMDV__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* set up the calling convention for DLL function import/export for - WIN32 cross compiling */ - -#ifdef __CODEC2_WIN32__ -#ifdef __CODEC2_BUILDING_DLL__ -#define CODEC2_WIN32SUPPORT __declspec(dllexport) __stdcall -#else -#define CODEC2_WIN32SUPPORT __declspec(dllimport) __stdcall -#endif -#else -#define CODEC2_WIN32SUPPORT -#endif - -#include "comp.h" - -#define FDMDV_NC 14 /* default number of data carriers */ -#define FDMDV_NC_MAX 20 /* maximum number of data carriers */ -#define FDMDV_BITS_PER_FRAME 28 /* 20ms frames, for nominal 1400 bit/s */ -#define FDMDV_NOM_SAMPLES_PER_FRAME 160 /* modulator output samples/frame and nominal demod samples/frame */ - /* at 8000 Hz sample rate */ -#define FDMDV_MAX_SAMPLES_PER_FRAME 200 /* max demod samples/frame, use this to allocate storage */ -#define FDMDV_SCALE 1000 /* suggested scaling for 16 bit shorts */ -#define FDMDV_FCENTRE 1500 /* Centre frequency, Nc/2 carriers below this, Nc/2 carriers above (Hz) */ - -/* 8 to 48 kHz sample rate conversion */ - -#define FDMDV_OS 6 /* oversampling rate */ -#define FDMDV_OS_TAPS 48 /* number of OS filter taps */ - -/* FFT points */ - -#define FDMDV_NSPEC 512 -#define FDMDV_MAX_F_HZ 4000 - -/* FDMDV states and stats structures */ - -struct FDMDV; - -struct FDMDV_STATS { - int Nc; - float snr_est; /* estimated SNR of rx signal in dB (3 kHz noise BW) */ - COMP rx_symbols[FDMDV_NC_MAX+1]; /* latest received symbols, for scatter plot */ - int sync; /* demod sync state */ - float foff; /* estimated freq offset in Hz */ - float rx_timing; /* estimated optimum timing offset in samples */ - float clock_offset; /* Estimated tx/rx sample clock offset in ppm */ -}; - -struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(int Nc); -void CODEC2_WIN32SUPPORT fdmdv_destroy(struct FDMDV *fdmdv_state); -void CODEC2_WIN32SUPPORT fdmdv_use_old_qpsk_mapping(struct FDMDV *fdmdv_state); -int CODEC2_WIN32SUPPORT fdmdv_bits_per_frame(struct FDMDV *fdmdv_state); -float CODEC2_WIN32SUPPORT fdmdv_get_fsep(struct FDMDV *fdmdv_state); -void CODEC2_WIN32SUPPORT fdmdv_set_fsep(struct FDMDV *fdmdv_state, float fsep); - -void CODEC2_WIN32SUPPORT fdmdv_mod(struct FDMDV *fdmdv_state, COMP tx_fdm[], int tx_bits[], int *sync_bit); -void CODEC2_WIN32SUPPORT fdmdv_demod(struct FDMDV *fdmdv_state, int rx_bits[], int *reliable_sync_bit, COMP rx_fdm[], int *nin); - -void CODEC2_WIN32SUPPORT fdmdv_get_test_bits(struct FDMDV *fdmdv_state, int tx_bits[]); -int CODEC2_WIN32SUPPORT fdmdv_error_pattern_size(struct FDMDV *fdmdv_state); -void CODEC2_WIN32SUPPORT fdmdv_put_test_bits(struct FDMDV *f, int *sync, short error_pattern[], int *bit_errors, int *ntest_bits, int rx_bits[]); - -void CODEC2_WIN32SUPPORT fdmdv_get_demod_stats(struct FDMDV *fdmdv_state, struct FDMDV_STATS *fdmdv_stats); -void CODEC2_WIN32SUPPORT fdmdv_get_rx_spectrum(struct FDMDV *fdmdv_state, float mag_dB[], COMP rx_fdm[], int nin); - -void CODEC2_WIN32SUPPORT fdmdv_8_to_48(float out48k[], float in8k[], int n); -void CODEC2_WIN32SUPPORT fdmdv_48_to_8(float out8k[], float in48k[], int n); - -void CODEC2_WIN32SUPPORT fdmdv_freq_shift(COMP rx_fdm_fcorr[], COMP rx_fdm[], float foff, COMP *foff_phase_rect, int nin); - -/* debug/development function(s) */ - -void CODEC2_WIN32SUPPORT fdmdv_dump_osc_mags(struct FDMDV *f); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/codec2/src/codec2_fifo.h b/codec2/src/codec2_fifo.h deleted file mode 100644 index dc93e157..00000000 --- a/codec2/src/codec2_fifo.h +++ /dev/null @@ -1,51 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: codec2_fifo.h - AUTHOR......: David Rowe - DATE CREATED: Oct 15 2012 - - A FIFO design useful in gluing the FDMDV modem and codec together in - integrated applications. - - The name codec2_fifo.h is used to make it unique when "make - installed". - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2012 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#ifndef __FIFO__ -#define __FIFO__ - -#ifdef __cplusplus -extern "C" { -#endif - -struct FIFO; - -struct FIFO *fifo_create(int nshort); -void fifo_destroy(struct FIFO *fifo); -int fifo_write(struct FIFO *fifo, short data[], int n); -int fifo_read(struct FIFO *fifo, short data[], int n); -int fifo_used(struct FIFO *fifo); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/codec2/src/codec2_internal.h b/codec2/src/codec2_internal.h deleted file mode 100644 index aaaf0baa..00000000 --- a/codec2/src/codec2_internal.h +++ /dev/null @@ -1,63 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: codec2_internal.h - AUTHOR......: David Rowe - DATE CREATED: April 16 2012 - - Header file for Codec2 internal states, exposed via this header - file to assist in testing. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2012 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#ifndef __CODEC2_INTERNAL__ -#define __CODEC2_INTERNAL__ - -struct CODEC2 { - int mode; - kiss_fft_cfg fft_fwd_cfg; /* forward FFT config */ - float w[M]; /* time domain hamming window */ - COMP W[FFT_ENC]; /* DFT of w[] */ - float Pn[2*N]; /* trapezoidal synthesis window */ - float Sn[M]; /* input speech */ - float hpf_states[2]; /* high pass filter states */ - void *nlp; /* pitch predictor states */ - int gray; /* non-zero for gray encoding */ - - kiss_fft_cfg fft_inv_cfg; /* inverse FFT config */ - float Sn_[2*N]; /* synthesised output speech */ - float ex_phase; /* excitation model phase track */ - float bg_est; /* background noise estimate for post filter */ - float prev_Wo_enc; /* previous frame's pitch estimate */ - MODEL prev_model_dec; /* previous frame's model parameters */ - float prev_lsps_dec[LPC_ORD]; /* previous frame's LSPs */ - float prev_e_dec; /* previous frame's LPC energy */ - - int lpc_pf; /* LPC post filter on */ - int bass_boost; /* LPC post filter bass boost */ - float beta; /* LPC post filter parameters */ - float gamma; - - float xq_enc[2]; /* joint pitch and energy VQ states */ - float xq_dec[2]; - - int smoothing; /* enable smoothing for channels with errors */ -}; - -#endif diff --git a/codec2/src/comp.h b/codec2/src/comp.h deleted file mode 100644 index cedcab37..00000000 --- a/codec2/src/comp.h +++ /dev/null @@ -1,38 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: comp.h - AUTHOR......: David Rowe - DATE CREATED: 24/08/09 - - Complex number definition. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2009 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#ifndef __COMP__ -#define __COMP__ - -/* Complex number */ - -typedef struct { - float real; - float imag; -} COMP; - -#endif diff --git a/codec2/src/defines.h b/codec2/src/defines.h deleted file mode 100644 index 4870770c..00000000 --- a/codec2/src/defines.h +++ /dev/null @@ -1,94 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: defines.h - AUTHOR......: David Rowe - DATE CREATED: 23/4/93 - - Defines and structures used throughout the codec. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2009 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#ifndef __DEFINES__ -#define __DEFINES__ - -/*---------------------------------------------------------------------------*\ - - DEFINES - -\*---------------------------------------------------------------------------*/ - -/* General defines */ - -#define N 80 /* number of samples per frame */ -#define MAX_AMP 80 /* maximum number of harmonics */ -#define PI 3.141592654 /* mathematical constant */ -#define TWO_PI 6.283185307 /* mathematical constant */ -#define FS 8000 /* sample rate in Hz */ -#define MAX_STR 256 /* maximum string size */ - -#define NW 279 /* analysis window size */ -#define FFT_ENC 512 /* size of FFT used for encoder */ -#define FFT_DEC 512 /* size of FFT used in decoder */ -#define TW 40 /* Trapezoidal synthesis window overlap */ -#define V_THRESH 6.0 /* voicing threshold in dB */ -#define LPC_MAX 20 /* maximum LPC order */ -#define LPC_ORD 10 /* phase modelling LPC order */ - -/* Pitch estimation defines */ - -#define M 320 /* pitch analysis frame size */ -#define P_MIN 20 /* minimum pitch */ -#define P_MAX 160 /* maximum pitch */ - -/*---------------------------------------------------------------------------*\ - - TYPEDEFS - -\*---------------------------------------------------------------------------*/ - -/* Structure to hold model parameters for one frame */ - -typedef struct { - float Wo; /* fundamental frequency estimate in radians */ - int L; /* number of harmonics */ - float A[MAX_AMP+1]; /* amplitiude of each harmonic */ - float phi[MAX_AMP+1]; /* phase of each harmonic */ - int voiced; /* non-zero if this frame is voiced */ -} MODEL; - -/* describes each codebook */ - -struct lsp_codebook { - int k; /* dimension of vector */ - int log2m; /* number of bits in m */ - int m; /* elements in codebook */ - const float * cb; /* The elements */ -}; - -extern const struct lsp_codebook lsp_cb[]; -extern const struct lsp_codebook lsp_cbd[]; -extern const struct lsp_codebook lsp_cbvq[]; -extern const struct lsp_codebook lsp_cbjnd[]; -extern const struct lsp_codebook lsp_cbdt[]; -extern const struct lsp_codebook lsp_cbjvm[]; -extern const struct lsp_codebook lsp_cbvqanssi[]; -extern const struct lsp_codebook ge_cb[]; - -#endif diff --git a/codec2/src/dump.c b/codec2/src/dump.c deleted file mode 100644 index 00ce8062..00000000 --- a/codec2/src/dump.c +++ /dev/null @@ -1,629 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: dump.c - AUTHOR......: David Rowe - DATE CREATED: 25/8/09 - - Routines to dump data to text files for Octave analysis. - -\*---------------------------------------------------------------------------*/ - -/* - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include "defines.h" -#include "comp.h" -#include "dump.h" -#include -#include -#include -#include -#include - -#ifdef __EMBEDDED__ -#include "gdb_stdio.h" -#define fprintf gdb_stdio_fprintf -#define fopen gdb_stdio_fopen -#define fclose gdb_stdio_fclose -#endif - -#ifdef DUMP -static int dumpon = 0; - -static FILE *fsn = NULL; -static FILE *fsw = NULL; -static FILE *few = NULL; -static FILE *fsw_ = NULL; -static FILE *fmodel = NULL; -static FILE *fqmodel = NULL; -static FILE *fpwb = NULL; -static FILE *fpw = NULL; -static FILE *frw = NULL; -static FILE *flsp = NULL; -static FILE *fweights = NULL; -static FILE *flsp_ = NULL; -static FILE *fmel = NULL; -static FILE *fphase = NULL; -static FILE *fphase_ = NULL; -static FILE *ffw = NULL; -static FILE *fe = NULL; -static FILE *fsq = NULL; -static FILE *fdec = NULL; -static FILE *fsnr = NULL; -static FILE *flpcsnr = NULL; -static FILE *fak = NULL; -static FILE *fak_ = NULL; -static FILE *fbg = NULL; -static FILE *fE = NULL; -static FILE *frk = NULL; -static FILE *fhephase = NULL; - -static char prefix[MAX_STR]; - -void dump_on(char p[]) { - dumpon = 1; - strcpy(prefix, p); -} - -void dump_off(){ - if (fsn != NULL) - fclose(fsn); - if (fsw != NULL) - fclose(fsw); - if (fsw_ != NULL) - fclose(fsw_); - if (few != NULL) - fclose(few); - if (fmodel != NULL) - fclose(fmodel); - if (fqmodel != NULL) - fclose(fqmodel); - if (fpwb != NULL) - fclose(fpwb); - if (fpw != NULL) - fclose(fpw); - if (frw != NULL) - fclose(frw); - if (flsp != NULL) - fclose(flsp); - if (fweights != NULL) - fclose(fweights); - if (flsp_ != NULL) - fclose(flsp_); - if (fmel != NULL) - fclose(fmel); - if (fphase != NULL) - fclose(fphase); - if (fphase_ != NULL) - fclose(fphase_); - if (ffw != NULL) - fclose(ffw); - if (fe != NULL) - fclose(fe); - if (fsq != NULL) - fclose(fsq); - if (fdec != NULL) - fclose(fdec); - if (fsnr != NULL) - fclose(fsnr); - if (flpcsnr != NULL) - fclose(flpcsnr); - if (fak != NULL) - fclose(fak); - if (fak_ != NULL) - fclose(fak_); - if (fbg != NULL) - fclose(fbg); - if (fE != NULL) - fclose(fE); - if (frk != NULL) - fclose(frk); - if (fhephase != NULL) - fclose(fhephase); -} - -void dump_Sn(float Sn[]) { - int i; - char s[MAX_STR]; - - if (!dumpon) return; - - if (fsn == NULL) { - sprintf(s,"%s_sn.txt", prefix); - fsn = fopen(s, "wt"); - assert(fsn != NULL); - } - - /* split across two lines to avoid max line length problems */ - /* reconstruct in Octave */ - - for(i=0; iWo, model->L); - for(l=1; l<=model->L; l++) { - sprintf(s,"%12f ",model->A[l]); - strcat(line, s); - } - for(l=model->L+1; l<=MAX_AMP; l++) { - sprintf(s,"%12f ", 0.0); - strcat(line,s); - } - - sprintf(s,"%d\n",model->voiced); - strcat(line,s); - fprintf(fmodel,"%s",line); -} - -void dump_quantised_model(MODEL *model) { - int l; - char s[MAX_STR]; - char line[2048]; - - if (!dumpon) return; - - if (fqmodel == NULL) { - sprintf(s,"%s_qmodel.txt", prefix); - fqmodel = fopen(s, "wt"); - assert(fqmodel != NULL); - } - - sprintf(line,"%12f %12d ", model->Wo, model->L); - for(l=1; l<=model->L; l++) { - sprintf(s,"%12f ",model->A[l]); - strcat(line, s); - } - for(l=model->L+1; l<=MAX_AMP; l++) { - sprintf(s,"%12f ", 0.0); - strcat(line, s); - } - - sprintf(s,"%d\n",model->voiced); - strcat(line, s); - fprintf(fqmodel, "%s", line); -} - -void dump_phase(float phase[], int L) { - int l; - char s[MAX_STR]; - - if (!dumpon) return; - - if (fphase == NULL) { - sprintf(s,"%s_phase.txt", prefix); - fphase = fopen(s, "wt"); - assert(fphase != NULL); - } - - for(l=1; l<=L; l++) - fprintf(fphase,"%f\t",phase[l]); - for(l=L+1; l<=MAX_AMP; l++) - fprintf(fphase,"%f\t",0.0); - fprintf(fphase,"\n"); -} - -void dump_phase_(float phase_[], int L) { - int l; - char s[MAX_STR]; - - if (!dumpon) return; - - if (fphase_ == NULL) { - sprintf(s,"%s_phase_.txt", prefix); - fphase_ = fopen(s, "wt"); - assert(fphase_ != NULL); - } - - for(l=1; l<=L; l++) - fprintf(fphase_,"%f\t",phase_[l]); - for(l=L+1; l. -*/ - -#ifndef __DUMP__ -#define __DUMP__ - -#include "defines.h" -#include "comp.h" -#include "kiss_fft.h" -#include "codec2_internal.h" - -void dump_on(char filename_prefix[]); -void dump_off(); - -void dump_Sn(float Sn[]); -void dump_Sw(COMP Sw[]); -void dump_Sw_(COMP Sw_[]); -void dump_Ew(COMP Ew[]); - -/* amplitude modelling */ - -void dump_model(MODEL *m); -void dump_quantised_model(MODEL *m); -void dump_Pwn(COMP Pw[]); -void dump_Pw(COMP Pw[]); -void dump_Rw(float Rw[]); -void dump_lsp(float lsp[]); -void dump_weights(float w[], int ndim); -void dump_lsp_(float lsp_[]); -void dump_mel(int mel[]); -void dump_ak(float ak[], int order); -void dump_ak_(float ak[], int order); -void dump_E(float E); -void dump_lpc_snr(float snr); - -/* phase modelling */ - -void dump_snr(float snr); -void dump_phase(float phase[], int L); -void dump_phase_(float phase[], int L); -void dump_hephase(int ind[], int dim); - -/* NLP states */ - -void dump_sq(float sq[]); -void dump_dec(COMP Fw[]); -void dump_Fw(COMP Fw[]); -void dump_e(float e_hz[]); -void dump_Rk(float Rk[]); - -/* post filter */ - -void dump_bg(float e, float bg_est, float percent_uv); -void dump_Pwb(COMP Pwb[]); - -#endif diff --git a/codec2/src/fdmdv.c b/codec2/src/fdmdv.c deleted file mode 100644 index 6c664f79..00000000 --- a/codec2/src/fdmdv.c +++ /dev/null @@ -1,1574 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: fdmdv.c - AUTHOR......: David Rowe - DATE CREATED: April 14 2012 - - Functions that implement the FDMDV modem. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2012 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -/*---------------------------------------------------------------------------*\ - - INCLUDES - -\*---------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include - -#include "fdmdv_internal.h" -#include "codec2_fdmdv.h" -#include "rn.h" -#include "test_bits.h" -#include "pilot_coeff.h" -#include "kiss_fft.h" -#include "hanning.h" -#include "os.h" - -static int sync_uw[] = {1,-1,1,-1,1,-1}; - -/*---------------------------------------------------------------------------* \ - - FUNCTIONS - -\*---------------------------------------------------------------------------*/ - -static COMP cneg(COMP a) -{ - COMP res; - - res.real = -a.real; - res.imag = -a.imag; - - return res; -} - -static COMP cconj(COMP a) -{ - COMP res; - - res.real = a.real; - res.imag = -a.imag; - - return res; -} - -static COMP cmult(COMP a, COMP b) -{ - COMP res; - - res.real = a.real*b.real - a.imag*b.imag; - res.imag = a.real*b.imag + a.imag*b.real; - - return res; -} - -static COMP fcmult(float a, COMP b) -{ - COMP res; - - res.real = a*b.real; - res.imag = a*b.imag; - - return res; -} - -static COMP cadd(COMP a, COMP b) -{ - COMP res; - - res.real = a.real + b.real; - res.imag = a.imag + b.imag; - - return res; -} - -static float cabsolute(COMP a) -{ - return sqrt(pow(a.real, 2.0) + pow(a.imag, 2.0)); -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: fdmdv_create - AUTHOR......: David Rowe - DATE CREATED: 16/4/2012 - - Create and initialise an instance of the modem. Returns a pointer - to the modem states or NULL on failure. One set of states is - sufficient for a full duplex modem. - -\*---------------------------------------------------------------------------*/ - -struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(int Nc) -{ - struct FDMDV *f; - int c, i, k; - - assert(NC == FDMDV_NC_MAX); /* check public and private #defines match */ - assert(Nc <= NC); - assert(FDMDV_NOM_SAMPLES_PER_FRAME == M); - assert(FDMDV_MAX_SAMPLES_PER_FRAME == (M+M/P)); - - f = (struct FDMDV*)malloc(sizeof(struct FDMDV)); - if (f == NULL) - return NULL; - - f->Nc = Nc; - - f->ntest_bits = Nc*NB*4; - f->current_test_bit = 0; - f->rx_test_bits_mem = (int*)malloc(sizeof(int)*f->ntest_bits); - assert(f->rx_test_bits_mem != NULL); - for(i=0; intest_bits; i++) - f->rx_test_bits_mem[i] = 0; - assert((sizeof(test_bits)/sizeof(int)) >= f->ntest_bits); - - f->old_qpsk_mapping = 0; - - f->tx_pilot_bit = 0; - - for(c=0; cprev_tx_symbols[c].real = 1.0; - f->prev_tx_symbols[c].imag = 0.0; - f->prev_rx_symbols[c].real = 1.0; - f->prev_rx_symbols[c].imag = 0.0; - - for(k=0; ktx_filter_memory[c][k].real = 0.0; - f->tx_filter_memory[c][k].imag = 0.0; - } - - for(k=0; krx_filter_memory[c][k].real = 0.0; - f->rx_filter_memory[c][k].imag = 0.0; - } - - /* Spread initial FDM carrier phase out as far as possible. - This helped PAPR for a few dB. We don't need to adjust rx - phase as DQPSK takes care of that. */ - - f->phase_tx[c].real = cos(2.0*PI*c/(Nc+1)); - f->phase_tx[c].imag = sin(2.0*PI*c/(Nc+1)); - - f->phase_rx[c].real = 1.0; - f->phase_rx[c].imag = 0.0; - - for(k=0; krx_filter_mem_timing[c][k].real = 0.0; - f->rx_filter_mem_timing[c][k].imag = 0.0; - } - for(k=0; krx_baseband_mem_timing[c][k].real = 0.0; - f->rx_baseband_mem_timing[c][k].imag = 0.0; - } - } - - fdmdv_set_fsep(f, FSEP); - f->freq[Nc].real = cos(2.0*PI*FDMDV_FCENTRE/FS); - f->freq[Nc].imag = sin(2.0*PI*FDMDV_FCENTRE/FS); - - /* Generate DBPSK pilot Look Up Table (LUT) */ - - generate_pilot_lut(f->pilot_lut, &f->freq[Nc]); - - /* freq Offset estimation states */ - - f->fft_pilot_cfg = kiss_fft_alloc (MPILOTFFT, 0, NULL, NULL); - assert(f->fft_pilot_cfg != NULL); - - for(i=0; ipilot_baseband1[i].real = f->pilot_baseband2[i].real = 0.0; - f->pilot_baseband1[i].imag = f->pilot_baseband2[i].imag = 0.0; - } - f->pilot_lut_index = 0; - f->prev_pilot_lut_index = 3*M; - - for(i=0; ipilot_lpf1[i].real = f->pilot_lpf2[i].real = 0.0; - f->pilot_lpf1[i].imag = f->pilot_lpf2[i].imag = 0.0; - } - - f->foff = 0.0; - f->foff_phase_rect.real = 1.0; - f->foff_phase_rect.imag = 0.0; - - f->fest_state = 0; - f->sync = 0; - f->timer = 0; - for(i=0; isync_mem[i] = 0; - - for(c=0; csig_est[c] = 0.0; - f->noise_est[c] = 0.0; - } - - for(i=0; i<2*FDMDV_NSPEC; i++) - f->fft_buf[i] = 0.0; - f->fft_cfg = kiss_fft_alloc (2*FDMDV_NSPEC, 0, NULL, NULL); - assert(f->fft_cfg != NULL); - - - return f; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: fdmdv_destroy - AUTHOR......: David Rowe - DATE CREATED: 16/4/2012 - - Destroy an instance of the modem. - -\*---------------------------------------------------------------------------*/ - -void CODEC2_WIN32SUPPORT fdmdv_destroy(struct FDMDV *fdmdv) -{ - assert(fdmdv != NULL); - KISS_FFT_FREE(fdmdv->fft_pilot_cfg); - KISS_FFT_FREE(fdmdv->fft_cfg); - free(fdmdv->rx_test_bits_mem); - free(fdmdv); -} - - -void CODEC2_WIN32SUPPORT fdmdv_use_old_qpsk_mapping(struct FDMDV *fdmdv) { - fdmdv->old_qpsk_mapping = 1; -} - - -int CODEC2_WIN32SUPPORT fdmdv_bits_per_frame(struct FDMDV *fdmdv) -{ - return (fdmdv->Nc * NB); -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: fdmdv_get_test_bits() - AUTHOR......: David Rowe - DATE CREATED: 16/4/2012 - - Generate a frame of bits from a repeating sequence of random data. OK so - it's not very random if it repeats but it makes syncing at the demod easier - for test purposes. - -\*---------------------------------------------------------------------------*/ - -void CODEC2_WIN32SUPPORT fdmdv_get_test_bits(struct FDMDV *f, int tx_bits[]) -{ - int i; - int bits_per_frame = fdmdv_bits_per_frame(f); - - for(i=0; icurrent_test_bit]; - f->current_test_bit++; - if (f->current_test_bit > (f->ntest_bits-1)) - f->current_test_bit = 0; - } - } - -float CODEC2_WIN32SUPPORT fdmdv_get_fsep(struct FDMDV *f) -{ - return f->fsep; -} - -void CODEC2_WIN32SUPPORT fdmdv_set_fsep(struct FDMDV *f, float fsep) { - int c; - float carrier_freq; - - f->fsep = fsep; - /* Set up frequency of each carrier */ - - for(c=0; cNc/2; c++) { - carrier_freq = (-f->Nc/2 + c)*f->fsep + FDMDV_FCENTRE; - f->freq[c].real = cos(2.0*PI*carrier_freq/FS); - f->freq[c].imag = sin(2.0*PI*carrier_freq/FS); - } - - for(c=f->Nc/2; cNc; c++) { - carrier_freq = (-f->Nc/2 + c + 1)*f->fsep + FDMDV_FCENTRE; - f->freq[c].real = cos(2.0*PI*carrier_freq/FS); - f->freq[c].imag = sin(2.0*PI*carrier_freq/FS); - } -} - - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: bits_to_dqpsk_symbols() - AUTHOR......: David Rowe - DATE CREATED: 16/4/2012 - - Maps bits to parallel DQPSK symbols. Generate Nc+1 QPSK symbols from - vector of (1,Nc*Nb) input tx_bits. The Nc+1 symbol is the +1 -1 +1 - .... BPSK sync carrier. - -\*---------------------------------------------------------------------------*/ - -void bits_to_dqpsk_symbols(COMP tx_symbols[], int Nc, COMP prev_tx_symbols[], int tx_bits[], int *pilot_bit, int old_qpsk_mapping) -{ - int c, msb, lsb; - COMP j = {0.0,1.0}; - - /* Map tx_bits to to Nc DQPSK symbols. Note legacy support for - old (suboptimal) V0.91 FreeDV mapping */ - - for(c=0; cNc, fdmdv->prev_tx_symbols, tx_bits, &fdmdv->tx_pilot_bit, fdmdv->old_qpsk_mapping); - memcpy(fdmdv->prev_tx_symbols, tx_symbols, sizeof(COMP)*(fdmdv->Nc+1)); - tx_filter(tx_baseband, fdmdv->Nc, tx_symbols, fdmdv->tx_filter_memory); - fdm_upconvert(tx_fdm, fdmdv->Nc, tx_baseband, fdmdv->phase_tx, fdmdv->freq); - - *sync_bit = fdmdv->tx_pilot_bit; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: generate_pilot_fdm() - AUTHOR......: David Rowe - DATE CREATED: 19/4/2012 - - Generate M samples of DBPSK pilot signal for Freq offset estimation. - -\*---------------------------------------------------------------------------*/ - -void generate_pilot_fdm(COMP *pilot_fdm, int *bit, float *symbol, - float *filter_mem, COMP *phase, COMP *freq) -{ - int i,j,k; - float tx_baseband[M]; - - /* +1 -1 +1 -1 DBPSK sync carrier, once filtered becomes (roughly) - two spectral lines at +/- RS/2 */ - - if (*bit) - *symbol = -*symbol; - else - *symbol = *symbol; - if (*bit) - *bit = 0; - else - *bit = 1; - - /* filter DPSK symbol to create M baseband samples */ - - filter_mem[NFILTER-1] = (sqrt(2)/2) * *symbol; - for(i=0; ireal; - pilot_fdm[i].imag = sqrt(2)*2*tx_baseband[i] * phase->imag; - } -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: generate_pilot_lut() - AUTHOR......: David Rowe - DATE CREATED: 19/4/2012 - - Generate a 4M sample vector of DBPSK pilot signal. As the pilot signal - is periodic in 4M samples we can then use this vector as a look up table - for pilot signal generation in the demod. - -\*---------------------------------------------------------------------------*/ - -void generate_pilot_lut(COMP pilot_lut[], COMP *pilot_freq) -{ - int pilot_rx_bit = 0; - float pilot_symbol = sqrt(2.0); - COMP pilot_phase = {1.0, 0.0}; - float pilot_filter_mem[NFILTER]; - COMP pilot[M]; - int i,f; - - for(i=0; i= 4) - memcpy(&pilot_lut[M*(f-4)], pilot, M*sizeof(COMP)); - } - -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: lpf_peak_pick() - AUTHOR......: David Rowe - DATE CREATED: 20/4/2012 - - LPF and peak pick part of freq est, put in a function as we call it twice. - -\*---------------------------------------------------------------------------*/ - -void lpf_peak_pick(float *foff, float *max, COMP pilot_baseband[], - COMP pilot_lpf[], kiss_fft_cfg fft_pilot_cfg, COMP S[], int nin) -{ - int i,j,k; - int mpilot; - COMP s[MPILOTFFT]; - float mag, imax; - int ix; - float r; - - /* LPF cutoff 200Hz, so we can handle max +/- 200 Hz freq offset */ - - for(i=0; i imax) { - imax = mag; - ix = i; - } - } - r = 2.0*200.0/MPILOTFFT; /* maps FFT bin to frequency in Hz */ - - if (ix >= MPILOTFFT/2) - *foff = (ix - MPILOTFFT)*r; - else - *foff = (ix)*r; - *max = imax; - -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: rx_est_freq_offset() - AUTHOR......: David Rowe - DATE CREATED: 19/4/2012 - - Estimate frequency offset of FDM signal using BPSK pilot. Note that - this algorithm is quite sensitive to pilot tone level wrt other - carriers, so test variations to the pilot amplitude carefully. - -\*---------------------------------------------------------------------------*/ - -float rx_est_freq_offset(struct FDMDV *f, COMP rx_fdm[], int nin) -{ - int i,j; - COMP pilot[M+M/P]; - COMP prev_pilot[M+M/P]; - float foff, foff1, foff2; - float max1, max2; - - assert(nin <= M+M/P); - - /* get pilot samples used for correlation/down conversion of rx signal */ - - for (i=0; ipilot_lut[f->pilot_lut_index]; - f->pilot_lut_index++; - if (f->pilot_lut_index >= 4*M) - f->pilot_lut_index = 0; - - prev_pilot[i] = f->pilot_lut[f->prev_pilot_lut_index]; - f->prev_pilot_lut_index++; - if (f->prev_pilot_lut_index >= 4*M) - f->prev_pilot_lut_index = 0; - } - - /* - Down convert latest M samples of pilot by multiplying by ideal - BPSK pilot signal we have generated locally. The peak of the - resulting signal is sensitive to the time shift between the - received and local version of the pilot, so we do it twice at - different time shifts and choose the maximum. - */ - - for(i=0; ipilot_baseband1[i] = f->pilot_baseband1[i+nin]; - f->pilot_baseband2[i] = f->pilot_baseband2[i+nin]; - } - - for(i=0,j=NPILOTBASEBAND-nin; ipilot_baseband1[j] = cmult(rx_fdm[i], cconj(pilot[i])); - f->pilot_baseband2[j] = cmult(rx_fdm[i], cconj(prev_pilot[i])); - } - - lpf_peak_pick(&foff1, &max1, f->pilot_baseband1, f->pilot_lpf1, f->fft_pilot_cfg, f->S1, nin); - lpf_peak_pick(&foff2, &max2, f->pilot_baseband2, f->pilot_lpf2, f->fft_pilot_cfg, f->S2, nin); - - if (max1 > max2) - foff = foff1; - else - foff = foff2; - - return foff; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: fdmdv_freq_shift() - AUTHOR......: David Rowe - DATE CREATED: 26/4/2012 - - Frequency shift modem signal. The use of complex input and output allows - single sided frequency shifting (no images). - -\*---------------------------------------------------------------------------*/ - -void CODEC2_WIN32SUPPORT fdmdv_freq_shift(COMP rx_fdm_fcorr[], COMP rx_fdm[], float foff, - COMP *foff_phase_rect, int nin) -{ - COMP foff_rect; - float mag; - int i; - - foff_rect.real = cos(2.0*PI*foff/FS); - foff_rect.imag = sin(2.0*PI*foff/FS); - for(i=0; ireal /= mag; - foff_phase_rect->imag /= mag; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: fdm_downconvert() - AUTHOR......: David Rowe - DATE CREATED: 22/4/2012 - - Frequency shift each modem carrier down to Nc+1 baseband signals. - -\*---------------------------------------------------------------------------*/ - -void fdm_downconvert(COMP rx_baseband[NC+1][M+M/P], int Nc, COMP rx_fdm[], COMP phase_rx[], COMP freq[], int nin) -{ - int i,c; - float mag; - - /* maximum number of input samples to demod */ - - assert(nin <= (M+M/P)); - - /* Nc/2 tones below centre freq */ - - for (c=0; c M) - rx_timing -= M; - if (rx_timing < -M) - rx_timing += M; - - /* rx_filt_mem_timing contains M + Nfilter + M samples of the - baseband signal at rate M this enables us to resample the - filtered rx symbol with M sample precision once we have - rx_timing */ - - for(c=0; c= 0) && (d.imag >= 0)) { - msb = 0; lsb = 0; - } - if ((d.real < 0) && (d.imag >= 0)) { - msb = 0; lsb = 1; - } - if ((d.real < 0) && (d.imag < 0)) { - if (old_qpsk_mapping) { - msb = 1; lsb = 0; - } else { - msb = 1; lsb = 1; - } - } - if ((d.real >= 0) && (d.imag < 0)) { - if (old_qpsk_mapping) { - msb = 1; lsb = 1; - } else { - msb = 1; lsb = 0; - } - } - rx_bits[2*c] = msb; - rx_bits[2*c+1] = lsb; - } - - /* Extract DBPSK encoded Sync bit and fine freq offset estimate */ - - norm = 1.0/(cabsolute(prev_rx_symbols[Nc])+1E-6); - phase_difference[Nc] = cmult(rx_symbols[Nc], fcmult(norm, cconj(prev_rx_symbols[Nc]))); - if (phase_difference[Nc].real < 0) { - *sync_bit = 1; - ferr = phase_difference[Nc].imag; - } - else { - *sync_bit = 0; - ferr = -phase_difference[Nc].imag; - } - - /* pilot carrier gets an extra pi/4 rotation to make it consistent - with other carriers, as we need it for snr_update and scatter - diagram */ - - phase_difference[Nc] = cmult(phase_difference[Nc], pi_on_4); - - return ferr; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: snr_update() - AUTHOR......: David Rowe - DATE CREATED: 17 May 2012 - - Given phase differences update estimates of signal and noise levels. - -\*---------------------------------------------------------------------------*/ - -void snr_update(float sig_est[], float noise_est[], int Nc, COMP phase_difference[]) -{ - float s[NC+1]; - COMP refl_symbols[NC+1]; - float n[NC+1]; - COMP pi_on_4; - int c; - - pi_on_4.real = cos(PI/4.0); - pi_on_4.imag = sin(PI/4.0); - - /* mag of each symbol is distance from origin, this gives us a - vector of mags, one for each carrier. */ - - for(c=0; cntest_bits; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: fdmdv_put_test_bits() - AUTHOR......: David Rowe - DATE CREATED: 24/4/2012 - - Accepts nbits from rx and attempts to sync with test_bits sequence. - If sync OK measures bit errors. - -\*---------------------------------------------------------------------------*/ - -void CODEC2_WIN32SUPPORT fdmdv_put_test_bits(struct FDMDV *f, int *sync, short error_pattern[], - int *bit_errors, int *ntest_bits, - int rx_bits[]) -{ - int i,j; - float ber; - int bits_per_frame = fdmdv_bits_per_frame(f); - - /* Append to our memory */ - - for(i=0,j=bits_per_frame; intest_bits-bits_per_frame; i++,j++) - f->rx_test_bits_mem[i] = f->rx_test_bits_mem[j]; - for(i=f->ntest_bits-bits_per_frame,j=0; intest_bits; i++,j++) - f->rx_test_bits_mem[i] = rx_bits[j]; - - /* see how many bit errors we get when checked against test sequence */ - - *bit_errors = 0; - for(i=0; intest_bits; i++) { - error_pattern[i] = test_bits[i] ^ f->rx_test_bits_mem[i]; - *bit_errors += error_pattern[i]; - //printf("%d %d %d %d\n", i, test_bits[i], f->rx_test_bits_mem[i], test_bits[i] ^ f->rx_test_bits_mem[i]); - } - - /* if less than a thresh we are aligned and in sync with test sequence */ - - ber = (float)*bit_errors/f->ntest_bits; - - *sync = 0; - if (ber < 0.2) - *sync = 1; - - *ntest_bits = f->ntest_bits; - -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: freq_state(() - AUTHOR......: David Rowe - DATE CREATED: 24/4/2012 - - Freq offset state machine. Moves between coarse and fine states - based on BPSK pilot sequence. Freq offset estimator occasionally - makes mistakes when used continuously. So we use it until we have - acquired the BPSK pilot, then switch to a more robust "fine" - tracking algorithm. If we lose sync we switch back to coarse mode - for fast re-acquisition of large frequency offsets. - - The sync state is also useful for higher layers to determine when - there is valid FDMDV data for decoding. We want to reliably and - quickly get into sync, stay in sync even on fading channels, and - fall out of sync quickly if tx stops or it's a false sync. - - In multipath fading channels the BPSK sync carrier may be pushed - down in the noise, despite other carriers being at full strength. - We want to avoid loss of sync in these cases. - -\*---------------------------------------------------------------------------*/ - -int freq_state(int *reliable_sync_bit, int sync_bit, int *state, int *timer, int *sync_mem) -{ - int next_state, sync, unique_word, i, corr; - - /* look for 6 symbols (120ms) 101010 of sync sequence */ - - unique_word = 0; - for(i=0; isync == 0) - fdmdv->foff = foff_coarse; - fdmdv_freq_shift(rx_fdm_fcorr, rx_fdm, -fdmdv->foff, &fdmdv->foff_phase_rect, *nin); - - /* baseband processing */ - - fdm_downconvert(rx_baseband, fdmdv->Nc, rx_fdm_fcorr, fdmdv->phase_rx, fdmdv->freq, *nin); - rx_filter(rx_filt, fdmdv->Nc, rx_baseband, fdmdv->rx_filter_memory, *nin); - fdmdv->rx_timing = rx_est_timing(rx_symbols, fdmdv->Nc, rx_filt, rx_baseband, fdmdv->rx_filter_mem_timing, env, fdmdv->rx_baseband_mem_timing, *nin); - - /* Adjust number of input samples to keep timing within bounds */ - - *nin = M; - - if (fdmdv->rx_timing > 2*M/P) - *nin += M/P; - - if (fdmdv->rx_timing < 0) - *nin -= M/P; - - foff_fine = qpsk_to_bits(rx_bits, &sync_bit, fdmdv->Nc, fdmdv->phase_difference, fdmdv->prev_rx_symbols, rx_symbols, - fdmdv->old_qpsk_mapping); - memcpy(fdmdv->prev_rx_symbols, rx_symbols, sizeof(COMP)*(fdmdv->Nc+1)); - snr_update(fdmdv->sig_est, fdmdv->noise_est, fdmdv->Nc, fdmdv->phase_difference); - - /* freq offset estimation state machine */ - - fdmdv->sync = freq_state(reliable_sync_bit, sync_bit, &fdmdv->fest_state, &fdmdv->timer, fdmdv->sync_mem); - fdmdv->foff -= TRACK_COEFF*foff_fine; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: calc_snr() - AUTHOR......: David Rowe - DATE CREATED: 17 May 2012 - - Calculate current SNR estimate (3000Hz noise BW) - -\*---------------------------------------------------------------------------*/ - -float calc_snr(int Nc, float sig_est[], float noise_est[]) -{ - float S, SdB; - float mean, N50, N50dB, N3000dB; - float snr_dB; - int c; - - S = 0.0; - for(c=0; cNc = fdmdv->Nc; - fdmdv_stats->snr_est = calc_snr(fdmdv->Nc, fdmdv->sig_est, fdmdv->noise_est); - fdmdv_stats->sync = fdmdv->sync; - fdmdv_stats->foff = fdmdv->foff; - fdmdv_stats->rx_timing = fdmdv->rx_timing; - fdmdv_stats->clock_offset = 0.0; /* TODO - implement clock offset estimation */ - - for(c=0; cNc+1; c++) { - fdmdv_stats->rx_symbols[c] = fdmdv->phase_difference[c]; - } -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: fdmdv_8_to_48() - AUTHOR......: David Rowe - DATE CREATED: 9 May 2012 - - Changes the sample rate of a signal from 8 to 48 kHz. Experience - with PC based modems has shown that PC sound cards have a more - accurate sample clock when set for 48 kHz than 8 kHz. - - n is the number of samples at the 8 kHz rate, there are FDMDV_OS*n samples - at the 48 kHz rate. A memory of FDMDV_OS_TAPS/FDMDV_OS samples is reqd for - in8k[] (see t48_8.c unit test as example). - - This is a classic polyphase upsampler. We take the 8 kHz samples - and insert (FDMDV_OS-1) zeroes between each sample, then - FDMDV_OS_TAPS FIR low pass filter the signal at 4kHz. As most of - the input samples are zeroes, we only need to multiply non-zero - input samples by filter coefficients. The zero insertion and - filtering are combined in the code below and I'm too lazy to explain - it further right now.... - -\*---------------------------------------------------------------------------*/ - -void CODEC2_WIN32SUPPORT fdmdv_8_to_48(float out48k[], float in8k[], int n) -{ - int i,j,k,l; - - /* make sure n is an integer multiple of the oversampling rate, ow - this function breaks */ - - assert((n % FDMDV_OS) == 0); - - for(i=0; ifft_buf[i] = f->fft_buf[i+nin]; - for(j=0; jfft_buf[i] = rx_fdm[j].real; - assert(i == 2*FDMDV_NSPEC); - - /* window and FFT */ - - for(i=0; i<2*FDMDV_NSPEC; i++) { - fft_in[i].real = f->fft_buf[i] * (0.5 - 0.5*cos((float)i*2.0*PI/(2*FDMDV_NSPEC))); - fft_in[i].imag = 0.0; - } - - kiss_fft(f->fft_cfg, (kiss_fft_cpx *)fft_in, (kiss_fft_cpx *)fft_out); - - /* FFT scales up a signal of level 1 FDMDV_NSPEC */ - - full_scale_dB = 20*log10(FDMDV_NSPEC); - - /* scale and convert to dB */ - - for(i=0; iNc; i++) - fprintf(stderr," %1.3f", cabsolute(f->phase_tx[i])); - fprintf(stderr,"\nfreq[]:\n"); - for(i=0; i<=f->Nc; i++) - fprintf(stderr," %1.3f", cabsolute(f->freq[i])); - fprintf(stderr,"\nfoff_phase_rect: %1.3f", cabsolute(f->foff_phase_rect)); - fprintf(stderr,"\nphase_rx[]:\n"); - for(i=0; i<=f->Nc; i++) - fprintf(stderr," %1.3f", cabsolute(f->phase_rx[i])); - fprintf(stderr, "\n\n"); -} diff --git a/codec2/src/fdmdv_demod.c b/codec2/src/fdmdv_demod.c deleted file mode 100644 index a64e5109..00000000 --- a/codec2/src/fdmdv_demod.c +++ /dev/null @@ -1,253 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: fdmdv_demod.c - AUTHOR......: David Rowe - DATE CREATED: April 30 2012 - - Given an input raw file (8kHz, 16 bit shorts) of FDMDV modem samples - outputs a file of bits. The output file is assumed to be arranged - as codec frames of 56 bits (7 bytes) which are received as two 28 - bit modem frames. - - Demod states can be optionally logged to an Octave file for display - using the Octave script fdmdv_demod_c.m. This is useful for - checking demod performance. - -\*---------------------------------------------------------------------------*/ - - -/* - Copyright (C) 2012 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include -#include -#include - -#include "codec2_fdmdv.h" -#include "octave.h" - -/* lof of information we want to dump to Octave */ - -#define MAX_FRAMES 50*60 /* 1 minute at 50 symbols/s */ - -int main(int argc, char *argv[]) -{ - FILE *fin, *fout; - struct FDMDV *fdmdv; - char *packed_bits; - int *rx_bits; - int *codec_bits; - COMP rx_fdm[FDMDV_MAX_SAMPLES_PER_FRAME]; - short rx_fdm_scaled[FDMDV_MAX_SAMPLES_PER_FRAME]; - int i, bit, byte, c; - int nin, nin_prev; - int sync_bit = 0, reliable_sync_bit; - int sync = 0; - int f; - FILE *foct = NULL; - struct FDMDV_STATS stats; - COMP *rx_fdm_log; - int rx_fdm_log_col_index; - COMP *rx_symbols_log; - int sync_log[MAX_FRAMES]; - float rx_timing_log[MAX_FRAMES]; - float foff_log[MAX_FRAMES]; - int sync_bit_log[MAX_FRAMES]; - int rx_bits_log[FDMDV_BITS_PER_FRAME*MAX_FRAMES]; - float snr_est_log[MAX_FRAMES]; - float *rx_spec_log; - int max_frames_reached; - int bits_per_fdmdv_frame; - int bits_per_codec_frame; - int bytes_per_codec_frame; - int Nc; - - if (argc < 3) { - printf("usage: %s InputModemRawFile OutputBitFile [Nc] [OctaveDumpFile]\n", argv[0]); - printf("e.g %s hts1a_fdmdv.raw hts1a.c2\n", argv[0]); - exit(1); - } - - if (strcmp(argv[1], "-") == 0) fin = stdin; - else if ( (fin = fopen(argv[1],"rb")) == NULL ) { - fprintf(stderr, "Error opening input modem sample file: %s: %s.\n", - argv[1], strerror(errno)); - exit(1); - } - - if (strcmp(argv[2], "-") == 0) fout = stdout; - else if ( (fout = fopen(argv[2],"wb")) == NULL ) { - fprintf(stderr, "Error opening output bit file: %s: %s.\n", - argv[2], strerror(errno)); - exit(1); - } - - if (argc >= 4) { - Nc = atoi(argv[3]); - if ((Nc % 2) != 0) { - fprintf(stderr, "Error number of carriers must be a multiple of 2\n"); - exit(1); - } - if ((Nc < 2) || (Nc > FDMDV_NC_MAX) ) { - fprintf(stderr, "Error number of carriers must be btween 2 and %d\n", FDMDV_NC_MAX); - exit(1); - } - } - else - Nc = FDMDV_NC; - - fdmdv = fdmdv_create(Nc); - - bits_per_fdmdv_frame = fdmdv_bits_per_frame(fdmdv); - bits_per_codec_frame = 2*fdmdv_bits_per_frame(fdmdv); - assert((bits_per_codec_frame % 8) == 0); /* make sure integer number of bytes per frame */ - bytes_per_codec_frame = bits_per_codec_frame/8; - - /* malloc some buffers that are dependant on Nc */ - - packed_bits = (char*)malloc(bytes_per_codec_frame); assert(packed_bits != NULL); - rx_bits = (int*)malloc(sizeof(int)*bits_per_codec_frame); assert(rx_bits != NULL); - codec_bits = (int*)malloc(2*sizeof(int)*bits_per_fdmdv_frame); assert(codec_bits != NULL); - - /* malloc some of the larger variables to prevent out of stack problems */ - - rx_fdm_log = (COMP*)malloc(sizeof(COMP)*FDMDV_MAX_SAMPLES_PER_FRAME*MAX_FRAMES); - assert(rx_fdm_log != NULL); - rx_spec_log = (float*)malloc(sizeof(float)*FDMDV_NSPEC*MAX_FRAMES); - assert(rx_spec_log != NULL); - rx_symbols_log = (COMP*)malloc(sizeof(COMP)*(Nc+1)*MAX_FRAMES); - assert(rx_fdm_log != NULL); - - f = 0; - nin = FDMDV_NOM_SAMPLES_PER_FRAME; - rx_fdm_log_col_index = 0; - max_frames_reached = 0; - - while(fread(rx_fdm_scaled, sizeof(short), nin, fin) == nin) - { - for(i=0; i. -*/ - -#include -#include -#include -#include -#include -#include - -#include "codec2_fdmdv.h" - -int main(int argc, char *argv[]) -{ - FILE *fout; - struct FDMDV *fdmdv; - char *packed_bits; - int *tx_bits; - int n, i, bit, byte; - int numBits, nCodecFrames; - int bits_per_fdmdv_frame; - int bits_per_codec_frame; - int bytes_per_codec_frame; - int Nc; - - if (argc < 3) { - printf("usage: %s OutputBitFile numBits [Nc]\n", argv[0]); - printf("e.g %s test.c2 1400\n", argv[0]); - exit(1); - } - - if (strcmp(argv[1], "-") == 0) fout = stdout; - else if ( (fout = fopen(argv[1],"wb")) == NULL ) { - fprintf(stderr, "Error opening output bit file: %s: %s.\n", - argv[1], strerror(errno)); - exit(1); - } - - numBits = atoi(argv[2]); - - if (argc == 4) { - Nc = atoi(argv[3]); - if ((Nc % 2) != 0) { - fprintf(stderr, "Error number of carriers must be a multiple of 2\n"); - exit(1); - } - if ((Nc < 2) || (Nc > FDMDV_NC_MAX) ) { - fprintf(stderr, "Error number of carriers must be btween 2 and %d\n", FDMDV_NC_MAX); - exit(1); - } - } - else - Nc = FDMDV_NC; - - fdmdv = fdmdv_create(Nc); - - bits_per_fdmdv_frame = fdmdv_bits_per_frame(fdmdv); - bits_per_codec_frame = 2*fdmdv_bits_per_frame(fdmdv); - assert((bits_per_codec_frame % 8) == 0); /* make sure integer number of bytes per frame */ - bytes_per_codec_frame = bits_per_codec_frame/8; - fprintf(stderr, "bits_per_fdmdv_frame: %d bits_per_codec_frame: %d bytes_per_codec_frame: %d\n", - bits_per_fdmdv_frame, bits_per_codec_frame, bytes_per_codec_frame); - - packed_bits = (char*)malloc(bytes_per_codec_frame); - assert(packed_bits != NULL); - tx_bits = (int*)malloc(sizeof(int)*bits_per_codec_frame); - assert(tx_bits != NULL); - - nCodecFrames = numBits/bits_per_codec_frame; - - for(n=0; n. -*/ - -#include -#include -#include -#include -#include -#include - -#include "codec2_fdmdv.h" - -#define MAX_INTERLEAVER 10000 - -int main(int argc, char *argv[]) -{ - FILE *fin, *fout, *finter; - int interleaver[MAX_INTERLEAVER]; - char *packed_bits; - int *bits; - int *interleaved_bits; - int i, bit, byte, m, mpacked, frames, interleave, src_bit, dest_bit; - - if (argc < 4) { - printf("usage: %s InputBitFile OutputBitFile InterleaverFile [de]\n", argv[0]); - printf("e.g %s hts1a.c2 hts1a_interleaved.c2 interleaver.txt\n", argv[0]); - exit(1); - } - - if (strcmp(argv[1], "-") == 0) fin = stdin; - else if ( (fin = fopen(argv[1],"rb")) == NULL ) { - fprintf(stderr, "Error opening input bit file: %s: %s.\n", - argv[1], strerror(errno)); - exit(1); - } - - if (strcmp(argv[2], "-") == 0) fout = stdout; - else if ( (fout = fopen(argv[2],"wb")) == NULL ) { - fprintf(stderr, "Error opening output bit file: %s: %s.\n", - argv[2], strerror(errno)); - exit(1); - } - - if ((finter = fopen(argv[3],"rt")) == NULL ) { - fprintf(stderr, "Error opening interleaver file: %s: %s.\n", - argv[3], strerror(errno)); - exit(1); - } - - if (argc == 5) - interleave = 1; - else - interleave = 0; - - /* load interleaver, size determines block size we will process */ - - src_bit = 0; - while(fscanf(finter, "%d\n", &dest_bit) == 1) { - if (interleave) - interleaver[dest_bit] = src_bit; - else - interleaver[src_bit] = dest_bit; - - src_bit++; - if (src_bit == MAX_INTERLEAVER) { - fprintf(stderr, "Error interleaver too big\n"); - exit(1); - } - } - fclose(finter); - - m = src_bit; - fprintf(stderr, "Interleaver size m = %d interleave = %d\n", m, interleave); - assert((m%8) == 0); - mpacked = m/8; - - packed_bits = (char*)malloc(mpacked*sizeof(char)); - assert(packed_bits != NULL); - bits = (int*)malloc(m*sizeof(int)); - assert(bits != NULL); - interleaved_bits = (int*)malloc(m*sizeof(int)); - assert(interleaved_bits != NULL); - - frames = 0; - - while(fread(packed_bits, sizeof(char), mpacked, fin) == mpacked) { - frames++; - - /* unpack bits, MSB first */ - - bit = 7; byte = 0; - for(i=0; i> bit) & 0x1; - bit--; - if (bit < 0) { - bit = 7; - byte++; - } - } - assert(byte == mpacked); - - /* (de) interleave */ - - for(i=0; i. -*/ - -#ifndef __FDMDV_INTERNAL__ -#define __FDMDV_INTERNAL__ - -#include "comp.h" -#include "codec2_fdmdv.h" -#include "kiss_fft.h" - -/*---------------------------------------------------------------------------*\ - - DEFINES - -\*---------------------------------------------------------------------------*/ - -#define PI 3.141592654 -#define FS 8000 /* sample rate in Hz */ -#define T (1.0/FS) /* sample period in seconds */ -#define RS 50 /* symbol rate in Hz */ -#define NC 20 /* max number of data carriers (plus one pilot in the centre) */ -#define NB 2 /* Bits/symbol for QPSK modulation */ -#define RB (NC*RS*NB) /* bit rate */ -#define M (FS/RS) /* oversampling factor */ -#define NSYM 6 /* number of symbols to filter over */ -#define NFILTER (NSYM*M) /* size of tx/rx filters at sample rate M */ - -#define FSEP 75 /* Default separation between carriers (Hz) */ - -#define NT 5 /* number of symbols we estimate timing over */ -#define P 4 /* oversample factor used for initial rx symbol filtering */ -#define NFILTERTIMING (M+NFILTER+M) /* filter memory used for resampling after timing estimation */ - -#define NPILOT_LUT (4*M) /* number of pilot look up table samples */ -#define NPILOTCOEFF 30 /* number of FIR filter coeffs in LP filter */ -#define NPILOTBASEBAND (NPILOTCOEFF+M+M/P) /* number of pilot baseband samples reqd for pilot LPF */ -#define NPILOTLPF (4*M) /* number of samples we DFT pilot over, pilot est window */ -#define MPILOTFFT 256 - -#define NSYNC_MEM 6 - -/* averaging filter coeffs */ - -#define TRACK_COEFF 0.5 -#define SNR_COEFF 0.9 /* SNR est averaging filter coeff */ - -/*---------------------------------------------------------------------------*\ - - STRUCT for States - -\*---------------------------------------------------------------------------*/ - -struct FDMDV { - - int Nc; - float fsep; - - /* test data (test frame) states */ - - int ntest_bits; - int current_test_bit; - int *rx_test_bits_mem; - - /* Modulator */ - - int old_qpsk_mapping; - int tx_pilot_bit; - COMP prev_tx_symbols[NC+1]; - COMP tx_filter_memory[NC+1][NSYM]; - COMP phase_tx[NC+1]; - COMP freq[NC+1]; - - /* Pilot generation at demodulator */ - - COMP pilot_lut[NPILOT_LUT]; - int pilot_lut_index; - int prev_pilot_lut_index; - - /* freq offset estimation states */ - - kiss_fft_cfg fft_pilot_cfg; - COMP pilot_baseband1[NPILOTBASEBAND]; - COMP pilot_baseband2[NPILOTBASEBAND]; - COMP pilot_lpf1[NPILOTLPF]; - COMP pilot_lpf2[NPILOTLPF]; - COMP S1[MPILOTFFT]; - COMP S2[MPILOTFFT]; - - /* freq offset correction states */ - - float foff; - COMP foff_phase_rect; - - /* Demodulator */ - - COMP phase_rx[NC+1]; - COMP rx_filter_memory[NC+1][NFILTER]; - COMP rx_filter_mem_timing[NC+1][NT*P]; - COMP rx_baseband_mem_timing[NC+1][NFILTERTIMING]; - float rx_timing; - COMP phase_difference[NC+1]; - COMP prev_rx_symbols[NC+1]; - - /* sync state machine */ - - int sync_mem[NSYNC_MEM]; - int fest_state; - int sync; - int timer; - - /* SNR estimation states */ - - float sig_est[NC+1]; - float noise_est[NC+1]; - - /* Buf for FFT/waterfall */ - - float fft_buf[2*FDMDV_NSPEC]; - kiss_fft_cfg fft_cfg; - }; - -/*---------------------------------------------------------------------------*\ - - FUNCTION PROTOTYPES - -\*---------------------------------------------------------------------------*/ - -void bits_to_dqpsk_symbols(COMP tx_symbols[], int Nc, COMP prev_tx_symbols[], int tx_bits[], int *pilot_bit, int old_qpsk_mapping); -void tx_filter(COMP tx_baseband[NC+1][M], int Nc, COMP tx_symbols[], COMP tx_filter_memory[NC+1][NSYM]); -void fdm_upconvert(COMP tx_fdm[], int Nc, COMP tx_baseband[NC+1][M], COMP phase_tx[], COMP freq_tx[]); -void generate_pilot_fdm(COMP *pilot_fdm, int *bit, float *symbol, float *filter_mem, COMP *phase, COMP *freq); -void generate_pilot_lut(COMP pilot_lut[], COMP *pilot_freq); -float rx_est_freq_offset(struct FDMDV *f, COMP rx_fdm[], int nin); -void lpf_peak_pick(float *foff, float *max, COMP pilot_baseband[], COMP pilot_lpf[], kiss_fft_cfg fft_pilot_cfg, COMP S[], int nin); -void fdm_downconvert(COMP rx_baseband[NC+1][M+M/P], int Nc, COMP rx_fdm[], COMP phase_rx[], COMP freq[], int nin); -void rx_filter(COMP rx_filt[NC+1][P+1], int Nc, COMP rx_baseband[NC+1][M+M/P], COMP rx_filter_memory[NC+1][NFILTER], int nin); -float rx_est_timing(COMP rx_symbols[], int Nc, - COMP rx_filt[NC+1][P+1], - COMP rx_baseband[NC+1][M+M/P], - COMP rx_filter_mem_timing[NC+1][NT*P], - float env[], - COMP rx_baseband_mem_timing[NC+1][NFILTERTIMING], - int nin); -float qpsk_to_bits(int rx_bits[], int *sync_bit, int Nc, COMP phase_difference[], COMP prev_rx_symbols[], COMP rx_symbols[], int old_qpsk_mapping); -void snr_update(float sig_est[], float noise_est[], int Nc, COMP phase_difference[]); -int freq_state(int *reliable_sync_bit, int sync_bit, int *state, int *timer, int *sync_mem); -float calc_snr(int Nc, float sig_est[], float noise_est[]); - -#endif diff --git a/codec2/src/fdmdv_mod.c b/codec2/src/fdmdv_mod.c deleted file mode 100644 index 22318db8..00000000 --- a/codec2/src/fdmdv_mod.c +++ /dev/null @@ -1,152 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: fdmdv_mod.c - AUTHOR......: David Rowe - DATE CREATED: April 28 2012 - - Given an input file of bits outputs a raw file (8kHz, 16 bit shorts) - of FDMDV modem samples ready to send over a HF radio channel. The - input file is assumed to be arranged as codec frames of 56 bits (7 - bytes) which we send as two 28 bit modem frames. - -\*---------------------------------------------------------------------------*/ - - -/* - Copyright (C) 2012 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include -#include -#include - -#include "codec2_fdmdv.h" - -int main(int argc, char *argv[]) -{ - FILE *fin, *fout; - struct FDMDV *fdmdv; - char *packed_bits; - int *tx_bits; - COMP tx_fdm[2*FDMDV_NOM_SAMPLES_PER_FRAME]; - short tx_fdm_scaled[2*FDMDV_NOM_SAMPLES_PER_FRAME]; - int frames; - int i, bit, byte; - int sync_bit; - int bits_per_fdmdv_frame; - int bits_per_codec_frame; - int bytes_per_codec_frame; - int Nc; - - if (argc < 3) { - printf("usage: %s InputBitFile OutputModemRawFile [Nc]\n", argv[0]); - printf("e.g %s hts1a.c2 hts1a_fdmdv.raw\n", argv[0]); - exit(1); - } - - if (strcmp(argv[1], "-") == 0) fin = stdin; - else if ( (fin = fopen(argv[1],"rb")) == NULL ) { - fprintf(stderr, "Error opening input bit file: %s: %s.\n", - argv[1], strerror(errno)); - exit(1); - } - - if (strcmp(argv[2], "-") == 0) fout = stdout; - else if ( (fout = fopen(argv[2],"wb")) == NULL ) { - fprintf(stderr, "Error opening output modem sample file: %s: %s.\n", - argv[2], strerror(errno)); - exit(1); - } - - if (argc == 4) { - Nc = atoi(argv[3]); - if ((Nc % 2) != 0) { - fprintf(stderr, "Error number of carriers must be a multiple of 2\n"); - exit(1); - } - if ((Nc < 2) || (Nc > FDMDV_NC_MAX) ) { - fprintf(stderr, "Error number of carriers must be btween 2 and %d\n", FDMDV_NC_MAX); - exit(1); - } - } - else - Nc = FDMDV_NC; - - fdmdv = fdmdv_create(Nc); - - bits_per_fdmdv_frame = fdmdv_bits_per_frame(fdmdv); - bits_per_codec_frame = 2*fdmdv_bits_per_frame(fdmdv); - assert((bits_per_codec_frame % 8) == 0); /* make sure integer number of bytes per frame */ - bytes_per_codec_frame = bits_per_codec_frame/8; - - packed_bits = (char*)malloc(bytes_per_codec_frame); - assert(packed_bits != NULL); - tx_bits = (int*)malloc(sizeof(int)*bits_per_codec_frame); - assert(tx_bits != NULL); - - frames = 0; - - while(fread(packed_bits, sizeof(char), bytes_per_codec_frame, fin) == bytes_per_codec_frame) { - frames++; - - /* unpack bits, MSB first */ - - bit = 7; byte = 0; - for(i=0; i> bit) & 0x1; - bit--; - if (bit < 0) { - bit = 7; - byte++; - } - } - assert(byte == bytes_per_codec_frame); - - /* modulate even and odd frames */ - - fdmdv_mod(fdmdv, tx_fdm, tx_bits, &sync_bit); - assert(sync_bit == 1); - - fdmdv_mod(fdmdv, &tx_fdm[FDMDV_NOM_SAMPLES_PER_FRAME], &tx_bits[bits_per_fdmdv_frame], &sync_bit); - assert(sync_bit == 0); - - /* scale and save to disk as shorts */ - - for(i=0; i<2*FDMDV_NOM_SAMPLES_PER_FRAME; i++) - tx_fdm_scaled[i] = FDMDV_SCALE * tx_fdm[i].real; - - fwrite(tx_fdm_scaled, sizeof(short), 2*FDMDV_NOM_SAMPLES_PER_FRAME, fout); - - /* if this is in a pipeline, we probably don't want the usual - buffering to occur */ - - if (fout == stdout) fflush(stdout); - if (fin == stdin) fflush(stdin); - } - - //fdmdv_dump_osc_mags(fdmdv); - - free(tx_bits); - free(packed_bits); - fclose(fin); - fclose(fout); - fdmdv_destroy(fdmdv); - - return 0; -} diff --git a/codec2/src/fdmdv_put_test_bits.c b/codec2/src/fdmdv_put_test_bits.c deleted file mode 100644 index c1e62f12..00000000 --- a/codec2/src/fdmdv_put_test_bits.c +++ /dev/null @@ -1,175 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: fdmdv_put_test_bits.c - AUTHOR......: David Rowe - DATE CREATED: 1 May 2012 - - Using a file of packed test bits as input, determines bit error - rate. Useful for testing fdmdv_demod. - -\*---------------------------------------------------------------------------*/ - - -/* - Copyright (C) 2012 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include -#include -#include - -#include "codec2_fdmdv.h" - -int main(int argc, char *argv[]) -{ - FILE *fin; - struct FDMDV *fdmdv; - char *packed_bits; - int *rx_bits; - int i, bit, byte; - int test_frame_sync, bit_errors, total_bit_errors, total_bits, ntest_bits; - int test_frame_sync_state, test_frame_count; - int bits_per_fdmdv_frame; - int bits_per_codec_frame; - int bytes_per_codec_frame; - int Nc; - short *error_pattern; - - if (argc < 2) { - printf("usage: %s InputBitFile [Nc]\n", argv[0]); - printf("e.g %s test.c2\n", argv[0]); - exit(1); - } - - if (strcmp(argv[1], "-") == 0) fin = stdin; - else if ( (fin = fopen(argv[1],"rb")) == NULL ) { - fprintf(stderr, "Error opening input bit file: %s: %s.\n", - argv[1], strerror(errno)); - exit(1); - } - - if (argc == 3) { - Nc = atoi(argv[2]); - if ((Nc % 2) != 0) { - fprintf(stderr, "Error number of carriers must be a multiple of 2\n"); - exit(1); - } - if ((Nc < 2) || (Nc > FDMDV_NC_MAX) ) { - fprintf(stderr, "Error number of carriers must be between 2 and %d\n", FDMDV_NC_MAX); - exit(1); - } - } - else - Nc = FDMDV_NC; - - fdmdv = fdmdv_create(Nc); - - bits_per_fdmdv_frame = fdmdv_bits_per_frame(fdmdv); - bits_per_codec_frame = 2*fdmdv_bits_per_frame(fdmdv); - assert((bits_per_codec_frame % 8) == 0); /* make sure integer number of bytes per frame */ - bytes_per_codec_frame = bits_per_codec_frame/8; - fprintf(stderr, "bits_per_fdmdv_frame: %d bits_per_codec_frame: %d bytes_per_codec_frame: %d\n", - bits_per_fdmdv_frame, bits_per_codec_frame, bytes_per_codec_frame); - - packed_bits = (char*)malloc(bytes_per_codec_frame); - assert(packed_bits != NULL); - rx_bits = (int*)malloc(sizeof(int)*bits_per_codec_frame); - assert(rx_bits != NULL); - - error_pattern = (short*)malloc(fdmdv_error_pattern_size(fdmdv)*sizeof(int)); - assert(error_pattern != NULL); - - total_bit_errors = 0; - total_bits = 0; - test_frame_sync_state = 0; - test_frame_count = 0; - - while(fread(packed_bits, sizeof(char), bytes_per_codec_frame, fin) == bytes_per_codec_frame) { - /* unpack bits, MSB first */ - - bit = 7; byte = 0; - for(i=0; i> bit) & 0x1; - //printf("%d 0x%x %d\n", i, packed_bits[byte], rx_bits[i]); - bit--; - if (bit < 0) { - bit = 7; - byte++; - } - } - assert(byte == bytes_per_codec_frame); - - fdmdv_put_test_bits(fdmdv, &test_frame_sync, error_pattern, &bit_errors, &ntest_bits, rx_bits); - - if (test_frame_sync == 1) { - test_frame_sync_state = 1; - test_frame_count = 0; - } - - if (test_frame_sync_state) { - if (test_frame_count == 0) { - total_bit_errors += bit_errors; - total_bits = total_bits + ntest_bits; - printf("+"); - } - else - printf("-"); - test_frame_count++; - if (test_frame_count == 4) - test_frame_count = 0; - } - else - printf("-"); - - fdmdv_put_test_bits(fdmdv, &test_frame_sync, error_pattern, &bit_errors, &ntest_bits, &rx_bits[bits_per_fdmdv_frame]); - - if (test_frame_sync == 1) { - test_frame_sync_state = 1; - test_frame_count = 0; - } - - if (test_frame_sync_state) { - if (test_frame_count == 0) { - total_bit_errors += bit_errors; - total_bits = total_bits + ntest_bits; - printf("+"); - } - else - printf("-"); - test_frame_count++; - if (test_frame_count == 4) - test_frame_count = 0; - } - else - printf("-"); - - /* if this is in a pipeline, we probably don't want the usual - buffering to occur */ - - if (fin == stdin) fflush(stdin); - } - - fclose(fin); - free(error_pattern); - fdmdv_destroy(fdmdv); - - printf("\nbits %d errors %d BER %1.4f\n", total_bits, total_bit_errors, (float)total_bit_errors/(1E-6+total_bits) ); - return 0; -} - diff --git a/codec2/src/fec_dec.c b/codec2/src/fec_dec.c deleted file mode 100644 index 350b0119..00000000 --- a/codec2/src/fec_dec.c +++ /dev/null @@ -1,307 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: fec_dec.c - AUTHOR......: David Rowe - DATE CREATED: 4 march 2013 - - FEC decoder for data from modem containing compressed Codec 2 data - and FEC. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2013 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include "codec2.h" -#include "codec2_fdmdv.h" -#include "golay23.h" - -#include -#include -#include -#include -#include - -#define MODE_1600 0 -#define MODE_1850 1 -#define MODE_2000 2 - -int main(int argc, char *argv[]) -{ - void *codec2, *fdmdv; - FILE *fin; - FILE *fout; - int bits_per_input_frame, bytes_per_input_frame; - unsigned char *packed_input_bits; - int *unpacked_input_bits; - int bits_per_output_frame, bytes_per_output_frame; - unsigned char *packed_output_bits; - int *unpacked_output_bits; - int codec2_mode, mode, Nc, bit, byte; - int i,j; - int recd_codeword, codeword1, codeword2; - - if (argc < 3) { - printf("%s InputFromModemWithFECFile OutputToCodec2File [2000|1600]\n", argv[0]); - exit(1); - } - - if (strcmp(argv[1], "-") == 0) fin = stdin; - else if ( (fin = fopen(argv[1],"rb")) == NULL ) { - fprintf(stderr, "Error opening input file from Demod: %s: %s.\n", - argv[2], strerror(errno)); - exit(1); - } - - if (strcmp(argv[2], "-") == 0) fout = stdout; - else if ( (fout = fopen(argv[2],"wb")) == NULL ) { - fprintf(stderr, "Error opening output file to Codec : %s: %s.\n", - argv[3], strerror(errno)); - exit(1); - } - - /* input parameters and buffers. Note data is split into two 20ms - frames for transmission over modem. */ - - if ((argc != 4) || (strcmp(argv[3],"2000") == 0)) { - /* 2000 bit/s with FEC */ - mode = MODE_2000; - codec2_mode = CODEC2_MODE_1400; - Nc = 20; - } else if ((strcmp(argv[3],"1850") == 0)) { - /* 1850 bit/s with FEC */ - mode = MODE_1850; - codec2_mode = CODEC2_MODE_1300; - Nc = 20; - } - else if (strcmp(argv[3],"1600") == 0) { - /* 1600 bit/s with FEC (actually 1575 with one spare) */ - mode = MODE_1600; - codec2_mode = CODEC2_MODE_1300; - Nc = 16; - } - else { - fprintf(stderr, "Error in mode: %s. Must be 2000 or 1600\n", argv[3]); - exit(1); - } - - fdmdv = fdmdv_create(Nc); - - bits_per_input_frame = 2*fdmdv_bits_per_frame(fdmdv); - bytes_per_input_frame = bits_per_input_frame / 8; - assert((bits_per_input_frame % 8) == 0); /* make sure integer number of bytes per frame */ - - packed_input_bits = (unsigned char*)malloc(bytes_per_input_frame*sizeof(char)); - assert(packed_input_bits != NULL); - unpacked_input_bits = (int*)malloc(bits_per_input_frame*sizeof(int)); - assert(unpacked_input_bits != NULL); - - /* - Output parameters and buffers. - */ - - codec2 = codec2_create(codec2_mode); - - bits_per_output_frame = codec2_bits_per_frame(codec2); - bytes_per_output_frame = (bits_per_output_frame+7)/8; - - packed_output_bits = (unsigned char*)malloc(bytes_per_output_frame*sizeof(char)); - assert(packed_output_bits != NULL); - unpacked_output_bits = (int*)malloc(bits_per_output_frame*sizeof(int)); - assert(unpacked_output_bits != NULL); - - fprintf(stderr, "input bits: %d input_bytes: %d output_bits: %d output_bytes: %d\n", - bits_per_input_frame, bytes_per_input_frame, bits_per_output_frame, bytes_per_output_frame); - - /* main loop */ - - golay23_init(); - - while(fread(packed_input_bits, sizeof(char), bytes_per_input_frame, fin) == (size_t)bytes_per_input_frame) { - - /* unpack bits, MSB first */ - - bit = 7; byte = 0; - for(i=0; i> bit) & 0x1; - bit--; - if (bit < 0) { - bit = 7; - byte++; - } - } - - #ifdef TEST - /* Some test bit errors (not comprehesnive) */ - unpacked_input_bits[0] = (unpacked_input_bits[0] ^ 1) & 0x1; - unpacked_input_bits[23] = (unpacked_input_bits[23] ^ 1) & 0x1; - #endif - - if (mode == MODE_2000) { - /* decode first codeword */ - - recd_codeword = 0; - for(i=0; i<12; i++) { - recd_codeword <<= 1; - recd_codeword |= unpacked_input_bits[i]; - } - for(i=bits_per_output_frame; i> (22-i)) & 0x1; - } - - /* decode second codeword */ - - recd_codeword = 0; - for(i=12; i<24; i++) { - recd_codeword <<= 1; - recd_codeword |= unpacked_input_bits[i]; - } - for(i=bits_per_output_frame+11; i> (22-i)) & 0x1; - } - - /* unprotected bits */ - - for(i=24; i> (22-i)) & 0x1; - } - for(i=8,j=11; i<12; i++,j++) { - unpacked_output_bits[j] = (codeword1 >> (22-i)) & 0x1; - } - } - - if (mode == MODE_1850) { - recd_codeword = 0; - for(i=0; i<8; i++) { - recd_codeword <<= 1; - recd_codeword |= unpacked_input_bits[i]; - } - for(i=11; i<15; i++) { - recd_codeword <<= 1; - recd_codeword |= unpacked_input_bits[i]; - } - for(i=bits_per_output_frame; i> (22-i)) & 0x1; - } - for(i=8,j=11; i<12; i++,j++) { - unpacked_output_bits[j] = (codeword1 >> (22-i)) & 0x1; - } - for(i=0,j=16; i<12; i++,j++) { - unpacked_output_bits[j] = (codeword2 >> (22-i)) & 0x1; - } - - } - - /* pack bits, MSB first */ - - bit = 7; byte = 0; - memset(packed_output_bits, 0, bytes_per_output_frame); - for(i=0; i. -*/ - -#include "codec2.h" -#include "codec2_fdmdv.h" -#include "golay23.h" - -#include -#include -#include -#include -#include - -#define MODE_1600 0 -#define MODE_1850 1 -#define MODE_2000 2 - -int main(int argc, char *argv[]) -{ - void *codec2, *fdmdv; - FILE *fin; - FILE *fout; - int bits_per_input_frame, bytes_per_input_frame; - unsigned char *packed_input_bits; - int *unpacked_input_bits; - int bits_per_output_frame, bytes_per_output_frame; - unsigned char *packed_output_bits; - int *unpacked_output_bits; - int codec2_mode, mode, Nc, bit, byte; - int i,j; - int data, codeword1, codeword2; - - if (argc < 3) { - printf("%s InputFromCodecFile OutputToModemWithFECFile [2000|1850|1600]\n", argv[0]); - exit(1); - } - - if (strcmp(argv[1], "-") == 0) fin = stdin; - else if ( (fin = fopen(argv[1],"rb")) == NULL ) { - fprintf(stderr, "Error opening input file from Codec: %s: %s.\n", - argv[2], strerror(errno)); - exit(1); - } - - if (strcmp(argv[2], "-") == 0) fout = stdout; - else if ( (fout = fopen(argv[2],"wb")) == NULL ) { - fprintf(stderr, "Error opening output file : %s: %s.\n", - argv[3], strerror(errno)); - exit(1); - } - - if ((argc != 4) || (strcmp(argv[3],"2000") == 0)) { - /* 2000 bit/s with FEC */ - mode = MODE_2000; - codec2_mode = CODEC2_MODE_1400; - Nc = 20; - } else if ((strcmp(argv[3],"1850") == 0)) { - /* 1850 bit/s with FEC */ - mode = MODE_1850; - codec2_mode = CODEC2_MODE_1300; - Nc = 20; - } - else if (strcmp(argv[3],"1600") == 0) { - /* 1600 bit/s with FEC (actually 1575 with one spare) */ - mode = MODE_1600; - codec2_mode = CODEC2_MODE_1300; - Nc = 16; - } - else { - fprintf(stderr, "Error in mode: %s. Must be 2000, 1850, or 1600\n", argv[3]); - exit(1); - } - - /* input parameters and buffers */ - - codec2 = codec2_create(codec2_mode); - - bits_per_input_frame = codec2_bits_per_frame(codec2); - bytes_per_input_frame = (bits_per_input_frame + 7)/8; - - packed_input_bits = (unsigned char*)malloc(bytes_per_input_frame*sizeof(char)); - assert(packed_input_bits != NULL); - unpacked_input_bits = (int*)malloc(bits_per_input_frame*sizeof(int)); - assert(unpacked_input_bits != NULL); - - /* - Output parameters and buffers. Data is split into two 20ms - frames for transmission over modem, but this doesn't really - bother us here, as fdmdv_mod takes care of that. - */ - - fdmdv = fdmdv_create(Nc); - - bits_per_output_frame = 2*fdmdv_bits_per_frame(fdmdv); - bytes_per_output_frame = (bits_per_output_frame+7)/8; - - packed_output_bits = (unsigned char*)malloc(bytes_per_output_frame*sizeof(char)); - assert(packed_output_bits != NULL); - unpacked_output_bits = (int*)malloc(bits_per_output_frame*sizeof(int)); - assert(unpacked_output_bits != NULL); - - fprintf(stderr, "mode: %d Nc: %d\n", mode, Nc); - fprintf(stderr, "input bits: %d input_bytes: %d output_bits: %d output_bytes: %d\n", - bits_per_input_frame, bytes_per_input_frame, bits_per_output_frame, bytes_per_output_frame); - - /* main loop */ - - golay23_init(); - - while(fread(packed_input_bits, sizeof(char), bytes_per_input_frame, fin) == (size_t)bytes_per_input_frame) { - - /* unpack bits, MSB first */ - - bit = 7; byte = 0; - for(i=0; i> bit) & 0x1; - bit--; - if (bit < 0) { - bit = 7; - byte++; - } - } - - /* add FEC ---------------------------------------------------------*/ - - if (mode == MODE_2000) { - /* Protect first 24 bits with (23,12) Golay Code. The first - 24 bits are the most sensitive, as they contain the - pitch/energy VQ and voicing bits. This uses 56 + 11 + 11 = - 78 bits, so we have two spare in 80 bit frame sent to - modem. */ - - /* first codeword */ - - data = 0; - for(i=0; i<12; i++) { - data <<= 1; - data |= unpacked_input_bits[i]; - } - codeword1 = golay23_encode(data); - //fprintf(stderr, "data1: 0x%x codeword1: 0x%x\n", data, codeword1); - - /* second codeword */ - - data = 0; - for(i=12; i<24; i++) { - data <<= 1; - data |= unpacked_input_bits[i]; - } - codeword2 = golay23_encode(data); - //fprintf(stderr, "data: 0x%x codeword2: 0x%x\n", data, codeword2); - - /* now pack output frame with parity bits at end to make them - as far apart as possible from the data the protect. Parity - bits are LSB of the Golay codeword */ - - for(i=0; i> (10-j)) & 0x1; - } - for(j=0; i> (10-j)) & 0x1; - } - } - - if (mode == MODE_1850) { - - /* Protect first 12 out of first 16 excitation bits with (23,12) Golay Code: - - 0,1,2,3: v[0]..v[1] - 4,5,6,7: MSB of pitch - 11,12,13,14: MSB of energy - - */ - - data = 0; - for(i=0; i<8; i++) { - data <<= 1; - data |= unpacked_input_bits[i]; - } - for(i=11; i<15; i++) { - data <<= 1; - data |= unpacked_input_bits[i]; - } - codeword1 = golay23_encode(data); - - /* Protect first 12 LSP bits with (23,12) Golay Code */ - - data = 0; - for(i=16; i<28; i++) { - data <<= 1; - data |= unpacked_input_bits[i]; - } - codeword2 = golay23_encode(data); - fprintf(stderr, "codeword2: 0x0%x\n", codeword2); - - /* now pack output frame with parity bits at end to make them - as far apart as possible from the data they protect. Parity - bits are LSB of the Golay codeword */ - - for(i=0; i> (10-j)) & 0x1; - unpacked_output_bits[i+11] = (codeword2 >> (10-j)) & 0x1; - } - for(i=bits_per_input_frame+11+11; i> (10-j)) & 0x1; - } - unpacked_output_bits[i] = 0; /* spare bit */ - } - - /* pack bits, MSB first */ - - bit = 7; byte = 0; - memset(packed_output_bits, 0, bytes_per_output_frame); - for(i=0; i. -*/ - -#include -#include -#include -#include "codec2_fifo.h" - -struct FIFO { - short *buf; - short *pin; - short *pout; - int nshort; -}; - -struct FIFO *fifo_create(int nshort) { - struct FIFO *fifo; - - fifo = (struct FIFO *)malloc(sizeof(struct FIFO)); - assert(fifo != NULL); - - fifo->buf = (short*)malloc(sizeof(short)*nshort); - assert(fifo->buf != NULL); - fifo->pin = fifo->buf; - fifo->pout = fifo->buf; - fifo->nshort = nshort; - - return fifo; -} - -void fifo_destroy(struct FIFO *fifo) { - assert(fifo != NULL); - free(fifo->buf); - free(fifo); -} - -int fifo_write(struct FIFO *fifo, short data[], int n) { - int i; - int fifo_free; - short *pdata; - short *pin = fifo->pin; - - assert(fifo != NULL); - assert(data != NULL); - - // available storage is one less than nshort as prd == pwr - // is reserved for empty rather than full - - fifo_free = fifo->nshort - fifo_used(fifo) - 1; - - if (n > fifo_free) { - return -1; - } - else { - - /* This could be made more efficient with block copies - using memcpy */ - - pdata = data; - for(i=0; ibuf + fifo->nshort)) - pin = fifo->buf; - } - fifo->pin = pin; - } - - return 0; -} - -int fifo_read(struct FIFO *fifo, short data[], int n) -{ - int i; - short *pdata; - short *pout = fifo->pout; - - assert(fifo != NULL); - assert(data != NULL); - - if (n > fifo_used(fifo)) { - return -1; - } - else { - - /* This could be made more efficient with block copies - using memcpy */ - - pdata = data; - for(i=0; ibuf + fifo->nshort)) - pout = fifo->buf; - } - fifo->pout = pout; - } - - return 0; -} - -int fifo_used(struct FIFO *fifo) -{ - short *pin = fifo->pin; - short *pout = fifo->pout; - unsigned int used; - - assert(fifo != NULL); - if (pin >= pout) - used = pin - pout; - else - used = fifo->nshort + (unsigned int)(pin - pout); - - return used; -} - diff --git a/codec2/src/fq20.sh b/codec2/src/fq20.sh deleted file mode 100755 index b83784b4..00000000 --- a/codec2/src/fq20.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# fq20.shsh -# David Rowe 27 July 2010 -# -# Decode a file with fully quantised codec at 20ms frame rate - -../src/sinedec ../raw/$1.raw $1.mdl -o $1_phase0_lsp_20_EWo2.raw --phase 0 --lpc 10 --lsp --postfilter --dec - diff --git a/codec2/src/generate_codebook.c b/codec2/src/generate_codebook.c deleted file mode 100644 index 0bea80d8..00000000 --- a/codec2/src/generate_codebook.c +++ /dev/null @@ -1,179 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: generate_codebook.c - AUTHOR......: Bruce Perens - DATE CREATED: 29 Sep 2010 - - Generate header files containing LSP quantisers, runs at compile time. - -\*---------------------------------------------------------------------------*/ - -/* - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include - -static const char usage[] = -"Usage: %s filename array_name [filename ...]\n" -"\tCreate C code for codebook tables.\n"; - -static const char format[] = -"The table format must be:\n" -"\tTwo integers describing the dimensions of the codebook.\n" -"\tThen, enough numbers to fill the specified dimensions.\n"; - -static const char header[] = -"/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */\n\n" -"/*\n" -" * This intermediary file and the files that used to create it are under \n" -" * The LGPL. See the file COPYING.\n" -" */\n\n" -"#include \"defines.h\"\n\n"; - -struct codebook { - unsigned int k; - unsigned int log2m; - unsigned int m; - float * cb; -}; - -static void -dump_array(const struct codebook * b, int index) -{ - int limit = b->k * b->m; - int i; - - printf("static const float codes%d[] = {\n", index); - for ( i = 0; i < limit; i++ ) { - printf(" %g", b->cb[i]); - if ( i < limit - 1 ) - printf(","); - - /* organise VQs by rows, looks prettier */ - if ( ((i+1) % b->k) == 0 ) - printf("\n"); - } - printf("};\n"); -} - -static void -dump_structure(const struct codebook * b, int index) -{ - printf(" {\n"); - printf(" %d,\n", b->k); - printf(" %g,\n", log(b->m) / log(2)); - printf(" %d,\n", b->m); - printf(" codes%d\n", index); - printf(" }"); -} - -float -get_float(FILE * in, const char * name, char * * cursor, char * buffer, - int size) -{ - for ( ; ; ) { - char * s = *cursor; - char c; - - while ( (c = *s) != '\0' && !isdigit(c) && c != '-' && c != '.' ) - s++; - - /* Comments start with "#" and continue to the end of the line. */ - if ( c != '\0' && c != '#' ) { - char * end = 0; - float f = 0; - - f = strtod(s, &end); - - if ( end != s ) - *cursor = end; - return f; - } - - if ( fgets(buffer, size, in) == NULL ) { - fprintf(stderr, "%s: Format error. %s\n", name, format); - exit(1); - } - *cursor = buffer; - } -} - -static struct codebook * -load(FILE * file, const char * name) -{ - char line[1024]; - char * cursor = line; - struct codebook * b = malloc(sizeof(struct codebook)); - int i; - int size; - - *cursor = '\0'; - - b->k = (int)get_float(file, name, &cursor, line, sizeof(line)); - b->m = (int)get_float(file, name ,&cursor, line, sizeof(line)); - size = b->k * b->m; - - b->cb = (float *)malloc(size * sizeof(float)); - - for ( i = 0; i < size; i++ ) - b->cb[i] = get_float(file, name, &cursor, line, sizeof(line)); - - return b; -} - -int -main(int argc, char * * argv) -{ - struct codebook * * cb = malloc(argc * sizeof(struct codebook *)); - int i; - - if ( argc < 2 ) { - fprintf(stderr, usage, argv[0]); - fprintf(stderr, format); - exit(1); - } - - for ( i = 0; i < argc - 2; i++ ) { - FILE * in = fopen(argv[i + 2], "r"); - - if ( in == NULL ) { - perror(argv[i + 2]); - exit(1); - } - - cb[i] = load(in, argv[i + 2]); - - fclose(in); - } - - printf(header); - for ( i = 0; i < argc - 2; i++ ) { - printf(" /* %s */\n", argv[i + 2]); - dump_array(cb[i], i); - } - printf("\nconst struct lsp_codebook %s[] = {\n", argv[1]); - for ( i = 0; i < argc - 2; i++ ) { - printf(" /* %s */\n", argv[i + 2]); - dump_structure(cb[i], i); - printf(",\n"); - } - printf(" { 0, 0, 0, 0 }\n"); - printf("};\n"); - - return 0; -} diff --git a/codec2/src/genlspdtcb.c b/codec2/src/genlspdtcb.c deleted file mode 100644 index efac19c5..00000000 --- a/codec2/src/genlspdtcb.c +++ /dev/null @@ -1,90 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: genlspdtcb.c - AUTHOR......: David Rowe - DATE CREATED: 2 Nov 2011 - - Generates codebooks (quantisation tables) for LSP delta-T VQ. - -\*---------------------------------------------------------------------------*/ - -/* - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . - -*/ - -#define MAX_ROWS 10 - -float lsp1to4[] = { - -25,0,25, - -25,0,25, - -50,0,50, - -50,0,50 -}; - -float lsp5to10[] = { - -50,0,50, - -50,0,50, - -50,0,50, - -50,0,50, - -50,0,50, - -50,0,50 -}; - -#include -#include -#include -#include -#include - -void create_codebook_text_file(char filename[], float lsp[], - int rows, int cols); - -int main(void) { - create_codebook_text_file("codebook/lspdt1-4.txt", lsp1to4, 4, 3); - create_codebook_text_file("codebook/lspdt5-10.txt", lsp5to10, 6, 3); - return 0; -} - -void create_codebook_text_file(char filename[], float lsp[], - int rows, int cols) -{ - FILE *f; - int i, digits[MAX_ROWS]; - - f = fopen(filename, "wt"); - if (f == NULL) { - printf("Can't open codebook text file %s\n", filename); - exit(0); - } - - for(i=0; i -#include -#include -#define X22 0x00400000 /* vector representation of X^{22} */ -#define X11 0x00000800 /* vector representation of X^{11} */ -#define MASK12 0xfffff800 /* auxiliary vector for testing */ -#define GENPOL 0x00000c75 /* generator polinomial, g(x) */ - -/* Global variables: - * - * pattern = error pattern, or information, or received vector - * encoding_table[] = encoding table - * decoding_table[] = decoding table - * data = information bits, i(x) - * codeword = code bits = x^{11}i(x) + (x^{11}i(x) mod g(x)) - * numerr = number of errors = Hamming weight of error polynomial e(x) - * position[] = error positions in the vector representation of e(x) - * recd = representation of corrupted received polynomial r(x) = c(x) + e(x) - * decerror = number of decoding errors - * a[] = auxiliary array to generate correctable error patterns - */ - -static int inited = 0; - -static int encoding_table[4096], decoding_table[2048]; -#ifdef GOLAY23_UNITTEST -static int position[23] = { 0x00000001, 0x00000002, 0x00000004, 0x00000008, - 0x00000010, 0x00000020, 0x00000040, 0x00000080, - 0x00000100, 0x00000200, 0x00000400, 0x00000800, - 0x00001000, 0x00002000, 0x00004000, 0x00008000, - 0x00010000, 0x00020000, 0x00040000, 0x00080000, - 0x00100000, 0x00200000, 0x00400000 }; -#endif -static int arr2int(int a[], int r) -/* - * Convert a binary vector of Hamming weight r, and nonzero positions in - * array a[1]...a[r], to a long integer \sum_{i=1}^r 2^{a[i]-1}. - */ -{ - int i; - long mul, result = 0, temp; - - for (i=1; i<=r; i++) { - mul = 1; - temp = a[i]-1; - while (temp--) - mul = mul << 1; - result += mul; - } - return(result); -} - -void nextcomb(int n, int r, int a[]) -/* - * Calculate next r-combination of an n-set. - */ -{ - int i, j; - - a[r]++; - if (a[r] <= n) - return; - j = r - 1; - while (a[j] == n - r + j) - j--; - for (i = r; i >= j; i--) - a[i] = a[j] + i - j + 1; - return; -} - -int get_syndrome(int pattern) -/* - * Compute the syndrome corresponding to the given pattern, i.e., the - * remainder after dividing the pattern (when considering it as the vector - * representation of a polynomial) by the generator polynomial, GENPOL. - * In the program this pattern has several meanings: (1) pattern = infomation - * bits, when constructing the encoding table; (2) pattern = error pattern, - * when constructing the decoding table; and (3) pattern = received vector, to - * obtain its syndrome in decoding. - */ -{ - int aux = X22; - - if (pattern >= X11) - while (pattern & MASK12) { - while (!(aux & pattern)) - aux = aux >> 1; - pattern ^= (aux/X11) * GENPOL; - } - return(pattern); -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: golay23_init() - AUTHOR......: David Rowe - DATE CREATED: 3 March 2013 - - Call this once when you start your program to init the Golay tables. - -\*---------------------------------------------------------------------------*/ - -void golay23_init(void ) { - int i; - long temp; - int a[4]; - int pattern; - - /* - * --------------------------------------------------------------------- - * Generate ENCODING TABLE - * - * An entry to the table is an information vector, a 32-bit integer, - * whose 12 least significant positions are the information bits. The - * resulting value is a codeword in the (23,12,7) Golay code: A 32-bit - * integer whose 23 least significant bits are coded bits: Of these, the - * 12 most significant bits are information bits and the 11 least - * significant bits are redundant bits (systematic encoding). - * --------------------------------------------------------------------- - */ - for (pattern = 0; pattern < 4096; pattern++) { - temp = pattern << 11; /* multiply information by X^{11} */ - encoding_table[pattern] = temp + get_syndrome(temp);/* add redundancy */ - } - - /* - * --------------------------------------------------------------------- - * Generate DECODING TABLE - * - * An entry to the decoding table is a syndrome and the resulting value - * is the most likely error pattern. First an error pattern is generated. - * Then its syndrome is calculated and used as a pointer to the table - * where the error pattern value is stored. - * --------------------------------------------------------------------- - * - * (1) Error patterns of WEIGHT 1 (SINGLE ERRORS) - */ - decoding_table[0] = 0; - decoding_table[1] = 1; - temp = 1; - for (i=2; i<= 23; i++) { - temp *= 2; - decoding_table[get_syndrome(temp)] = temp; - } - /* - * (2) Error patterns of WEIGHT 2 (DOUBLE ERRORS) - */ - a[1] = 1; a[2] = 2; - temp = arr2int(a,2); - decoding_table[get_syndrome(temp)] = temp; - for (i=1; i<253; i++) { - nextcomb(23,2,a); - temp = arr2int(a,2); - decoding_table[get_syndrome(temp)] = temp; - } - /* - * (3) Error patterns of WEIGHT 3 (TRIPLE ERRORS) - */ - a[1] = 1; a[2] = 2; a[3] = 3; - temp = arr2int(a,3); - decoding_table[get_syndrome(temp)] = temp; - for (i=1; i<1771; i++) { - nextcomb(23,3,a); - temp = arr2int(a,3); - decoding_table[get_syndrome(temp)] = temp; - } - - inited = 1; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: golay23_encode() - AUTHOR......: David Rowe - DATE CREATED: 3 March 2013 - - Given 12 bits of data retiurns a 23 bit codeword for transmission - over the channel. - -\*---------------------------------------------------------------------------*/ - -int golay23_encode(int data) { - assert(inited); - - //printf("data: 0x%x\n", data); - assert(data <= 0xfff); - return encoding_table[data]; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: golay23_decode() - AUTHOR......: David Rowe - DATE CREATED: 3 March 2013 - - Given a 23 bit received codeword, returns the 12 bit corrected data. - -\*---------------------------------------------------------------------------*/ - -int golay23_decode(int received_codeword) { - assert(inited); - - //printf("syndrome: 0x%x\n", get_syndrome(received_codeword)); - return received_codeword ^= decoding_table[get_syndrome(received_codeword)]; -} - -int golay23_count_errors(int recd_codeword, int corrected_codeword) -{ - int errors = 0; - int diff, i; - - diff = recd_codeword ^ corrected_codeword; - for(i=0; i<23; i++) { - if (diff & 0x1) - errors++; - diff >>= 1; - } - - return errors; -} - -#ifdef GOLAY23_UNITTEST - -static int golay23_test(int error_pattern) { - int data; - int codeword; - int recd; - int pattern; - int decerror; - int i, tests; - - decerror = 0; - tests = 0; - - for (data = 0; data<(1<<12); data++) { - - codeword = golay23_encode(data); - recd = codeword ^ error_pattern; - recd = golay23_decode(recd); - pattern = (recd ^ codeword) >> 11; - for (i=0; i<12; i++) - if (pattern & position[i]) - decerror++; - if (decerror) { - printf("data: 0x%x codeword: 0x%x recd: 0x%x\n", data, codeword, recd); - printf("there were %d decoding errors\n", decerror); - exit(1); - } - tests++; - } - - return tests; -} - -int main(void) -{ - int i; - long temp; - long pattern; - int tests; - int a[4]; - int error_pattern; - - /* - * --------------------------------------------------------------------- - * Generate ENCODING TABLE - * - * An entry to the table is an information vector, a 32-bit integer, - * whose 12 least significant positions are the information bits. The - * resulting value is a codeword in the (23,12,7) Golay code: A 32-bit - * integer whose 23 least significant bits are coded bits: Of these, the - * 12 most significant bits are information bits and the 11 least - * significant bits are redundant bits (systematic encoding). - * --------------------------------------------------------------------- - */ - for (pattern = 0; pattern < 4096; pattern++) { - temp = pattern << 11; /* multiply information by X^{11} */ - encoding_table[pattern] = temp + get_syndrome(temp);/* add redundancy */ - } - - /* - * --------------------------------------------------------------------- - * Generate DECODING TABLE - * - * An entry to the decoding table is a syndrome and the resulting value - * is the most likely error pattern. First an error pattern is generated. - * Then its syndrome is calculated and used as a pointer to the table - * where the error pattern value is stored. - * --------------------------------------------------------------------- - * - * (1) Error patterns of WEIGHT 1 (SINGLE ERRORS) - */ - decoding_table[0] = 0; - decoding_table[1] = 1; - temp = 1; - for (i=2; i<= 23; i++) { - temp *= 2; - decoding_table[get_syndrome(temp)] = temp; - } - /* - * (2) Error patterns of WEIGHT 2 (DOUBLE ERRORS) - */ - a[1] = 1; a[2] = 2; - temp = arr2int(a,2); - decoding_table[get_syndrome(temp)] = temp; - for (i=1; i<253; i++) { - nextcomb(23,2,a); - temp = arr2int(a,2); - decoding_table[get_syndrome(temp)] = temp; - } - /* - * (3) Error patterns of WEIGHT 3 (TRIPLE ERRORS) - */ - a[1] = 1; a[2] = 2; a[3] = 3; - temp = arr2int(a,3); - decoding_table[get_syndrome(temp)] = temp; - for (i=1; i<1771; i++) { - nextcomb(23,3,a); - temp = arr2int(a,3); - decoding_table[get_syndrome(temp)] = temp; - } - - /* --------------------------------------------------------------------- - * Generate DATA - * --------------------------------------------------------------------- - */ - - /* Test all combinations of data and 1,2 or 3 errors */ - - tests = 0; - error_pattern = 1; - for (i=0; i< 23; i++) { - //printf("error_pattern: 0x%x\n", error_pattern); - tests += golay23_test(error_pattern); - error_pattern *= 2; - } - printf("%d 1 bit error tests performed OK!\n", tests); - - tests = 0; - a[1] = 1; a[2] = 2; - error_pattern = arr2int(a,2); - tests += golay23_test(error_pattern); - for (i=1; i<253; i++) { - nextcomb(23,2,a); - error_pattern = arr2int(a,2); - //printf("error_pattern: 0x%x\n", error_pattern); - tests += golay23_test(error_pattern); - } - printf("%d 2 bit error tests performed OK!\n", tests); - - tests = 0; - a[1] = 1; a[2] = 2; a[3] = 3; - error_pattern = arr2int(a,3); - tests += golay23_test(error_pattern); - for (i=1; i<1771; i++) { - nextcomb(23,3,a); - error_pattern = arr2int(a,3); - //printf("error_pattern: 0x%x\n", error_pattern); - tests += golay23_test(error_pattern); - } - printf("%d 3 bit error tests performed OK!\n", tests); - - return 0; -} -#endif diff --git a/codec2/src/golay23.h b/codec2/src/golay23.h deleted file mode 100644 index a916d29f..00000000 --- a/codec2/src/golay23.h +++ /dev/null @@ -1,44 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: golay23.h - AUTHOR......: David Rowe - DATE CREATED: 3 March 2013 - - Header file for Golay FEC. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2013 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#ifndef __GOLAY23__ -#define __GOLAY23__ - -#ifdef __cplusplus -extern "C" { -#endif - -void golay23_init(void); -int golay23_encode(int data); -int golay23_decode(int received_codeword); -int golay23_count_errors(int recd_codeword, int corrected_codeword); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/codec2/src/hanning.h b/codec2/src/hanning.h deleted file mode 100644 index 81d88dcb..00000000 --- a/codec2/src/hanning.h +++ /dev/null @@ -1,644 +0,0 @@ -/* Generated by hanning_file() Octave function */ - -const float hanning[]={ - 0, - 2.4171e-05, - 9.66816e-05, - 0.000217525, - 0.000386689, - 0.000604158, - 0.00086991, - 0.00118392, - 0.00154616, - 0.00195659, - 0.00241517, - 0.00292186, - 0.00347661, - 0.00407937, - 0.00473008, - 0.00542867, - 0.00617507, - 0.00696922, - 0.00781104, - 0.00870045, - 0.00963736, - 0.0106217, - 0.0116533, - 0.0127322, - 0.0138581, - 0.0150311, - 0.0162509, - 0.0175175, - 0.0188308, - 0.0201906, - 0.0215968, - 0.0230492, - 0.0245478, - 0.0260923, - 0.0276826, - 0.0293186, - 0.0310001, - 0.032727, - 0.034499, - 0.036316, - 0.0381779, - 0.0400844, - 0.0420354, - 0.0440307, - 0.04607, - 0.0481533, - 0.0502802, - 0.0524506, - 0.0546643, - 0.056921, - 0.0592206, - 0.0615627, - 0.0639473, - 0.0663741, - 0.0688427, - 0.0713531, - 0.0739048, - 0.0764978, - 0.0791318, - 0.0818064, - 0.0845214, - 0.0872767, - 0.0900718, - 0.0929066, - 0.0957807, - 0.0986939, - 0.101646, - 0.104636, - 0.107665, - 0.110732, - 0.113836, - 0.116978, - 0.120156, - 0.123372, - 0.126624, - 0.129912, - 0.133235, - 0.136594, - 0.139989, - 0.143418, - 0.146881, - 0.150379, - 0.153911, - 0.157476, - 0.161074, - 0.164705, - 0.168368, - 0.172063, - 0.17579, - 0.179549, - 0.183338, - 0.187158, - 0.191008, - 0.194888, - 0.198798, - 0.202737, - 0.206704, - 0.2107, - 0.214724, - 0.218775, - 0.222854, - 0.226959, - 0.231091, - 0.235249, - 0.239432, - 0.243641, - 0.247874, - 0.252132, - 0.256414, - 0.260719, - 0.265047, - 0.269398, - 0.273772, - 0.278167, - 0.282584, - 0.287021, - 0.29148, - 0.295958, - 0.300456, - 0.304974, - 0.30951, - 0.314065, - 0.318638, - 0.323228, - 0.327835, - 0.332459, - 0.3371, - 0.341756, - 0.346427, - 0.351113, - 0.355814, - 0.360528, - 0.365256, - 0.369997, - 0.374751, - 0.379516, - 0.384293, - 0.389082, - 0.393881, - 0.398691, - 0.40351, - 0.408338, - 0.413176, - 0.418022, - 0.422876, - 0.427737, - 0.432605, - 0.43748, - 0.44236, - 0.447247, - 0.452138, - 0.457034, - 0.461935, - 0.466839, - 0.471746, - 0.476655, - 0.481568, - 0.486481, - 0.491397, - 0.496313, - 0.501229, - 0.506145, - 0.511061, - 0.515976, - 0.520889, - 0.5258, - 0.530708, - 0.535614, - 0.540516, - 0.545414, - 0.550308, - 0.555197, - 0.560081, - 0.564958, - 0.56983, - 0.574695, - 0.579552, - 0.584402, - 0.589244, - 0.594077, - 0.598901, - 0.603715, - 0.60852, - 0.613314, - 0.618097, - 0.622868, - 0.627628, - 0.632375, - 0.63711, - 0.641831, - 0.646538, - 0.651232, - 0.655911, - 0.660574, - 0.665222, - 0.669855, - 0.67447, - 0.679069, - 0.683651, - 0.688215, - 0.69276, - 0.697287, - 0.701795, - 0.706284, - 0.710752, - 0.7152, - 0.719627, - 0.724033, - 0.728418, - 0.73278, - 0.73712, - 0.741437, - 0.74573, - 0.75, - 0.754246, - 0.758467, - 0.762663, - 0.766833, - 0.770978, - 0.775097, - 0.779189, - 0.783254, - 0.787291, - 0.791301, - 0.795283, - 0.799236, - 0.80316, - 0.807055, - 0.810921, - 0.814756, - 0.81856, - 0.822334, - 0.826077, - 0.829788, - 0.833468, - 0.837115, - 0.840729, - 0.844311, - 0.847859, - 0.851374, - 0.854855, - 0.858301, - 0.861713, - 0.86509, - 0.868431, - 0.871737, - 0.875007, - 0.87824, - 0.881437, - 0.884598, - 0.887721, - 0.890806, - 0.893854, - 0.896864, - 0.899835, - 0.902768, - 0.905661, - 0.908516, - 0.911331, - 0.914106, - 0.916841, - 0.919536, - 0.92219, - 0.924804, - 0.927376, - 0.929907, - 0.932397, - 0.934845, - 0.93725, - 0.939614, - 0.941935, - 0.944213, - 0.946448, - 0.94864, - 0.950789, - 0.952894, - 0.954955, - 0.956972, - 0.958946, - 0.960874, - 0.962759, - 0.964598, - 0.966393, - 0.968142, - 0.969846, - 0.971505, - 0.973118, - 0.974686, - 0.976207, - 0.977683, - 0.979112, - 0.980495, - 0.981832, - 0.983122, - 0.984365, - 0.985561, - 0.986711, - 0.987813, - 0.988868, - 0.989876, - 0.990837, - 0.99175, - 0.992616, - 0.993434, - 0.994204, - 0.994927, - 0.995601, - 0.996228, - 0.996807, - 0.997337, - 0.99782, - 0.998255, - 0.998641, - 0.998979, - 0.999269, - 0.999511, - 0.999704, - 0.999849, - 0.999946, - 0.999994, - 0.999994, - 0.999946, - 0.999849, - 0.999704, - 0.999511, - 0.999269, - 0.998979, - 0.998641, - 0.998255, - 0.99782, - 0.997337, - 0.996807, - 0.996228, - 0.995601, - 0.994927, - 0.994204, - 0.993434, - 0.992616, - 0.99175, - 0.990837, - 0.989876, - 0.988868, - 0.987813, - 0.986711, - 0.985561, - 0.984365, - 0.983122, - 0.981832, - 0.980495, - 0.979112, - 0.977683, - 0.976207, - 0.974686, - 0.973118, - 0.971505, - 0.969846, - 0.968142, - 0.966393, - 0.964598, - 0.962759, - 0.960874, - 0.958946, - 0.956972, - 0.954955, - 0.952894, - 0.950789, - 0.94864, - 0.946448, - 0.944213, - 0.941935, - 0.939614, - 0.93725, - 0.934845, - 0.932397, - 0.929907, - 0.927376, - 0.924804, - 0.92219, - 0.919536, - 0.916841, - 0.914106, - 0.911331, - 0.908516, - 0.905661, - 0.902768, - 0.899835, - 0.896864, - 0.893854, - 0.890806, - 0.887721, - 0.884598, - 0.881437, - 0.87824, - 0.875007, - 0.871737, - 0.868431, - 0.86509, - 0.861713, - 0.858301, - 0.854855, - 0.851374, - 0.847859, - 0.844311, - 0.840729, - 0.837115, - 0.833468, - 0.829788, - 0.826077, - 0.822334, - 0.81856, - 0.814756, - 0.810921, - 0.807055, - 0.80316, - 0.799236, - 0.795283, - 0.791301, - 0.787291, - 0.783254, - 0.779189, - 0.775097, - 0.770978, - 0.766833, - 0.762663, - 0.758467, - 0.754246, - 0.75, - 0.74573, - 0.741437, - 0.73712, - 0.73278, - 0.728418, - 0.724033, - 0.719627, - 0.7152, - 0.710752, - 0.706284, - 0.701795, - 0.697287, - 0.69276, - 0.688215, - 0.683651, - 0.679069, - 0.67447, - 0.669855, - 0.665222, - 0.660574, - 0.655911, - 0.651232, - 0.646538, - 0.641831, - 0.63711, - 0.632375, - 0.627628, - 0.622868, - 0.618097, - 0.613314, - 0.60852, - 0.603715, - 0.598901, - 0.594077, - 0.589244, - 0.584402, - 0.579552, - 0.574695, - 0.56983, - 0.564958, - 0.560081, - 0.555197, - 0.550308, - 0.545414, - 0.540516, - 0.535614, - 0.530708, - 0.5258, - 0.520889, - 0.515976, - 0.511061, - 0.506145, - 0.501229, - 0.496313, - 0.491397, - 0.486481, - 0.481568, - 0.476655, - 0.471746, - 0.466839, - 0.461935, - 0.457034, - 0.452138, - 0.447247, - 0.44236, - 0.43748, - 0.432605, - 0.427737, - 0.422876, - 0.418022, - 0.413176, - 0.408338, - 0.40351, - 0.398691, - 0.393881, - 0.389082, - 0.384293, - 0.379516, - 0.374751, - 0.369997, - 0.365256, - 0.360528, - 0.355814, - 0.351113, - 0.346427, - 0.341756, - 0.3371, - 0.332459, - 0.327835, - 0.323228, - 0.318638, - 0.314065, - 0.30951, - 0.304974, - 0.300456, - 0.295958, - 0.29148, - 0.287021, - 0.282584, - 0.278167, - 0.273772, - 0.269398, - 0.265047, - 0.260719, - 0.256414, - 0.252132, - 0.247874, - 0.243641, - 0.239432, - 0.235249, - 0.231091, - 0.226959, - 0.222854, - 0.218775, - 0.214724, - 0.2107, - 0.206704, - 0.202737, - 0.198798, - 0.194888, - 0.191008, - 0.187158, - 0.183338, - 0.179549, - 0.17579, - 0.172063, - 0.168368, - 0.164705, - 0.161074, - 0.157476, - 0.153911, - 0.150379, - 0.146881, - 0.143418, - 0.139989, - 0.136594, - 0.133235, - 0.129912, - 0.126624, - 0.123372, - 0.120156, - 0.116978, - 0.113836, - 0.110732, - 0.107665, - 0.104636, - 0.101646, - 0.0986939, - 0.0957807, - 0.0929066, - 0.0900718, - 0.0872767, - 0.0845214, - 0.0818064, - 0.0791318, - 0.0764978, - 0.0739048, - 0.0713531, - 0.0688427, - 0.0663741, - 0.0639473, - 0.0615627, - 0.0592206, - 0.056921, - 0.0546643, - 0.0524506, - 0.0502802, - 0.0481533, - 0.04607, - 0.0440307, - 0.0420354, - 0.0400844, - 0.0381779, - 0.036316, - 0.034499, - 0.032727, - 0.0310001, - 0.0293186, - 0.0276826, - 0.0260923, - 0.0245478, - 0.0230492, - 0.0215968, - 0.0201906, - 0.0188308, - 0.0175175, - 0.0162509, - 0.0150311, - 0.0138581, - 0.0127322, - 0.0116533, - 0.0106217, - 0.00963736, - 0.00870045, - 0.00781104, - 0.00696922, - 0.00617507, - 0.00542867, - 0.00473008, - 0.00407937, - 0.00347661, - 0.00292186, - 0.00241517, - 0.00195659, - 0.00154616, - 0.00118392, - 0.00086991, - 0.000604158, - 0.000386689, - 0.000217525, - 9.66816e-05, - 2.4171e-05, - 0 -}; diff --git a/codec2/src/insert_errors.c b/codec2/src/insert_errors.c deleted file mode 100644 index 87ef2f8b..00000000 --- a/codec2/src/insert_errors.c +++ /dev/null @@ -1,121 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: insert_errors.c - AUTHOR......: David Rowe - DATE CREATED: 20/2/2013 - - Inserts errors into a Codec 2 bit stream using error files. The - error files have one 16 bit short per bit, the short is set to 1 if - there is an error, or zero otherwise. The Codec 2 bit stream files - are in packed format, i.e. c2enc/c2dec format. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2013 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include "codec2.h" - -#include -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - FILE *fin; - FILE *fout; - FILE *ferror; - int i, start_bit, end_bit, bit; - unsigned char byte; - short error; - int errors, bits; - int bits_per_frame; - - if (argc < 4) { - printf("%s InputBitFile OutputBitFile ErrorFile bitsPerFrame [startBit endBit]\n", argv[0]); - printf("%s InputBitFile OutputBitFile BER\n", argv[0]); - exit(1); - } - - if (strcmp(argv[1], "-") == 0) fin = stdin; - else if ( (fin = fopen(argv[1],"rb")) == NULL ) { - fprintf(stderr, "Error opening input bit file: %s: %s.\n", - argv[1], strerror(errno)); - exit(1); - } - - if (strcmp(argv[2], "-") == 0) fout = stdout; - else if ( (fout = fopen(argv[2],"wb")) == NULL ) { - fprintf(stderr, "Error opening output speech file: %s: %s.\n", - argv[2], strerror(errno)); - exit(1); - } - - if ((ferror = fopen(argv[3],"rb")) == NULL ) { - fprintf(stderr, "Error opening error file: %s: %s.\n", - argv[3], strerror(errno)); - exit(1); - } - - bits_per_frame = atoi(argv[4]); - assert((bits_per_frame % 8) == 0); - - start_bit = 0; end_bit = bits_per_frame; - if (argc == 7) { - start_bit = atoi(argv[5]); - end_bit = atoi(argv[6]); - } - - bit = 0; - bits = errors = 0; - - while(fread(&byte, sizeof(char), 1, fin) == 1) { - - for(i=0; i<8; i++) { - bits++; - //printf("bit: %d start_bit: %d end_bit: %d\n", bit, start_bit, end_bit); - if (fread(&error, sizeof(short), 1, ferror)) { - if ((bit >= start_bit) && (bit <= end_bit)) - byte ^= error << (7-i); - if (error) - errors++; - } - else { - fprintf(stderr,"bits: %d ber: %4.3f\n", bits, (float)errors/bits); - fclose (fin); fclose(fout); fclose(ferror); - exit(0); - } - bit++; - if (bit == bits_per_frame) - bit = 0; - } - fwrite(&byte, sizeof(char), 1, fout); - if (fout == stdout) fflush(stdout); - if (fin == stdin) fflush(stdin); - - } - - fclose(fin); - fclose(fout); - fclose(ferror); - - fprintf(stderr,"bits: %d ber: %4.3f\n", bits, (float)errors/bits); - - return 0; -} diff --git a/codec2/src/interp.c b/codec2/src/interp.c deleted file mode 100644 index e712a46e..00000000 --- a/codec2/src/interp.c +++ /dev/null @@ -1,323 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: interp.c - AUTHOR......: David Rowe - DATE CREATED: 9/10/09 - - Interpolation of 20ms frames to 10ms frames. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2009 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include - -#include "defines.h" -#include "interp.h" -#include "lsp.h" -#include "quantise.h" - -float sample_log_amp(MODEL *model, float w); - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: interp() - AUTHOR......: David Rowe - DATE CREATED: 22/8/10 - - Given two frames decribed by model parameters 20ms apart, determines - the model parameters of the 10ms frame between them. Assumes - voicing is available for middle (interpolated) frame. Outputs are - amplitudes and Wo for the interpolated frame. - - This version can interpolate the amplitudes between two frames of - different Wo and L. - - This version works by log linear interpolation, but listening tests - showed it creates problems in background noise, e.g. hts2a and mmt1. - When this function is used (--dec mode) bg noise appears to be - amplitude modulated, and gets louder. The interp_lsp() function - below seems to do a better job. - -\*---------------------------------------------------------------------------*/ - -void interpolate( - MODEL *interp, /* interpolated model params */ - MODEL *prev, /* previous frames model params */ - MODEL *next /* next frames model params */ -) -{ - int l; - float w,log_amp; - - /* Wo depends on voicing of this and adjacent frames */ - - if (interp->voiced) { - if (prev->voiced && next->voiced) - interp->Wo = (prev->Wo + next->Wo)/2.0; - if (!prev->voiced && next->voiced) - interp->Wo = next->Wo; - if (prev->voiced && !next->voiced) - interp->Wo = prev->Wo; - } - else { - interp->Wo = TWO_PI/P_MAX; - } - interp->L = PI/interp->Wo; - - /* Interpolate amplitudes using linear interpolation in log domain */ - - for(l=1; l<=interp->L; l++) { - w = l*interp->Wo; - log_amp = (sample_log_amp(prev, w) + sample_log_amp(next, w))/2.0; - interp->A[l] = pow(10.0, log_amp); - } -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: sample_log_amp() - AUTHOR......: David Rowe - DATE CREATED: 22/8/10 - - Samples the amplitude envelope at an arbitrary frequency w. Uses - linear interpolation in the log domain to sample between harmonic - amplitudes. - -\*---------------------------------------------------------------------------*/ - -float sample_log_amp(MODEL *model, float w) -{ - int m; - float f, log_amp; - - assert(w > 0.0); assert (w <= PI); - - m = floorf(w/model->Wo + 0.5); - f = (w - m*model->Wo)/w; - assert(f <= 1.0); - - if (m < 1) { - log_amp = f*log10f(model->A[1] + 1E-6); - } - else if ((m+1) > model->L) { - log_amp = (1.0-f)*log10f(model->A[model->L] + 1E-6); - } - else { - log_amp = (1.0-f)*log10f(model->A[m] + 1E-6) + - f*log10f(model->A[m+1] + 1E-6); - } - - return log_amp; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: interp_lsp() - AUTHOR......: David Rowe - DATE CREATED: 10 Nov 2010 - - Given two frames decribed by model parameters 20ms apart, determines - the model parameters of the 10ms frame between them. Assumes - voicing is available for middle (interpolated) frame. Outputs are - amplitudes and Wo for the interpolated frame. - - This version uses interpolation of LSPs, seems to do a better job - with bg noise. - -\*---------------------------------------------------------------------------*/ - -void interpolate_lsp( - kiss_fft_cfg fft_fwd_cfg, - MODEL *interp, /* interpolated model params */ - MODEL *prev, /* previous frames model params */ - MODEL *next, /* next frames model params */ - float *prev_lsps, /* previous frames LSPs */ - float prev_e, /* previous frames LPC energy */ - float *next_lsps, /* next frames LSPs */ - float next_e, /* next frames LPC energy */ - float *ak_interp, /* interpolated aks for this frame */ - float *lsps_interp/* interpolated lsps for this frame */ -) -{ - int i; - float e; - float snr; - - /* trap corner case where V est is probably wrong */ - - if (interp->voiced && !prev->voiced && !next->voiced) { - interp->voiced = 0; - } - - /* Wo depends on voicing of this and adjacent frames */ - - if (interp->voiced) { - if (prev->voiced && next->voiced) - interp->Wo = (prev->Wo + next->Wo)/2.0; - if (!prev->voiced && next->voiced) - interp->Wo = next->Wo; - if (prev->voiced && !next->voiced) - interp->Wo = prev->Wo; - } - else { - interp->Wo = TWO_PI/P_MAX; - } - interp->L = PI/interp->Wo; - - //printf(" interp: prev_v: %d next_v: %d prev_Wo: %f next_Wo: %f\n", - // prev->voiced, next->voiced, prev->Wo, next->Wo); - //printf(" interp: Wo: %1.5f L: %d\n", interp->Wo, interp->L); - - /* interpolate LSPs */ - - for(i=0; iA[1]); -} - - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: interp_Wo() - AUTHOR......: David Rowe - DATE CREATED: 22 May 2012 - - Interpolates centre 10ms sample of Wo and L samples given two - samples 20ms apart. Assumes voicing is available for centre - (interpolated) frame. - -\*---------------------------------------------------------------------------*/ - -void interp_Wo( - MODEL *interp, /* interpolated model params */ - MODEL *prev, /* previous frames model params */ - MODEL *next /* next frames model params */ - ) -{ - interp_Wo2(interp, prev, next, 0.5); -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: interp_Wo2() - AUTHOR......: David Rowe - DATE CREATED: 22 May 2012 - - Weighted interpolation of two Wo samples. - -\*---------------------------------------------------------------------------*/ - -void interp_Wo2( - MODEL *interp, /* interpolated model params */ - MODEL *prev, /* previous frames model params */ - MODEL *next, /* next frames model params */ - float weight -) -{ - /* trap corner case where voicing est is probably wrong */ - - if (interp->voiced && !prev->voiced && !next->voiced) { - interp->voiced = 0; - } - - /* Wo depends on voicing of this and adjacent frames */ - - if (interp->voiced) { - if (prev->voiced && next->voiced) - interp->Wo = (1.0 - weight)*prev->Wo + weight*next->Wo; - if (!prev->voiced && next->voiced) - interp->Wo = next->Wo; - if (prev->voiced && !next->voiced) - interp->Wo = prev->Wo; - } - else { - interp->Wo = TWO_PI/P_MAX; - } - interp->L = PI/interp->Wo; -} - - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: interp_energy() - AUTHOR......: David Rowe - DATE CREATED: 22 May 2012 - - Interpolates centre 10ms sample of energy given two samples 20ms - apart. - -\*---------------------------------------------------------------------------*/ - -float interp_energy(float prev_e, float next_e) -{ - return powf(10.0, (log10f(prev_e) + log10f(next_e))/2.0); - -} - - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: interp_energy2() - AUTHOR......: David Rowe - DATE CREATED: 22 May 2012 - - Interpolates centre 10ms sample of energy given two samples 20ms - apart. - -\*---------------------------------------------------------------------------*/ - -float interp_energy2(float prev_e, float next_e, float weight) -{ - return powf(10.0, (1.0 - weight)*log10f(prev_e) + weight*log10f(next_e)); - -} - - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: interpolate_lsp_ver2() - AUTHOR......: David Rowe - DATE CREATED: 22 May 2012 - - Weighted interpolation of LSPs. - -\*---------------------------------------------------------------------------*/ - -void interpolate_lsp_ver2(float interp[], float prev[], float next[], float weight) -{ - int i; - - for(i=0; i. -*/ - -#ifndef __INTERP__ -#define __INTERP__ - -#include "kiss_fft.h" - -void interpolate(MODEL *interp, MODEL *prev, MODEL *next); -void interpolate_lsp(kiss_fft_cfg fft_dec_cfg, - MODEL *interp, MODEL *prev, MODEL *next, - float *prev_lsps, float prev_e, - float *next_lsps, float next_e, - float *ak_interp, float *lsps_interp); -void interp_Wo(MODEL *interp, MODEL *prev, MODEL *next); -void interp_Wo2(MODEL *interp, MODEL *prev, MODEL *next, float weight); -float interp_energy(float prev, float next); -float interp_energy2(float prev, float next, float weight); -void interpolate_lsp_ver2(float interp[], float prev[], float next[], float weight); - -#endif diff --git a/codec2/src/kiss_fft.c b/codec2/src/kiss_fft.c deleted file mode 100644 index 465d6c97..00000000 --- a/codec2/src/kiss_fft.c +++ /dev/null @@ -1,408 +0,0 @@ -/* -Copyright (c) 2003-2010, Mark Borgerding - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -#include "_kiss_fft_guts.h" -/* The guts header contains all the multiplication and addition macros that are defined for - fixed or floating point complex numbers. It also delares the kf_ internal functions. - */ - -static void kf_bfly2( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - int m - ) -{ - kiss_fft_cpx * Fout2; - kiss_fft_cpx * tw1 = st->twiddles; - kiss_fft_cpx t; - Fout2 = Fout + m; - do{ - C_FIXDIV(*Fout,2); C_FIXDIV(*Fout2,2); - - C_MUL (t, *Fout2 , *tw1); - tw1 += fstride; - C_SUB( *Fout2 , *Fout , t ); - C_ADDTO( *Fout , t ); - ++Fout2; - ++Fout; - }while (--m); -} - -static void kf_bfly4( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - const size_t m - ) -{ - kiss_fft_cpx *tw1,*tw2,*tw3; - kiss_fft_cpx scratch[6]; - size_t k=m; - const size_t m2=2*m; - const size_t m3=3*m; - - - tw3 = tw2 = tw1 = st->twiddles; - - do { - C_FIXDIV(*Fout,4); C_FIXDIV(Fout[m],4); C_FIXDIV(Fout[m2],4); C_FIXDIV(Fout[m3],4); - - C_MUL(scratch[0],Fout[m] , *tw1 ); - C_MUL(scratch[1],Fout[m2] , *tw2 ); - C_MUL(scratch[2],Fout[m3] , *tw3 ); - - C_SUB( scratch[5] , *Fout, scratch[1] ); - C_ADDTO(*Fout, scratch[1]); - C_ADD( scratch[3] , scratch[0] , scratch[2] ); - C_SUB( scratch[4] , scratch[0] , scratch[2] ); - C_SUB( Fout[m2], *Fout, scratch[3] ); - tw1 += fstride; - tw2 += fstride*2; - tw3 += fstride*3; - C_ADDTO( *Fout , scratch[3] ); - - if(st->inverse) { - Fout[m].r = scratch[5].r - scratch[4].i; - Fout[m].i = scratch[5].i + scratch[4].r; - Fout[m3].r = scratch[5].r + scratch[4].i; - Fout[m3].i = scratch[5].i - scratch[4].r; - }else{ - Fout[m].r = scratch[5].r + scratch[4].i; - Fout[m].i = scratch[5].i - scratch[4].r; - Fout[m3].r = scratch[5].r - scratch[4].i; - Fout[m3].i = scratch[5].i + scratch[4].r; - } - ++Fout; - }while(--k); -} - -static void kf_bfly3( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - size_t m - ) -{ - size_t k=m; - const size_t m2 = 2*m; - kiss_fft_cpx *tw1,*tw2; - kiss_fft_cpx scratch[5]; - kiss_fft_cpx epi3; - epi3 = st->twiddles[fstride*m]; - - tw1=tw2=st->twiddles; - - do{ - C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3); - - C_MUL(scratch[1],Fout[m] , *tw1); - C_MUL(scratch[2],Fout[m2] , *tw2); - - C_ADD(scratch[3],scratch[1],scratch[2]); - C_SUB(scratch[0],scratch[1],scratch[2]); - tw1 += fstride; - tw2 += fstride*2; - - Fout[m].r = Fout->r - HALF_OF(scratch[3].r); - Fout[m].i = Fout->i - HALF_OF(scratch[3].i); - - C_MULBYSCALAR( scratch[0] , epi3.i ); - - C_ADDTO(*Fout,scratch[3]); - - Fout[m2].r = Fout[m].r + scratch[0].i; - Fout[m2].i = Fout[m].i - scratch[0].r; - - Fout[m].r -= scratch[0].i; - Fout[m].i += scratch[0].r; - - ++Fout; - }while(--k); -} - -static void kf_bfly5( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - int m - ) -{ - kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4; - int u; - kiss_fft_cpx scratch[13]; - kiss_fft_cpx * twiddles = st->twiddles; - kiss_fft_cpx *tw; - kiss_fft_cpx ya,yb; - ya = twiddles[fstride*m]; - yb = twiddles[fstride*2*m]; - - Fout0=Fout; - Fout1=Fout0+m; - Fout2=Fout0+2*m; - Fout3=Fout0+3*m; - Fout4=Fout0+4*m; - - tw=st->twiddles; - for ( u=0; ur += scratch[7].r + scratch[8].r; - Fout0->i += scratch[7].i + scratch[8].i; - - scratch[5].r = scratch[0].r + S_MUL(scratch[7].r,ya.r) + S_MUL(scratch[8].r,yb.r); - scratch[5].i = scratch[0].i + S_MUL(scratch[7].i,ya.r) + S_MUL(scratch[8].i,yb.r); - - scratch[6].r = S_MUL(scratch[10].i,ya.i) + S_MUL(scratch[9].i,yb.i); - scratch[6].i = -S_MUL(scratch[10].r,ya.i) - S_MUL(scratch[9].r,yb.i); - - C_SUB(*Fout1,scratch[5],scratch[6]); - C_ADD(*Fout4,scratch[5],scratch[6]); - - scratch[11].r = scratch[0].r + S_MUL(scratch[7].r,yb.r) + S_MUL(scratch[8].r,ya.r); - scratch[11].i = scratch[0].i + S_MUL(scratch[7].i,yb.r) + S_MUL(scratch[8].i,ya.r); - scratch[12].r = - S_MUL(scratch[10].i,yb.i) + S_MUL(scratch[9].i,ya.i); - scratch[12].i = S_MUL(scratch[10].r,yb.i) - S_MUL(scratch[9].r,ya.i); - - C_ADD(*Fout2,scratch[11],scratch[12]); - C_SUB(*Fout3,scratch[11],scratch[12]); - - ++Fout0;++Fout1;++Fout2;++Fout3;++Fout4; - } -} - -/* perform the butterfly for one stage of a mixed radix FFT */ -static void kf_bfly_generic( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - int m, - int p - ) -{ - int u,k,q1,q; - kiss_fft_cpx * twiddles = st->twiddles; - kiss_fft_cpx t; - int Norig = st->nfft; - - kiss_fft_cpx * scratch = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC(sizeof(kiss_fft_cpx)*p); - - for ( u=0; u=Norig) twidx-=Norig; - C_MUL(t,scratch[q] , twiddles[twidx] ); - C_ADDTO( Fout[ k ] ,t); - } - k += m; - } - } - KISS_FFT_TMP_FREE(scratch); -} - -static -void kf_work( - kiss_fft_cpx * Fout, - const kiss_fft_cpx * f, - const size_t fstride, - int in_stride, - int * factors, - const kiss_fft_cfg st - ) -{ - kiss_fft_cpx * Fout_beg=Fout; - const int p=*factors++; /* the radix */ - const int m=*factors++; /* stage's fft length/p */ - const kiss_fft_cpx * Fout_end = Fout + p*m; - -#ifdef _OPENMP - // use openmp extensions at the - // top-level (not recursive) - if (fstride==1 && p<=5) - { - int k; - - // execute the p different work units in different threads -# pragma omp parallel for - for (k=0;k floor_sqrt) - p = n; /* no more factors, skip to end */ - } - n /= p; - *facbuf++ = p; - *facbuf++ = n; - } while (n > 1); -} - -/* - * - * User-callable function to allocate all necessary storage space for the fft. - * - * The return value is a contiguous block of memory, allocated with malloc. As such, - * It can be freed with free(), rather than a kiss_fft-specific function. - * */ -kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem ) -{ - kiss_fft_cfg st=NULL; - size_t memneeded = sizeof(struct kiss_fft_state) - + sizeof(kiss_fft_cpx)*(nfft-1); /* twiddle factors*/ - - if ( lenmem==NULL ) { - st = ( kiss_fft_cfg)KISS_FFT_MALLOC( memneeded ); - }else{ - if (mem != NULL && *lenmem >= memneeded) - st = (kiss_fft_cfg)mem; - *lenmem = memneeded; - } - if (st) { - int i; - st->nfft=nfft; - st->inverse = inverse_fft; - - for (i=0;iinverse) - phase *= -1; - kf_cexp(st->twiddles+i, phase ); - } - - kf_factor(nfft,st->factors); - } - return st; -} - - -void kiss_fft_stride(kiss_fft_cfg st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int in_stride) -{ - if (fin == fout) { - //NOTE: this is not really an in-place FFT algorithm. - //It just performs an out-of-place FFT into a temp buffer - kiss_fft_cpx * tmpbuf = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC( sizeof(kiss_fft_cpx)*st->nfft); - kf_work(tmpbuf,fin,1,in_stride, st->factors,st); - memcpy(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft); - KISS_FFT_TMP_FREE(tmpbuf); - }else{ - kf_work( fout, fin, 1,in_stride, st->factors,st ); - } -} - -void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) -{ - kiss_fft_stride(cfg,fin,fout,1); -} - - -void kiss_fft_cleanup(void) -{ - // nothing needed any more -} - -int kiss_fft_next_fast_size(int n) -{ - while(1) { - int m=n; - while ( (m%2) == 0 ) m/=2; - while ( (m%3) == 0 ) m/=3; - while ( (m%5) == 0 ) m/=5; - if (m<=1) - break; /* n is completely factorable by twos, threes, and fives */ - n++; - } - return n; -} diff --git a/codec2/src/kiss_fft.h b/codec2/src/kiss_fft.h deleted file mode 100644 index 64c50f4a..00000000 --- a/codec2/src/kiss_fft.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef KISS_FFT_H -#define KISS_FFT_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - ATTENTION! - If you would like a : - -- a utility that will handle the caching of fft objects - -- real-only (no imaginary time component ) FFT - -- a multi-dimensional FFT - -- a command-line utility to perform ffts - -- a command-line utility to perform fast-convolution filtering - - Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c - in the tools/ directory. -*/ - -#ifdef USE_SIMD -# include -# define kiss_fft_scalar __m128 -#define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16) -#define KISS_FFT_FREE _mm_free -#else -#define KISS_FFT_MALLOC malloc -#define KISS_FFT_FREE free -#endif - - -#ifdef FIXED_POINT -#include -# if (FIXED_POINT == 32) -# define kiss_fft_scalar int32_t -# else -# define kiss_fft_scalar int16_t -# endif -#else -# ifndef kiss_fft_scalar -/* default is float */ -# define kiss_fft_scalar float -# endif -#endif - -typedef struct { - kiss_fft_scalar r; - kiss_fft_scalar i; -}kiss_fft_cpx; - -typedef struct kiss_fft_state* kiss_fft_cfg; - -/* - * kiss_fft_alloc - * - * Initialize a FFT (or IFFT) algorithm's cfg/state buffer. - * - * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL); - * - * The return value from fft_alloc is a cfg buffer used internally - * by the fft routine or NULL. - * - * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc. - * The returned value should be free()d when done to avoid memory leaks. - * - * The state can be placed in a user supplied buffer 'mem': - * If lenmem is not NULL and mem is not NULL and *lenmem is large enough, - * then the function places the cfg in mem and the size used in *lenmem - * and returns mem. - * - * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough), - * then the function returns NULL and places the minimum cfg - * buffer size in *lenmem. - * */ - -kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); - -/* - * kiss_fft(cfg,in_out_buf) - * - * Perform an FFT on a complex input buffer. - * for a forward FFT, - * fin should be f[0] , f[1] , ... ,f[nfft-1] - * fout will be F[0] , F[1] , ... ,F[nfft-1] - * Note that each element is complex and can be accessed like - f[k].r and f[k].i - * */ -void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); - -/* - A more generic version of the above function. It reads its input from every Nth sample. - * */ -void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride); - -/* If kiss_fft_alloc allocated a buffer, it is one contiguous - buffer and can be simply free()d when no longer needed*/ -#define kiss_fft_free free - -/* - Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up - your compiler output to call this before you exit. -*/ -void kiss_fft_cleanup(void); - - -/* - * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5) - */ -int kiss_fft_next_fast_size(int n); - -/* for real ffts, we need an even size */ -#define kiss_fftr_next_fast_size_real(n) \ - (kiss_fft_next_fast_size( ((n)+1)>>1)<<1) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/codec2/src/listensim.sh b/codec2/src/listensim.sh deleted file mode 100755 index b296cac5..00000000 --- a/codec2/src/listensim.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# listensim.sh -# David Rowe 10 Sep 2009 -# -# Listen to files processed with sim.sh - -../script/menu.sh $1_uq.raw $1_lpc10.raw $1_lpcpf.raw $1_phase0.raw $1_phase0_lpcpf.raw $2 $3 $4 $5 - - diff --git a/codec2/src/lpc.c b/codec2/src/lpc.c deleted file mode 100644 index d03cb178..00000000 --- a/codec2/src/lpc.c +++ /dev/null @@ -1,309 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: lpc.c - AUTHOR......: David Rowe - DATE CREATED: 30 Sep 1990 (!) - - Linear Prediction functions written in C. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2009-2012 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#define LPC_MAX_N 512 /* maximum no. of samples in frame */ -#define PI 3.141592654 /* mathematical constant */ - -#define ALPHA 1.0 -#define BETA 0.94 - -#include -#include -#include "defines.h" -#include "lpc.h" - -/*---------------------------------------------------------------------------*\ - - pre_emp() - - Pre-emphasise (high pass filter with zero close to 0 Hz) a frame of - speech samples. Helps reduce dynamic range of LPC spectrum, giving - greater weight and hensea better match to low energy formants. - - Should be balanced by de-emphasis of the output speech. - -\*---------------------------------------------------------------------------*/ - -void pre_emp( - float Sn_pre[], /* output frame of speech samples */ - float Sn[], /* input frame of speech samples */ - float *mem, /* Sn[-1]single sample memory */ - int Nsam /* number of speech samples to use */ -) -{ - int i; - - for(i=0; i 1.0) - k[i] = 0.0; - - a[i][i] = k[i]; - - for(j=1; j<=i-1; j++) - a[i][j] = a[i-1][j] + k[i]*a[i-1][i-j]; /* Equation 38c, Makhoul */ - - E[i] = (1-k[i]*k[i])*E[i-1]; /* Equation 38d, Makhoul */ - } - - for(i=1; i<=order; i++) - lpcs[i] = a[order][i]; - lpcs[0] = 1.0; -} - -/*---------------------------------------------------------------------------*\ - - inverse_filter() - - Inverse Filter, A(z). Produces an array of residual samples from an array - of input samples and linear prediction coefficients. - - The filter memory is stored in the first order samples of the input array. - -\*---------------------------------------------------------------------------*/ - -void inverse_filter( - float Sn[], /* Nsam input samples */ - float a[], /* LPCs for this frame of samples */ - int Nsam, /* number of samples */ - float res[], /* Nsam residual samples */ - int order /* order of LPC */ -) -{ - int i,j; /* loop variables */ - - for(i=0; i. -*/ - -#ifndef __LPC__ -#define __LPC__ - -#define LPC_MAX_ORDER 20 - -void pre_emp(float Sn_pre[], float Sn[], float *mem, int Nsam); -void de_emp(float Sn_se[], float Sn[], float *mem, int Nsam); -void hanning_window(float Sn[], float Wn[], int Nsam); -void autocorrelate(float Sn[], float Rn[], int Nsam, int order); -void levinson_durbin(float R[], float lpcs[], int order); -void inverse_filter(float Sn[], float a[], int Nsam, float res[], int order); -void synthesis_filter(float res[], float a[], int Nsam, int order, float Sn_[]); -void find_aks(float Sn[], float a[], int Nsam, int order, float *E); -void weight(float ak[], float gamma, int order, float akw[]); - -#endif diff --git a/codec2/src/lsp.c b/codec2/src/lsp.c deleted file mode 100644 index c5167b7a..00000000 --- a/codec2/src/lsp.c +++ /dev/null @@ -1,325 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: lsp.c - AUTHOR......: David Rowe - DATE CREATED: 24/2/93 - - - This file contains functions for LPC to LSP conversion and LSP to - LPC conversion. Note that the LSP coefficients are not in radians - format but in the x domain of the unit circle. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2009 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include "defines.h" -#include "lsp.h" -#include -#include -#include - -/* Only 10 gets used, so far. */ -#define LSP_MAX_ORDER 20 - -/*---------------------------------------------------------------------------*\ - - Introduction to Line Spectrum Pairs (LSPs) - ------------------------------------------ - - LSPs are used to encode the LPC filter coefficients {ak} for - transmission over the channel. LSPs have several properties (like - less sensitivity to quantisation noise) that make them superior to - direct quantisation of {ak}. - - A(z) is a polynomial of order lpcrdr with {ak} as the coefficients. - - A(z) is transformed to P(z) and Q(z) (using a substitution and some - algebra), to obtain something like: - - A(z) = 0.5[P(z)(z+z^-1) + Q(z)(z-z^-1)] (1) - - As you can imagine A(z) has complex zeros all over the z-plane. P(z) - and Q(z) have the very neat property of only having zeros _on_ the - unit circle. So to find them we take a test point z=exp(jw) and - evaluate P (exp(jw)) and Q(exp(jw)) using a grid of points between 0 - and pi. - - The zeros (roots) of P(z) also happen to alternate, which is why we - swap coefficients as we find roots. So the process of finding the - LSP frequencies is basically finding the roots of 5th order - polynomials. - - The root so P(z) and Q(z) occur in symmetrical pairs at +/-w, hence - the name Line Spectrum Pairs (LSPs). - - To convert back to ak we just evaluate (1), "clocking" an impulse - thru it lpcrdr times gives us the impulse response of A(z) which is - {ak}. - -\*---------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: cheb_poly_eva() - AUTHOR......: David Rowe - DATE CREATED: 24/2/93 - - This function evalutes a series of chebyshev polynomials - - FIXME: performing memory allocation at run time is very inefficient, - replace with stack variables of MAX_P size. - -\*---------------------------------------------------------------------------*/ - - -static float -cheb_poly_eva(float *coef,float x,int m) -/* float coef[] coefficients of the polynomial to be evaluated */ -/* float x the point where polynomial is to be evaluated */ -/* int m order of the polynomial */ -{ - int i; - float *t,*u,*v,sum; - float T[(LSP_MAX_ORDER / 2) + 1]; - - /* Initialise pointers */ - - t = T; /* T[i-2] */ - *t++ = 1.0; - u = t--; /* T[i-1] */ - *u++ = x; - v = u--; /* T[i] */ - - /* Evaluate chebyshev series formulation using iterative approach */ - - for(i=2;i<=m/2;i++) - *v++ = (2*x)*(*u++) - *t++; /* T[i] = 2*x*T[i-1] - T[i-2] */ - - sum=0.0; /* initialise sum to zero */ - t = T; /* reset pointer */ - - /* Evaluate polynomial and return value also free memory space */ - - for(i=0;i<=m/2;i++) - sum+=coef[(m/2)-i]**t++; - - return sum; -} - - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: lpc_to_lsp() - AUTHOR......: David Rowe - DATE CREATED: 24/2/93 - - This function converts LPC coefficients to LSP coefficients. - -\*---------------------------------------------------------------------------*/ - -int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta) -/* float *a lpc coefficients */ -/* int lpcrdr order of LPC coefficients (10) */ -/* float *freq LSP frequencies in radians */ -/* int nb number of sub-intervals (4) */ -/* float delta grid spacing interval (0.02) */ -{ - float psuml,psumr,psumm,temp_xr,xl,xr,xm = 0; - float temp_psumr; - int i,j,m,flag,k; - float *px; /* ptrs of respective P'(z) & Q'(z) */ - float *qx; - float *p; - float *q; - float *pt; /* ptr used for cheb_poly_eval() - whether P' or Q' */ - int roots=0; /* number of roots found */ - float Q[LSP_MAX_ORDER + 1]; - float P[LSP_MAX_ORDER + 1]; - - flag = 1; - m = lpcrdr/2; /* order of P'(z) & Q'(z) polynimials */ - - /* Allocate memory space for polynomials */ - - /* determine P'(z)'s and Q'(z)'s coefficients where - P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */ - - px = P; /* initilaise ptrs */ - qx = Q; - p = px; - q = qx; - *px++ = 1.0; - *qx++ = 1.0; - for(i=1;i<=m;i++){ - *px++ = a[i]+a[lpcrdr+1-i]-*p++; - *qx++ = a[i]-a[lpcrdr+1-i]+*q++; - } - px = P; - qx = Q; - for(i=0;i= -1.0)){ - xr = xl - delta ; /* interval spacing */ - psumr = cheb_poly_eva(pt,xr,lpcrdr);/* poly(xl-delta_x) */ - temp_psumr = psumr; - temp_xr = xr; - - /* if no sign change increment xr and re-evaluate - poly(xr). Repeat til sign change. if a sign change has - occurred the interval is bisected and then checked again - for a sign change which determines in which interval the - zero lies in. If there is no sign change between poly(xm) - and poly(xl) set interval between xm and xr else set - interval between xl and xr and repeat till root is located - within the specified limits */ - - if(((psumr*psuml)<0.0) || (psumr == 0.0)){ - roots++; - - psumm=psuml; - for(k=0;k<=nb;k++){ - xm = (xl+xr)/2; /* bisect the interval */ - psumm=cheb_poly_eva(pt,xm,lpcrdr); - if(psumm*psuml>0.){ - psuml=psumm; - xl=xm; - } - else{ - psumr=psumm; - xr=xm; - } - } - - /* once zero is found, reset initial interval to xr */ - freq[j] = (xm); - xl = xm; - flag = 0; /* reset flag for next search */ - } - else{ - psuml=temp_psumr; - xl=temp_xr; - } - } - } - - /* convert from x domain to radians */ - - for(i=0; i. -*/ - -#ifndef __LSP__ -#define __LSP__ - -int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta); -void lsp_to_lpc(float *freq, float *ak, int lpcrdr); - -#endif diff --git a/codec2/src/machdep.h b/codec2/src/machdep.h deleted file mode 100644 index ef2e6494..00000000 --- a/codec2/src/machdep.h +++ /dev/null @@ -1,51 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: machdep.h - AUTHOR......: David Rowe - DATE CREATED: May 2 2013 - - Machine dependant functions. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2013 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#ifndef __MACHDEP__ -#define __MACHDEP__ - -#ifdef TIMER -#define TIMER_VAR(...) unsigned int __VA_ARGS__ -#define TIMER_SAMPLE(timestamp) timestamp = machdep_timer_sample() -#define TIMER_SAMPLE_AND_LOG(timestamp, prev_timestamp, label) \ - timestamp = machdep_timer_sample_and_log(prev_timestamp, label) -#define TIMER_SAMPLE_AND_LOG2(prev_timestamp, label) \ - machdep_timer_sample_and_log(prev_timestamp, label) -#else -#define TIMER_VAR(...) -#define TIMER_SAMPLE(timestamp) -#define TIMER_SAMPLE_AND_LOG(timestamp, prev_timestamp, label) -#define TIMER_SAMPLE_AND_LOG2(prev_timestamp, label) -#endif - -void machdep_timer_init(void); -void machdep_timer_reset(void); -unsigned int machdep_timer_sample(void); -unsigned int machdep_timer_sample_and_log(unsigned int start, char s[]); -void machdep_timer_print_logged_samples(void); - -#endif diff --git a/codec2/src/nlp.c b/codec2/src/nlp.c deleted file mode 100644 index 7d842e53..00000000 --- a/codec2/src/nlp.c +++ /dev/null @@ -1,589 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: nlp.c - AUTHOR......: David Rowe - DATE CREATED: 23/3/93 - - Non Linear Pitch (NLP) estimation functions. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2009 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include "defines.h" -#include "nlp.h" -#include "dump.h" -#include "kiss_fft.h" -#undef TIMER -#include "machdep.h" - -#include -#include -#include - -/*---------------------------------------------------------------------------*\ - - DEFINES - -\*---------------------------------------------------------------------------*/ - -#define PMAX_M 600 /* maximum NLP analysis window size */ -#define COEFF 0.95 /* notch filter parameter */ -#define PE_FFT_SIZE 512 /* DFT size for pitch estimation */ -#define DEC 5 /* decimation factor */ -#define SAMPLE_RATE 8000 -#define PI 3.141592654 /* mathematical constant */ -#define T 0.1 /* threshold for local minima candidate */ -#define F0_MAX 500 -#define CNLP 0.3 /* post processor constant */ -#define NLP_NTAP 48 /* Decimation LPF order */ - -//#undef DUMP - -/*---------------------------------------------------------------------------*\ - - GLOBALS - -\*---------------------------------------------------------------------------*/ - -/* 48 tap 600Hz low pass FIR filter coefficients */ - -const float nlp_fir[] = { - -1.0818124e-03, - -1.1008344e-03, - -9.2768838e-04, - -4.2289438e-04, - 5.5034190e-04, - 2.0029849e-03, - 3.7058509e-03, - 5.1449415e-03, - 5.5924666e-03, - 4.3036754e-03, - 8.0284511e-04, - -4.8204610e-03, - -1.1705810e-02, - -1.8199275e-02, - -2.2065282e-02, - -2.0920610e-02, - -1.2808831e-02, - 3.2204775e-03, - 2.6683811e-02, - 5.5520624e-02, - 8.6305944e-02, - 1.1480192e-01, - 1.3674206e-01, - 1.4867556e-01, - 1.4867556e-01, - 1.3674206e-01, - 1.1480192e-01, - 8.6305944e-02, - 5.5520624e-02, - 2.6683811e-02, - 3.2204775e-03, - -1.2808831e-02, - -2.0920610e-02, - -2.2065282e-02, - -1.8199275e-02, - -1.1705810e-02, - -4.8204610e-03, - 8.0284511e-04, - 4.3036754e-03, - 5.5924666e-03, - 5.1449415e-03, - 3.7058509e-03, - 2.0029849e-03, - 5.5034190e-04, - -4.2289438e-04, - -9.2768838e-04, - -1.1008344e-03, - -1.0818124e-03 -}; - -typedef struct { - int m; - float w[PMAX_M/DEC]; /* DFT window */ - float sq[PMAX_M]; /* squared speech samples */ - float mem_x,mem_y; /* memory for notch filter */ - float mem_fir[NLP_NTAP]; /* decimation FIR filter memory */ - kiss_fft_cfg fft_cfg; /* kiss FFT config */ -} NLP; - -float test_candidate_mbe(COMP Sw[], COMP W[], float f0); -float post_process_mbe(COMP Fw[], int pmin, int pmax, float gmax, COMP Sw[], COMP W[], float *prev_Wo); -float post_process_sub_multiples(COMP Fw[], - int pmin, int pmax, float gmax, int gmax_bin, - float *prev_Wo); - -/*---------------------------------------------------------------------------*\ - - nlp_create() - - Initialisation function for NLP pitch estimator. - -\*---------------------------------------------------------------------------*/ - -void *nlp_create( -int m /* analysis window size */ -) -{ - NLP *nlp; - int i; - - assert(m <= PMAX_M); - - nlp = (NLP*)malloc(sizeof(NLP)); - if (nlp == NULL) - return NULL; - - nlp->m = m; - for(i=0; iw[i] = 0.5 - 0.5*cosf(2*PI*i/(m/DEC-1)); - } - - for(i=0; isq[i] = 0.0; - nlp->mem_x = 0.0; - nlp->mem_y = 0.0; - for(i=0; imem_fir[i] = 0.0; - - nlp->fft_cfg = kiss_fft_alloc (PE_FFT_SIZE, 0, NULL, NULL); - assert(nlp->fft_cfg != NULL); - - return (void*)nlp; -} - -/*---------------------------------------------------------------------------*\ - - nlp_destroy() - - Shut down function for NLP pitch estimator. - -\*---------------------------------------------------------------------------*/ - -void nlp_destroy(void *nlp_state) -{ - NLP *nlp; - assert(nlp_state != NULL); - nlp = (NLP*)nlp_state; - - KISS_FFT_FREE(nlp->fft_cfg); - free(nlp_state); -} - -/*---------------------------------------------------------------------------*\ - - nlp() - - Determines the pitch in samples using the Non Linear Pitch (NLP) - algorithm [1]. Returns the fundamental in Hz. Note that the actual - pitch estimate is for the centre of the M sample Sn[] vector, not - the current N sample input vector. This is (I think) a delay of 2.5 - frames with N=80 samples. You should align further analysis using - this pitch estimate to be centred on the middle of Sn[]. - - Two post processors have been tried, the MBE version (as discussed - in [1]), and a post processor that checks sub-multiples. Both - suffer occasional gross pitch errors (i.e. neither are perfect). In - the presence of background noise the sub-multiple algorithm tends - towards low F0 which leads to better sounding background noise than - the MBE post processor. - - A good way to test and develop the NLP pitch estimator is using the - tnlp (codec2/unittest) and the codec2/octave/plnlp.m Octave script. - - A pitch tracker searching a few frames forward and backward in time - would be a useful addition. - - References: - - [1] http://www.itr.unisa.edu.au/~steven/thesis/dgr.pdf Chapter 4 - -\*---------------------------------------------------------------------------*/ - -float nlp( - void *nlp_state, - float Sn[], /* input speech vector */ - int n, /* frames shift (no. new samples in Sn[]) */ - int pmin, /* minimum pitch value */ - int pmax, /* maximum pitch value */ - float *pitch, /* estimated pitch period in samples */ - COMP Sw[], /* Freq domain version of Sn[] */ - COMP W[], /* Freq domain window */ - float *prev_Wo -) -{ - NLP *nlp; - float notch; /* current notch filter output */ - COMP fw[PE_FFT_SIZE]; /* DFT of squared signal (input) */ - COMP Fw[PE_FFT_SIZE]; /* DFT of squared signal (output) */ - float gmax; - int gmax_bin; - int m, i,j; - float best_f0; - TIMER_VAR(start, tnotch, filter, peakpick, window, fft, magsq, shiftmem); - - assert(nlp_state != NULL); - nlp = (NLP*)nlp_state; - m = nlp->m; - - TIMER_SAMPLE(start); - - /* Square, notch filter at DC, and LP filter vector */ - - for(i=m-n; isq[i] = Sn[i]*Sn[i]; - - for(i=m-n; isq[i] - nlp->mem_x; - notch += COEFF*nlp->mem_y; - nlp->mem_x = nlp->sq[i]; - nlp->mem_y = notch; - nlp->sq[i] = notch + 1.0; /* With 0 input vectors to codec, - kiss_fft() would take a long - time to execute when running in - real time. Problem was traced - to kiss_fft function call in - this function. Adding this small - constant fixed problem. Not - exactly sure why. */ - } - - TIMER_SAMPLE_AND_LOG(tnotch, start, " square and notch"); - - for(i=m-n; imem_fir[j] = nlp->mem_fir[j+1]; - nlp->mem_fir[NLP_NTAP-1] = nlp->sq[i]; - - nlp->sq[i] = 0.0; - for(j=0; jsq[i] += nlp->mem_fir[j]*nlp_fir[j]; - } - - TIMER_SAMPLE_AND_LOG(filter, tnotch, " filter"); - - /* Decimate and DFT */ - - for(i=0; isq[i*DEC]*nlp->w[i]; - } - TIMER_SAMPLE_AND_LOG(window, filter, " window"); - #ifdef DUMP - dump_dec(Fw); - #endif - - kiss_fft(nlp->fft_cfg, (kiss_fft_cpx *)fw, (kiss_fft_cpx *)Fw); - TIMER_SAMPLE_AND_LOG(fft, window, " fft"); - - for(i=0; isq); - dump_Fw(Fw); - #endif - - /* find global peak */ - - gmax = 0.0; - gmax_bin = PE_FFT_SIZE*DEC/pmax; - for(i=PE_FFT_SIZE*DEC/pmax; i<=PE_FFT_SIZE*DEC/pmin; i++) { - if (Fw[i].real > gmax) { - gmax = Fw[i].real; - gmax_bin = i; - } - } - - TIMER_SAMPLE_AND_LOG(peakpick, magsq, " peak pick"); - - //#define POST_PROCESS_MBE - #ifdef POST_PROCESS_MBE - best_f0 = post_process_mbe(Fw, pmin, pmax, gmax, Sw, W, prev_Wo); - #else - best_f0 = post_process_sub_multiples(Fw, pmin, pmax, gmax, gmax_bin, prev_Wo); - #endif - - TIMER_SAMPLE_AND_LOG(shiftmem, peakpick, " post process"); - - /* Shift samples in buffer to make room for new samples */ - - for(i=0; isq[i] = nlp->sq[i+n]; - - /* return pitch and F0 estimate */ - - *pitch = (float)SAMPLE_RATE/best_f0; - - TIMER_SAMPLE_AND_LOG2(shiftmem, " shift mem"); - - TIMER_SAMPLE_AND_LOG2(start, " nlp int"); - - return(best_f0); -} - -/*---------------------------------------------------------------------------*\ - - post_process_sub_multiples() - - Given the global maximma of Fw[] we search integer submultiples for - local maxima. If local maxima exist and they are above an - experimentally derived threshold (OK a magic number I pulled out of - the air) we choose the submultiple as the F0 estimate. - - The rational for this is that the lowest frequency peak of Fw[] - should be F0, as Fw[] can be considered the autocorrelation function - of Sw[] (the speech spectrum). However sometimes due to phase - effects the lowest frequency maxima may not be the global maxima. - - This works OK in practice and favours low F0 values in the presence - of background noise which means the sinusoidal codec does an OK job - of synthesising the background noise. High F0 in background noise - tends to sound more periodic introducing annoying artifacts. - -\*---------------------------------------------------------------------------*/ - -float post_process_sub_multiples(COMP Fw[], - int pmin, int pmax, float gmax, int gmax_bin, - float *prev_Wo) -{ - int min_bin, cmax_bin; - int mult; - float thresh, best_f0; - int b, bmin, bmax, lmax_bin; - float lmax; - int prev_f0_bin; - - /* post process estimate by searching submultiples */ - - mult = 2; - min_bin = PE_FFT_SIZE*DEC/pmax; - cmax_bin = gmax_bin; - prev_f0_bin = *prev_Wo*(4000.0/PI)*(PE_FFT_SIZE*DEC)/SAMPLE_RATE; - - while(gmax_bin/mult >= min_bin) { - - b = gmax_bin/mult; /* determine search interval */ - bmin = 0.8*b; - bmax = 1.2*b; - if (bmin < min_bin) - bmin = min_bin; - - /* lower threshold to favour previous frames pitch estimate, - this is a form of pitch tracking */ - - if ((prev_f0_bin > bmin) && (prev_f0_bin < bmax)) - thresh = CNLP*0.5*gmax; - else - thresh = CNLP*gmax; - - lmax = 0; - lmax_bin = bmin; - for (b=bmin; b<=bmax; b++) /* look for maximum in interval */ - if (Fw[b].real > lmax) { - lmax = Fw[b].real; - lmax_bin = b; - } - - if (lmax > thresh) - if ((lmax > Fw[lmax_bin-1].real) && (lmax > Fw[lmax_bin+1].real)) { - cmax_bin = lmax_bin; - } - - mult++; - } - - best_f0 = (float)cmax_bin*SAMPLE_RATE/(PE_FFT_SIZE*DEC); - - return best_f0; -} - -/*---------------------------------------------------------------------------*\ - - post_process_mbe() - - Use the MBE pitch estimation algorithm to evaluate pitch candidates. This - works OK but the accuracy at low F0 is affected by NW, the analysis window - size used for the DFT of the input speech Sw[]. Also favours high F0 in - the presence of background noise which causes periodic artifacts in the - synthesised speech. - -\*---------------------------------------------------------------------------*/ - -float post_process_mbe(COMP Fw[], int pmin, int pmax, float gmax, COMP Sw[], COMP W[], float *prev_Wo) -{ - float candidate_f0; - float f0,best_f0; /* fundamental frequency */ - float e,e_min; /* MBE cost function */ - int i; - #ifdef DUMP - float e_hz[F0_MAX]; - #endif - #if !defined(NDEBUG) || defined(DUMP) - int bin; - #endif - float f0_min, f0_max; - float f0_start, f0_end; - - f0_min = (float)SAMPLE_RATE/pmax; - f0_max = (float)SAMPLE_RATE/pmin; - - /* Now look for local maxima. Each local maxima is a candidate - that we test using the MBE pitch estimation algotithm */ - - #ifdef DUMP - for(i=0; i Fw[i-1].real) && (Fw[i].real > Fw[i+1].real)) { - - /* local maxima found, lets test if it's big enough */ - - if (Fw[i].real > T*gmax) { - - /* OK, sample MBE cost function over +/- 10Hz range in 2.5Hz steps */ - - candidate_f0 = (float)i*SAMPLE_RATE/(PE_FFT_SIZE*DEC); - f0_start = candidate_f0-20; - f0_end = candidate_f0+20; - if (f0_start < f0_min) f0_start = f0_min; - if (f0_end > f0_max) f0_end = f0_max; - - for(f0=f0_start; f0<=f0_end; f0+= 2.5) { - e = test_candidate_mbe(Sw, W, f0); - #if !defined(NDEBUG) || defined(DUMP) - bin = floor(f0); assert((bin > 0) && (bin < F0_MAX)); - #endif - #ifdef DUMP - e_hz[bin] = e; - #endif - if (e < e_min) { - e_min = e; - best_f0 = f0; - } - } - - } - } - } - - /* finally sample MBE cost function around previous pitch estimate - (form of pitch tracking) */ - - candidate_f0 = *prev_Wo * SAMPLE_RATE/TWO_PI; - f0_start = candidate_f0-20; - f0_end = candidate_f0+20; - if (f0_start < f0_min) f0_start = f0_min; - if (f0_end > f0_max) f0_end = f0_max; - - for(f0=f0_start; f0<=f0_end; f0+= 2.5) { - e = test_candidate_mbe(Sw, W, f0); - #if !defined(NDEBUG) || defined(DUMP) - bin = floor(f0); assert((bin > 0) && (bin < F0_MAX)); - #endif - #ifdef DUMP - e_hz[bin] = e; - #endif - if (e < e_min) { - e_min = e; - best_f0 = f0; - } - } - - #ifdef DUMP - dump_e(e_hz); - #endif - - return best_f0; -} - -/*---------------------------------------------------------------------------*\ - - test_candidate_mbe() - - Returns the error of the MBE cost function for the input f0. - - Note: I think a lot of the operations below can be simplified as - W[].imag = 0 and has been normalised such that den always equals 1. - -\*---------------------------------------------------------------------------*/ - -float test_candidate_mbe( - COMP Sw[], - COMP W[], - float f0 -) -{ - COMP Sw_[FFT_ENC]; /* DFT of all voiced synthesised signal */ - int l,al,bl,m; /* loop variables */ - COMP Am; /* amplitude sample for this band */ - int offset; /* centers Hw[] about current harmonic */ - float den; /* denominator of Am expression */ - float error; /* accumulated error between originl and synthesised */ - float Wo; /* current "test" fundamental freq. */ - int L; - - L = floor((SAMPLE_RATE/2.0)/f0); - Wo = f0*(2*PI/SAMPLE_RATE); - - error = 0.0; - - /* Just test across the harmonics in the first 1000 Hz (L/4) */ - - for(l=1; l. -*/ - -#ifndef __NLP__ -#define __NLP__ - -#include "comp.h" - -void *nlp_create(int m); -void nlp_destroy(void *nlp_state); -float nlp(void *nlp_state, float Sn[], int n, int pmin, int pmax, - float *pitch, COMP Sw[], COMP W[], float *prev_Wo); - -#endif diff --git a/codec2/src/octave.c b/codec2/src/octave.c deleted file mode 100644 index 2ff5ad14..00000000 --- a/codec2/src/octave.c +++ /dev/null @@ -1,85 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: octave.c - AUTHOR......: David Rowe - DATE CREATED: April 28 2012 - - Functions to save C arrays in GNU Octave matrix format. The output text - file can be directly read into Octave using "load filename". - -\*---------------------------------------------------------------------------*/ - - -/* - Copyright (C) 2012 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include "octave.h" - -void octave_save_int(FILE *f, char name[], int data[], int rows, int cols) -{ - int r,c; - - fprintf(f, "# name: %s\n", name); - fprintf(f, "# type: matrix\n"); - fprintf(f, "# rows: %d\n", rows); - fprintf(f, "# columns: %d\n", cols); - - for(r=0; r. -*/ - -#ifndef __OCTAVE__ -#define __OCTAVE__ - -#include "comp.h" - -void octave_save_int(FILE *f, char name[], int data[], int rows, int cols); -void octave_save_float(FILE *f, char name[], float data[], int rows, int cols, int col_len); -void octave_save_complex(FILE *f, char name[], COMP data[], int rows, int cols, int col_len); - -#endif diff --git a/codec2/src/os.h b/codec2/src/os.h deleted file mode 100644 index 0dae9bfd..00000000 --- a/codec2/src/os.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Generate using fir1(47,1/6) in Octave */ - -const float fdmdv_os_filter[]= { - -3.55606818e-04, - -8.98615286e-04, - -1.40119781e-03, - -1.71713852e-03, - -1.56471179e-03, - -6.28128960e-04, - 1.24522223e-03, - 3.83138676e-03, - 6.41309478e-03, - 7.85893186e-03, - 6.93514929e-03, - 2.79361991e-03, - -4.51051400e-03, - -1.36671853e-02, - -2.21034939e-02, - -2.64084653e-02, - -2.31425052e-02, - -9.84218694e-03, - 1.40648474e-02, - 4.67316298e-02, - 8.39615986e-02, - 1.19925275e-01, - 1.48381174e-01, - 1.64097819e-01, - 1.64097819e-01, - 1.48381174e-01, - 1.19925275e-01, - 8.39615986e-02, - 4.67316298e-02, - 1.40648474e-02, - -9.84218694e-03, - -2.31425052e-02, - -2.64084653e-02, - -2.21034939e-02, - -1.36671853e-02, - -4.51051400e-03, - 2.79361991e-03, - 6.93514929e-03, - 7.85893186e-03, - 6.41309478e-03, - 3.83138676e-03, - 1.24522223e-03, - -6.28128960e-04, - -1.56471179e-03, - -1.71713852e-03, - -1.40119781e-03, - -8.98615286e-04, - -3.55606818e-04 -}; - diff --git a/codec2/src/pack.c b/codec2/src/pack.c deleted file mode 100644 index b0625645..00000000 --- a/codec2/src/pack.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - Copyright (C) 2010 Perens LLC - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include "defines.h" -#include "quantise.h" -#include - -/* Compile-time constants */ -/* Size of unsigned char in bits. Assumes 8 bits-per-char. */ -static const unsigned int WordSize = 8; - -/* Mask to pick the bit component out of bitIndex. */ -static const unsigned int IndexMask = 0x7; - -/* Used to pick the word component out of bitIndex. */ -static const unsigned int ShiftRight = 3; - -/** Pack a bit field into a bit string, encoding the field in Gray code. - * - * The output is an array of unsigned char data. The fields are efficiently - * packed into the bit string. The Gray coding is a naive attempt to reduce - * the effect of single-bit errors, we expect to do a better job as the - * codec develops. - * - * This code would be simpler if it just set one bit at a time in the string, - * but would hit the same cache line more often. I'm not sure the complexity - * gains us anything here. - * - * Although field is currently of int type rather than unsigned for - * compatibility with the rest of the code, indices are always expected to - * be >= 0. - */ -void -pack( - unsigned char * bitArray, /* The output bit string. */ - unsigned int * bitIndex, /* Index into the string in BITS, not bytes.*/ - int field, /* The bit field to be packed. */ - unsigned int fieldWidth/* Width of the field in BITS, not bytes. */ - ) -{ - pack_natural_or_gray(bitArray, bitIndex, field, fieldWidth, 1); -} - -void -pack_natural_or_gray( - unsigned char * bitArray, /* The output bit string. */ - unsigned int * bitIndex, /* Index into the string in BITS, not bytes.*/ - int field, /* The bit field to be packed. */ - unsigned int fieldWidth,/* Width of the field in BITS, not bytes. */ - unsigned int gray /* non-zero for gray coding */ - ) -{ - if (gray) { - /* Convert the field to Gray code */ - field = (field >> 1) ^ field; - } - - do { - unsigned int bI = *bitIndex; - unsigned int bitsLeft = WordSize - (bI & IndexMask); - unsigned int sliceWidth = - bitsLeft < fieldWidth ? bitsLeft : fieldWidth; - unsigned int wordIndex = bI >> ShiftRight; - - bitArray[wordIndex] |= - ((unsigned char)((field >> (fieldWidth - sliceWidth)) - << (bitsLeft - sliceWidth))); - - *bitIndex = bI + sliceWidth; - fieldWidth -= sliceWidth; - } while ( fieldWidth != 0 ); -} - -/** Unpack a field from a bit string, converting from Gray code to binary. - * - */ -int -unpack( - const unsigned char * bitArray, /* The input bit string. */ - unsigned int * bitIndex, /* Index into the string in BITS, not bytes.*/ - unsigned int fieldWidth/* Width of the field in BITS, not bytes. */ - ) -{ - return unpack_natural_or_gray(bitArray, bitIndex, fieldWidth, 1); -} - -/** Unpack a field from a bit string, to binary, optionally using - * natural or Gray code. - * - */ -int -unpack_natural_or_gray( - const unsigned char * bitArray, /* The input bit string. */ - unsigned int * bitIndex, /* Index into the string in BITS, not bytes.*/ - unsigned int fieldWidth,/* Width of the field in BITS, not bytes. */ - unsigned int gray /* non-zero for Gray coding */ - ) -{ - unsigned int field = 0; - unsigned int t; - - do { - unsigned int bI = *bitIndex; - unsigned int bitsLeft = WordSize - (bI & IndexMask); - unsigned int sliceWidth = - bitsLeft < fieldWidth ? bitsLeft : fieldWidth; - - field |= (((bitArray[bI >> ShiftRight] >> (bitsLeft - sliceWidth)) & ((1 << sliceWidth) - 1)) << (fieldWidth - sliceWidth)); - - *bitIndex = bI + sliceWidth; - fieldWidth -= sliceWidth; - } while ( fieldWidth != 0 ); - - if (gray) { - /* Convert from Gray code to binary. Works for maximum 8-bit fields. */ - t = field ^ (field >> 8); - t ^= (t >> 4); - t ^= (t >> 2); - t ^= (t >> 1); - } - else { - t = field; - } - - return t; -} diff --git a/codec2/src/phase.c b/codec2/src/phase.c deleted file mode 100644 index e1476862..00000000 --- a/codec2/src/phase.c +++ /dev/null @@ -1,253 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: phase.c - AUTHOR......: David Rowe - DATE CREATED: 1/2/09 - - Functions for modelling and synthesising phase. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2009 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not,see . -*/ - -#include "defines.h" -#include "phase.h" -#include "kiss_fft.h" -#include "comp.h" -#include "sine.h" - -#include -#include -#include -#include -#include - -/*---------------------------------------------------------------------------*\ - - aks_to_H() - - Samples the complex LPC synthesis filter spectrum at the harmonic - frequencies. - -\*---------------------------------------------------------------------------*/ - -void aks_to_H( - kiss_fft_cfg fft_fwd_cfg, - MODEL *model, /* model parameters */ - float aks[], /* LPC's */ - float G, /* energy term */ - COMP H[], /* complex LPC spectral samples */ - int order -) -{ - COMP pw[FFT_ENC]; /* power spectrum (input) */ - COMP Pw[FFT_ENC]; /* power spectrum (output) */ - int i,m; /* loop variables */ - int am,bm; /* limits of current band */ - float r; /* no. rads/bin */ - float Em; /* energy in band */ - float Am; /* spectral amplitude sample */ - int b; /* centre bin of harmonic */ - float phi_; /* phase of LPC spectra */ - - r = TWO_PI/(FFT_ENC); - - /* Determine DFT of A(exp(jw)) ------------------------------------------*/ - - for(i=0; iL; m++) { - am = (int)((m - 0.5)*model->Wo/r + 0.5); - bm = (int)((m + 0.5)*model->Wo/r + 0.5); - b = (int)(m*model->Wo/r + 0.5); - - Em = 0.0; - for(i=am; iWo)*N/2; - */ - - ex_phase[0] += (model->Wo)*N; - ex_phase[0] -= TWO_PI*floorf(ex_phase[0]/TWO_PI + 0.5); - - for(m=1; m<=model->L; m++) { - - /* generate excitation */ - - if (model->voiced) { - - Ex[m].real = cosf(ex_phase[0]*m); - Ex[m].imag = sinf(ex_phase[0]*m); - } - else { - - /* When a few samples were tested I found that LPC filter - phase is not needed in the unvoiced case, but no harm in - keeping it. - */ - float phi = TWO_PI*(float)codec2_rand()/CODEC2_RAND_MAX; - Ex[m].real = cosf(phi); - Ex[m].imag = sinf(phi); - } - - /* filter using LPC filter */ - - A_[m].real = H[m].real*Ex[m].real - H[m].imag*Ex[m].imag; - A_[m].imag = H[m].imag*Ex[m].real + H[m].real*Ex[m].imag; - - /* modify sinusoidal phase */ - - new_phi = atan2f(A_[m].imag, A_[m].real+1E-12); - model->phi[m] = new_phi; - } - -} - diff --git a/codec2/src/phase.h b/codec2/src/phase.h deleted file mode 100644 index 367948df..00000000 --- a/codec2/src/phase.h +++ /dev/null @@ -1,39 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: phase.h - AUTHOR......: David Rowe - DATE CREATED: 1/2/09 - - Functions for modelling phase. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2009 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#ifndef __PHASE__ -#define __PHASE__ - -#include "kiss_fft.h" - -void phase_synth_zero_order(kiss_fft_cfg fft_dec_cfg, - MODEL *model, - float aks[], - float *ex_phase, - int order); - -#endif diff --git a/codec2/src/phaseexp.c b/codec2/src/phaseexp.c deleted file mode 100644 index be2ad9be..00000000 --- a/codec2/src/phaseexp.c +++ /dev/null @@ -1,1455 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: phaseexp.c - AUTHOR......: David Rowe - DATE CREATED: June 2012 - - Experimental functions for quantising, modelling and synthesising phase. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2012 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not,see . -*/ - -#include "defines.h" -#include "phase.h" -#include "kiss_fft.h" -#include "comp.h" - -#include -#include -#include -#include -#include - -/* Bruce Perens' funcs to load codebook files */ - -struct codebook { - unsigned int k; - unsigned int log2m; - unsigned int m; - COMP *cb; - unsigned int offset; -}; - -static const char format[] = -"The table format must be:\n" -"\tTwo integers describing the dimensions of the codebook.\n" -"\tThen, enough numbers to fill the specified dimensions.\n"; - -float get_float(FILE * in, const char * name, char * * cursor, char * buffer, int size) -{ - for ( ; ; ) { - char * s = *cursor; - char c; - - while ( (c = *s) != '\0' && !isdigit(c) && c != '-' && c != '.' ) - s++; - - /* Comments start with "#" and continue to the end of the line. */ - if ( c != '\0' && c != '#' ) { - char * end = 0; - float f = 0; - - f = strtod(s, &end); - - if ( end != s ) - *cursor = end; - return f; - } - - if ( fgets(buffer, size, in) == NULL ) { - fprintf(stderr, "%s: Format error. %s\n", name, format); - exit(1); - } - *cursor = buffer; - } -} - -static struct codebook *load(const char * name) -{ - FILE *file; - char line[2048]; - char *cursor = line; - struct codebook *b = malloc(sizeof(struct codebook)); - int i; - int size; - float angle; - - file = fopen(name, "rt"); - assert(file != NULL); - - *cursor = '\0'; - - b->k = (int)get_float(file, name, &cursor, line, sizeof(line)); - b->m = (int)get_float(file, name ,&cursor, line, sizeof(line)); - size = b->k * b->m; - - b->cb = (COMP *)malloc(size * sizeof(COMP)); - - for ( i = 0; i < size; i++ ) { - angle = get_float(file, name, &cursor, line, sizeof(line)); - b->cb[i].real = cos(angle); - b->cb[i].imag = sin(angle); - } - - fclose(file); - - return b; -} - - -/* states for phase experiments */ - -struct PEXP { - float phi1; - float phi_prev[MAX_AMP]; - float Wo_prev; - int frames; - float snr; - float var; - int var_n; - struct codebook *vq1,*vq2,*vq3,*vq4,*vq5; - float vq_var; - int vq_var_n; - MODEL prev_model; - int state; -}; - - -/*---------------------------------------------------------------------------* \ - - phase_experiment_create() - - Inits states for phase quantisation experiments. - -\*---------------------------------------------------------------------------*/ - -struct PEXP * phase_experiment_create() { - struct PEXP *pexp; - int i; - - pexp = (struct PEXP *)malloc(sizeof(struct PEXP)); - assert (pexp != NULL); - - pexp->phi1 = 0; - for(i=0; iphi_prev[i] = 0.0; - pexp->Wo_prev = 0.0; - pexp->frames = 0; - pexp->snr = 0.0; - pexp->var = 0.0; - pexp->var_n = 0; - - /* smoothed 10th order for 1st 1 khz */ - //pexp->vq1 = load("../unittest/ph1_10_1024.txt"); - //pexp->vq1->offset = 0; - - /* load experimental phase VQ */ - - //pexp->vq1 = load("../unittest/testn1_20_1024.txt"); - pexp->vq1 = load("../unittest/test.txt"); - //pexp->vq2 = load("../unittest/testn21_40_1024.txt"); - pexp->vq2 = load("../unittest/test11_20_1024.txt"); - pexp->vq3 = load("../unittest/test21_30_1024.txt"); - pexp->vq4 = load("../unittest/test31_40_1024.txt"); - pexp->vq5 = load("../unittest/test41_60_1024.txt"); - pexp->vq1->offset = 0; - pexp->vq2->offset = 10; - pexp->vq3->offset = 20; - pexp->vq4->offset = 30; - pexp->vq5->offset = 40; - - pexp->vq_var = 0.0; - pexp->vq_var_n = 0; - - pexp->state = 0; - - return pexp; -} - - -/*---------------------------------------------------------------------------* \ - - phase_experiment_destroy() - -\*---------------------------------------------------------------------------*/ - -void phase_experiment_destroy(struct PEXP *pexp) { - assert(pexp != NULL); - if (pexp->snr != 0.0) - printf("snr: %4.2f dB\n", pexp->snr/pexp->frames); - if (pexp->var != 0.0) - printf("var...: %4.3f std dev...: %4.3f (%d non zero phases)\n", - pexp->var/pexp->var_n, sqrt(pexp->var/pexp->var_n), pexp->var_n); - if (pexp->vq_var != 0.0) - printf("vq var: %4.3f vq std dev: %4.3f (%d non zero phases)\n", - pexp->vq_var/pexp->vq_var_n, sqrt(pexp->vq_var/pexp->vq_var_n), pexp->vq_var_n); - free(pexp); -} - - -/*---------------------------------------------------------------------------* \ - - Various test and experimental functions ................ - -\*---------------------------------------------------------------------------*/ - -/* Bubblesort to find highest amplitude harmonics */ - -struct AMPINDEX { - float amp; - int index; -}; - -static void bubbleSort(struct AMPINDEX numbers[], int array_size) -{ - int i, j; - struct AMPINDEX temp; - - for (i = (array_size - 1); i > 0; i--) - { - for (j = 1; j <= i; j++) - { - //printf("i %d j %d %f %f \n", i, j, numbers[j-1].amp, numbers[j].amp); - if (numbers[j-1].amp < numbers[j].amp) - { - temp = numbers[j-1]; - numbers[j-1] = numbers[j]; - numbers[j] = temp; - } - } - } -} - - -static void print_pred_error(struct PEXP *pexp, MODEL *model, int start, int end, float mag_thresh) { - int i; - float mag; - - mag = 0.0; - for(i=start; i<=end; i++) - mag += model->A[i]*model->A[i]; - mag = 10*log10(mag/(end-start)); - - if (mag > mag_thresh) { - for(i=start; i<=end; i++) { - float pred = pexp->phi_prev[i] + N*i*(model->Wo + pexp->Wo_prev)/2.0; - float err = pred - model->phi[i]; - err = atan2(sin(err),cos(err)); - printf("%f\n",err); - } - //printf("\n"); - } - -} - - -static void predict_phases(struct PEXP *pexp, MODEL *model, int start, int end) { - int i; - - for(i=start; i<=end; i++) { - model->phi[i] = pexp->phi_prev[i] + N*i*model->Wo; - } - -} -static float refine_Wo(struct PEXP *pexp, - MODEL *model, - int start, - int end); - -/* Fancy state based phase prediction. Actually works OK on most utterances, - but could use some tuning. Breaks down a bit on mmt1. */ - -static void predict_phases_state(struct PEXP *pexp, MODEL *model, int start, int end) { - int i, next_state; - float best_Wo, dWo; - - //best_Wo = refine_Wo(pexp, model, start, end); - //best_Wo = (model->Wo + pexp->Wo_prev)/2.0; - best_Wo = model->Wo; - - dWo = fabs(model->Wo - pexp->Wo_prev)/model->Wo; - next_state = pexp->state; - switch(pexp->state) { - case 0: - if (dWo < 0.1) { - /* UV -> V transition, so start with phases in lock. They will - drift a bit over voiced track which is kinda what we want, so - we don't get clicky speech. - */ - next_state = 1; - for(i=start; i<=end; i++) - pexp->phi_prev[i] = i*pexp->phi1; - } - - break; - case 1: - if (dWo > 0.1) - next_state = 0; - break; - } - pexp->state = next_state; - - if (pexp->state == 0) - for(i=start; i<=end; i++) { - model->phi[i] = PI*(1.0 - 2.0*rand()/RAND_MAX); - } - else - for(i=start; i<=end; i++) { - model->phi[i] = pexp->phi_prev[i] + N*i*best_Wo; - } - printf("state %d\n", pexp->state); -} - -static void struct_phases(struct PEXP *pexp, MODEL *model, int start, int end) { - int i; - - for(i=start; i<=end; i++) - model->phi[i] = pexp->phi1*i; - -} - - -static void predict_phases2(struct PEXP *pexp, MODEL *model, int start, int end) { - int i; - float pred, str, diff; - - for(i=start; i<=end; i++) { - pred = pexp->phi_prev[i] + N*i*model->Wo; - str = pexp->phi1*i; - diff = str - pred; - diff = atan2(sin(diff), cos(diff)); - if (diff > 0) - pred += PI/16; - else - pred -= PI/16; - model->phi[i] = pred; - } - -} - -static void rand_phases(MODEL *model, int start, int end) { - int i; - - for(i=start; i<=end; i++) - model->phi[i] = PI*(1.0 - 2.0*(float)rand()/RAND_MAX); - -} - -static void quant_phase(float *phase, float min, float max, int bits) { - int levels = 1 << bits; - int index; - float norm, step; - - norm = (*phase - min)/(max - min); - index = floor(levels*norm); - - //printf("phase %f norm %f index %d ", *phase, norm, index); - if (index < 0 ) index = 0; - if (index > (levels-1)) index = levels-1; - //printf("index %d ", index); - step = (max - min)/levels; - *phase = min + step*index + 0.5*step; - //printf("step %f phase %f\n", step, *phase); -} - -static void quant_phases(MODEL *model, int start, int end, int bits) { - int i; - - for(i=start; i<=end; i++) { - quant_phase(&model->phi[i], -PI, PI, bits); - } -} - -static void fixed_bits_per_frame(struct PEXP *pexp, MODEL *model, int m, int budget) { - int res, finished; - - res = 3; - finished = 0; - - while(!finished) { - if (m > model->L/2) - res = 2; - if (((budget - res) < 0) || (m > model->L)) - finished = 1; - else { - quant_phase(&model->phi[m], -PI, PI, res); - budget -= res; - m++; - } - } - printf("m: %d L: %d budget: %d\n", m, model->L, budget); - predict_phases(pexp, model, m, model->L); - //rand_phases(model, m, model->L); -} - -/* used to plot histogram of quantisation error, for 3 bits, 8 levels, - should be uniform between +/- PI/8 */ - -static void check_phase_quant(MODEL *model, float tol) -{ - int m; - float phi_before[MAX_AMP]; - - for(m=1; m<=model->L; m++) - phi_before[m] = model->phi[m]; - - quant_phases(model, 1, model->L, 3); - - for(m=1; m<=model->L; m++) { - float err = phi_before[m] - model->phi[m]; - printf("%f\n", err); - if (fabs(err) > tol) - exit(0); - } -} - - -static float est_phi1(MODEL *model, int start, int end) -{ - int m; - float delta, s, c, phi1_est; - - if (end > model->L) - end = model->L; - - s = c = 0.0; - for(m=start; mphi[m+1] - model->phi[m]; - s += sin(delta); - c += cos(delta); - } - - phi1_est = atan2(s,c); - - return phi1_est; -} - -static void print_phi1_pred_error(MODEL *model, int start, int end) -{ - int m; - float phi1_est; - - phi1_est = est_phi1(model, start, end); - - for(m=start; mphi[m+1] - model->phi[m] - phi1_est; - err = atan2(sin(err),cos(err)); - printf("%f\n", err); - } -} - - -static void first_order_band(MODEL *model, int start, int end, float phi1_est) -{ - int m; - float pred_err, av_pred_err; - float c,s; - - s = c = 0.0; - for(m=start; mphi[m] - phi1_est*m; - s += sin(pred_err); - c += cos(pred_err); - } - - av_pred_err = atan2(s,c); - for(m=start; mphi[m] = av_pred_err + phi1_est*m; - model->phi[m] = atan2(sin(model->phi[m]), cos(model->phi[m])); - } - -} - - -static void sub_linear(MODEL *model, int start, int end, float phi1_est) -{ - int m; - - for(m=start; mphi[m] = m*phi1_est; - } -} - - -static void top_amp(struct PEXP *pexp, MODEL *model, int start, int end, int n_harm, int pred) -{ - int removed = 0, not_removed = 0; - int top, i, j; - struct AMPINDEX sorted[MAX_AMP]; - - /* sort into ascending order of amplitude */ - - printf("\n"); - for(i=start,j=0; iA[i]; - sorted[j].index = i; - printf("%f ", model->A[i]); - } - bubbleSort(sorted, end-start); - - printf("\n"); - for(j=0; jA[i] == sorted[j].amp) { - top = 1; - assert(i == sorted[j].index); - } - } - - #define ALTTOP - #ifdef ALTTOP - model->phi[i] = 0.0; /* make sure */ - if (top) { - model->phi[i] = i*pexp->phi1; - removed++; - } - else { - model->phi[i] = PI*(1.0 - 2.0*(float)rand()/RAND_MAX); // note: try rand for higher harms - removed++; - } - #else - if (!top) { - model->phi[i] = 0.0; /* make sure */ - if (pred) { - //model->phi[i] = pexp->phi_prev[i] + i*N*(model->Wo + pexp->Wo_prev)/2.0; - model->phi[i] = i*model->phi[1]; - } - else - model->phi[i] = PI*(1.0 - 2.0*(float)rand()/RAND_MAX); // note: try rand for higher harms - removed++; - } - else { - /* need to make this work thru budget of bits */ - quant_phase(&model->phi[i], -PI, PI, 3); - not_removed++; - } - #endif - } - printf("dim: %d rem %d not_rem %d\n", end-start, removed, not_removed); - -} - - -static void limit_prediction_error(struct PEXP *pexp, MODEL *model, int start, int end, float limit) -{ - int i; - float pred, pred_error, error; - - for(i=start; i<=end; i++) { - pred = pexp->phi_prev[i] + N*i*(model->Wo + pexp->Wo_prev)/2.0; - pred_error = pred - model->phi[i]; - pred_error -= TWO_PI*floor((pred_error+PI)/TWO_PI); - quant_phase(&pred_error, -limit, limit, 2); - - error = pred - pred_error - model->phi[i]; - error -= TWO_PI*floor((error+PI)/TWO_PI); - printf("%f\n", pred_error); - model->phi[i] = pred - pred_error; - } -} - - -static void quant_prediction_error(struct PEXP *pexp, MODEL *model, int start, int end, float limit) -{ - int i; - float pred, pred_error; - - for(i=start; i<=end; i++) { - pred = pexp->phi_prev[i] + N*i*(model->Wo + pexp->Wo_prev)/2.0; - pred_error = pred - model->phi[i]; - pred_error -= TWO_PI*floor((pred_error+PI)/TWO_PI); - - printf("%f\n", pred_error); - model->phi[i] = pred - pred_error; - } -} - - -static void print_sparse_pred_error(struct PEXP *pexp, MODEL *model, int start, int end, float mag_thresh) -{ - int i, index; - float mag, pred, error; - float sparse_pe[MAX_AMP]; - - mag = 0.0; - for(i=start; i<=end; i++) - mag += model->A[i]*model->A[i]; - mag = 10*log10(mag/(end-start)); - - if (mag > mag_thresh) { - for(i=0; iphi_prev[i] + N*i*(model->Wo + pexp->Wo_prev)/2.0; - error = pred - model->phi[i]; - error = atan2(sin(error),cos(error)); - - index = MAX_AMP*i*model->Wo/PI; - assert(index < MAX_AMP); - sparse_pe[index] = error; - } - - /* dump spare phase vector in polar format */ - - for(i=0; iL; m++) { - signal += model->A[m]*model->A[m]; - diff = cos(model->phi[m]) - cos(before[m]); - noise += pow(model->A[m]*diff, 2.0); - diff = sin(model->phi[m]) - sin(before[m]); - noise += pow(model->A[m]*diff, 2.0); - //printf("%f %f\n", before[m], model->phi[m]); - } - //printf("%f %f snr = %f\n", signal, noise, 10.0*log10(signal/noise)); - pexp->snr += 10.0*log10(signal/noise); -} - - -static void update_variance_calc(struct PEXP *pexp, MODEL *model, float before[]) -{ - int m; - float diff; - - for(m=1; mL; m++) { - diff = model->phi[m] - before[m]; - diff = atan2(sin(diff), cos(diff)); - pexp->var += diff*diff; - } - pexp->var_n += model->L; -} - -void print_vec(COMP cb[], int d, int e) -{ - int i,j; - - for(j=0; jWo + pexp->Wo_prev)/2.0; - best_var = 1E32; - for(Wo=0.97*Wo_est; Wo<=1.03*Wo_est; Wo+=0.001*Wo_est) { - - /* predict phase and sum differences between harmonics */ - - var = 0.0; - for(i=start; i<=end; i++) { - pred = pexp->phi_prev[i] + N*i*Wo; - error = pred - model->phi[i]; - error = atan2(sin(error),cos(error)); - var += error*error; - } - - if (var < best_var) { - best_var = var; - best_Wo = Wo; - } - } - - return best_Wo; -} - - -static void split_vq(COMP sparse_pe_out[], struct PEXP *pexp, struct codebook *vq, float weights[], COMP sparse_pe_in[]) -{ - int i, j, non_zero, vq_ind; - - //printf("\n offset %d k %d m %d j: ", vq->offset, vq->k, vq->m); - vq_ind = vq_phase(vq->cb, &sparse_pe_in[vq->offset], &weights[vq->offset], vq->k, vq->m, &pexp->vq_var); - - non_zero = 0; - for(i=0, j=vq->offset; ik; i++,j++) { - //printf("%f ", atan2(sparse_pe[i].imag, sparse_pe[i].real)); - if ((sparse_pe_in[j].real != 0.0) && (sparse_pe_in[j].imag != 0.0)) { - //printf("%d ", j); - sparse_pe_out[j] = vq->cb[vq->k * vq_ind + i]; - non_zero++; - } - } - pexp->vq_var_n += non_zero; -} - - -static void sparse_vq_pred_error(struct PEXP *pexp, - MODEL *model -) -{ - int i, index; - float pred, error, error_q_angle, best_Wo; - COMP sparse_pe_in[MAX_AMP], sparse_pe_out[MAX_AMP]; - float weights[MAX_AMP]; - COMP error_q_rect; - - best_Wo = refine_Wo(pexp, model, 1, model->L); - //best_Wo = (model->Wo + pexp->Wo_prev)/2.0; - - /* transform to sparse pred error vector */ - - for(i=0; iL; i++) { - pred = pexp->phi_prev[i] + N*i*best_Wo; - error = pred - model->phi[i]; - - index = MAX_AMP*i*model->Wo/PI; - assert(index < MAX_AMP); - sparse_pe_in[index].real = cos(error); - sparse_pe_in[index].imag = sin(error); - sparse_pe_out[index] = sparse_pe_in[index]; - weights[index] = model->A[i]; - //printf("%d ", index); - } - - /* vector quantise */ - - split_vq(sparse_pe_out, pexp, pexp->vq1, weights, sparse_pe_in); - split_vq(sparse_pe_out, pexp, pexp->vq2, weights, sparse_pe_in); - split_vq(sparse_pe_out, pexp, pexp->vq3, weights, sparse_pe_in); - split_vq(sparse_pe_out, pexp, pexp->vq4, weights, sparse_pe_in); - split_vq(sparse_pe_out, pexp, pexp->vq5, weights, sparse_pe_in); - - /* transform quantised phases back */ - - for(i=1; i<=model->L; i++) { - pred = pexp->phi_prev[i] + N*i*best_Wo; - - index = MAX_AMP*i*model->Wo/PI; - assert(index < MAX_AMP); - error_q_rect = sparse_pe_out[index]; - error_q_angle = atan2(error_q_rect.imag, error_q_rect.real); - model->phi[i] = pred - error_q_angle; - model->phi[i] = atan2(sin(model->phi[i]), cos(model->phi[i])); - } -} - - -static void predict_phases1(struct PEXP *pexp, MODEL *model, int start, int end) { - int i; - float best_Wo; - - best_Wo = refine_Wo(pexp, model, 1, model->L); - - for(i=start; i<=end; i++) { - model->phi[i] = pexp->phi_prev[i] + N*i*best_Wo; - } -} - - -/* - This functions tests theory that some bands can be combined together - due to less frequency resolution at higher frequencies. This will - reduce the amount of information we need to encode. -*/ - -void smooth_phase(struct PEXP *pexp, MODEL *model, int mode) -{ - int m, i, j, index, step, v, en, nav, st; - COMP sparse_pe_in[MAX_AMP], av; - COMP sparse_pe_out[MAX_AMP]; - COMP smoothed[MAX_AMP]; - float best_Wo, pred, err; - float weights[MAX_AMP]; - float avw, smoothed_weights[MAX_AMP]; - COMP smoothed_in[MAX_AMP], smoothed_out[MAX_AMP]; - - best_Wo = refine_Wo(pexp, model, 1, model->L); - - for(m=0; mL; m++) { - pred = pexp->phi_prev[m] + N*m*best_Wo; - err = model->phi[m] - pred; - err = atan2(sin(err),cos(err)); - - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - sparse_pe_in[index].real = model->A[m]*cos(err); - sparse_pe_in[index].imag = model->A[m]*sin(err); - sparse_pe_out[index] = sparse_pe_in[index]; - weights[index] = model->A[m]; - } - - /* now combine samples at high frequencies to reduce dimension */ - - step = 2; - st = 0; - for(i=st,v=0; i (MAX_AMP-1)) - en = MAX_AMP-1; - for(j=i; jvq1, smoothed_weights, smoothed_in); - for(i=0; i (MAX_AMP-1)) - en = MAX_AMP-1; - for(j=i; jL; m++) { - index = MAX_AMP*m*model->Wo/PI; - assert(index < MAX_AMP); - pred = pexp->phi_prev[m] + N*m*best_Wo; - err = atan2(sparse_pe_out[index].imag, sparse_pe_out[index].real); - model->phi[m] = pred + err; - } - -} - -/* - Another version of a functions that tests the theory that some bands - can be combined together due to less frequency resolution at higher - frequencies. This will reduce the amount of information we need to - encode. -*/ - -void smooth_phase2(struct PEXP *pexp, MODEL *model) { - float m; - float step; - int a,b,h,i; - float best_Wo, pred, err, s,c, phi1_; - - best_Wo = refine_Wo(pexp, model, 1, model->L); - - step = (float)model->L/30; - printf("\nL: %d step: %3.2f am,bm: ", model->L, step); - for(m=(float)model->L/4; m<=model->L; m+=step) { - a = floor(m); - b = floor(m+step); - if (b > model->L) b = model->L; - h = b-a; - - printf("%d,%d,(%d) ", a, b, h); - c = s = 0.0; - if (h>1) { - for(i=a; iphi_prev[i] + N*i*best_Wo; - err = model->phi[i] - pred; - c += cos(err); s += sin(err); - } - phi1_ = atan2(s,c); - for(i=a; iphi_prev[i] + N*i*best_Wo; - printf("%d: %4.3f -> ", i, model->phi[i]); - model->phi[i] = pred + phi1_; - model->phi[i] = atan2(sin(model->phi[i]),cos(model->phi[i])); - printf("%4.3f ", model->phi[i]); - } - } - } -} - - -#define MAX_BINS 40 -//static float bins[] = {2600.0, 2800.0, 3000.0, 3200.0, 3400.0, 3600.0, 3800.0, 4000.0}; -static float bins[] = {/* - - 1000.0, 1100.0, 1200.0, 1300.0, 1400.0, - 1500.0, 1600.0, 1700.0, 1800.0, 1900.0,*/ - - 2000.0, 2400.0, 2800.0, - 3000.0, 3400.0, 3600.0, 4000.0}; - -void smooth_phase3(struct PEXP *pexp, MODEL *model) { - int m, i; - int nbins; - int b; - float f, best_Wo, pred, err; - COMP av[MAX_BINS]; - - nbins = sizeof(bins)/sizeof(float); - best_Wo = refine_Wo(pexp, model, 1, model->L); - - /* clear all bins */ - - for(i=0; iL; m++) { - f = m*model->Wo*FS/TWO_PI; - if (f > bins[0]) { - - /* find bin */ - - for(i=0; i bins[i]) && (f <= bins[i+1])) - b = i; - assert(b < MAX_BINS); - - /* est predicted phase from average */ - - pred = pexp->phi_prev[m] + N*m*best_Wo; - err = model->phi[m] - pred; - av[b].real += cos(err); av[b].imag += sin(err); - } - - } - - /* use averages to est phases */ - - for(m=1; m<=model->L; m++) { - f = m*model->Wo*FS/TWO_PI; - if (f > bins[0]) { - - /* find bin */ - - for(i=0; i bins[i]) && (f <= bins[i+1])) - b = i; - assert(b < MAX_BINS); - - /* add predicted phase error to this bin */ - - printf("L %d m %d f %4.f b %d\n", model->L, m, f, b); - - pred = pexp->phi_prev[m] + N*m*best_Wo; - err = atan2(av[b].imag, av[b].real); - printf(" %d: %4.3f -> ", m, model->phi[m]); - model->phi[m] = pred + err; - model->phi[m] = atan2(sin(model->phi[m]),cos(model->phi[m])); - printf("%4.3f\n", model->phi[m]); - } - } - printf("\n"); -} - - -/* - Try to code the phase of the largest amplitude in each band. Randomise the - phase of the other harmonics. The theory is that only the largest harmonic - will be audible. -*/ - -void cb_phase1(struct PEXP *pexp, MODEL *model) { - int m, i; - int nbins; - int b; - float f, best_Wo; - float max_val[MAX_BINS]; - int max_ind[MAX_BINS]; - - nbins = sizeof(bins)/sizeof(float); - best_Wo = refine_Wo(pexp, model, 1, model->L); - - for(i=0; iL; m++) { - f = m*model->Wo*FS/TWO_PI; - if (f > bins[0]) { - - /* find bin */ - - for(i=0; i bins[i]) && (f <= bins[i+1])) - b = i; - assert(b < MAX_BINS); - - if (model->A[m] > max_val[b]) { - max_val[b] = model->A[m]; - max_ind[b] = m; - } - } - - } - - /* randomise phase of other harmonics */ - - for(m=1; m<=model->L; m++) { - f = m*model->Wo*FS/TWO_PI; - if (f > bins[0]) { - - /* find bin */ - - for(i=0; i bins[i]) && (f <= bins[i+1])) - b = i; - assert(b < MAX_BINS); - - if (m != max_ind[b]) - model->phi[m] = pexp->phi_prev[m] + N*m*best_Wo; - } - } -} - - -/* - Theory is only the phase of the envelope of signal matters within a - Critical Band. So we estimate the position of an impulse that - approximates the envelope of the signal. -*/ - -void cb_phase2(struct PEXP *pexp, MODEL *model) { - int st, m, i, a, b, step; - float diff,w,c,s,phi1_; - float A[MAX_AMP]; - - for(m=1; m<=model->L; m++) { - A[m] = model->A[m]; - model->A[m] = 0; - } - - st = 2*model->L/4; - step = 3; - model->phi[1] = pexp->phi_prev[1] + (pexp->Wo_prev+model->Wo)*N/2.0; - - printf("L=%d ", model->L); - for(m=st; m model->L) - b = model->L; - - c = s = 0; - for(i=a; iphi[i+1] - model->phi[i]; - //w = (model->A[i+1] + model->A[i])/2; - w = 1.0; - c += w*cos(diff); s += w*sin(diff); - } - phi1_ = atan2(s,c); - printf("replacing: "); - for(i=a; iphi[i] = i*phi1_; - //model->phi[i] = i*model->phi[1]; - //model->phi[i] = m*(pexp->Wo_prev+model->Wo)*N/2.0; - model->A[m] = A[m]; - printf("%d ", i); - } - printf(" . "); - } - printf("\n"); -} - - -static void smooth_phase4(MODEL *model) { - int m; - float phi_m, phi_m_1; - - if (model->L > 25) { - printf("\nL %d\n", model->L); - for(m=model->L/2; m<=model->L; m+=2) { - if ((m+1) <= model->L) { - phi_m = (model->phi[m] - model->phi[m+1])/2.0; - phi_m_1 = (model->phi[m+1] - model->phi[m])/2.0; - model->phi[m] = phi_m; - model->phi[m+1] = phi_m_1; - printf("%d %4.3f %4.3f ", m, phi_m, phi_m_1); - } - } - } - -} - -/* try repeating last frame, just advance phases to account for time shift */ - -static void repeat_phases(struct PEXP *pexp, MODEL *model) { - int m; - - *model = pexp->prev_model; - for(m=1; m<=model->L; m++) - model->phi[m] += N*m*model->Wo; - -} - -/*---------------------------------------------------------------------------*\ - - phase_experiment() - - Phase quantisation experiments. - -\*---------------------------------------------------------------------------*/ - -void phase_experiment(struct PEXP *pexp, MODEL *model, char *arg) { - int m; - float before[MAX_AMP]; - - assert(pexp != NULL); - memcpy(before, &model->phi[0], sizeof(float)*MAX_AMP); - - if (strcmp(arg,"q3") == 0) { - quant_phases(model, 1, model->L, 3); - update_snr_calc(pexp, model, before); - update_variance_calc(pexp, model, before); - } - - if (strcmp(arg,"dec2") == 0) { - if ((pexp->frames % 2) != 0) { - predict_phases(pexp, model, 1, model->L); - update_snr_calc(pexp, model, before); - update_variance_calc(pexp, model, before); - } - } - - if (strcmp(arg,"repeat") == 0) { - if ((pexp->frames % 2) != 0) { - repeat_phases(pexp, model); - update_snr_calc(pexp, model, before); - update_variance_calc(pexp, model, before); - } - } - - if (strcmp(arg,"vq") == 0) { - sparse_vq_pred_error(pexp, model); - update_snr_calc(pexp, model, before); - update_variance_calc(pexp, model, before); - } - - if (strcmp(arg,"pred") == 0) - predict_phases_state(pexp, model, 1, model->L); - - if (strcmp(arg,"pred1k") == 0) - predict_phases(pexp, model, 1, model->L/4); - - if (strcmp(arg,"smooth") == 0) { - smooth_phase(pexp, model,0); - update_snr_calc(pexp, model, before); - } - if (strcmp(arg,"smoothtrain") == 0) - smooth_phase(pexp, model,1); - if (strcmp(arg,"smoothvq") == 0) { - smooth_phase(pexp, model,2); - update_snr_calc(pexp, model, before); - } - - if (strcmp(arg,"smooth2") == 0) - smooth_phase2(pexp, model); - if (strcmp(arg,"smooth3") == 0) - smooth_phase3(pexp, model); - if (strcmp(arg,"smooth4") == 0) - smooth_phase4(model); - if (strcmp(arg,"vqsmooth3") == 0) { - sparse_vq_pred_error(pexp, model); - smooth_phase3(pexp, model); - } - - if (strcmp(arg,"cb1") == 0) { - cb_phase1(pexp, model); - update_snr_calc(pexp, model, before); - } - - if (strcmp(arg,"top") == 0) { - //top_amp(pexp, model, 1, model->L/4, 4, 1); - //top_amp(pexp, model, model->L/4, model->L/3, 4, 1); - //top_amp(pexp, model, model->L/3+1, model->L/2, 4, 1); - //top_amp(pexp, model, model->L/2, model->L, 6, 1); - //rand_phases(model, model->L/2, 3*model->L/4); - //struct_phases(pexp, model, model->L/2, 3*model->L/4); - //update_snr_calc(pexp, model, before); - } - - if (strcmp(arg,"pred23") == 0) { - predict_phases2(pexp, model, model->L/2, model->L); - update_snr_calc(pexp, model, before); - } - - if (strcmp(arg,"struct23") == 0) { - struct_phases(pexp, model, model->L/2, 3*model->L/4 ); - update_snr_calc(pexp, model, before); - } - - if (strcmp(arg,"addnoise") == 0) { - int m; - float max; - - max = 0; - for(m=1; m<=model->L; m++) - if (model->A[m] > max) - max = model->A[m]; - max = 20.0*log10(max); - for(m=1; m<=model->L; m++) - if (20.0*log10(model->A[m]) < (max-20)) { - model->phi[m] += (PI/4)*(1.0 -2.0*rand()/RAND_MAX); - //printf("m %d\n", m); - } - } - - /* normalise phases */ - - for(m=1; m<=model->L; m++) - model->phi[m] = atan2(sin(model->phi[m]), cos(model->phi[m])); - - /* update states */ - - //best_Wo = refine_Wo(pexp, model, model->L/2, model->L); - pexp->phi1 += N*model->Wo; - - for(m=1; m<=model->L; m++) - pexp->phi_prev[m] = model->phi[m]; - pexp->Wo_prev = model->Wo; - pexp->frames++; - pexp->prev_model = *model; -} - -#ifdef OLD_STUFF - //quant_phases(model, 1, model->L, 3); - //update_variance_calc(pexp, model, before); - //print_sparse_pred_error(pexp, model, 1, model->L, 40.0); - - //sparse_vq_pred_error(pexp, model); - - //quant_phases(model, model->L/4+1, model->L, 3); - - //predict_phases1(pexp, model, 1, model->L/4); - //quant_phases(model, model->L/4+1, model->L, 3); - - //quant_phases(model, 1, model->L/8, 3); - - //update_snr_calc(pexp, model, before); - //update_variance_calc(pexp, model, before); - - //fixed_bits_per_frame(pexp, model, 40); - //struct_phases(pexp, model, 1, model->L/4); - //rand_phases(model, 10, model->L); - //for(m=1; m<=model->L; m++) - // model->A[m] = 0.0; - //model->A[model->L/2] = 1000; - //repeat_phases(model, 20); - //predict_phases(pexp, model, 1, model->L/4); - //quant_phases(model, 1, 10, 3); - //quant_phases(model, 10, 20, 2); - //repeat_phases(model, 20); - //rand_phases(model, 3*model->L/4, model->L); - // print_phi1_pred_error(model, 1, model->L); - //predict_phases(pexp, model, 1, model->L/4); - //first_order_band(model, model->L/4, model->L/2); - //first_order_band(model, model->L/2, 3*model->L/4); - //if (fabs(model->Wo - pexp->Wo_prev)< 0.1*model->Wo) - - //print_pred_error(pexp, model, 1, model->L, 40.0); - //print_sparse_pred_error(pexp, model, 1, model->L, 40.0); - - //phi1_est = est_phi1(model, 1, model->L/4); - //print_phi1_pred_error(model, 1, model->L/4); - - //first_order_band(model, 1, model->L/4, phi1_est); - //sub_linear(model, 1, model->L/4, phi1_est); - - //top_amp(pexp, model, 1, model->L/4, 4); - //top_amp(pexp, model, model->L/4, model->L/2, 4); - - //first_order_band(model, 1, model->L/4, phi1_est); - //first_order_band(model, model->L/4, model->L/2, phi1_est); - - //if (fabs(model->Wo - pexp->Wo_prev) > 0.2*model->Wo) - // rand_phases(model, model->L/2, model->L); - - //top_amp(pexp, model, 1, model->L/4, 4); - //top_amp(pexp, model, model->L/4, model->L/2, 8); - //top_amp(pexp, model, model->L/4+1, model->L/2, 10, 1); - //top_amp(pexp, model, 1, model->L/4, 10, 1); - //top_amp(pexp, model, model->L/4+1, 3*model->L/4, 10, 1); - //top_amp(pexp, model, 1, 3*model->L/4, 20, 1); - - #ifdef REAS_CAND1 - predict_phases(pexp, model, 1, model->L/4); - top_amp(pexp, model, model->L/4+1, 3*model->L/4, 10, 1); - rand_phases(model, 3*model->L/4+1, model->L); - #endif - - #ifdef REAS_CAND2 - if ((pexp->frames % 2) == 0) { - //printf("quant\n"); - predict_phases(pexp, model, 1, model->L/4); - //top_amp(pexp, model, model->L/4+1, 3*model->L/4, 20, 1); - top_amp(pexp, model, model->L/4+1, 7*model->L/8, 20, 1); - rand_phases(model, 7*model->L/8+1, model->L); - } - else { - //printf("predict\n"); - predict_phases(pexp, model, 1, model->L); - } - #endif - - //#define REAS_CAND3 - #ifdef REAS_CAND3 - if ((pexp->frames % 3) != 0) { - printf("pred\n"); - predict_phases(pexp, model, 1, model->L); - } - else { - predict_phases(pexp, model, 1, model->L/4); - fixed_bits_per_frame(pexp, model, model->L/4+1, 60); - } - #endif - //predict_phases(pexp, model, model->L/4, model->L); - - - //print_pred_error(pexp, model, 1, model->L); - //limit_prediction_error(pexp, model, model->L/2, model->L, PI/2); -#endif diff --git a/codec2/src/phaseexp.h b/codec2/src/phaseexp.h deleted file mode 100644 index b43db75e..00000000 --- a/codec2/src/phaseexp.h +++ /dev/null @@ -1,39 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: phaseexp.h - AUTHOR......: David Rowe - DATE CREATED: June 2012 - - Experimental functions for quantising, modelling and synthesising phase. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2012 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#ifndef __PHASEEXP__ -#define __PHASEEXP__ - -#include "kiss_fft.h" - -struct PEXP; - -struct PEXP * phase_experiment_create(); -void phase_experiment_destroy(struct PEXP *pexp); -void phase_experiment(struct PEXP *pexp, MODEL *model, char *arg); - -#endif diff --git a/codec2/src/pilot_coeff.h b/codec2/src/pilot_coeff.h deleted file mode 100644 index b284af93..00000000 --- a/codec2/src/pilot_coeff.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Generated by pilot_coeff_file() Octave function */ - -const float pilot_coeff[]={ - 0.00223001, - 0.00301037, - 0.00471258, - 0.0075934, - 0.0118145, - 0.0174153, - 0.0242969, - 0.0322204, - 0.0408199, - 0.0496286, - 0.0581172, - 0.0657392, - 0.0719806, - 0.0764066, - 0.0787022, - 0.0787022, - 0.0764066, - 0.0719806, - 0.0657392, - 0.0581172, - 0.0496286, - 0.0408199, - 0.0322204, - 0.0242969, - 0.0174153, - 0.0118145, - 0.0075934, - 0.00471258, - 0.00301037, - 0.00223001 -}; diff --git a/codec2/src/postfilter.c b/codec2/src/postfilter.c deleted file mode 100644 index f347658c..00000000 --- a/codec2/src/postfilter.c +++ /dev/null @@ -1,142 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: postfilter.c - AUTHOR......: David Rowe - DATE CREATED: 13/09/09 - - Postfilter to improve sound quality for speech with high levels of - background noise. Unlike mixed-excitation models requires no bits - to be transmitted to handle background noise. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2009 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include - -#include "defines.h" -#include "comp.h" -#include "dump.h" -#include "sine.h" -#include "postfilter.h" - -/*---------------------------------------------------------------------------*\ - - DEFINES - -\*---------------------------------------------------------------------------*/ - -#define BG_THRESH 40.0 /* only consider low levels signals for bg_est */ -#define BG_BETA 0.1 /* averaging filter constant */ -#define BG_MARGIN 6.0 /* harmonics this far above BG noise are - randomised. Helped make bg noise less - spikey (impulsive) for mmt1, but speech was - perhaps a little rougher. - */ - -/*---------------------------------------------------------------------------*\ - - postfilter() - - The post filter is designed to help with speech corrupted by - background noise. The zero phase model tends to make speech with - background noise sound "clicky". With high levels of background - noise the low level inter-formant parts of the spectrum will contain - noise rather than speech harmonics, so modelling them as voiced - (i.e. a continuous, non-random phase track) is inaccurate. - - Some codecs (like MBE) have a mixed voicing model that breaks the - spectrum into voiced and unvoiced regions. Several bits/frame - (5-12) are required to transmit the frequency selective voicing - information. Mixed excitation also requires accurate voicing - estimation (parameter estimators always break occasionally under - exceptional conditions). - - In our case we use a post filter approach which requires no - additional bits to be transmitted. The decoder measures the average - level of the background noise during unvoiced frames. If a harmonic - is less than this level it is made unvoiced by randomising it's - phases. - - This idea is rather experimental. Some potential problems that may - happen: - - 1/ If someone says "aaaaaaaahhhhhhhhh" will background estimator track - up to speech level? This would be a bad thing. - - 2/ If background noise suddenly dissapears from the source speech does - estimate drop quickly? What is noise suddenly re-appears? - - 3/ Background noise with a non-flat sepctrum. Current algorithm just - comsiders scpetrum as a whole, but this could be broken up into - bands, each with their own estimator. - - 4/ Males and females with the same level of background noise. Check - performance the same. Changing Wo affects width of each band, may - affect bg energy estimates. - - 5/ Not sure what happens during long periods of voiced speech - e.g. "sshhhhhhh" - -\*---------------------------------------------------------------------------*/ - -void postfilter( - MODEL *model, - float *bg_est -) -{ - int m, uv; - float e, thresh; - - /* determine average energy across spectrum */ - - e = 1E-12; - for(m=1; m<=model->L; m++) - e += model->A[m]*model->A[m]; - - assert(e > 0.0); - e = 10.0*log10f(e/model->L); - - /* If beneath threhold, update bg estimate. The idea - of the threshold is to prevent updating during high level - speech. */ - - if ((e < BG_THRESH) && !model->voiced) - *bg_est = *bg_est*(1.0 - BG_BETA) + e*BG_BETA; - - /* now mess with phases during voiced frames to make any harmonics - less then our background estimate unvoiced. - */ - - uv = 0; - thresh = powf(10.0, (*bg_est + BG_MARGIN)/20.0); - if (model->voiced) - for(m=1; m<=model->L; m++) - if (model->A[m] < thresh) { - model->phi[m] = TWO_PI*(float)codec2_rand()/CODEC2_RAND_MAX; - uv++; - } - -#ifdef DUMP - dump_bg(e, *bg_est, 100.0*uv/model->L); -#endif - -} diff --git a/codec2/src/postfilter.h b/codec2/src/postfilter.h deleted file mode 100644 index bf080b1b..00000000 --- a/codec2/src/postfilter.h +++ /dev/null @@ -1,33 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: postfilter.h - AUTHOR......: David Rowe - DATE CREATED: 13/09/09 - - Postfilter header file. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2009 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#ifndef __POSTFILTER__ -#define __POSTFILTER__ - -void postfilter(MODEL *model, float *bg_est); - -#endif diff --git a/codec2/src/quantise.c b/codec2/src/quantise.c deleted file mode 100644 index 95a45ce6..00000000 --- a/codec2/src/quantise.c +++ /dev/null @@ -1,1970 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: quantise.c - AUTHOR......: David Rowe - DATE CREATED: 31/5/92 - - Quantisation functions for the sinusoidal coder. - -\*---------------------------------------------------------------------------*/ - -/* - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . - -*/ - -#include -#include -#include -#include -#include -#include - -#include "defines.h" -#include "dump.h" -#include "quantise.h" -#include "lpc.h" -#include "lsp.h" -#include "kiss_fft.h" -#undef TIMER -#include "machdep.h" - -#define LSP_DELTA1 0.01 /* grid spacing for LSP root searches */ - -/*---------------------------------------------------------------------------*\ - - FUNCTION HEADERS - -\*---------------------------------------------------------------------------*/ - -float speech_to_uq_lsps(float lsp[], float ak[], float Sn[], float w[], - int order); - -/*---------------------------------------------------------------------------*\ - - FUNCTIONS - -\*---------------------------------------------------------------------------*/ - -int lsp_bits(int i) { - return lsp_cb[i].log2m; -} - -int lspd_bits(int i) { - return lsp_cbd[i].log2m; -} - -#ifdef __EXPERIMENTAL__ -int lspdt_bits(int i) { - return lsp_cbdt[i].log2m; -} -#endif - -int lsp_pred_vq_bits(int i) { - return lsp_cbjvm[i].log2m; -} - -/*---------------------------------------------------------------------------*\ - - quantise_init - - Loads the entire LSP quantiser comprised of several vector quantisers - (codebooks). - -\*---------------------------------------------------------------------------*/ - -void quantise_init() -{ -} - -/*---------------------------------------------------------------------------*\ - - quantise - - Quantises vec by choosing the nearest vector in codebook cb, and - returns the vector index. The squared error of the quantised vector - is added to se. - -\*---------------------------------------------------------------------------*/ - -long quantise(const float * cb, float vec[], float w[], int k, int m, float *se) -/* float cb[][K]; current VQ codebook */ -/* float vec[]; vector to quantise */ -/* float w[]; weighting vector */ -/* int k; dimension of vectors */ -/* int m; size of codebook */ -/* float *se; accumulated squared error */ -{ - float e; /* current error */ - long besti; /* best index so far */ - float beste; /* best error so far */ - long j; - int i; - float diff; - - besti = 0; - beste = 1E32; - for(j=0; j 0); - mbest = (struct MBEST *)malloc(sizeof(struct MBEST)); - assert(mbest != NULL); - - mbest->entries = entries; - mbest->list = (struct MBEST_LIST *)malloc(entries*sizeof(struct MBEST_LIST)); - assert(mbest->list != NULL); - - for(i=0; ientries; i++) { - for(j=0; jlist[i].index[j] = 0; - mbest->list[i].error = 1E32; - } - - return mbest; -} - - -static void mbest_destroy(struct MBEST *mbest) { - assert(mbest != NULL); - free(mbest->list); - free(mbest); -} - - -/*---------------------------------------------------------------------------*\ - - mbest_insert - - Insert the results of a vector to codebook entry comparison. The - list is ordered in order or error, so those entries with the - smallest error will be first on the list. - -\*---------------------------------------------------------------------------*/ - -static void mbest_insert(struct MBEST *mbest, int index[], float error) { - int i, j, found; - struct MBEST_LIST *list = mbest->list; - int entries = mbest->entries; - - found = 0; - for(i=0; ii; j--) - list[j] = list[j-1]; - for(j=0; jentries; i++) { - for(j=0; jlist[i].index[j]); - printf(" %f\n", mbest->list[i].error); - } -} - - -/*---------------------------------------------------------------------------*\ - - mbest_search - - Searches vec[] to a codebbook of vectors, and maintains a list of the mbest - closest matches. - -\*---------------------------------------------------------------------------*/ - -static void mbest_search( - const float *cb, /* VQ codebook to search */ - float vec[], /* target vector */ - float w[], /* weighting vector */ - int k, /* dimension of vector */ - int m, /* number on entries in codebook */ - struct MBEST *mbest, /* list of closest matches */ - int index[] /* indexes that lead us here */ -) -{ - float e; - int i,j; - float diff; - - for(j=0; jlist[j].index[0]; - for(i=0; ilist[j].index[1]; - index[1] = n2 = mbest_stage2->list[j].index[0]; - for(i=0; ilist[j].index[2]; - index[2] = n2 = mbest_stage3->list[j].index[1]; - index[1] = n3 = mbest_stage3->list[j].index[0]; - for(i=0; ilist[0].index[3]; - n2 = mbest_stage4->list[0].index[2]; - n3 = mbest_stage4->list[0].index[1]; - n4 = mbest_stage4->list[0].index[0]; - for (i=0;i max_Rw) - max_Rw = Rw[i]; - if (Rw[i] < min_Rw) - min_Rw = Rw[i]; - - } - - TIMER_SAMPLE_AND_LOG(tr, tww, " R"); - - #ifdef DUMP - if (dump) - dump_Rw(Rw); - #endif - - /* create post filter mag spectrum and apply ------------------*/ - - /* measure energy before post filtering */ - - e_before = 1E-4; - for(i=0; iL; m++) { - am = (int)((m - 0.5)*model->Wo/r + 0.5); - bm = (int)((m + 0.5)*model->Wo/r + 0.5); - Em = 0.0; - - for(i=am; iA[m]*model->A[m]; - noise += (model->A[m] - Am)*(model->A[m] - Am); - - /* This code significantly improves perf of LPC model, in - particular when combined with phase0. The LPC spectrum tends - to track just under the peaks of the spectral envelope, and - just above nulls. This algorithm does the reverse to - compensate - raising the amplitudes of spectral peaks, while - attenuating the null. This enhances the formants, and - supresses the energy between formants. */ - - if (sim_pf) { - if (Am > model->A[m]) - Am *= 0.7; - if (Am < model->A[m]) - Am *= 1.4; - } - - model->A[m] = Am; - } - *snr = 10.0*log10f(signal/noise); - - TIMER_SAMPLE_AND_LOG2(tpf, " rec"); -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: encode_Wo() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 - - Encodes Wo using a WO_LEVELS quantiser. - -\*---------------------------------------------------------------------------*/ - -int encode_Wo(float Wo) -{ - int index; - float Wo_min = TWO_PI/P_MAX; - float Wo_max = TWO_PI/P_MIN; - float norm; - - norm = (Wo - Wo_min)/(Wo_max - Wo_min); - index = floorf(WO_LEVELS * norm + 0.5); - if (index < 0 ) index = 0; - if (index > (WO_LEVELS-1)) index = WO_LEVELS-1; - - return index; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: decode_Wo() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 - - Decodes Wo using a WO_LEVELS quantiser. - -\*---------------------------------------------------------------------------*/ - -float decode_Wo(int index) -{ - float Wo_min = TWO_PI/P_MAX; - float Wo_max = TWO_PI/P_MIN; - float step; - float Wo; - - step = (Wo_max - Wo_min)/WO_LEVELS; - Wo = Wo_min + step*(index); - - return Wo; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: encode_Wo_dt() - AUTHOR......: David Rowe - DATE CREATED: 6 Nov 2011 - - Encodes Wo difference from last frame. - -\*---------------------------------------------------------------------------*/ - -int encode_Wo_dt(float Wo, float prev_Wo) -{ - int index, mask, max_index, min_index; - float Wo_min = TWO_PI/P_MAX; - float Wo_max = TWO_PI/P_MIN; - float norm; - - norm = (Wo - prev_Wo)/(Wo_max - Wo_min); - index = floor(WO_LEVELS * norm + 0.5); - //printf("ENC index: %d ", index); - - /* hard limit */ - - max_index = (1 << (WO_DT_BITS-1)) - 1; - min_index = - (max_index+1); - if (index > max_index) index = max_index; - if (index < min_index) index = min_index; - //printf("max_index: %d min_index: %d hard index: %d ", - // max_index, min_index, index); - - /* mask so that only LSB WO_DT_BITS remain, bit WO_DT_BITS is the sign bit */ - - mask = ((1 << WO_DT_BITS) - 1); - index &= mask; - //printf("mask: 0x%x index: 0x%x\n", mask, index); - - return index; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: decode_Wo_dt() - AUTHOR......: David Rowe - DATE CREATED: 6 Nov 2011 - - Decodes Wo using WO_DT_BITS difference from last frame. - -\*---------------------------------------------------------------------------*/ - -float decode_Wo_dt(int index, float prev_Wo) -{ - float Wo_min = TWO_PI/P_MAX; - float Wo_max = TWO_PI/P_MIN; - float step; - float Wo; - int mask; - - /* sign extend index */ - - //printf("DEC index: %d "); - if (index & (1 << (WO_DT_BITS-1))) { - mask = ~((1 << WO_DT_BITS) - 1); - index |= mask; - } - //printf("DEC mask: 0x%x index: %d \n", mask, index); - - step = (Wo_max - Wo_min)/WO_LEVELS; - Wo = prev_Wo + step*(index); - - /* bit errors can make us go out of range leading to all sorts of - probs like seg faults */ - - if (Wo > Wo_max) Wo = Wo_max; - if (Wo < Wo_min) Wo = Wo_min; - - return Wo; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: speech_to_uq_lsps() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 - - Analyse a windowed frame of time domain speech to determine LPCs - which are the converted to LSPs for quantisation and transmission - over the channel. - -\*---------------------------------------------------------------------------*/ - -float speech_to_uq_lsps(float lsp[], - float ak[], - float Sn[], - float w[], - int order -) -{ - int i, roots; - float Wn[M]; - float R[LPC_MAX+1]; - float e, E; - - e = 0.0; - for(i=0; iWo < (PI*150.0/4000)) { - model->A[1] *= 0.032; - } -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: encode_energy() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 - - Encodes LPC energy using an E_LEVELS quantiser. - -\*---------------------------------------------------------------------------*/ - -int encode_energy(float e) -{ - int index; - float e_min = E_MIN_DB; - float e_max = E_MAX_DB; - float norm; - - e = 10.0*log10f(e); - norm = (e - e_min)/(e_max - e_min); - index = floorf(E_LEVELS * norm + 0.5); - if (index < 0 ) index = 0; - if (index > (E_LEVELS-1)) index = E_LEVELS-1; - - return index; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: decode_energy() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 - - Decodes energy using a E_LEVELS quantiser. - -\*---------------------------------------------------------------------------*/ - -float decode_energy(int index) -{ - float e_min = E_MIN_DB; - float e_max = E_MAX_DB; - float step; - float e; - - step = (e_max - e_min)/E_LEVELS; - e = e_min + step*(index); - e = powf(10.0,e/10.0); - - return e; -} - -#ifdef NOT_USED -/*---------------------------------------------------------------------------*\ - - FUNCTION....: decode_amplitudes() - AUTHOR......: David Rowe - DATE CREATED: 22/8/2010 - - Given the amplitude quantiser indexes recovers the harmonic - amplitudes. - -\*---------------------------------------------------------------------------*/ - -float decode_amplitudes(kiss_fft_cfg fft_fwd_cfg, - MODEL *model, - float ak[], - int lsp_indexes[], - int energy_index, - float lsps[], - float *e -) -{ - float snr; - - decode_lsps_scalar(lsps, lsp_indexes, LPC_ORD); - bw_expand_lsps(lsps, LPC_ORD); - lsp_to_lpc(lsps, ak, LPC_ORD); - *e = decode_energy(energy_index); - aks_to_M2(ak, LPC_ORD, model, *e, &snr, 1, 0, 0, 1); - apply_lpc_correction(model); - - return snr; -} -#endif - -static float ge_coeff[2] = {0.8, 0.9}; - -void compute_weights2(const float *x, const float *xp, float *w, int ndim) -{ - w[0] = 30; - w[1] = 1; - if (x[1]<0) - { - w[0] *= .6; - w[1] *= .3; - } - if (x[1]<-10) - { - w[0] *= .3; - w[1] *= .3; - } - /* Higher weight if pitch is stable */ - if (fabsf(x[0]-xp[0])<.2) - { - w[0] *= 2; - w[1] *= 1.5; - } else if (fabsf(x[0]-xp[0])>.5) /* Lower if not stable */ - { - w[0] *= .5; - } - - /* Lower weight for low energy */ - if (x[1] < xp[1]-10) - { - w[1] *= .5; - } - if (x[1] < xp[1]-20) - { - w[1] *= .5; - } - - //w[0] = 30; - //w[1] = 1; - - /* Square the weights because it's applied on the squared error */ - w[0] *= w[0]; - w[1] *= w[1]; - -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: quantise_WoE() - AUTHOR......: Jean-Marc Valin & David Rowe - DATE CREATED: 29 Feb 2012 - - Experimental joint Wo and LPC energy vector quantiser developed by - Jean-Marc Valin. Exploits correlations between the difference in - the log pitch and log energy from frame to frame. For example - both the pitch and energy tend to only change by small amounts - during voiced speech, however it is important that these changes be - coded carefully. During unvoiced speech they both change a lot but - the ear is less sensitve to errors so coarser quantisation is OK. - - The ear is sensitive to log energy and loq pitch so we quantise in - these domains. That way the error measure used to quantise the - values is close to way the ear senses errors. - - See http://jmspeex.livejournal.com/10446.html - -\*---------------------------------------------------------------------------*/ - -void quantise_WoE(MODEL *model, float *e, float xq[]) -{ - int i, n1; - float x[2]; - float err[2]; - float w[2]; - const float *codebook1 = ge_cb[0].cb; - int nb_entries = ge_cb[0].m; - int ndim = ge_cb[0].k; - float Wo_min = TWO_PI/P_MAX; - float Wo_max = TWO_PI/P_MIN; - - x[0] = log10f((model->Wo/PI)*4000.0/50.0)/log10f(2); - x[1] = 10.0*log10f(1e-4 + *e); - - compute_weights2(x, xq, w, ndim); - for (i=0;iWo = powf(2.0, xq[0])*(PI*50.0)/4000.0; - - /* bit errors can make us go out of range leading to all sorts of - probs like seg faults */ - - if (model->Wo > Wo_max) model->Wo = Wo_max; - if (model->Wo < Wo_min) model->Wo = Wo_min; - - model->L = PI/model->Wo; /* if we quantise Wo re-compute L */ - - *e = powf(10.0, xq[1]/10.0); -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: encode_WoE() - AUTHOR......: Jean-Marc Valin & David Rowe - DATE CREATED: 11 May 2012 - - Joint Wo and LPC energy vector quantiser developed my Jean-Marc - Valin. Returns index, and updated states xq[]. - -\*---------------------------------------------------------------------------*/ - -int encode_WoE(MODEL *model, float e, float xq[]) -{ - int i, n1; - float x[2]; - float err[2]; - float w[2]; - const float *codebook1 = ge_cb[0].cb; - int nb_entries = ge_cb[0].m; - int ndim = ge_cb[0].k; - - assert((1<Wo/PI)*4000.0/50.0)/log10f(2); - x[1] = 10.0*log10f(1e-4 + e); - - compute_weights2(x, xq, w, ndim); - for (i=0;iWo = powf(2.0, xq[0])*(PI*50.0)/4000.0; - - /* bit errors can make us go out of range leading to all sorts of - probs like seg faults */ - - if (model->Wo > Wo_max) model->Wo = Wo_max; - if (model->Wo < Wo_min) model->Wo = Wo_min; - - model->L = PI/model->Wo; /* if we quantise Wo re-compute L */ - - *e = powf(10.0, xq[1]/10.0); -} - diff --git a/codec2/src/quantise.h b/codec2/src/quantise.h deleted file mode 100644 index 007d34d6..00000000 --- a/codec2/src/quantise.h +++ /dev/null @@ -1,126 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: quantise.h - AUTHOR......: David Rowe - DATE CREATED: 31/5/92 - - Quantisation functions for the sinusoidal coder. - -\*---------------------------------------------------------------------------*/ - -/* - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#ifndef __QUANTISE__ -#define __QUANTISE__ - -#include "kiss_fft.h" - -#define WO_BITS 7 -#define WO_LEVELS (1<. -*/ - -/*---------------------------------------------------------------------------*\ - - INCLUDES - -\*---------------------------------------------------------------------------*/ - -#include -#include -#include - -#include "defines.h" -#include "sine.h" -#include "kiss_fft.h" - -#define HPF_BETA 0.125 - -/*---------------------------------------------------------------------------*\ - - HEADERS - -\*---------------------------------------------------------------------------*/ - -void hs_pitch_refinement(MODEL *model, COMP Sw[], float pmin, float pmax, - float pstep); - -/*---------------------------------------------------------------------------*\ - - FUNCTIONS - -\*---------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: make_analysis_window - AUTHOR......: David Rowe - DATE CREATED: 11/5/94 - - Init function that generates the time domain analysis window and it's DFT. - -\*---------------------------------------------------------------------------*/ - -void make_analysis_window(kiss_fft_cfg fft_fwd_cfg, float w[], COMP W[]) -{ - float m; - COMP wshift[FFT_ENC]; - COMP temp; - int i,j; - - /* - Generate Hamming window centered on M-sample pitch analysis window - - 0 M/2 M-1 - |-------------|-------------| - |-------|-------| - NW samples - - All our analysis/synthsis is centred on the M/2 sample. - */ - - m = 0.0; - for(i=0; iWo + 5; - pmin = TWO_PI/model->Wo - 5; - pstep = 1.0; - hs_pitch_refinement(model,Sw,pmin,pmax,pstep); - - /* Fine refinement */ - - pmax = TWO_PI/model->Wo + 1; - pmin = TWO_PI/model->Wo - 1; - pstep = 0.25; - hs_pitch_refinement(model,Sw,pmin,pmax,pstep); - - /* Limit range */ - - if (model->Wo < TWO_PI/P_MAX) - model->Wo = TWO_PI/P_MAX; - if (model->Wo > TWO_PI/P_MIN) - model->Wo = TWO_PI/P_MIN; - - model->L = floor(PI/model->Wo); -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: hs_pitch_refinement - AUTHOR......: David Rowe - DATE CREATED: 27/5/94 - - Harmonic sum pitch refinement function. - - pmin pitch search range minimum - pmax pitch search range maximum - step pitch search step size - model current pitch estimate in model.Wo - - model refined pitch estimate in model.Wo - -\*---------------------------------------------------------------------------*/ - -void hs_pitch_refinement(MODEL *model, COMP Sw[], float pmin, float pmax, float pstep) -{ - int m; /* loop variable */ - int b; /* bin for current harmonic centre */ - float E; /* energy for current pitch*/ - float Wo; /* current "test" fundamental freq. */ - float Wom; /* Wo that maximises E */ - float Em; /* mamimum energy */ - float r, one_on_r; /* number of rads/bin */ - float p; /* current pitch */ - - /* Initialisation */ - - model->L = PI/model->Wo; /* use initial pitch est. for L */ - Wom = model->Wo; - Em = 0.0; - r = TWO_PI/FFT_ENC; - one_on_r = 1.0/r; - - /* Determine harmonic sum for a range of Wo values */ - - for(p=pmin; p<=pmax; p+=pstep) { - E = 0.0; - Wo = TWO_PI/p; - - /* Sum harmonic magnitudes */ - for(m=1; m<=model->L; m++) { - b = (int)(m*Wo*one_on_r + 0.5); - E += Sw[b].real*Sw[b].real + Sw[b].imag*Sw[b].imag; - } - /* Compare to see if this is a maximum */ - - if (E > Em) { - Em = E; - Wom = Wo; - } - } - - model->Wo = Wom; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: estimate_amplitudes - AUTHOR......: David Rowe - DATE CREATED: 27/5/94 - - Estimates the complex amplitudes of the harmonics. - -\*---------------------------------------------------------------------------*/ - -void estimate_amplitudes(MODEL *model, COMP Sw[], COMP W[], int est_phase) -{ - int i,m; /* loop variables */ - int am,bm; /* bounds of current harmonic */ - int b; /* DFT bin of centre of current harmonic */ - float den; /* denominator of amplitude expression */ - float r, one_on_r; /* number of rads/bin */ - int offset; - COMP Am; - - r = TWO_PI/FFT_ENC; - one_on_r = 1.0/r; - - for(m=1; m<=model->L; m++) { - den = 0.0; - am = (int)((m - 0.5)*model->Wo*one_on_r + 0.5); - bm = (int)((m + 0.5)*model->Wo*one_on_r + 0.5); - b = (int)(m*model->Wo/r + 0.5); - - /* Estimate ampltude of harmonic */ - - den = 0.0; - Am.real = Am.imag = 0.0; - offset = FFT_ENC/2 - (int)(m*model->Wo*one_on_r + 0.5); - for(i=am; iA[m] = sqrtf(den); - - if (est_phase) { - - /* Estimate phase of harmonic, this is expensive in CPU for - embedded devicesso we make it an option */ - - model->phi[m] = atan2(Sw[b].imag,Sw[b].real); - } - } -} - -/*---------------------------------------------------------------------------*\ - - est_voicing_mbe() - - Returns the error of the MBE cost function for a fiven F0. - - Note: I think a lot of the operations below can be simplified as - W[].imag = 0 and has been normalised such that den always equals 1. - -\*---------------------------------------------------------------------------*/ - -float est_voicing_mbe( - MODEL *model, - COMP Sw[], - COMP W[], - COMP Sw_[], /* DFT of all voiced synthesised signal */ - /* useful for debugging/dump file */ - COMP Ew[], /* DFT of error */ - float prev_Wo) -{ - int i,l,al,bl,m; /* loop variables */ - COMP Am; /* amplitude sample for this band */ - int offset; /* centers Hw[] about current harmonic */ - float den; /* denominator of Am expression */ - float error; /* accumulated error between original and synthesised */ - float Wo; - float sig, snr; - float elow, ehigh, eratio; - float sixty; - - sig = 1E-4; - for(l=1; l<=model->L/4; l++) { - sig += model->A[l]*model->A[l]; - } - for(i=0; iWo; - error = 1E-4; - - /* Just test across the harmonics in the first 1000 Hz (L/4) */ - - for(l=1; l<=model->L/4; l++) { - Am.real = 0.0; - Am.imag = 0.0; - den = 0.0; - al = ceil((l - 0.5)*Wo*FFT_ENC/TWO_PI); - bl = ceil((l + 0.5)*Wo*FFT_ENC/TWO_PI); - - /* Estimate amplitude of harmonic assuming harmonic is totally voiced */ - - offset = FFT_ENC/2 - l*Wo*FFT_ENC/TWO_PI + 0.5; - for(m=al; m V_THRESH) - model->voiced = 1; - else - model->voiced = 0; - - /* post processing, helps clean up some voicing errors ------------------*/ - - /* - Determine the ratio of low freqency to high frequency energy, - voiced speech tends to be dominated by low frequency energy, - unvoiced by high frequency. This measure can be used to - determine if we have made any gross errors. - */ - - elow = ehigh = 1E-4; - for(l=1; l<=model->L/2; l++) { - elow += model->A[l]*model->A[l]; - } - for(l=model->L/2; l<=model->L; l++) { - ehigh += model->A[l]*model->A[l]; - } - eratio = 10.0*log10f(elow/ehigh); - - /* Look for Type 1 errors, strongly V speech that has been - accidentally declared UV */ - - if (model->voiced == 0) - if (eratio > 10.0) - model->voiced = 1; - - /* Look for Type 2 errors, strongly UV speech that has been - accidentally declared V */ - - if (model->voiced == 1) { - if (eratio < -10.0) - model->voiced = 0; - - /* A common source of Type 2 errors is the pitch estimator - gives a low (50Hz) estimate for UV speech, which gives a - good match with noise due to the close harmoonic spacing. - These errors are much more common than people with 50Hz3 - pitch, so we have just a small eratio threshold. */ - - sixty = 60.0*TWO_PI/FS; - if ((eratio < -4.0) && (model->Wo <= sixty)) - model->voiced = 0; - } - //printf(" v: %d snr: %f eratio: %3.2f %f\n",model->voiced,snr,eratio,dF0); - - return snr; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: make_synthesis_window - AUTHOR......: David Rowe - DATE CREATED: 11/5/94 - - Init function that generates the trapezoidal (Parzen) sythesis window. - -\*---------------------------------------------------------------------------*/ - -void make_synthesis_window(float Pn[]) -{ - int i; - float win; - - /* Generate Parzen window in time domain */ - - win = 0.0; - for(i=0; i 10ms sound poor. The effect can also - be seen when synthesising test signals like single sine waves, some - sort of amplitude modulation at the frame rate. - - Another possibility is using a larger FFT size (1024 or 2048). - */ - -#define FFT_SYNTHESIS -#ifdef FFT_SYNTHESIS - /* Now set up frequency domain synthesised speech */ - for(l=1; l<=model->L; l++) { - //for(l=model->L/2; l<=model->L; l++) { - //for(l=1; l<=model->L/4; l++) { - b = (int)(l*model->Wo*FFT_DEC/TWO_PI + 0.5); - if (b > ((FFT_DEC/2)-1)) { - b = (FFT_DEC/2)-1; - } - Sw_[b].real = model->A[l]*cosf(model->phi[l]); - Sw_[b].imag = model->A[l]*sinf(model->phi[l]); - Sw_[FFT_DEC-b].real = Sw_[b].real; - Sw_[FFT_DEC-b].imag = -Sw_[b].imag; - } - - /* Perform inverse DFT */ - - kiss_fft(fft_inv_cfg, (kiss_fft_cpx *)Sw_, (kiss_fft_cpx *)sw_); -#else - /* - Direct time domain synthesis using the cos() function. Works - well at 10ms and 20ms frames rates. Note synthesis window is - still used to handle overlap-add between adjacent frames. This - could be simplified as we don't need to synthesise where Pn[] - is zero. - */ - for(l=1; l<=model->L; l++) { - for(i=0,j=-N+1; iA[l]*cos(j*model->Wo*l + model->phi[l]); - } - for(i=N-1,j=0; i<2*N; i++,j++) - Sw_[j].real += 2.0*model->A[l]*cos(j*model->Wo*l + model->phi[l]); - } -#endif - - /* Overlap add to previous samples */ - - for(i=0; i. -*/ - -#ifndef __SINE__ -#define __SINE__ - -#include "defines.h" -#include "comp.h" -#include "kiss_fft.h" - -void make_analysis_window(kiss_fft_cfg fft_fwd_cfg, float w[], COMP W[]); -float hpf(float x, float states[]); -void dft_speech(kiss_fft_cfg fft_fwd_cfg, COMP Sw[], float Sn[], float w[]); -void two_stage_pitch_refinement(MODEL *model, COMP Sw[]); -void estimate_amplitudes(MODEL *model, COMP Sw[], COMP W[], int est_phase); -float est_voicing_mbe(MODEL *model, COMP Sw[], COMP W[], COMP Sw_[],COMP Ew[], - float prev_Wo); -void make_synthesis_window(float Pn[]); -void synthesise(kiss_fft_cfg fft_inv_cfg, float Sn_[], MODEL *model, float Pn[], int shift); - -#define CODEC2_RAND_MAX 32767 -int codec2_rand(void); - -#endif diff --git a/codec2/src/test_bits.h b/codec2/src/test_bits.h deleted file mode 100644 index d1c01a03..00000000 --- a/codec2/src/test_bits.h +++ /dev/null @@ -1,164 +0,0 @@ -/* Generated by test_bits_file() Octave function */ - -const int test_bits[]={ - 0, - 1, - 1, - 0, - 0, - 0, - 1, - 1, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 1, - 0, - 1, - 1, - 0, - 0, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 0, - 1, - 1, - 0, - 0, - 1, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 1, - 1, - 1, - 0, - 0, - 1, - 0, - 0, - 1, - 1, - 1, - 0, - 0, - 1, - 1, - 1, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 1, - 1, - 0, - 0, - 1, - 1, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 0, - 1, - 1, - 0, - 1, - 0, - 0, - 0, - 1, - 1, - 1, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 1, - 0, - 0, - 0, - 1, - 0, - 0, - 1, - 0, - 0, - 0, - 1, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 0, - 0, - 1, - 0, - 1, - 1, - 1, - 0, - 1 -}; diff --git a/codec2/stm32/Makefile b/codec2/stm32/Makefile deleted file mode 100644 index 0288407a..00000000 --- a/codec2/stm32/Makefile +++ /dev/null @@ -1,215 +0,0 @@ -# Makefile for stm32f4 Codec 2 test programs - -################################################### - -PROJ_NAME=stm32f4_codec2 -FLOAT_TYPE=hard - -################################################### - -BINPATH=~/gcc-arm-none-eabi-4_7-2013q1/bin -CC=$(BINPATH)/arm-none-eabi-gcc -OBJCOPY=$(BINPATH)/arm-none-eabi-objcopy -SIZE=$(BINPATH)/arm-none-eabi-size - -################################################### - -CFLAGS = -std=gnu99 -O2 -g -Wall -Tstm32_flash.ld -DSTM32F4XX -DCORTEX_M4 -CFLAGS += -mlittle-endian -mthumb -mthumb-interwork -nostartfiles -mcpu=cortex-m4 - -ifeq ($(FLOAT_TYPE), hard) -CFLAGS += -fsingle-precision-constant -Wdouble-promotion -#CFLAGS += -fsingle-precision-constant -CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard -D__FPU_PRESENT=1 -D__FPU_USED=1 -else -CFLAGS += -msoft-float -endif - -################################################### - -# Definitions for the STM32F4 Standard Peripheral Library - -PERIPHLIBURL = http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/firmware/ -PERIPHLIBZIP = stm32f4_dsp_stdperiph_lib.zip -PERIPHLIBVER = V1.1.0 -PERIPHLIBNAME = STM32F4xx_DSP_StdPeriph_Lib -PERIPHLIBDIR = $(PERIPHLIBNAME)_$(PERIPHLIBVER) -CMSIS = $(PERIPHLIBDIR)/Libraries/CMSIS -STM32F4LIB = $(PERIPHLIBDIR)/Libraries/STM32F4xx_StdPeriph_Driver -STM32F4TEMPLATE = $(PERIPHLIBDIR)/Project/STM32F4xx_StdPeriph_Templates -DSPLIB = $(PERIPHLIBDIR)/Libraries/CMSIS/DSP_Lib - -CFLAGS += -DUSE_STDPERIPH_DRIVER -I$(STM32F4LIB)/inc -I$(STM32F4TEMPLATE) -CFLAGS += -I$(CMSIS)/Include -I$(CMSIS)/Device/ST/STM32F4xx/Include -CFLAGS += -DARM_MATH_CM4 - -################################################### - -# Sources - -SRCS = main.c gdb_stdio.c stm32f4_timer.c system_stm32f4xx.c - -# Codec 2 - -CODEC2_SRC=../src -SRCS += \ -$(CODEC2_SRC)/lpc.c \ -$(CODEC2_SRC)/nlp.c \ -$(CODEC2_SRC)/postfilter.c \ -$(CODEC2_SRC)/sine.c \ -$(CODEC2_SRC)/codec2.c \ -$(CODEC2_SRC)/kiss_fft.c \ -$(CODEC2_SRC)/interp.c \ -$(CODEC2_SRC)/lsp.c \ -$(CODEC2_SRC)/phase.c \ -$(CODEC2_SRC)/quantise.c \ -$(CODEC2_SRC)/pack.c \ -$(CODEC2_SRC)/codebook.c \ -$(CODEC2_SRC)/codebookd.c \ -$(CODEC2_SRC)/codebookjvm.c \ -$(CODEC2_SRC)/codebookge.c \ -$(CODEC2_SRC)/dump.c - -CFLAGS += -D__EMBEDDED__ -DTIMER - -#enable this for dump files to help verify optimisation -#CFLAGS += -DDUMP - -CFLAGS += -I../src -CFLAGS += -I../unittest -CFLAGS += -Iinc - -FFT_TEST_SRCS = \ -$(DSPLIB)/Examples/arm_fft_bin_example/arm_fft_bin_data.c \ -fft_test.c \ -src/startup_stm32f4xx.s \ -stm32f4_timer.c \ -gdb_stdio.c \ -../src/kiss_fft.c - -################################################### - -vpath %.c src -vpath %.a lib - -ROOT=$(shell pwd) - -# Library paths - -LIBPATHS = - -# Libraries to link - -LIBS = libstm32f4.a -lg -lnosys -lm - -# startup file - -SRCS += src/startup_stm32f4xx.s src/init.c - -OBJS = $(SRCS:.c=.o) - -################################################### - -all: libstm32f4.a $(PROJ_NAME).elf fft_test.elf dac_ut.elf dac_play.elf adc_rec.elf pwm_ut.elf power_ut.elf - -dl/$(PERIPHLIBZIP): - mkdir -p dl - cd dl; wget $(PERIPHLIBURL)/$(PERIPHLIBZIP) - -$(PERIPHLIBDIR): dl/$(PERIPHLIBZIP) - cd dl; unzip $(PERIPHLIBZIP) - mv dl/$(PERIPHLIBDIR) $(PERIPHLIBDIR) - -libstm32f4.a: $(PERIPHLIBDIR) - $(MAKE) $(STM32F4TEMPLATE)/system_stm32f4xx.o - for F in $(STM32F4LIB)/src/*.c ; do $(MAKE) $${F%.c}.o ; done - for F in $(CMSIS)/DSP_Lib/Source/*/*.c ; do $(MAKE) $${F%.c}.o ; done - find $(PERIPHLIBDIR) -type f -name '*.o' -exec $(AR) crs libstm32f4.a {} ";" - -$(PROJ_NAME).elf: $(SRCS) - $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) - -fft_test.elf: $(FFT_TEST_SRCS) - $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) - -DAC_UT_SRCS=\ -src/dac_ut.c \ -../src/fifo.c \ -src/stm32f4_dac.c \ -src/system_stm32f4xx.c \ -src/startup_stm32f4xx.s \ -src/init.c - -dac_ut.elf: $(DAC_UT_SRCS) - $(CC) $(CFLAGS) -O0 $^ -o $@ $(LIBPATHS) $(LIBS) - -DAC_PLAY_SRCS=\ -src/dac_play.c \ -../src/fifo.c \ -gdb_stdio.c \ -src/stm32f4_dac.c \ -src/system_stm32f4xx.c \ -src/startup_stm32f4xx.s \ -src/init.c - -dac_play.elf: $(DAC_PLAY_SRCS) - $(CC) $(CFLAGS) -O0 $^ -o $@ $(LIBPATHS) $(LIBS) - -ADC_REC_SRCS=\ -src/adc_rec.c \ -../src/fifo.c \ -gdb_stdio.c \ -src/stm32f4_adc.c \ -src/system_stm32f4xx.c \ -src/startup_stm32f4xx.s \ -src/init.c - -adc_rec.elf: $(ADC_REC_SRCS) - $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) - -PWM_UT_SRCS=\ -src/stm32f4_pwm.c \ -src/system_stm32f4xx.c \ -src/startup_stm32f4xx.s \ -src/init.c - -pwm_ut.elf: $(PWM_UT_SRCS) - $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) - -POWER_UT_SRCS=\ -src/power_ut.c \ -gdb_stdio.c \ -../src/fifo.c \ -src/stm32f4_adc.c \ -src/stm32f4_dac.c \ -src/system_stm32f4xx.c \ -src/startup_stm32f4xx.s \ -src/init.c \ -src/stm32f4_timer.c \ - -POWER_UT_SRCS += \ -$(CODEC2_SRC)/lpc.c \ -$(CODEC2_SRC)/nlp.c \ -$(CODEC2_SRC)/postfilter.c \ -$(CODEC2_SRC)/sine.c \ -$(CODEC2_SRC)/codec2.c \ -$(CODEC2_SRC)/kiss_fft.c \ -$(CODEC2_SRC)/interp.c \ -$(CODEC2_SRC)/lsp.c \ -$(CODEC2_SRC)/phase.c \ -$(CODEC2_SRC)/quantise.c \ -$(CODEC2_SRC)/pack.c \ -$(CODEC2_SRC)/codebook.c \ -$(CODEC2_SRC)/codebookd.c \ -$(CODEC2_SRC)/codebookjvm.c \ -$(CODEC2_SRC)/codebookge.c \ -$(CODEC2_SRC)/dump.c - -power_ut.elf: $(POWER_UT_SRCS) - $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) - -clean: - rm -f *.o - rm -f *.elf - rm -f libstm32f4.a - find $(PERIPHLIBDIR) -type f -name '*.o' -exec rm {} \; diff --git a/codec2/stm32/README.txt b/codec2/stm32/README.txt deleted file mode 100644 index 9b79ee88..00000000 --- a/codec2/stm32/README.txt +++ /dev/null @@ -1,114 +0,0 @@ -README.txt -codec2 support for the stm32f4 -David Rowe May 2013 - -Introduction ------------- - -The Makefile generates several unit tests, stm32f4_codec2.elf is the -most important. It's is equivalent to c2demo.c and runs the encoder -and decoder on raw speech files. It also gathers and prints profiling -information and can dump the codec states to compare changes. - -gdb_stdio system ----------------- - -stutil contains a gdb server that talks to the target firmware. -stutil has been patched to allow "semihosting": stdio requests on the -target are re-directed to the host PC. So if you call printf on the -target, it appears on the host PC console. With printf/fread/fwrite -and gdb it makes developing on bare metal just like developing on any -command line gcc system. - -The root path for files accessed by the target is the path st-util is -run from. - -Getting Started ---------------- - -. Install arm toolchain binary - - $ cd ~ - $ wget https://launchpad.net/gcc-arm-embedded/4.7/4.7-2013-q1-update/+download/gcc-arm-none-eabi-4_7-2013q1-20130313-linux.tar.bz2 - $ tar xjf gcc-arm-none-eabi-4_7-2012q4-20121208-linux.tar.bz2 - -. Build codec2 unit test: - - $ cd codec2_dev/stm32 - If necessary, edit the BINPATH variable in Makefile for your toolchain location - $ make - -. Build stlink: - - $ cd ~ - $ git clone https://github.com/shenki/stlink.git - $ cd stlink - ~/stlink$ sudo apt-get install libusb-1.0-0-dev libelf-dev automake - ~/stlink$ ./autogen.sh - ~/stlink$ ./configure - ~/stlink$ make - -. Place a copy of hts1a.raw in the stlink directory and start st-util: - - ~/stlink$ cp ~/codec2/raw/hts1a.raw stm_in.raw - ~/stlink$ sudo ./st-util -f /home/david/codec2/stm32/stm32f4_codec2.elf - -. In _another_ console start gdb: - - $ ~/codec2/stm32$ ~/gcc-arm-none-eabi-4_7-2013q1/bin/arm-none-eabi-gdb stm32f4_codec2.elf - - (gdb) tar ext :4242 - - (gdb) load - `/home/david/codec2/stm32/fft_test.elf' has changed; re-reading symbols. - Loading section .isr_vector, size 0x188 lma 0x8000000 - Loading section .text, size 0x1a4b4 lma 0x8000188 - Loading section .data, size 0x28f0 lma 0x801a63c - Start address 0x800a885, load size 118572 - Transfer rate: 13 KB/sec, 10779 bytes/write. - -. Power cycle Discovery. - -. Stop st-util using ctrl-C, then restart st-util - -. Back to gdb: - - (gdb) tar ext :4242 - A program is being debugged already. Kill it? (y or n) y - Remote connection closed - (gdb) tar ext :4242 - Remote debugging using :4242 - Reset_Handler () at lib/startup_stm32f4xx.s:69 - 69 movs r1, #0 - - (gdb) c - Continuing. - -. gdb will prints various debug messages, and the codec output file - will be written to ~/stlink. - - ~/stlink$ play -r 8000 -s -2 stm_out.raw - -Process -------- - -1. Profiling macros, grep on TIMER_xxxx - -2. Enable DUMP variable in Makefile to dump files, note profiling - times will be corrupted by this due to latency in talking to Host - -3. Compare outputs using octave/diff_codec. Example: - - octave:> diff_codec("~/stlink/ref/hts1a_out_1300.raw", "~/stlink/hts1a_out_1300.raw","~/stlink/stm32f4", "~/stlink/ref/stm32f4") - -Gotcha ------- - -Using printf rather than gdb_stdio_printf, regular stdio functions are -stubbed out so will link, just nothing will happen. - -TODO ----- - - + check if "CFLAGS: -mlittle-endian -mthumb -mthumb-interwork" needed - + double check if _fini hack is OK (src/init.c) diff --git a/codec2/stm32/inc/gdb_stdio.h b/codec2/stm32/inc/gdb_stdio.h deleted file mode 100644 index eafabca4..00000000 --- a/codec2/stm32/inc/gdb_stdio.h +++ /dev/null @@ -1,47 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: gdb_stdio.h - AUTHOR......: David Rowe - DATE CREATED: April 23 2013 - - Some stdio I/O functions that perform I/O on the host using gdb. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2013 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#ifndef __GDB_STDIO__ -#define __GDB_STDIO__ - -#include -#include - -void gdb_stdio_fprintf(FILE *file, const char *format, ...); -void gdb_stdio_printf(const char *format, ...); -FILE *gdb_stdio_fopen(char file_name[], char mode[]); -void gdb_stdio_fclose(FILE *file); -int gdb_stdio_fwrite(void *ptr, int size, int nmemb, FILE *file); -int gdb_stdio_fread(void *ptr, int size, int nmemb, FILE *file); - -#define printf gdb_stdio_printf -#define fopen gdb_stdio_fopen -#define fclose gdb_stdio_fclose -#define fread gdb_stdio_fread -#define fwrite gdb_stdio_fwrite - -#endif diff --git a/codec2/stm32/inc/stm32f4_adc.h b/codec2/stm32/inc/stm32f4_adc.h deleted file mode 100644 index b14110cb..00000000 --- a/codec2/stm32/inc/stm32f4_adc.h +++ /dev/null @@ -1,34 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: stm32f4_adc.h - AUTHOR......: David Rowe - DATE CREATED: 30 May 2014 - - ADC driver module for STM32F4. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2014 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#ifndef __STM32F4_ADC__ -#define __STM32F4_ADC__ - -void adc_open(void); -int adc_read(short buf[], int n); - -#endif diff --git a/codec2/stm32/inc/stm32f4_dac.h b/codec2/stm32/inc/stm32f4_dac.h deleted file mode 100644 index 3a298321..00000000 --- a/codec2/stm32/inc/stm32f4_dac.h +++ /dev/null @@ -1,34 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: stm32f4_dac.h - AUTHOR......: David Rowe - DATE CREATED: 1 June 2013 - - DAC driver module for STM32F4. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2013 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#ifndef __STM32F4_DAC__ -#define __STM32F4_DAC__ - -void dac_open(void); -int dac_write(short buf[], int n); - -#endif diff --git a/codec2/stm32/inc/stm32f4xx_conf.h b/codec2/stm32/inc/stm32f4xx_conf.h deleted file mode 100644 index a791166d..00000000 --- a/codec2/stm32/inc/stm32f4xx_conf.h +++ /dev/null @@ -1,94 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4xx_conf.h - * @author MCD Application Team - * @version V1.0.0 - * @date 19-September-2011 - * @brief Library configuration file. - ****************************************************************************** - * @attention - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2011 STMicroelectronics

- ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4xx_CONF_H -#define __STM32F4xx_CONF_H - -#if defined (HSE_VALUE) -/* Redefine the HSE value; it's equal to 8 MHz on the STM32F4-DISCOVERY Kit */ - #undef HSE_VALUE - #define HSE_VALUE ((uint32_t)8000000) -#endif /* HSE_VALUE */ - -/* Includes ------------------------------------------------------------------*/ -/* Uncomment the line below to enable peripheral header file inclusion */ -#include "stm32f4xx_adc.h" -#include "stm32f4xx_can.h" -#include "stm32f4xx_crc.h" -#include "stm32f4xx_cryp.h" -#include "stm32f4xx_dac.h" -#include "stm32f4xx_dbgmcu.h" -#include "stm32f4xx_dcmi.h" -#include "stm32f4xx_dma.h" -#include "stm32f4xx_exti.h" -#include "stm32f4xx_flash.h" -#include "stm32f4xx_fsmc.h" -#include "stm32f4xx_hash.h" -#include "stm32f4xx_gpio.h" -#include "stm32f4xx_i2c.h" -#include "stm32f4xx_iwdg.h" -#include "stm32f4xx_pwr.h" -#include "stm32f4xx_rcc.h" -#include "stm32f4xx_rng.h" -#include "stm32f4xx_rtc.h" -#include "stm32f4xx_sdio.h" -#include "stm32f4xx_spi.h" -#include "stm32f4xx_syscfg.h" -#include "stm32f4xx_tim.h" -#include "stm32f4xx_usart.h" -#include "stm32f4xx_wwdg.h" -#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* If an external clock source is used, then the value of the following define - should be set to the value of the external clock source, else, if no external - clock is used, keep this define commented */ -/*#define I2S_EXTERNAL_CLOCK_VAL 12288000 */ /* Value of the external clock in Hz */ - - -/* Uncomment the line below to expanse the "assert_param" macro in the - Standard Peripheral Library drivers code */ -/* #define USE_FULL_ASSERT 1 */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT - -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ - #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ - void assert_failed(uint8_t* file, uint32_t line); -#else - #define assert_param(expr) ((void)0) -#endif /* USE_FULL_ASSERT */ - -#endif /* __STM32F4xx_CONF_H */ - -/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/codec2/stm32/src/adc_rec.c b/codec2/stm32/src/adc_rec.c deleted file mode 100644 index 3d5992f9..00000000 --- a/codec2/stm32/src/adc_rec.c +++ /dev/null @@ -1,58 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: adc_rec.c - AUTHOR......: David Rowe - DATE CREATED: 30 May 2014 - - Recordss a 16 kHz sample rate raw file from the STM32F4 ADC. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2014 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include "stm32f4_adc.h" -#include "gdb_stdio.h" - -#define REC_TIME_SECS 10 -#define N 2000 -#define FS 16000 - -int main(void){ - short buf[N]; - FILE *frec; - int i, bufs; - - adc_open(); - - frec = fopen("stm_out.raw", "wb"); - if (frec == NULL) { - printf("Error opening input file: stm_out.raw\n\nTerminating....\n"); - exit(1); - } - bufs = FS*REC_TIME_SECS/N; - - printf("Starting!\n"); - for(i=0; i
© COPYRIGHT 2013 STMicroelectronics
- * - * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/software_license_agreement_liberty_v2 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ -int interrupts; - - -/* Includes ------------------------------------------------------------------*/ -#include "dac_it.h" - -/** @addtogroup STM32F4xx_StdPeriph_Examples - * @{ - */ - -/** @addtogroup DMA_FLASHToRAM - * @{ - */ - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* Private function prototypes -----------------------------------------------*/ -/* Private functions ---------------------------------------------------------*/ - -/******************************************************************************/ -/* Cortex-M4 Processor Exceptions Handlers */ -/******************************************************************************/ - -/** - * @brief This function handles NMI exception. - * @param None - * @retval None - */ -void NMI_Handler(void) -{ -} - -/** - * @brief This function handles Hard Fault exception. - * @param None - * @retval None - */ -void HardFault_Handler(void) -{ - /* Go to infinite loop when Hard Fault exception occurs */ - while (1) - { - } -} - -/** - * @brief This function handles Memory Manage exception. - * @param None - * @retval None - */ -void MemManage_Handler(void) -{ - /* Go to infinite loop when Memory Manage exception occurs */ - while (1) - { - } -} - -/** - * @brief This function handles Bus Fault exception. - * @param None - * @retval None - */ -void BusFault_Handler(void) -{ - /* Go to infinite loop when Bus Fault exception occurs */ - while (1) - { - } -} - -/** - * @brief This function handles Usage Fault exception. - * @param None - * @retval None - */ -void UsageFault_Handler(void) -{ - /* Go to infinite loop when Usage Fault exception occurs */ - while (1) - { - } -} - -/** - * @brief This function handles SVCall exception. - * @param None - * @retval None - */ -void SVC_Handler(void) -{ -} - -/** - * @brief This function handles Debug Monitor exception. - * @param None - * @retval None - */ -void DebugMon_Handler(void) -{ -} - -/** - * @brief This function handles PendSVC exception. - * @param None - * @retval None - */ -void PendSV_Handler(void) -{ -} - -/** - * @brief This function handles SysTick Handler. - * @param None - * @retval None - */ -void SysTick_Handler(void) -{ -} - -/******************************************************************************/ -/* STM32F4xx Peripherals Interrupt Handlers */ -/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ -/* available peripheral interrupt handler's name please refer to the startup */ -/* file (startup_stm32f40xx.s/startup_stm32f427x.s). */ -/******************************************************************************/ - -/** - * @brief This function handles DMA Stream interrupt request. - * @param None - * @retval None - */ -void DMA1_Stream6_IRQHandler(void) -{ - - /* Transfer half empty interrupt */ - - if(DMA_GetITStatus(DMA1_Stream6, DMA_IT_HTIF6) != RESET)) - { - /* fill first half from fifo */ - - fifo_read(DMA1_Stream6_fifo, dac_buf, DAC_BUF_SZ/2); - - /* Clear DMA Stream Transfer Complete interrupt pending bit */ - - DMA_ClearITPendingBit(DMA1_Stream6, DMA_IT_HTIF6); - - interrupts++; - } - - /* Transfer complete interrupt */ - - if(DMA_GetITStatus(DMA1_Stream6, DMA_IT_TCIF6) != RESET)) - { - /* fill second half from fifo */ - - fifo_read(DMA1_Stream6_fifo, &dac_buf[DAC_BUF_SZ/2], DAC_BUF_SZ/2); - - /* Clear DMA Stream Transfer Complete interrupt pending bit */ - - DMA_ClearITPendingBit(DMA1_Stream6, DMA_IT_TCIF6); - - interrupts++; - } -} - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/codec2/stm32/src/dac_play.c b/codec2/stm32/src/dac_play.c deleted file mode 100644 index ba0ec1ab..00000000 --- a/codec2/stm32/src/dac_play.c +++ /dev/null @@ -1,61 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: dac_play.c - AUTHOR......: David Rowe - DATE CREATED: 1 June 2013 - - Plays a 16 kHz sample rate raw file to the STM32F4 DAC. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2013 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include "stm32f4_dac.h" -#include "gdb_stdio.h" - -#define N 2000 - -int main(void) { - short buf[N]; - FILE *fplay; - - dac_open(); - - while(1) { - fplay = fopen("stm_in.raw", "rb"); - if (fplay == NULL) { - printf("Error opening input file: stm_in.raw\n\nTerminating....\n"); - exit(1); - } - - printf("Starting!\n"); - - while(fread(buf, sizeof(short), N, fplay) == N) { - while(dac_write(buf, N) == -1); - } - - printf("Finished!\n"); - fclose(fplay); - } - - /* let FIFO empty */ - - while(1); -} - diff --git a/codec2/stm32/src/dac_ut.c b/codec2/stm32/src/dac_ut.c deleted file mode 100644 index 139dc759..00000000 --- a/codec2/stm32/src/dac_ut.c +++ /dev/null @@ -1,61 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: dac_ut.c - AUTHOR......: David Rowe - DATE CREATED: May 31 2013 - - Plays a 500 Hz sine wave sampled at 16 kHz out of PA5 on a Discovery board. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2013 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include "stm32f4_dac.h" - -#define SINE_SAMPLES 32 - - -/* 32 sample sine wave which at Fs=16kHz will be 500Hz. Not sampels - are 16 bit 2's complement, the DAC driver convertsto 12 bit - unsigned. */ - -short aSine[] = { - -16, 6384, 12528, 18192, 23200, 27232, 30256, 32128, 32752, 32128, - 30256, 27232, 23152, 18192, 12528, 6384, -16, -6416, -12560, -18224, - -23184, -27264, -30288, -32160, -32768, -32160, -30288, -27264, -23184, -18224, - -12560, -6416 -}; - -int main(void) { - int i; - - //for(i=0; i<32; i++) - // aSine[i] /= 2; - - dac_open(); - - while (1) { - - /* keep DAC FIFO topped up */ - - dac_write((short*)aSine, SINE_SAMPLES); - } - -} - diff --git a/codec2/stm32/src/fft_test.c b/codec2/stm32/src/fft_test.c deleted file mode 100644 index cc25653b..00000000 --- a/codec2/stm32/src/fft_test.c +++ /dev/null @@ -1,176 +0,0 @@ -/* ---------------------------------------------------------------------- -* Copyright (C) 2010 ARM Limited. All rights reserved. -* -* $Date: 29. November 2010 -* $Revision: V1.0.3 -* -* Project: CMSIS DSP Library -* Title: arm_fft_bin_example_f32.c -* -* Description: Example code demonstrating calculation of Max energy bin of -* frequency domain of input signal. -* -* Target Processor: Cortex-M4/Cortex-M3 -* -* -* Version 1.0.3 2010/11/29 -* Re-organized the CMSIS folders and updated documentation. -* -* Version 1.0.1 2010/10/05 KK -* Production release and review comments incorporated. -* -* Version 1.0.0 2010/09/20 KK -* Production release and review comments incorporated. -* ------------------------------------------------------------------- */ - -/** - * @ingroup groupExamples - */ - -/** - * @defgroup FrequencyBin Frequency Bin Example - * - * \par Description - * \par - * Demonstrates the calculation of the maximum energy bin in the frequency - * domain of the input signal with the use of Complex FFT, Complex - * Magnitude, and Maximum functions. - * - * \par Algorithm: - * \par - * The input test signal contains a 10 kHz signal with uniformly distributed white noise. - * Calculating the FFT of the input signal will give us the maximum energy of the - * bin corresponding to the input frequency of 10 kHz. - * - * \par Block Diagram: - * \image html FFTBin.gif "Block Diagram" - * \par - * The figure below shows the time domain signal of 10 kHz signal with - * uniformly distributed white noise, and the next figure shows the input - * in the frequency domain. The bin with maximum energy corresponds to 10 kHz signal. - * \par - * \image html FFTBinInput.gif "Input signal in Time domain" - * \image html FFTBinOutput.gif "Input signal in Frequency domain" - * - * \par Variables Description: - * \par - * \li \c testInput_f32_10khz points to the input data - * \li \c testOutput points to the output data - * \li \c fftSize length of FFT - * \li \c ifftFlag flag for the selection of CFFT/CIFFT - * \li \c doBitReverse Flag for selection of normal order or bit reversed order - * \li \c refIndex reference index value at which maximum energy of bin ocuurs - * \li \c testIndex calculated index value at which maximum energy of bin ocuurs - * - * \par CMSIS DSP Software Library Functions Used: - * \par - * - arm_cfft_radix4_init_f32() - * - arm_cfft_radix4_f32() - * - arm_cmplx_mag_f32() - * - arm_max_f32() - * - * Refer - * \link arm_fft_bin_example_f32.c \endlink - * - */ - - -/** \example arm_fft_bin_example_f32.c - */ - - -#include "arm_math.h" -#include "gdb_stdio.h" -#include "machdep.h" -#include "kiss_fft.h" - -#define TEST_LENGTH_SAMPLES 1024 - -/* ------------------------------------------------------------------- -* External Input and Output buffer Declarations for FFT Bin Example -* ------------------------------------------------------------------- */ -extern float32_t testInput_f32_10khz[TEST_LENGTH_SAMPLES]; -static float32_t testOutput[TEST_LENGTH_SAMPLES/2]; -static float32_t kiss_complex_out[TEST_LENGTH_SAMPLES]; - -/* ------------------------------------------------------------------ -* Global variables for FFT Bin Example -* ------------------------------------------------------------------- */ -uint32_t fftSize = TEST_LENGTH_SAMPLES/2; -uint32_t ifftFlag = 0; -uint32_t doBitReverse = 1; - -/* Reference index at which max energy of bin ocuurs */ -uint32_t refIndex = 213, testIndex = 0; - -/* ---------------------------------------------------------------------- -* Max magnitude FFT Bin test -* ------------------------------------------------------------------- */ - -void SystemInit(void); - -int main(void) -{ - - arm_status status; - arm_cfft_radix2_instance_f32 S; - float32_t maxValue; - unsigned int fft_start, kiss_fft_start; - kiss_fft_cfg fft_fwd_cfg; - - SystemInit(); - machdep_timer_init(); - fft_fwd_cfg = kiss_fft_alloc(fftSize, 0, NULL, NULL); - kiss_fft_start = machdep_timer_sample(); - kiss_fft(fft_fwd_cfg, (kiss_fft_cpx *)testInput_f32_10khz, - (kiss_fft_cpx *)kiss_complex_out); - machdep_timer_sample_and_log(kiss_fft_start, " kiss_fft"); - - status = ARM_MATH_SUCCESS; - - /* Initialize the CFFT/CIFFT module */ - status = arm_cfft_radix2_init_f32(&S, fftSize, ifftFlag, doBitReverse); - - /* Process the data through the CFFT/CIFFT module */ - fft_start = machdep_timer_sample(); - arm_cfft_radix2_f32(&S, testInput_f32_10khz); - machdep_timer_sample_and_log(fft_start, " fft"); - machdep_timer_print_logged_samples(); - - /* Process the data through the Complex Magnitude Module for - calculating the magnitude at each bin */ - arm_cmplx_mag_f32(testInput_f32_10khz, testOutput,fftSize); - - /* Calculates maxValue and returns corresponding BIN value */ - arm_max_f32(testOutput, fftSize, &maxValue, &testIndex); - - if(testIndex != refIndex) - { - status = ARM_MATH_TEST_FAILURE; - } - - /* ---------------------------------------------------------------------- - ** Loop here if the signals fail the PASS check. - ** This denotes a test failure - ** ------------------------------------------------------------------- */ - - if( status != ARM_MATH_SUCCESS) - { - while(1); - } - - while(1); /* main function does not return */ - - return 0; -} - - /** \endlink */ - - -/* - * Dummy function to avoid compiler error - */ -void _init() { } - - - diff --git a/codec2/stm32/src/gdb_stdio.c b/codec2/stm32/src/gdb_stdio.c deleted file mode 100644 index 942d7bae..00000000 --- a/codec2/stm32/src/gdb_stdio.c +++ /dev/null @@ -1,125 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: gdb_stdio.c - AUTHOR......: David Rowe - DATE CREATED: April 23 2013 - - Some stdio I/O functions that perform I/O on the host using gdb. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2013 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include "gdb_stdio.h" - -#define MAX_STR 2048 - -/* command codes we use to signal host */ - -#define GDB_STDIO_PRINTF 1 -#define GDB_STDIO_FOPEN 2 -#define GDB_STDIO_FCLOSE 3 -#define GDB_STDIO_FWRITE 4 -#define GDB_STDIO_FREAD 5 -#define GDB_STDIO_FPRINTF 6 - -/* globals we use to communicate with host */ - -volatile int gdb_stdio_func = 0; -volatile int gdb_stdio_ret = 0; -volatile char *gdb_stdio_pstr1; -volatile char *gdb_stdio_pstr2; -volatile int gdb_stdio_strlen1; -volatile int gdb_stdio_strlen2; -volatile FILE *gdb_stdio_file; -volatile void *gdb_stdio_ptr; -volatile int gdb_stdio_size; -volatile int gdb_stdio_nmem; - -void gdb_stdio_fprintf(FILE *file, const char *format, ...) { - va_list arg; - char str[MAX_STR]; - - va_start(arg, format); - vsnprintf(str, MAX_STR, format, arg); - va_end(arg); - gdb_stdio_file = file; - gdb_stdio_pstr1 = str; - gdb_stdio_strlen1 = strlen(str); - - gdb_stdio_func = GDB_STDIO_FPRINTF; - while(gdb_stdio_func); -} - -void gdb_stdio_printf(const char *format, ...) { - va_list arg; - char str[MAX_STR]; - - va_start(arg, format); - vsnprintf(str, MAX_STR, format, arg); - va_end(arg); - gdb_stdio_pstr1 = str; - gdb_stdio_strlen1 = strlen(str); - - gdb_stdio_func = GDB_STDIO_PRINTF; - while(gdb_stdio_func); -} - -FILE *gdb_stdio_fopen(char file_name[], char mode[]) { - gdb_stdio_pstr1 = file_name; - gdb_stdio_pstr2 = mode; - gdb_stdio_strlen1 = strlen(file_name); - gdb_stdio_strlen2 = strlen(mode); - - gdb_stdio_func = GDB_STDIO_FOPEN; - while(gdb_stdio_func); - return (FILE*)gdb_stdio_ret; -} - -void gdb_stdio_fclose(FILE *file) { - gdb_stdio_file = file; - - gdb_stdio_func = GDB_STDIO_FCLOSE; - while(gdb_stdio_func); -} - -int gdb_stdio_fwrite(void *ptr, int size, int nmem, FILE *file) { - gdb_stdio_ptr = ptr; - gdb_stdio_size = size; - gdb_stdio_nmem = nmem; - gdb_stdio_file = file; - - gdb_stdio_func = GDB_STDIO_FWRITE; - while(gdb_stdio_func); - return gdb_stdio_ret; -} - -int gdb_stdio_fread(void *ptr, int size, int nmem, FILE *file) { - gdb_stdio_ptr = ptr; - gdb_stdio_size = size; - gdb_stdio_nmem = nmem; - gdb_stdio_file = file; - - gdb_stdio_func = GDB_STDIO_FREAD; - while(gdb_stdio_func); - return gdb_stdio_ret; -} - diff --git a/codec2/stm32/src/init.c b/codec2/stm32/src/init.c deleted file mode 100644 index 527141d4..00000000 --- a/codec2/stm32/src/init.c +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Dummy function to avoid compiler error - */ -void _init() { - -} -void _fini() { - -} - diff --git a/codec2/stm32/src/main.c b/codec2/stm32/src/main.c deleted file mode 100644 index 28d8ba75..00000000 --- a/codec2/stm32/src/main.c +++ /dev/null @@ -1,156 +0,0 @@ -#include -#include -#include -#include - -#include "stm32f4xx_conf.h" -#include "stm32f4xx.h" -#include "gdb_stdio.h" -#include "codec2.h" -#include "dump.h" -#include "sine.h" -#include "machdep.h" - -#ifdef __EMBEDDED__ -#define printf gdb_stdio_printf -#define fopen gdb_stdio_fopen -#define fclose gdb_stdio_fclose -#define fread gdb_stdio_fread -#define fwrite gdb_stdio_fwrite -#endif - -static void c2demo(int mode, char inputfile[], char outputfile[]) -{ - struct CODEC2 *codec2; - short *inbuf, *outbuf; - unsigned char *bits; - int nsam, nbit; - FILE *fin, *fout; - int frame; - TIMER_VAR(enc_start, dec_start); - - codec2 = codec2_create(mode); - nsam = codec2_samples_per_frame(codec2); - outbuf = (short*)malloc(nsam*sizeof(short)); - inbuf = (short*)malloc(nsam*sizeof(short)); - nbit = codec2_bits_per_frame(codec2); - bits = (unsigned char*)malloc(nbit*sizeof(char)); - - fin = fopen(inputfile, "rb"); - if (fin == NULL) { - printf("Error opening input file: %s\n\nTerminating....\n",inputfile); - exit(1); - } - - fout = fopen(outputfile, "wb"); - if (fout == NULL) { - printf("Error opening output file: %s\n\nTerminating....\n",outputfile); - exit(1); - } - - #ifdef DUMP - dump_on("stm32f4"); - #endif - frame = 0; - - while (fread(inbuf, sizeof(short), nsam, fin) == nsam) { - TIMER_SAMPLE(enc_start); - codec2_encode(codec2, bits, inbuf); - TIMER_SAMPLE_AND_LOG(dec_start, enc_start, " enc"); - codec2_decode(codec2, outbuf, bits); - TIMER_SAMPLE_AND_LOG2(dec_start, " dec"); - TIMER_SAMPLE_AND_LOG2(enc_start, " enc & dec"); - fwrite((char*)outbuf, sizeof(short), nsam, fout); - printf("frame: %d\n", ++frame); - machdep_timer_print_logged_samples(); - } - - #ifdef DUMP - dump_off("sm32f4"); - #endif - - fclose(fin); - fclose(fout); - free(inbuf); - free(outbuf); - free(bits); - codec2_destroy(codec2); -} - -#define SPEED_TEST_SAMPLES 24000 - -static void c2speedtest(int mode, char inputfile[]) -{ - struct CODEC2 *codec2; - short *inbuf, *outbuf, *pinbuf; - unsigned char *bits; - int nsam, nbit, nframes; - FILE *fin; - int f, nread; - - codec2 = codec2_create(mode); - nsam = codec2_samples_per_frame(codec2); - nframes = SPEED_TEST_SAMPLES/nsam; - outbuf = (short*)malloc(nsam*sizeof(short)); - inbuf = (short*)malloc(SPEED_TEST_SAMPLES*sizeof(short)); - nbit = codec2_bits_per_frame(codec2); - bits = (unsigned char*)malloc(nbit*sizeof(char)); - - fin = fopen(inputfile, "rb"); - if (fin == NULL) { - printf("Error opening input file: %s\nTerminating....\n",inputfile); - exit(1); - } - - nread = fread(inbuf, sizeof(short), SPEED_TEST_SAMPLES, fin); - if (nread != SPEED_TEST_SAMPLES) { - printf("error reading %s, %d samples reqd, %d read\n", - inputfile, SPEED_TEST_SAMPLES, nread); - } - fclose(fin); - - pinbuf = inbuf; - for(f=0; fODR = (1 << 13); - codec2_encode(codec2, bits, pinbuf); - pinbuf += nsam; - GPIOD->ODR &= ~(1 << 13); - codec2_decode(codec2, outbuf, bits); - } - - free(inbuf); - free(outbuf); - free(bits); - codec2_destroy(codec2); -} - -void gpio_init() { - RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN; // enable the clock to GPIOD - GPIOD->MODER = (1 << 26); // set pin 13 to be general - // purpose output -} - -int main(int argc, char *argv[]) { - SystemInit(); - gpio_init(); - machdep_timer_init (); - - printf("Starting c2demo\n"); - - /* File I/O test for profiling or (with #define DUMP) - dumping states for optimisation and tiuning */ - - c2demo(CODEC2_MODE_1600, "stm_in.raw", "stm_out.raw"); - - printf("Starting c2 speed test\n"); - - /* Another test of execution speed. Look at PD13 with a - oscilliscope. On time is enc, off is dec */ - - c2speedtest(CODEC2_MODE_1600, "stm_in.raw"); - - printf("Finished\n"); - - return 0; -} - diff --git a/codec2/stm32/src/startup_stm32f4xx.s b/codec2/stm32/src/startup_stm32f4xx.s deleted file mode 100644 index 658ab363..00000000 --- a/codec2/stm32/src/startup_stm32f4xx.s +++ /dev/null @@ -1,512 +0,0 @@ -/** - ****************************************************************************** - * @file startup_stm32f4xx.s - * @author MCD Application Team - * @version V1.0.0 - * @date 30-September-2011 - * @brief STM32F4xx Devices vector table for Atollic TrueSTUDIO toolchain. - * This module performs: - * - Set the initial SP - * - Set the initial PC == Reset_Handler, - * - Set the vector table entries with the exceptions ISR address - * - Configure the clock system and the external SRAM mounted on - * STM324xG-EVAL board to be used as data memory (optional, - * to be enabled by user) - * - Branches to main in the C library (which eventually - * calls main()). - * After Reset the Cortex-M4 processor is in Thread mode, - * priority is Privileged, and the Stack is set to Main. - ****************************************************************************** - * @attention - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2011 STMicroelectronics

- ****************************************************************************** - */ - - .syntax unified - .cpu cortex-m3 - .fpu softvfp - .thumb - -.global g_pfnVectors -.global Default_Handler - -/* start address for the initialization values of the .data section. -defined in linker script */ -.word _sidata -/* start address for the .data section. defined in linker script */ -.word _sdata -/* end address for the .data section. defined in linker script */ -.word _edata -/* start address for the .bss section. defined in linker script */ -.word _sbss -/* end address for the .bss section. defined in linker script */ -.word _ebss -/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ - -/** - * @brief This is the code that gets called when the processor first - * starts execution following a reset event. Only the absolutely - * necessary set is performed, after which the application - * supplied main() routine is called. - * @param None - * @retval : None -*/ - - .section .text.Reset_Handler - .weak Reset_Handler - .type Reset_Handler, %function -Reset_Handler: - -/* Copy the data segment initializers from flash to SRAM */ - movs r1, #0 - b LoopCopyDataInit - -CopyDataInit: - ldr r3, =_sidata - ldr r3, [r3, r1] - str r3, [r0, r1] - adds r1, r1, #4 - -LoopCopyDataInit: - ldr r0, =_sdata - ldr r3, =_edata - adds r2, r0, r1 - cmp r2, r3 - bcc CopyDataInit - ldr r2, =_sbss - b LoopFillZerobss -/* Zero fill the bss segment. */ -FillZerobss: - movs r3, #0 - str r3, [r2], #4 - -LoopFillZerobss: - ldr r3, = _ebss - cmp r2, r3 - bcc FillZerobss - -/* Call the clock system intitialization function.*/ - bl SystemInit -/* Call static constructors */ - bl __libc_init_array -/* Call the application's entry point.*/ - bl main - bx lr -.size Reset_Handler, .-Reset_Handler - -/** - * @brief This is the code that gets called when the processor receives an - * unexpected interrupt. This simply enters an infinite loop, preserving - * the system state for examination by a debugger. - * @param None - * @retval None -*/ - .section .text.Default_Handler,"ax",%progbits -Default_Handler: -Infinite_Loop: - b Infinite_Loop - .size Default_Handler, .-Default_Handler -/****************************************************************************** -* -* The minimal vector table for a Cortex M3. Note that the proper constructs -* must be placed on this to ensure that it ends up at physical address -* 0x0000.0000. -* -*******************************************************************************/ - .section .isr_vector,"a",%progbits - .type g_pfnVectors, %object - .size g_pfnVectors, .-g_pfnVectors - - -g_pfnVectors: - .word _estack - .word Reset_Handler - .word NMI_Handler - .word HardFault_Handler - .word MemManage_Handler - .word BusFault_Handler - .word UsageFault_Handler - .word 0 - .word 0 - .word 0 - .word 0 - .word SVC_Handler - .word DebugMon_Handler - .word 0 - .word PendSV_Handler - .word SysTick_Handler - - /* External Interrupts */ - .word WWDG_IRQHandler /* Window WatchDog */ - .word PVD_IRQHandler /* PVD through EXTI Line detection */ - .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ - .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ - .word FLASH_IRQHandler /* FLASH */ - .word RCC_IRQHandler /* RCC */ - .word EXTI0_IRQHandler /* EXTI Line0 */ - .word EXTI1_IRQHandler /* EXTI Line1 */ - .word EXTI2_IRQHandler /* EXTI Line2 */ - .word EXTI3_IRQHandler /* EXTI Line3 */ - .word EXTI4_IRQHandler /* EXTI Line4 */ - .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ - .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ - .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ - .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ - .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ - .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ - .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ - .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ - .word CAN1_TX_IRQHandler /* CAN1 TX */ - .word CAN1_RX0_IRQHandler /* CAN1 RX0 */ - .word CAN1_RX1_IRQHandler /* CAN1 RX1 */ - .word CAN1_SCE_IRQHandler /* CAN1 SCE */ - .word EXTI9_5_IRQHandler /* External Line[9:5]s */ - .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ - .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ - .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ - .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ - .word TIM2_IRQHandler /* TIM2 */ - .word TIM3_IRQHandler /* TIM3 */ - .word TIM4_IRQHandler /* TIM4 */ - .word I2C1_EV_IRQHandler /* I2C1 Event */ - .word I2C1_ER_IRQHandler /* I2C1 Error */ - .word I2C2_EV_IRQHandler /* I2C2 Event */ - .word I2C2_ER_IRQHandler /* I2C2 Error */ - .word SPI1_IRQHandler /* SPI1 */ - .word SPI2_IRQHandler /* SPI2 */ - .word USART1_IRQHandler /* USART1 */ - .word USART2_IRQHandler /* USART2 */ - .word USART3_IRQHandler /* USART3 */ - .word EXTI15_10_IRQHandler /* External Line[15:10]s */ - .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ - .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ - .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ - .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ - .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ - .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ - .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ - .word FSMC_IRQHandler /* FSMC */ - .word SDIO_IRQHandler /* SDIO */ - .word TIM5_IRQHandler /* TIM5 */ - .word SPI3_IRQHandler /* SPI3 */ - .word UART4_IRQHandler /* UART4 */ - .word UART5_IRQHandler /* UART5 */ - .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ - .word TIM7_IRQHandler /* TIM7 */ - .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ - .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ - .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ - .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ - .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ - .word ETH_IRQHandler /* Ethernet */ - .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ - .word CAN2_TX_IRQHandler /* CAN2 TX */ - .word CAN2_RX0_IRQHandler /* CAN2 RX0 */ - .word CAN2_RX1_IRQHandler /* CAN2 RX1 */ - .word CAN2_SCE_IRQHandler /* CAN2 SCE */ - .word OTG_FS_IRQHandler /* USB OTG FS */ - .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ - .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ - .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ - .word USART6_IRQHandler /* USART6 */ - .word I2C3_EV_IRQHandler /* I2C3 event */ - .word I2C3_ER_IRQHandler /* I2C3 error */ - .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ - .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ - .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ - .word OTG_HS_IRQHandler /* USB OTG HS */ - .word DCMI_IRQHandler /* DCMI */ - .word CRYP_IRQHandler /* CRYP crypto */ - .word HASH_RNG_IRQHandler /* Hash and Rng */ - .word FPU_IRQHandler /* FPU */ - - -/******************************************************************************* -* -* Provide weak aliases for each Exception handler to the Default_Handler. -* As they are weak aliases, any function with the same name will override -* this definition. -* -*******************************************************************************/ - .weak NMI_Handler - .thumb_set NMI_Handler,Default_Handler - - .weak HardFault_Handler - .thumb_set HardFault_Handler,Default_Handler - - .weak MemManage_Handler - .thumb_set MemManage_Handler,Default_Handler - - .weak BusFault_Handler - .thumb_set BusFault_Handler,Default_Handler - - .weak UsageFault_Handler - .thumb_set UsageFault_Handler,Default_Handler - - .weak SVC_Handler - .thumb_set SVC_Handler,Default_Handler - - .weak DebugMon_Handler - .thumb_set DebugMon_Handler,Default_Handler - - .weak PendSV_Handler - .thumb_set PendSV_Handler,Default_Handler - - .weak SysTick_Handler - .thumb_set SysTick_Handler,Default_Handler - - .weak WWDG_IRQHandler - .thumb_set WWDG_IRQHandler,Default_Handler - - .weak PVD_IRQHandler - .thumb_set PVD_IRQHandler,Default_Handler - - .weak TAMP_STAMP_IRQHandler - .thumb_set TAMP_STAMP_IRQHandler,Default_Handler - - .weak RTC_WKUP_IRQHandler - .thumb_set RTC_WKUP_IRQHandler,Default_Handler - - .weak FLASH_IRQHandler - .thumb_set FLASH_IRQHandler,Default_Handler - - .weak RCC_IRQHandler - .thumb_set RCC_IRQHandler,Default_Handler - - .weak EXTI0_IRQHandler - .thumb_set EXTI0_IRQHandler,Default_Handler - - .weak EXTI1_IRQHandler - .thumb_set EXTI1_IRQHandler,Default_Handler - - .weak EXTI2_IRQHandler - .thumb_set EXTI2_IRQHandler,Default_Handler - - .weak EXTI3_IRQHandler - .thumb_set EXTI3_IRQHandler,Default_Handler - - .weak EXTI4_IRQHandler - .thumb_set EXTI4_IRQHandler,Default_Handler - - .weak DMA1_Stream0_IRQHandler - .thumb_set DMA1_Stream0_IRQHandler,Default_Handler - - .weak DMA1_Stream1_IRQHandler - .thumb_set DMA1_Stream1_IRQHandler,Default_Handler - - .weak DMA1_Stream2_IRQHandler - .thumb_set DMA1_Stream2_IRQHandler,Default_Handler - - .weak DMA1_Stream3_IRQHandler - .thumb_set DMA1_Stream3_IRQHandler,Default_Handler - - .weak DMA1_Stream4_IRQHandler - .thumb_set DMA1_Stream4_IRQHandler,Default_Handler - - .weak DMA1_Stream5_IRQHandler - .thumb_set DMA1_Stream5_IRQHandler,Default_Handler - - .weak DMA1_Stream6_IRQHandler - .thumb_set DMA1_Stream6_IRQHandler,Default_Handler - - .weak ADC_IRQHandler - .thumb_set ADC_IRQHandler,Default_Handler - - .weak CAN1_TX_IRQHandler - .thumb_set CAN1_TX_IRQHandler,Default_Handler - - .weak CAN1_RX0_IRQHandler - .thumb_set CAN1_RX0_IRQHandler,Default_Handler - - .weak CAN1_RX1_IRQHandler - .thumb_set CAN1_RX1_IRQHandler,Default_Handler - - .weak CAN1_SCE_IRQHandler - .thumb_set CAN1_SCE_IRQHandler,Default_Handler - - .weak EXTI9_5_IRQHandler - .thumb_set EXTI9_5_IRQHandler,Default_Handler - - .weak TIM1_BRK_TIM9_IRQHandler - .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler - - .weak TIM1_UP_TIM10_IRQHandler - .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler - - .weak TIM1_TRG_COM_TIM11_IRQHandler - .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler - - .weak TIM1_CC_IRQHandler - .thumb_set TIM1_CC_IRQHandler,Default_Handler - - .weak TIM2_IRQHandler - .thumb_set TIM2_IRQHandler,Default_Handler - - .weak TIM3_IRQHandler - .thumb_set TIM3_IRQHandler,Default_Handler - - .weak TIM4_IRQHandler - .thumb_set TIM4_IRQHandler,Default_Handler - - .weak I2C1_EV_IRQHandler - .thumb_set I2C1_EV_IRQHandler,Default_Handler - - .weak I2C1_ER_IRQHandler - .thumb_set I2C1_ER_IRQHandler,Default_Handler - - .weak I2C2_EV_IRQHandler - .thumb_set I2C2_EV_IRQHandler,Default_Handler - - .weak I2C2_ER_IRQHandler - .thumb_set I2C2_ER_IRQHandler,Default_Handler - - .weak SPI1_IRQHandler - .thumb_set SPI1_IRQHandler,Default_Handler - - .weak SPI2_IRQHandler - .thumb_set SPI2_IRQHandler,Default_Handler - - .weak USART1_IRQHandler - .thumb_set USART1_IRQHandler,Default_Handler - - .weak USART2_IRQHandler - .thumb_set USART2_IRQHandler,Default_Handler - - .weak USART3_IRQHandler - .thumb_set USART3_IRQHandler,Default_Handler - - .weak EXTI15_10_IRQHandler - .thumb_set EXTI15_10_IRQHandler,Default_Handler - - .weak RTC_Alarm_IRQHandler - .thumb_set RTC_Alarm_IRQHandler,Default_Handler - - .weak OTG_FS_WKUP_IRQHandler - .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler - - .weak TIM8_BRK_TIM12_IRQHandler - .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler - - .weak TIM8_UP_TIM13_IRQHandler - .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler - - .weak TIM8_TRG_COM_TIM14_IRQHandler - .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler - - .weak TIM8_CC_IRQHandler - .thumb_set TIM8_CC_IRQHandler,Default_Handler - - .weak DMA1_Stream7_IRQHandler - .thumb_set DMA1_Stream7_IRQHandler,Default_Handler - - .weak FSMC_IRQHandler - .thumb_set FSMC_IRQHandler,Default_Handler - - .weak SDIO_IRQHandler - .thumb_set SDIO_IRQHandler,Default_Handler - - .weak TIM5_IRQHandler - .thumb_set TIM5_IRQHandler,Default_Handler - - .weak SPI3_IRQHandler - .thumb_set SPI3_IRQHandler,Default_Handler - - .weak UART4_IRQHandler - .thumb_set UART4_IRQHandler,Default_Handler - - .weak UART5_IRQHandler - .thumb_set UART5_IRQHandler,Default_Handler - - .weak TIM6_DAC_IRQHandler - .thumb_set TIM6_DAC_IRQHandler,Default_Handler - - .weak TIM7_IRQHandler - .thumb_set TIM7_IRQHandler,Default_Handler - - .weak DMA2_Stream0_IRQHandler - .thumb_set DMA2_Stream0_IRQHandler,Default_Handler - - .weak DMA2_Stream1_IRQHandler - .thumb_set DMA2_Stream1_IRQHandler,Default_Handler - - .weak DMA2_Stream2_IRQHandler - .thumb_set DMA2_Stream2_IRQHandler,Default_Handler - - .weak DMA2_Stream3_IRQHandler - .thumb_set DMA2_Stream3_IRQHandler,Default_Handler - - .weak DMA2_Stream4_IRQHandler - .thumb_set DMA2_Stream4_IRQHandler,Default_Handler - - .weak ETH_IRQHandler - .thumb_set ETH_IRQHandler,Default_Handler - - .weak ETH_WKUP_IRQHandler - .thumb_set ETH_WKUP_IRQHandler,Default_Handler - - .weak CAN2_TX_IRQHandler - .thumb_set CAN2_TX_IRQHandler,Default_Handler - - .weak CAN2_RX0_IRQHandler - .thumb_set CAN2_RX0_IRQHandler,Default_Handler - - .weak CAN2_RX1_IRQHandler - .thumb_set CAN2_RX1_IRQHandler,Default_Handler - - .weak CAN2_SCE_IRQHandler - .thumb_set CAN2_SCE_IRQHandler,Default_Handler - - .weak OTG_FS_IRQHandler - .thumb_set OTG_FS_IRQHandler,Default_Handler - - .weak DMA2_Stream5_IRQHandler - .thumb_set DMA2_Stream5_IRQHandler,Default_Handler - - .weak DMA2_Stream6_IRQHandler - .thumb_set DMA2_Stream6_IRQHandler,Default_Handler - - .weak DMA2_Stream7_IRQHandler - .thumb_set DMA2_Stream7_IRQHandler,Default_Handler - - .weak USART6_IRQHandler - .thumb_set USART6_IRQHandler,Default_Handler - - .weak I2C3_EV_IRQHandler - .thumb_set I2C3_EV_IRQHandler,Default_Handler - - .weak I2C3_ER_IRQHandler - .thumb_set I2C3_ER_IRQHandler,Default_Handler - - .weak OTG_HS_EP1_OUT_IRQHandler - .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler - - .weak OTG_HS_EP1_IN_IRQHandler - .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler - - .weak OTG_HS_WKUP_IRQHandler - .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler - - .weak OTG_HS_IRQHandler - .thumb_set OTG_HS_IRQHandler,Default_Handler - - .weak DCMI_IRQHandler - .thumb_set DCMI_IRQHandler,Default_Handler - - .weak CRYP_IRQHandler - .thumb_set CRYP_IRQHandler,Default_Handler - - .weak HASH_RNG_IRQHandler - .thumb_set HASH_RNG_IRQHandler,Default_Handler - - .weak FPU_IRQHandler - .thumb_set FPU_IRQHandler,Default_Handler - -/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/codec2/stm32/src/stm32f4_adc.c b/codec2/stm32/src/stm32f4_adc.c deleted file mode 100644 index 62fe8a99..00000000 --- a/codec2/stm32/src/stm32f4_adc.c +++ /dev/null @@ -1,314 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: stm32f4_adc.c - AUTHOR......: David Rowe - DATE CREATED: 4 June 2013 - - ADC driver module for STM32F4. - - TODO: - [X] just get ADC to run at all, prove its sampling something.... - [X] as above with DMA - [X] half and finished interrupts, ISR - [X] timer config to drive ADC conversion, measure sample rate and confirm 16kHz - + larger ADC DMA buffer - + fifos - + work out a way to unit test - [ ] ADC working at same time as DAC - [X] remove (or make optional) the TIM_Config() code that sends PWM output to pins - [ ] check comments still valid - [X] convert to driver - [ ] way to determine which timers are used so they don't get re-sued - [ ] way to select different pins/ADCs for multiple channels, multiple channel support - [ ] access functions for halff/full/overflow to trap any issues - [ ] should FIFOs be in this drivr or in UTs connected to stdio? SmartMic will just need - 40ms of buffering - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2013 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include -#include - -#include "stm32f4xx_adc.h" -#include "stm32f4xx_gpio.h" -#include "stm32f4xx_rcc.h" - -#include "codec2_fifo.h" -#include "gdb_stdio.h" -#include "stm32f4_adc.h" - -#define ADC_BUF_SZ 320 -#define FIFO_SZ 1000 - -struct FIFO *DMA2_Stream0_fifo; -unsigned short adc_buf[ADC_BUF_SZ]; -int adc_overflow; -int half,full; - -#define ADCx_DR_ADDRESS ((uint32_t)0x4001204C) -#define DMA_CHANNELx DMA_Channel_0 -#define DMA_STREAMx DMA2_Stream0 -#define ADCx ADC1 - -#define TIM1_CCR3_ADDRESS 0x4001223C - -TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; -TIM_OCInitTypeDef TIM_OCInitStructure; -uint16_t uhTimerPeriod; -uint16_t aSRC_Buffer[3] = {0, 0, 0}; - -void Timer1Config(); -void adc_configure(); - -void adc_open(void) { - DMA2_Stream0_fifo = fifo_create(FIFO_SZ); - assert(DMA2_Stream0_fifo != NULL); - - Timer1Config(); - adc_configure(); - ADC_SoftwareStartConv(ADC1); -} - -/* n signed 16 bit samples in buf[] if return != -1 */ - -int adc_read(short buf[], int n) { - return fifo_read(DMA2_Stream0_fifo, buf, n); -} - -void Timer1Config() { - - /* TIM1 example ------------------------------------------------- - - TIM1 input clock (TIM1CLK) is set to 2 * APB2 clock (PCLK2), since APB2 - prescaler is different from 1. - TIM1CLK = 2 * PCLK2 - PCLK2 = HCLK / 2 - => TIM1CLK = 2 * (HCLK / 2) = HCLK = SystemCoreClock - - TIM1CLK = SystemCoreClock, Prescaler = 0, TIM1 counter clock = SystemCoreClock - SystemCoreClock is set to 168 MHz for STM32F4xx devices. - - The objective is to configure TIM1 channel 3 to generate complementary PWM - signal with a frequency equal to F KHz: - - TIM1_Period = (SystemCoreClock / F) - 1 - - The number of this repetitive requests is defined by the TIM1 Repetion counter, - each 3 Update Requests, the TIM1 Channel 3 Duty Cycle changes to the next new - value defined by the aSRC_Buffer. - - Note: - SystemCoreClock variable holds HCLK frequency and is defined in system_stm32f4xx.c file. - Each time the core clock (HCLK) changes, user had to call SystemCoreClockUpdate() - function to update SystemCoreClock variable value. Otherwise, any configuration - based on this variable will be incorrect. - -----------------------------------------------------------------------------*/ - - /* Compute the value to be set in ARR regiter to generate signal frequency at 16.00 Khz */ - uhTimerPeriod = (SystemCoreClock / 16000 ) - 1; - /* Compute CCR1 value to generate a duty cycle at 50% */ - aSRC_Buffer[0] = (uint16_t) (((uint32_t) 5 * (uhTimerPeriod - 1)) / 10); - /* Compute CCR1 value to generate a duty cycle at 37.5% */ - aSRC_Buffer[1] = (uint16_t) (((uint32_t) 375 * (uhTimerPeriod - 1)) / 1000); - /* Compute CCR1 value to generate a duty cycle at 25% */ - aSRC_Buffer[2] = (uint16_t) (((uint32_t) 25 * (uhTimerPeriod - 1)) / 100); - - /* TIM1 Peripheral Configuration -------------------------------------------*/ - /* TIM1 clock enable */ - RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE); - - /* Time Base configuration */ - - TIM_DeInit(TIM1); - TIM_TimeBaseStructure.TIM_Prescaler = 0; - TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; - TIM_TimeBaseStructure.TIM_Period = uhTimerPeriod; - TIM_TimeBaseStructure.TIM_ClockDivision = 0; - TIM_TimeBaseStructure.TIM_RepetitionCounter = 0; - - TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure); - - /* Channel 3 Configuration in PWM mode */ - - /* I think we just ned to enable channel 3 somehow, but without - (or optionally with) actual ouput to a GPIO pin. */ - - TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2; - TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; - TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable; - TIM_OCInitStructure.TIM_Pulse = aSRC_Buffer[0]; - TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low; - TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_Low; - TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set; - TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset; - - TIM_OC3Init(TIM1, &TIM_OCInitStructure); - - /* Enable preload feature */ - TIM_OC3PreloadConfig(TIM1, TIM_OCPreload_Enable); - - /* TIM1 counter enable */ - TIM_Cmd(TIM1, ENABLE); - - /* Main Output Enable */ - TIM_CtrlPWMOutputs(TIM1, ENABLE); -} - -void adc_configure(){ - ADC_InitTypeDef ADC_init_structure; - GPIO_InitTypeDef GPIO_initStructre; - DMA_InitTypeDef DMA_InitStructure; - NVIC_InitTypeDef NVIC_InitStructure; - - // Clock configuration - - RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1,ENABLE); - RCC_AHB1PeriphClockCmd(RCC_AHB1ENR_GPIOCEN,ENABLE); - RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE); - - // Analog pin configuration - - GPIO_initStructre.GPIO_Pin = GPIO_Pin_0; // ADC Channel 10 is connected to PC0 - GPIO_initStructre.GPIO_Mode = GPIO_Mode_AN; - GPIO_initStructre.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOC,&GPIO_initStructre); - - // ADC structure configuration - - ADC_DeInit(); - ADC_init_structure.ADC_DataAlign = ADC_DataAlign_Left; - ADC_init_structure.ADC_Resolution = ADC_Resolution_12b; - ADC_init_structure.ADC_ContinuousConvMode = DISABLE; - ADC_init_structure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC3; - ADC_init_structure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_Rising; - ADC_init_structure.ADC_NbrOfConversion = 1; - ADC_init_structure.ADC_ScanConvMode = DISABLE; - ADC_Init(ADCx,&ADC_init_structure); - - // Select the channel to be read from - - ADC_RegularChannelConfig(ADCx,ADC_Channel_10,1,ADC_SampleTime_144Cycles); - - /* DMA configuration **************************************/ - - DMA_DeInit(DMA_STREAMx); - DMA_InitStructure.DMA_Channel = DMA_CHANNELx; - DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADCx_DR_ADDRESS; - DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)adc_buf; - DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; - DMA_InitStructure.DMA_BufferSize = ADC_BUF_SZ; - DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; - DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; - DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; - DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; - DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; - DMA_InitStructure.DMA_Priority = DMA_Priority_High; - DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; - DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; - DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; - DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; - DMA_Init(DMA_STREAMx, &DMA_InitStructure); - - /* Enable DMA request after last transfer (Single-ADC mode) */ - - ADC_DMARequestAfterLastTransferCmd(ADCx, ENABLE); - - /* Enable ADC1 DMA */ - - ADC_DMACmd(ADCx, ENABLE); - - /* DMA2_Stream0 enable */ - - DMA_Cmd(DMA_STREAMx, ENABLE); - - /* Enable DMA Half & Complete interrupts */ - - DMA_ITConfig(DMA2_Stream0, DMA_IT_TC | DMA_IT_HT, ENABLE); - - /* Enable the DMA Stream IRQ Channel */ - - NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream0_IRQn; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; - NVIC_Init(&NVIC_InitStructure); - - // Enable ADC conversion - - ADC_Cmd(ADC1,ENABLE); -} - -/* - This function handles DMA Stream interrupt request. -*/ - -void DMA2_Stream0_IRQHandler(void) { - int i, sam; - short signed_buf[ADC_BUF_SZ/2]; - - /* Half transfer interrupt */ - - if(DMA_GetITStatus(DMA2_Stream0, DMA_IT_HTIF0) != RESET) { - half++; - - /* convert to signed */ - - for(i=0; i. -*/ - -#include -#include -#include -#include "stm32f4xx.h" -#include "codec2_fifo.h" -#include "stm32f4_dac.h" - -#define DAC_DHR12R2_ADDRESS 0x40007414 -#define DAC_DHR12L2_ADDRESS 0x40007418 - -#define DAC_BUF_SZ 320 -#define FIFO_SZ 1000 -#define DAC_MAX 4096 - -DAC_InitTypeDef DAC_InitStructure; -struct FIFO *DMA1_Stream6_fifo; - -unsigned short dac_buf[DAC_BUF_SZ]; - -static void TIM6_Config(void); -static void DAC_Ch2_Config(void); - -int dac_underflow; - -void dac_open(void) { - - memset(dac_buf, 32768, sizeof(short)*DAC_BUF_SZ); - - /* Create fifo */ - - DMA1_Stream6_fifo = fifo_create(FIFO_SZ); - assert(DMA1_Stream6_fifo != NULL); - - /*!< At this stage the microcontroller clock setting is already configured, - this is done through SystemInit() function which is called from startup - files (startup_stm32f40xx.s/startup_stm32f427x.s) before to branch to - application main. - To reconfigure the default setting of SystemInit() function, refer to - system_stm32f4xx.c file - */ - - /* Preconfiguration before using DAC----------------------------------------*/ - - GPIO_InitTypeDef GPIO_InitStructure; - - /* DMA1 clock enable */ - RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1, ENABLE); - /* GPIOA clock enable (to be used with DAC) */ - RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); - /* DAC Periph clock enable */ - RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE); - - /* DAC channel 1 & 2 (DAC_OUT1 = PA.4)(DAC_OUT2 = PA.5) configuration */ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOA, &GPIO_InitStructure); - - /* TIM6 Configuration ------------------------------------------------------*/ - - TIM6_Config(); - DAC_Ch2_Config(); - -} - -/* Accepts signed 16 bit samples */ - -int dac_write(short buf[], int n) { - return fifo_write(DMA1_Stream6_fifo, buf, n); -} - -/** - * @brief TIM6 Configuration - * @note TIM6 configuration is based on APB1 frequency - * @note TIM6 Update event occurs each TIM6CLK/256 - * @param None - * @retval None - */ -static void TIM6_Config(void) -{ - TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; - /* TIM6 Periph clock enable */ - RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE); - - /* -------------------------------------------------------- - - TIM3 input clock (TIM6CLK) is set to 2 * APB1 clock (PCLK1), since - APB1 prescaler is different from 1 (see system_stm32f4xx.c and Fig - 13 clock tree figure in DM0031020.pdf). - - Sample rate Fs = 2*PCLK1/TIM_ClockDivision - = (HCLK/2)/TIM_ClockDivision - - ----------------------------------------------------------- */ - - /* Time base configuration */ - TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); - TIM_TimeBaseStructure.TIM_Period = 5250; - TIM_TimeBaseStructure.TIM_Prescaler = 0; - TIM_TimeBaseStructure.TIM_ClockDivision = 0; - TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; - TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure); - - /* TIM6 TRGO selection */ - - TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update); - - /* TIM6 enable counter */ - TIM_Cmd(TIM6, ENABLE); -} - -/** - * @brief DAC Channel2 SineWave Configuration - * @param None - * @retval None - */ -static void DAC_Ch2_Config(void) -{ - DMA_InitTypeDef DMA_InitStructure; - NVIC_InitTypeDef NVIC_InitStructure; - - /* DAC channel2 Configuration */ - DAC_InitStructure.DAC_Trigger = DAC_Trigger_T6_TRGO; - DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; - DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable; - DAC_Init(DAC_Channel_2, &DAC_InitStructure); - - /* DMA1_Stream6 channel7 configuration **************************************/ - DMA_DeInit(DMA1_Stream6); - DMA_InitStructure.DMA_Channel = DMA_Channel_7; - DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)DAC_DHR12L2_ADDRESS; - DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)dac_buf; - DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; - DMA_InitStructure.DMA_BufferSize = DAC_BUF_SZ; - DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; - DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; - DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; - DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; - DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; - DMA_InitStructure.DMA_Priority = DMA_Priority_High; - DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; - DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; - DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; - DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; - DMA_Init(DMA1_Stream6, &DMA_InitStructure); - - /* Enable DMA Half & Complete interrupts */ - DMA_ITConfig(DMA1_Stream6, DMA_IT_TC | DMA_IT_HT, ENABLE); - - /* Enable the DMA Stream IRQ Channel */ - - NVIC_InitStructure.NVIC_IRQChannel = DMA1_Stream6_IRQn; - NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; - NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; - NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; - NVIC_Init(&NVIC_InitStructure); - - /* Enable DMA1_Stream6 */ - DMA_Cmd(DMA1_Stream6, ENABLE); - - /* Enable DAC Channel2 */ - DAC_Cmd(DAC_Channel_2, ENABLE); - - /* Enable DMA for DAC Channel2 */ - DAC_DMACmd(DAC_Channel_2, ENABLE); -} - -/******************************************************************************/ -/* STM32F4xx Peripherals Interrupt Handlers */ -/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ -/* available peripheral interrupt handler's name please refer to the startup */ -/* file (startup_stm32f40xx.s/startup_stm32f427x.s). */ -/******************************************************************************/ - -/* - This function handles DMA Stream interrupt request. -*/ - -void DMA1_Stream6_IRQHandler(void) { - int i, sam; - short signed_buf[DAC_BUF_SZ/2]; - - /* Transfer half empty interrupt */ - - if(DMA_GetITStatus(DMA1_Stream6, DMA_IT_HTIF6) != RESET) { - /* fill first half from fifo */ - - if (fifo_read(DMA1_Stream6_fifo, signed_buf, DAC_BUF_SZ/2) == -1) { - memset(signed_buf, 0, sizeof(short)*DAC_BUF_SZ/2); - dac_underflow++; - } - - /* convert to unsigned */ - - for(i=0; i. -*/ - - -#include -#include -#include - -#include "stm32f4xx_gpio.h" -#include "stm32f4xx_rcc.h" - -#define TIM1_CCR3_ADDRESS 0x4001003C -//#define TIM1_CCR3_ADDRESS 0x4001223C -#define SINE_SAMPLES 32 - -TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; -TIM_OCInitTypeDef TIM_OCInitStructure; -uint16_t uhTimerPeriod; -uint16_t aSRC_Buffer[SINE_SAMPLES] = {0, 0, 0}; - -/* 32 sample sine wave which at Fs=16kHz will be 500Hz. Not sampels - are 16 bit 2's complement, the DAC driver convertsto 12 bit - unsigned. */ - -short aSine[SINE_SAMPLES] = { - -16, 6384, 12528, 18192, 23200, 27232, 30256, 32128, 32752, 32128, - 30256, 27232, 23152, 18192, 12528, 6384, -16, -6416, -12560, -18224, - -23184, -27264, -30288, -32160, -32768, -32160, -30288, -27264, -23184, -18224, - -12560, -6416 -}; - -void Timer1Config(); - -#define FS 16000 - -int main(void){ - Timer1Config(); - while(1); -} - -/* DR: TIM_Config configures a couple of I/O pins for PWM output from - Timer1 Channel 3. Note I dont think any of this is needed, except - perhaps to check timer frequency. Can be removed down the track. */ - -/** - * @brief Configure the TIM1 Pins. - * @param None - * @retval None - */ -static void TIM_Config(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - DMA_InitTypeDef DMA_InitStructure; - - /* GPIOA and GPIOB clock enable */ - RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB, ENABLE); - - /* GPIOA Configuration: Channel 3 as alternate function push-pull */ - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 ; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; - GPIO_Init(GPIOA, &GPIO_InitStructure); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_TIM1); - - /* GPIOB Configuration: Channel 3N as alternate function push-pull */ - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; - GPIO_Init(GPIOB, &GPIO_InitStructure); - GPIO_PinAFConfig(GPIOB, GPIO_PinSource15, GPIO_AF_TIM1); - - /* DMA clock enable */ - RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2 , ENABLE); - - DMA_DeInit(DMA2_Stream6); - DMA_InitStructure.DMA_Channel = DMA_Channel_6; - DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(TIM1_CCR3_ADDRESS) ; - DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)aSRC_Buffer; - DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; - DMA_InitStructure.DMA_BufferSize = SINE_SAMPLES; - DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; - DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; - DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; - DMA_InitStructure.DMA_MemoryDataSize = DMA_PeripheralDataSize_HalfWord; - DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; - DMA_InitStructure.DMA_Priority = DMA_Priority_High; - DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; - DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; - DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; - DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; - - DMA_Init(DMA2_Stream6, &DMA_InitStructure); -} - -void Timer1Config() { - int i; - - /* TIM Configuration */ - - TIM_Config(); - - /* TIM1 example ------------------------------------------------- - - TIM1 input clock (TIM1CLK) is set to 2 * APB2 clock (PCLK2), since APB2 - prescaler is different from 1. - TIM1CLK = 2 * PCLK2 - PCLK2 = HCLK / 2 - => TIM1CLK = 2 * (HCLK / 2) = HCLK = SystemCoreClock - - TIM1CLK = SystemCoreClock, Prescaler = 0, TIM1 counter clock = SystemCoreClock - SystemCoreClock is set to 168 MHz for STM32F4xx devices. - - The objective is to configure TIM1 channel 3 to generate complementary PWM - signal with a frequency equal to F KHz: - - TIM1_Period = (SystemCoreClock / F) - 1 - - The number of this repetitive requests is defined by the TIM1 Repetion counter, - each 3 Update Requests, the TIM1 Channel 3 Duty Cycle changes to the next new - value defined by the aSRC_Buffer. - - Note: - SystemCoreClock variable holds HCLK frequency and is defined in system_stm32f4xx.c file. - Each time the core clock (HCLK) changes, user had to call SystemCoreClockUpdate() - function to update SystemCoreClock variable value. Otherwise, any configuration - based on this variable will be incorrect. - -----------------------------------------------------------------------------*/ - - /* Compute the value to be set in ARR regiter to generate signal frequency at FS */ - - uhTimerPeriod = (SystemCoreClock / FS ) - 1; - - /* Compute CCR1 values to generate a duty cycle at 50% */ - - for(i=0; i. -*/ - -#include -#include "machdep.h" -#include "gdb_stdio.h" - -volatile unsigned int *DWT_CYCCNT = (volatile unsigned int *)0xE0001004; -volatile unsigned int *DWT_CONTROL = (volatile unsigned int *)0xE0001000; -volatile unsigned int *SCB_DEMCR = (volatile unsigned int *)0xE000EDFC; - -#define CORE_CLOCK 168E6 -#define BUF_SZ 4096 - -static char buf[BUF_SZ]; - -void machdep_timer_init(void) -{ - static int enabled = 0; - - if (!enabled) { - *SCB_DEMCR = *SCB_DEMCR | 0x01000000; - *DWT_CYCCNT = 0; // reset the counter - *DWT_CONTROL = *DWT_CONTROL | 1 ; // enable the counter - - enabled = 1; - } - *buf = 0; -} - -void machdep_timer_reset(void) -{ - *DWT_CYCCNT = 0; // reset the counter -} - -unsigned int machdep_timer_sample(void) { - return *DWT_CYCCNT; -} - -/* log to a buffer, we only call printf after timing finished as it is slow */ - -unsigned int machdep_timer_sample_and_log(unsigned int start, char s[]) -{ - char tmp[80]; - - unsigned int dwt = *DWT_CYCCNT - start; - sprintf(tmp, "%s %5.2f msecs\n",s,1000.0*(float)dwt/CORE_CLOCK); - if ((strlen(buf) + strlen(tmp)) < BUF_SZ) - strcat(buf, tmp); - return *DWT_CYCCNT; -} - -void machdep_timer_print_logged_samples(void) -{ - gdb_stdio_printf("%s", buf); - *buf = 0; -} diff --git a/codec2/stm32/src/system_stm32f4xx.c b/codec2/stm32/src/system_stm32f4xx.c deleted file mode 100644 index 86953137..00000000 --- a/codec2/stm32/src/system_stm32f4xx.c +++ /dev/null @@ -1,584 +0,0 @@ -/** - ****************************************************************************** - * @file system_stm32f4xx.c - * @author MCD Application Team - * @version V1.0.1 - * @date 10-July-2012 - * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File. - * This file contains the system clock configuration for STM32F4xx devices, - * and is generated by the clock configuration tool - * stm32f4xx_Clock_Configuration_V1.0.1.xls - * - * 1. This file provides two functions and one global variable to be called from - * user application: - * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier - * and Divider factors, AHB/APBx prescalers and Flash settings), - * depending on the configuration made in the clock xls tool. - * This function is called at startup just after reset and - * before branch to main program. This call is made inside - * the "startup_stm32f4xx.s" file. - * - * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used - * by the user application to setup the SysTick - * timer or configure other parameters. - * - * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must - * be called whenever the core clock is changed - * during program execution. - * - * 2. After each device reset the HSI (16 MHz) is used as system clock source. - * Then SystemInit() function is called, in "startup_stm32f4xx.s" file, to - * configure the system clock before to branch to main program. - * - * 3. If the system clock source selected by user fails to startup, the SystemInit() - * function will do nothing and HSI still used as system clock source. User can - * add some code to deal with this issue inside the SetSysClock() function. - * - * 4. The default value of HSE crystal is set to 25MHz, refer to "HSE_VALUE" define - * in "stm32f4xx.h" file. When HSE is used as system clock source, directly or - * through PLL, and you are using different crystal you have to adapt the HSE - * value to your own configuration. - * - * 5. This file configures the system clock as follows: - *============================================================================= - *============================================================================= - * Supported STM32F4xx device revision | Rev A - *----------------------------------------------------------------------------- - * System Clock source | PLL (HSE) - *----------------------------------------------------------------------------- - * SYSCLK(Hz) | 168000000 - *----------------------------------------------------------------------------- - * HCLK(Hz) | 168000000 - *----------------------------------------------------------------------------- - * AHB Prescaler | 1 - *----------------------------------------------------------------------------- - * APB1 Prescaler | 4 - *----------------------------------------------------------------------------- - * APB2 Prescaler | 2 - *----------------------------------------------------------------------------- - * HSE Frequency(Hz) | 8000000 - *----------------------------------------------------------------------------- - * PLL_M | 8 - *----------------------------------------------------------------------------- - * PLL_N | 336 - *----------------------------------------------------------------------------- - * PLL_P | 2 - *----------------------------------------------------------------------------- - * PLL_Q | 7 - *----------------------------------------------------------------------------- - * PLLI2S_N | 352 - *----------------------------------------------------------------------------- - * PLLI2S_R | 2 - *----------------------------------------------------------------------------- - * I2S input clock(Hz) | 176000000 - * | - * To achieve the following I2S config: | - * - Master clock output (MCKO): OFF | - * - Frame wide : 16bit | - * - Error % : 0,0000 | - * - Prescaler Odd factor (ODD): 1 | - * - Linear prescaler (DIV) : 14 | - *----------------------------------------------------------------------------- - * VDD(V) | 3,3 - *----------------------------------------------------------------------------- - * Main regulator output voltage | Scale1 mode - *----------------------------------------------------------------------------- - * Flash Latency(WS) | 5 - *----------------------------------------------------------------------------- - * Prefetch Buffer | OFF - *----------------------------------------------------------------------------- - * Instruction cache | ON - *----------------------------------------------------------------------------- - * Data cache | ON - *----------------------------------------------------------------------------- - * Require 48MHz for USB OTG FS, | Enabled - * SDIO and RNG clock | - *----------------------------------------------------------------------------- - *============================================================================= - ****************************************************************************** - * @attention - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2011 STMicroelectronics

- ****************************************************************************** - */ - -/** @addtogroup CMSIS - * @{ - */ - -/** @addtogroup stm32f4xx_system - * @{ - */ - -/** @addtogroup STM32F4xx_System_Private_Includes - * @{ - */ - -#include "stm32f4xx.h" - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_Defines - * @{ - */ - -/************************* Miscellaneous Configuration ************************/ -/*!< Uncomment the following line if you need to use external SRAM mounted - on STM324xG_EVAL board as data memory */ -/* #define DATA_IN_ExtSRAM */ - -/*!< Uncomment the following line if you need to relocate your vector Table in - Internal SRAM. */ -/* #define VECT_TAB_SRAM */ -#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ -/******************************************************************************/ - -/************************* PLL Parameters *************************************/ -/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */ -#define PLL_M 8 -#define PLL_N 336 - -/* SYSCLK = PLL_VCO / PLL_P */ -#define PLL_P 2 - -/* USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ */ -#define PLL_Q 7 - -/* PLLI2S_VCO = (HSE_VALUE Or HSI_VALUE / PLL_M) * PLLI2S_N - I2SCLK = PLLI2S_VCO / PLLI2S_R */ -#define START_I2SCLOCK 0 -#define PLLI2S_N 352 -#define PLLI2S_R 2 - -/******************************************************************************/ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_Variables - * @{ - */ - -uint32_t SystemCoreClock = 168000000; - -__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes - * @{ - */ - -static void SetSysClock(void); -#ifdef DATA_IN_ExtSRAM -static void SystemInit_ExtMemCtl(void); -#endif /* DATA_IN_ExtSRAM */ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_Functions - * @{ - */ - -/** - * @brief Setup the microcontroller system - * Initialize the Embedded Flash Interface, the PLL and update the - * SystemFrequency variable. - * @param None - * @retval None - */ -void SystemInit(void) -{ - /* FPU settings ------------------------------------------------------------*/ -#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) - SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ -#endif - /* Reset the RCC clock configuration to the default reset state ------------*/ - /* Set HSION bit */ - RCC->CR |= (uint32_t)0x00000001; - - /* Reset CFGR register */ - RCC->CFGR = 0x00000000; - - /* Reset HSEON, CSSON and PLLON bits */ - RCC->CR &= (uint32_t)0xFEF6FFFF; - - /* Reset PLLCFGR register */ - RCC->PLLCFGR = 0x24003010; - - /* Reset HSEBYP bit */ - RCC->CR &= (uint32_t)0xFFFBFFFF; - - /* Disable all interrupts */ - RCC->CIR = 0x00000000; - -#ifdef DATA_IN_ExtSRAM - SystemInit_ExtMemCtl(); -#endif /* DATA_IN_ExtSRAM */ - - /* Configure the System clock source, PLL Multiplier and Divider factors, - AHB/APBx prescalers and Flash settings ----------------------------------*/ - SetSysClock(); - - /* Configure the Vector Table location add offset address ------------------*/ -#ifdef VECT_TAB_SRAM - SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ -#else - SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ -#endif -} - -/** - * @brief Update SystemCoreClock variable according to Clock Register Values. - * The SystemCoreClock variable contains the core clock (HCLK), it can - * be used by the user application to setup the SysTick timer or configure - * other parameters. - * - * @note Each time the core clock (HCLK) changes, this function must be called - * to update SystemCoreClock variable value. Otherwise, any configuration - * based on this variable will be incorrect. - * - * @note - The system frequency computed by this function is not the real - * frequency in the chip. It is calculated based on the predefined - * constant and the selected clock source: - * - * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) - * - * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) - * - * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) - * or HSI_VALUE(*) multiplied/divided by the PLL factors. - * - * (*) HSI_VALUE is a constant defined in stm32f4xx.h file (default value - * 16 MHz) but the real value may vary depending on the variations - * in voltage and temperature. - * - * (**) HSE_VALUE is a constant defined in stm32f4xx.h file (default value - * 25 MHz), user has to ensure that HSE_VALUE is same as the real - * frequency of the crystal used. Otherwise, this function may - * have wrong result. - * - * - The result of this function could be not correct when using fractional - * value for HSE crystal. - * - * @param None - * @retval None - */ -void SystemCoreClockUpdate(void) -{ - uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2; - - /* Get SYSCLK source -------------------------------------------------------*/ - tmp = RCC->CFGR & RCC_CFGR_SWS; - - switch (tmp) - { - case 0x00: /* HSI used as system clock source */ - SystemCoreClock = HSI_VALUE; - break; - case 0x04: /* HSE used as system clock source */ - SystemCoreClock = HSE_VALUE; - break; - case 0x08: /* PLL used as system clock source */ - - /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N - SYSCLK = PLL_VCO / PLL_P - */ - pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22; - pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM; - - if (pllsource != 0) - { - /* HSE used as PLL clock source */ - pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); - } - else - { - /* HSI used as PLL clock source */ - pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); - } - - pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2; - SystemCoreClock = pllvco/pllp; - break; - default: - SystemCoreClock = HSI_VALUE; - break; - } - /* Compute HCLK frequency --------------------------------------------------*/ - /* Get HCLK prescaler */ - tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; - /* HCLK frequency */ - SystemCoreClock >>= tmp; -} - -/** - * @brief Configures the System clock source, PLL Multiplier and Divider factors, - * AHB/APBx prescalers and Flash settings - * @Note This function should be called only once the RCC clock configuration - * is reset to the default reset state (done in SystemInit() function). - * @param None - * @retval None - */ -static void SetSysClock(void) -{ - /******************************************************************************/ - /* PLL (clocked by HSE) used as System clock source */ - /******************************************************************************/ - __IO uint32_t StartUpCounter = 0, HSEStatus = 0; - - /* Enable HSE */ - RCC->CR |= ((uint32_t)RCC_CR_HSEON); - - /* Wait till HSE is ready and if Time out is reached exit */ - do - { - HSEStatus = RCC->CR & RCC_CR_HSERDY; - StartUpCounter++; - } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT)); - - if ((RCC->CR & RCC_CR_HSERDY) != RESET) - { - HSEStatus = (uint32_t)0x01; - } - else - { - HSEStatus = (uint32_t)0x00; - } - - if (HSEStatus == (uint32_t)0x01) - { - /* Select regulator voltage output Scale 1 mode, System frequency up to 168 MHz */ - RCC->APB1ENR |= RCC_APB1ENR_PWREN; - PWR->CR |= PWR_CR_VOS; - - /* HCLK = SYSCLK / 1*/ - RCC->CFGR |= RCC_CFGR_HPRE_DIV1; - - /* PCLK2 = HCLK / 2*/ - RCC->CFGR |= RCC_CFGR_PPRE2_DIV2; - - /* PCLK1 = HCLK / 4*/ - RCC->CFGR |= RCC_CFGR_PPRE1_DIV4; - - /* Configure the main PLL */ - RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) -1) << 16) | - (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24); - - /* Enable the main PLL */ - RCC->CR |= RCC_CR_PLLON; - - /* Wait till the main PLL is ready */ - while((RCC->CR & RCC_CR_PLLRDY) == 0) - { - } - - /* Configure Flash prefetch, Instruction cache, Data cache and wait state */ - FLASH->ACR = FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS; - - /* Select the main PLL as system clock source */ - RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); - RCC->CFGR |= RCC_CFGR_SW_PLL; - - /* Wait till the main PLL is used as system clock source */ - while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL); - { - } - } - else - { /* If HSE fails to start-up, the application will have wrong clock - configuration. User can add here some code to deal with this error */ - } - - - /******************************************************************************/ - /* I2S clock configuration */ - /******************************************************************************/ - -#if START_I2SCLOCK - /* PLLI2S clock used as I2S clock source */ - RCC->CFGR &= ~RCC_CFGR_I2SSRC; - - /* Configure PLLI2S */ - RCC->PLLI2SCFGR = (PLLI2S_N << 6) | (PLLI2S_R << 28); - - /* Enable PLLI2S */ - RCC->CR |= ((uint32_t)RCC_CR_PLLI2SON); - - /* Wait till PLLI2S is ready */ - while((RCC->CR & RCC_CR_PLLI2SRDY) == 0) - { - } -#endif -} - -/** - * @brief Setup the external memory controller. Called in startup_stm32f4xx.s - * before jump to __main - * @param None - * @retval None - */ -#ifdef DATA_IN_ExtSRAM -/** - * @brief Setup the external memory controller. - * Called in startup_stm32f4xx.s before jump to main. - * This function configures the external SRAM mounted on STM324xG_EVAL board - * This SRAM will be used as program data memory (including heap and stack). - * @param None - * @retval None - */ -void SystemInit_ExtMemCtl(void) -{ - /*-- GPIOs Configuration -----------------------------------------------------*/ - /* - +-------------------+--------------------+------------------+------------------+ - + SRAM pins assignment + - +-------------------+--------------------+------------------+------------------+ - | PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 | - | PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 | - | PD4 <-> FSMC_NOE | PE3 <-> FSMC_A19 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 | - | PD5 <-> FSMC_NWE | PE4 <-> FSMC_A20 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 | - | PD8 <-> FSMC_D13 | PE7 <-> FSMC_D4 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 | - | PD9 <-> FSMC_D14 | PE8 <-> FSMC_D5 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 | - | PD10 <-> FSMC_D15 | PE9 <-> FSMC_D6 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 | - | PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7 | PF13 <-> FSMC_A7 |------------------+ - | PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8 | PF14 <-> FSMC_A8 | - | PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9 | PF15 <-> FSMC_A9 | - | PD14 <-> FSMC_D0 | PE13 <-> FSMC_D10 |------------------+ - | PD15 <-> FSMC_D1 | PE14 <-> FSMC_D11 | - | | PE15 <-> FSMC_D12 | - +-------------------+--------------------+ - */ - /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */ - RCC->AHB1ENR = 0x00000078; - - /* Connect PDx pins to FSMC Alternate function */ - GPIOD->AFR[0] = 0x00cc00cc; - GPIOD->AFR[1] = 0xcc0ccccc; - /* Configure PDx pins in Alternate function mode */ - GPIOD->MODER = 0xaaaa0a0a; - /* Configure PDx pins speed to 100 MHz */ - GPIOD->OSPEEDR = 0xffff0f0f; - /* Configure PDx pins Output type to push-pull */ - GPIOD->OTYPER = 0x00000000; - /* No pull-up, pull-down for PDx pins */ - GPIOD->PUPDR = 0x00000000; - - /* Connect PEx pins to FSMC Alternate function */ - GPIOE->AFR[0] = 0xc00cc0cc; - GPIOE->AFR[1] = 0xcccccccc; - /* Configure PEx pins in Alternate function mode */ - GPIOE->MODER = 0xaaaa828a; - /* Configure PEx pins speed to 100 MHz */ - GPIOE->OSPEEDR = 0xffffc3cf; - /* Configure PEx pins Output type to push-pull */ - GPIOE->OTYPER = 0x00000000; - /* No pull-up, pull-down for PEx pins */ - GPIOE->PUPDR = 0x00000000; - - /* Connect PFx pins to FSMC Alternate function */ - GPIOF->AFR[0] = 0x00cccccc; - GPIOF->AFR[1] = 0xcccc0000; - /* Configure PFx pins in Alternate function mode */ - GPIOF->MODER = 0xaa000aaa; - /* Configure PFx pins speed to 100 MHz */ - GPIOF->OSPEEDR = 0xff000fff; - /* Configure PFx pins Output type to push-pull */ - GPIOF->OTYPER = 0x00000000; - /* No pull-up, pull-down for PFx pins */ - GPIOF->PUPDR = 0x00000000; - - /* Connect PGx pins to FSMC Alternate function */ - GPIOG->AFR[0] = 0x00cccccc; - GPIOG->AFR[1] = 0x000000c0; - /* Configure PGx pins in Alternate function mode */ - GPIOG->MODER = 0x00080aaa; - /* Configure PGx pins speed to 100 MHz */ - GPIOG->OSPEEDR = 0x000c0fff; - /* Configure PGx pins Output type to push-pull */ - GPIOG->OTYPER = 0x00000000; - /* No pull-up, pull-down for PGx pins */ - GPIOG->PUPDR = 0x00000000; - - /*-- FSMC Configuration ------------------------------------------------------*/ - /* Enable the FSMC interface clock */ - RCC->AHB3ENR = 0x00000001; - - /* Configure and enable Bank1_SRAM2 */ - FSMC_Bank1->BTCR[2] = 0x00001015; - FSMC_Bank1->BTCR[3] = 0x00010603; - FSMC_Bank1E->BWTR[2] = 0x0fffffff; - /* - Bank1_SRAM2 is configured as follow: - - p.FSMC_AddressSetupTime = 3; - p.FSMC_AddressHoldTime = 0; - p.FSMC_DataSetupTime = 6; - p.FSMC_BusTurnAroundDuration = 1; - p.FSMC_CLKDivision = 0; - p.FSMC_DataLatency = 0; - p.FSMC_AccessMode = FSMC_AccessMode_A; - - FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2; - FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; - FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_PSRAM; - FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; - FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; - FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; - FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; - FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; - FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; - FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; - FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; - FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; - */ -} -#endif /* DATA_IN_ExtSRAM */ - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ diff --git a/codec2/stm32/stlink/elfsym.c b/codec2/stm32/stlink/elfsym.c deleted file mode 100644 index 1a62981b..00000000 --- a/codec2/stm32/stlink/elfsym.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - elfsym.c - - Read symbol adresses from a .elf file. - - Based on libelf-howto.c from: http://em386.blogspot.com - - Unit test with: - - gcc elfsym.c -o elfsym -D__UNITTEST__ -Wall -lelf - ./elfsym elf_file.elf -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "elfsym.h" - -#define ERR -1 - -int elfsym_open(char file[]) { - int fd; /* File Descriptor */ - char *base_ptr; /* ptr to our object in memory */ - struct stat elf_stats; /* fstat struct */ - - if((fd = open(file, O_RDWR)) == ERR) { - printf("couldnt open %s\n", file); - return ERR; - } - - if((fstat(fd, &elf_stats))) { - printf("could not fstat %s\n", file); - close(fd); - return ERR; - } - - if((base_ptr = (char *) malloc(elf_stats.st_size)) == NULL) { - fprintf(stderr, "could not malloc\n"); - close(fd); - return ERR; - } - - if((read(fd, base_ptr, elf_stats.st_size)) < elf_stats.st_size) { - fprintf(stderr, "could not read %s\n", file); - free(base_ptr); - close(fd); - return ERR; - } - - /* Check libelf version first */ - - if(elf_version(EV_CURRENT) == EV_NONE) { - fprintf(stderr, "WARNING Elf Library is out of date!\n"); - } - - free(base_ptr); - - return fd; -} - - -void elfsym_close(int fd) { - close(fd); -} - -unsigned int elfsym_get_symbol_address(int fd, char symbol_name[]) -{ - Elf_Scn *scn; /* Section Descriptor */ - Elf_Data *edata; /* Data Descriptor */ - GElf_Sym sym; /* Symbol */ - GElf_Shdr shdr; /* Section Header */ - Elf *elf; /* Our Elf pointer for libelf */ - unsigned int symbol_address; - int symbol_count; - int i; - - /* Iterate through section headers, stop when we find symbols, - and check for match */ - - elf = elf_begin(fd, ELF_C_READ, NULL); - if (elf == 0) { - fprintf(stderr, "could not elf_begin\n"); - } - symbol_address = 0; - scn = NULL; - - while((scn = elf_nextscn(elf, scn)) != 0) { - gelf_getshdr(scn, &shdr); - - // When we find a section header marked SHT_SYMTAB stop and get symbols - edata = NULL; - if(shdr.sh_type == SHT_SYMTAB) { - // edata points to our symbol table - edata = elf_getdata(scn, edata); - - // how many symbols are there? this number comes from the size of - // the section divided by the entry size - symbol_count = shdr.sh_size / shdr.sh_entsize; - - // loop through to grab all symbols - for(i = 0; i < symbol_count; i++) { - // libelf grabs the symbol data using gelf_getsym() - gelf_getsym(edata, i, &sym); - - if (strcmp(symbol_name, - elf_strptr(elf, shdr.sh_link, sym.st_name)) == 0) { - symbol_address = sym.st_value; - } - } - - } - } - - return symbol_address; -} - -#ifdef __UNITTEST__ - -int main(int argc, char *argv[]) -{ - int fd; - unsigned int flag_addr, ptr_addr, file_addr, len_addr; - - fd = elfsym_open(argv[1]); - flag_addr = elfsym_get_symbol_address(fd, "syscalls_gdb_flag"); - ptr_addr = elfsym_get_symbol_address(fd, "syscalls_gdb_ptr"); - file_addr = elfsym_get_symbol_address(fd, "syscalls_gdb_file"); - len_addr = elfsym_get_symbol_address(fd, "syscalls_gdb_len"); - elfsym_close(fd); - - printf("flag_addr: 0x%x\n", flag_addr); - printf("ptr_addr: 0x%x\n", ptr_addr); - printf("file_addr: 0x%x\n", file_addr); - printf("len_addr: 0x%x\n", len_addr); - - return 0; -} - -#endif diff --git a/codec2/stm32/stlink/elfsym.h b/codec2/stm32/stlink/elfsym.h deleted file mode 100644 index fcd287ab..00000000 --- a/codec2/stm32/stlink/elfsym.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - elfsym.h - - Read symbol adresses from a .elf file. -*/ - -#ifndef __ELFSYM__ -#define __ELFSYM__ - -int elfsym_open(char file[]); -void elfsym_close(int fd); -unsigned int elfsym_get_symbol_address(int fd, char symbol_name[]); - -#endif diff --git a/codec2/stm32/stlink/stlink.patch b/codec2/stm32/stlink/stlink.patch deleted file mode 100644 index 74cf2401..00000000 --- a/codec2/stm32/stlink/stlink.patch +++ /dev/null @@ -1,428 +0,0 @@ -diff --git Makefile.am Makefile.am -index a315dd7..7406216 100644 ---- Makefile.am -+++ Makefile.am -@@ -7,7 +7,7 @@ bin_PROGRAMS = st-flash st-util - noinst_LIBRARIES = libstlink.a - - st_flash_SOURCES = flash/main.c --st_util_SOURCES = gdbserver/gdb-remote.c gdbserver/gdb-remote.h gdbserver/gdb-server.c mingw/mingw.c mingw/mingw.h -+st_util_SOURCES = gdbserver/gdb-remote.c gdbserver/gdb-remote.h gdbserver/gdb-server.c gdbserver/elfsym.c mingw/mingw.c mingw/mingw.h - - CFILES = \ - src/stlink-common.c \ -@@ -24,14 +24,14 @@ HFILES = \ - - libstlink_a_SOURCES = $(CFILES) $(HFILES) - --libstlink_a_CPPFLAGS = -std=gnu99 -Wall -Wextra -O2 -+libstlink_a_CPPFLAGS = -std=gnu99 -Wall -Wextra -g - libstlink_a_LIBADD = $(LIBOBJS) - - st_flash_LDADD = libstlink.a --st_flash_CPPFLAGS = -std=gnu99 -Wall -Wextra -O2 -I$(top_srcdir)/src -I$(top_srcdir)/mingw -+st_flash_CPPFLAGS = -std=gnu99 -Wall -Wextra -g -I$(top_srcdir)/src -I$(top_srcdir)/mingw - --st_util_LDADD = libstlink.a --st_util_CPPFLAGS = -std=gnu99 -Wall -Wextra -O2 -I$(top_srcdir)/src -I$(top_srcdir)/mingw -+st_util_LDADD = libstlink.a -lelf -+st_util_CPPFLAGS = -std=gnu99 -Wall -Wextra -g -I$(top_srcdir)/src -I$(top_srcdir)/mingw - - EXTRA_DIST = autogen.sh - -diff --git gdbserver/Makefile gdbserver/Makefile -index bd5c73d..6763388 100644 ---- gdbserver/Makefile -+++ gdbserver/Makefile -@@ -1,12 +1,11 @@ - PRG := st-util --OBJS = gdb-remote.o gdb-server.o -+OBJS = gdb-remote.o gdb-server.o elfsym.o - - CFLAGS+=-g -Wall -Werror -std=gnu99 -I../src - LDFLAGS=-L.. -lstlink - - # libusb location --LDFLAGS+=`pkg-config --libs libusb-1.0` --CFLAGS+=`pkg-config --cflags libusb-1.0` -+LDFLAGS+=`pkg-config --libs libusb-1.0` -lelfCFLAGS+=`pkg-config --cflags libusb-1.0` - - all: $(PRG) - -diff --git gdbserver/gdb-server.c gdbserver/gdb-server.c -index f92fc05..e54d136 100644 ---- gdbserver/gdb-server.c -+++ gdbserver/gdb-server.c -@@ -1,11 +1,12 @@ - /* -*- tab-width:8 -*- */ --#define DEBUG 0 -+//#define DEBUG 0 - /* - Copyright (C) 2011 Peter Zotov - Use of this source code is governed by a BSD-style - license that can be found in the LICENSE file. - */ - -+#include - #include - #include - #include -@@ -20,14 +21,29 @@ - #include - #include - #endif -+#include -+#include -+#include - - #include - - #include "gdb-remote.h" -+#include "elfsym.h" - - #define DEFAULT_LOGGING_LEVEL 50 - #define DEFAULT_GDB_LISTEN_PORT 4242 - -+/* stdio command codes from target */ -+ -+#define GDB_STDIO_PRINTF 1 -+#define GDB_STDIO_FOPEN 2 -+#define GDB_STDIO_FCLOSE 3 -+#define GDB_STDIO_FWRITE 4 -+#define GDB_STDIO_FREAD 5 -+#define GDB_STDIO_FPRINTF 6 -+ -+#define MAX_STR 256 -+ - #define STRINGIFY_inner(name) #name - #define STRINGIFY(name) STRINGIFY_inner(name) - -@@ -46,11 +62,12 @@ typedef struct _st_state_t { - // "/dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTE531X6-if00-port0" is only 58 chars - char devicename[100]; - int logging_level; -- int listen_port; -+ int listen_port; -+ char elf_filename[255]; - } st_state_t; - - --int serve(stlink_t *sl, int port); -+int serve(stlink_t *sl, int port, char *elf_filename); - char* make_memory_map(stlink_t *sl); - - -@@ -76,13 +93,14 @@ int parse_options(int argc, char** argv, st_state_t *st) { - " -p 4242, --listen_port=1234\n" - "\t\t\tSet the gdb server listen port. " - "(default port: " STRINGIFY(DEFAULT_GDB_LISTEN_PORT) ")\n" -+ " -f \tenable File I/O of target executable elf_filename" - ; - - - int option_index = 0; - int c; - int q; -- while ((c = getopt_long(argc, argv, "hv::d:s:1p:", long_options, &option_index)) != -1) { -+ while ((c = getopt_long(argc, argv, "hv::d:s:1p:1f:", long_options, &option_index)) != -1) { - switch (c) { - case 0: - printf("XXXXX Shouldn't really normally come here, only if there's no corresponding option\n"); -@@ -110,25 +128,29 @@ int parse_options(int argc, char** argv, st_state_t *st) { - strcpy(st->devicename, optarg); - } - break; -- case '1': -- st->stlink_version = 1; -- break; -- case 's': -- sscanf(optarg, "%i", &q); -- if (q < 0 || q > 2) { -- fprintf(stderr, "stlink version %d unknown!\n", q); -- exit(EXIT_FAILURE); -- } -- st->stlink_version = q; -- break; -- case 'p': -- sscanf(optarg, "%i", &q); -- if (q < 0) { -- fprintf(stderr, "Can't use a negative port to listen on: %d\n", q); -- exit(EXIT_FAILURE); -- } -- st->listen_port = q; -- break; -+ case '1': -+ st->stlink_version = 1; -+ break; -+ case 's': -+ sscanf(optarg, "%i", &q); -+ if (q < 0 || q > 2) { -+ fprintf(stderr, "stlink version %d unknown!\n", q); -+ exit(EXIT_FAILURE); -+ } -+ st->stlink_version = q; -+ break; -+ case 'p': -+ sscanf(optarg, "%i", &q); -+ if (q < 0) { -+ fprintf(stderr, "Can't use a negative port to listen on: %d\n", q); -+ exit(EXIT_FAILURE); -+ } -+ st->listen_port = q; -+ break; -+ case 'f': -+ sscanf(optarg, "%s", st->elf_filename); -+ printf("-f arg; %s\n", st->elf_filename); -+ break; - } - } - -@@ -162,7 +184,7 @@ int main(int argc, char** argv) { - sl = stlink_v1_open(state.logging_level); - if(sl == NULL) return 1; - break; -- } -+ } - - printf("Chip ID is %08x, Core ID is %08x.\n", sl->chip_id, sl->core_id); - -@@ -177,7 +199,7 @@ int main(int argc, char** argv) { - } - #endif - -- while(serve(sl, state.listen_port) == 0); -+ while(serve(sl, state.listen_port, state.elf_filename) == 0); - - #ifdef __MINGW32__ - winsock_error: -@@ -625,7 +647,179 @@ error: - return error; - } - --int serve(stlink_t *sl, int port) { -+static unsigned int func_addr, ret_addr, pstr1_addr, pstr2_addr; -+static unsigned int strlen1_addr, strlen2_addr, file_addr, ptr_addr; -+static unsigned int size_addr, nmem_addr; -+ -+static void write_buffer(stlink_t *sl, int target_addr, char* buf, size_t size) { -+ /* write the buffer right after the loader */ -+ size_t chunk = size & ~0x3; -+ size_t rem = size & 0x3; -+ -+ if (chunk) { -+ memcpy(sl->q_buf, buf, chunk); -+ stlink_write_mem32(sl, target_addr, chunk); -+ } -+ if (rem) { -+ memcpy(sl->q_buf, buf+chunk, rem); -+ stlink_write_mem8(sl, target_addr+chunk, rem); -+ } -+} -+ -+static void read_buffer(stlink_t *sl, int target_addr, char* buf, size_t size) { -+ unsigned adj_start = target_addr % 4; -+ unsigned count_rnd = (size + adj_start + 4 - 1) / 4 * 4; -+ size_t i; -+ -+ stlink_read_mem32(sl, target_addr - adj_start, count_rnd); -+ -+ for(i=0; iq_buf[i + adj_start]; -+} -+ -+static void fileio(stlink_t *sl) -+{ -+ int func, pstr1, pstr2, strlen1, strlen2, ptr, size, nmem; -+ int ret = 0; -+ FILE *file; -+ char file_name[MAX_STR]; -+ char mode[MAX_STR]; -+ char *buf; -+ -+ stlink_read_mem32(sl, func_addr, 4); -+ func = read_uint32(sl->q_buf, 0); -+ -+ /* func != 0 means target has requested a system call */ -+ -+ switch(func) { -+ -+ case GDB_STDIO_PRINTF: -+ stlink_read_mem32(sl, pstr1_addr, 4); -+ pstr1 = read_uint32(sl->q_buf, 0); -+ stlink_read_mem32(sl, strlen1_addr, 4); -+ strlen1 = read_uint32(sl->q_buf, 0); -+ buf = (char*)malloc(strlen1+1); -+ assert(buf != NULL); -+ read_buffer(sl, pstr1, buf, strlen1); -+ buf[strlen1] = 0; -+ #ifdef DEBUG -+ //printf("gdb_stdio printf pstr1: 0x%0x strlen1: %d buf: %s\n", pstr1, strlen1, buf); -+ #endif -+ fputs(buf, stdout); -+ free(buf); -+ -+ break; -+ -+ case GDB_STDIO_FPRINTF: -+ stlink_read_mem32(sl, file_addr, 4); -+ file = (FILE*)read_uint32(sl->q_buf, 0); -+ stlink_read_mem32(sl, pstr1_addr, 4); -+ pstr1 = read_uint32(sl->q_buf, 0); -+ stlink_read_mem32(sl, strlen1_addr, 4); -+ strlen1 = read_uint32(sl->q_buf, 0); -+ buf = (char*)malloc(strlen1+1); -+ assert(buf != NULL); -+ read_buffer(sl, pstr1, buf, strlen1); -+ buf[strlen1] = 0; -+ #ifdef DEBUG -+ //printf("gdb_stdio fprintf pstr1: 0x%0x strlen1: %d buf: %s file: 0x%x\n", pstr1, strlen1, buf, (unsigned int)file); -+ #endif -+ fputs(buf, file); -+ free(buf); -+ -+ break; -+ -+ case GDB_STDIO_FOPEN: -+ stlink_read_mem32(sl, pstr1_addr, 4); -+ pstr1 = read_uint32(sl->q_buf, 0); -+ stlink_read_mem32(sl, strlen1_addr, 4); -+ strlen1 = read_uint32(sl->q_buf, 0); -+ assert(strlen1 < MAX_STR); -+ read_buffer(sl, pstr1, file_name, strlen1); -+ file_name[strlen1] = 0; -+ -+ stlink_read_mem32(sl, pstr2_addr, 4); -+ pstr2 = read_uint32(sl->q_buf, 0); -+ stlink_read_mem32(sl, strlen2_addr, 4); -+ strlen2 = read_uint32(sl->q_buf, 0); -+ assert(strlen2 < MAX_STR); -+ read_buffer(sl, pstr2, mode, strlen2); -+ mode[strlen2] = 0; -+ -+ file = fopen(file_name, mode); -+ -+ ret = (int)file; -+ #ifdef DEBUG -+ printf("gdb_stdio fopen file_name: %s mode: %s file: 0x%x\n", file_name, mode, (unsigned int)file); -+ #endif -+ break; -+ -+ case GDB_STDIO_FCLOSE: -+ stlink_read_mem32(sl, file_addr, 4); -+ file = (FILE*)read_uint32(sl->q_buf, 0); -+ fclose(file); -+ -+ #ifdef DEBUG -+ printf("gdb_stdio fclose file: 0x%x\n", (unsigned int)file); -+ #endif -+ break; -+ -+ case GDB_STDIO_FWRITE: -+ stlink_read_mem32(sl, ptr_addr, 4); -+ ptr = read_uint32(sl->q_buf, 0); -+ stlink_read_mem32(sl, size_addr, 4); -+ size = read_uint32(sl->q_buf, 0); -+ stlink_read_mem32(sl, nmem_addr, 4); -+ nmem = read_uint32(sl->q_buf, 0); -+ stlink_read_mem32(sl, file_addr, 4); -+ file = (FILE*)read_uint32(sl->q_buf, 0); -+ -+ buf = (char*)malloc(size*nmem); -+ assert(buf != NULL); -+ read_buffer(sl, ptr, buf, size*nmem); -+ ret = fwrite(buf, size, nmem, file); -+ free(buf); -+ #ifdef DEBUG -+ printf("gdb_stdio fwrite ptr: 0x%x size: %d nmem: %d file: 0x%x\n", -+ ptr, size, nmem, (unsigned int)file); -+ #endif -+ break; -+ -+ case GDB_STDIO_FREAD: -+ stlink_read_mem32(sl, ptr_addr, 4); -+ ptr = read_uint32(sl->q_buf, 0); -+ stlink_read_mem32(sl, size_addr, 4); -+ size = read_uint32(sl->q_buf, 0); -+ stlink_read_mem32(sl, nmem_addr, 4); -+ nmem = read_uint32(sl->q_buf, 0); -+ stlink_read_mem32(sl, file_addr, 4); -+ file = (FILE*)read_uint32(sl->q_buf, 0); -+ -+ buf = (char*)malloc(size*nmem); -+ assert(buf != NULL); -+ ret = fread(buf, size, nmem, file); -+ write_buffer(sl, ptr, buf, size*nmem); -+ free(buf); -+ -+ #ifdef DEBUG -+ printf("gdb_stdio fread ptr: 0x%x size: %d nmem: %d file: 0x%x\n", -+ ptr, size, nmem, (unsigned int)file); -+ #endif -+ break; -+ } -+ -+ if (func) { -+ memcpy(sl->q_buf, &ret, sizeof(int)); -+ stlink_write_mem32(sl, ret_addr, 4); -+ -+ func = 0; -+ memcpy(sl->q_buf, &func, sizeof(int)); -+ stlink_write_mem32(sl, func_addr, 4); -+ } -+} -+ -+ -+int serve(stlink_t *sl, int port, char *elf_filename) { - int sock = socket(AF_INET, SOCK_STREAM, 0); - if(sock < 0) { - perror("socket"); -@@ -650,7 +844,33 @@ int serve(stlink_t *sl, int port) { - perror("listen"); - return 1; - } -- -+ -+ /* init for file I/O */ -+ -+ func_addr = ret_addr = pstr1_addr = pstr2_addr = strlen1_addr = strlen2_addr = 0; -+ file_addr = ptr_addr = size_addr = nmem_addr = 0; -+ -+ printf("elf_filename: %s----------------------------------\n", elf_filename); -+ if (*elf_filename != 0) { -+ int fd = elfsym_open(elf_filename); -+ if (fd == -1) -+ exit(0); -+ func_addr = elfsym_get_symbol_address(fd, "gdb_stdio_func"); -+ ret_addr = elfsym_get_symbol_address(fd, "gdb_stdio_ret"); -+ pstr1_addr = elfsym_get_symbol_address(fd, "gdb_stdio_pstr1"); -+ pstr2_addr = elfsym_get_symbol_address(fd, "gdb_stdio_pstr2"); -+ strlen1_addr = elfsym_get_symbol_address(fd, "gdb_stdio_strlen1"); -+ strlen2_addr = elfsym_get_symbol_address(fd, "gdb_stdio_strlen2"); -+ file_addr = elfsym_get_symbol_address(fd, "gdb_stdio_file"); -+ ptr_addr = elfsym_get_symbol_address(fd, "gdb_stdio_ptr"); -+ size_addr = elfsym_get_symbol_address(fd, "gdb_stdio_size"); -+ nmem_addr = elfsym_get_symbol_address(fd, "gdb_stdio_nmem"); -+ elfsym_close(fd); -+ #ifdef DEBUG -+ printf("func_addr: 0x%x\n", func_addr); -+ #endif -+ } -+ - start_again: - stlink_force_debug(sl); - stlink_reset(sl); -@@ -924,8 +1144,13 @@ start_again: - if(sl->core_stat == STLINK_CORE_HALTED) { - break; - } -+ -+ /* file I/O if enabled */ -+ -+ if (*elf_filename != 0) -+ fileio(sl); - -- usleep(100000); -+ usleep(10000); - } - - reply = strdup("S05"); // TRAP diff --git a/codec2/stm32/stm32_flash.ld b/codec2/stm32/stm32_flash.ld deleted file mode 100644 index 6822ffad..00000000 --- a/codec2/stm32/stm32_flash.ld +++ /dev/null @@ -1,116 +0,0 @@ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = 0x20020000; /* end of 128K RAM on AHB bus*/ - -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0; /* required amount of heap */ -_Min_Stack_Size = 0x400; /* required amount of stack */ - -/* Specify the memory areas */ -MEMORY -{ - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K - CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K -} - -SECTIONS -{ - .isr_vector : - { - . = ALIGN(4); - KEEP(*(.isr_vector)) - . = ALIGN(4); - } >FLASH - - .text : - { - . = ALIGN(4); - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - _exit = .; - } >FLASH - - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH - .ARM : { - __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - } >FLASH - - .preinit_array : - { - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP (*(.preinit_array*)) - PROVIDE_HIDDEN (__preinit_array_end = .); - } >FLASH - .init_array : - { - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array*)) - PROVIDE_HIDDEN (__init_array_end = .); - } >FLASH - .fini_array : - { - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(.fini_array*)) - KEEP (*(SORT(.fini_array.*))) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = .; - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss secion */ - _sbss = .; /* define a global symbol at bss start */ - __bss_start__ = _sbss; - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - __bss_end__ = _ebss; - } >RAM - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(4); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; - . = . + _Min_Stack_Size; - . = ALIGN(4); - } >RAM -} diff --git a/codec2/stm32/stm32_ram.ld b/codec2/stm32/stm32_ram.ld deleted file mode 100644 index 88c735a3..00000000 --- a/codec2/stm32/stm32_ram.ld +++ /dev/null @@ -1,116 +0,0 @@ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = 0x20020000; /* end of 128K RAM on AHB bus*/ - -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0; /* required amount of heap */ -_Min_Stack_Size = 0x400; /* required amount of stack */ - -/* Specify the memory areas */ -MEMORY -{ - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K - CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K -} - -SECTIONS -{ - .isr_vector : - { - . = ALIGN(4); - KEEP(*(.isr_vector)) - . = ALIGN(4); - } >RAM - - .text : - { - . = ALIGN(4); - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - _exit = .; - } >RAM - - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >RAM - .ARM : { - __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - } >RAM - - .preinit_array : - { - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP (*(.preinit_array*)) - PROVIDE_HIDDEN (__preinit_array_end = .); - } >RAM - .init_array : - { - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array*)) - PROVIDE_HIDDEN (__init_array_end = .); - } >RAM - .fini_array : - { - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(.fini_array*)) - KEEP (*(SORT(.fini_array.*))) - PROVIDE_HIDDEN (__fini_array_end = .); - } >RAM - - /* used by the startup to initialize data */ - _sidata = .; - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : AT ( _sidata ) - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss secion */ - _sbss = .; /* define a global symbol at bss start */ - __bss_start__ = _sbss; - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - __bss_end__ = _ebss; - } >RAM - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(4); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; - . = . + _Min_Stack_Size; - . = ALIGN(4); - } >RAM -} diff --git a/codec2/tags/.gitignore b/codec2/tags/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/codec2/unittest/CMakeLists.txt b/codec2/unittest/CMakeLists.txt deleted file mode 100644 index af72e13d..00000000 --- a/codec2/unittest/CMakeLists.txt +++ /dev/null @@ -1,83 +0,0 @@ -add_definitions(-DFLOATING_POINT -DVAR_ARRAYS) -include_directories(../src) - -add_executable(genres genres.c ../src/lpc.c) -target_link_libraries(genres codec2) - -add_executable(genlsp genlsp.c ../src/lpc.c ../src/lsp.c) -target_link_libraries(genlsp codec2) - -add_executable(extract extract.c) -target_link_libraries(extract codec2) - -add_executable(vqtrain vqtrain.c) -target_link_libraries(vqtrain codec2) - -add_executable(vqtrainjnd vqtrainjnd.c) -target_link_libraries(vqtrainjnd codec2) - -add_executable(vqtrainph vqtrainph.c) -target_link_libraries(vqtrainph codec2) - -add_executable(vqtrainsp vqtrainsp.c) -target_link_libraries(vqtrainsp codec2) - -add_executable(genphdata genphdata.c) -target_link_libraries(genphdata codec2) - -add_executable(genampdata genampdata.c) -target_link_libraries(genampdata codec2) - -add_executable(polar2rect polar2rect.c) -target_link_libraries(polar2rect codec2) - -add_executable(vq_train_jvm vq_train_jvm.c) -target_link_libraries(vq_train_jvm codec2) - -set(CODEBOOKS ../src/codebook.c ../src/codebookd.c ../src/codebookvq.c ../src/codebookjnd.c ../src/codebookdt.c ../src/codebookjvm.c ../src/codebookvqanssi.c ../src/codebookge.c) - -add_executable(tnlp tnlp.c ../src/sine.c ../src/nlp.c ../src/kiss_fft.c ../src/dump.c) -target_link_libraries(tnlp codec2) - -add_executable(tinterp tinterp.c ../src/sine.c ../src/kiss_fft.c ../src/interp.c ../src/lpc.c ../src/lsp.c ../src/quantise.c ${CODEBOOKS} ../src/dump.c) -target_link_libraries(tinterp codec2) - -add_executable(tquant tquant.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c ${CODEBOOKS}) -target_link_libraries(tquant codec2) - -add_executable(scalarlsptest scalarlsptest.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c ${CODEBOOKS}) -target_link_libraries(scalarlsptest codec2) - -add_executable(tfdmdv tfdmdv.c ../src/fdmdv.c ../src/kiss_fft.c ../src/octave.c) -target_link_libraries(tfdmdv codec2) - -add_executable(t48_8 t48_8.c ../src/fdmdv.c ../src/kiss_fft.c) -target_link_libraries(t48_8 codec2) - -add_executable(lspsync lspsync.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c ../src/codec2.c ../src/sine.c ../src/nlp.c ../src/postfilter.c ../src/phase.c ../src/interp.c ../src/pack.c ${CODEBOOKS}) -target_link_libraries(lspsync codec2) - -add_executable(create_interleaver create_interleaver.c) -target_link_libraries(create_interleaver codec2) - -add_executable(tlspsens tlspsens.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c ../src/codec2.c ../src/sine.c ../src/nlp.c ../src/pack.c ../src/interp.c ../src/postfilter.c ../src/phase.c ${CODEBOOKS}) -target_link_libraries(tlspsens codec2) - -add_executable(tprede tprede.c ../src/lpc.c) -target_link_libraries(tprede codec2) - -add_executable(pre pre.c ../src/lpc.c) -target_link_libraries(pre codec2) - -add_executable(de de.c ../src/lpc.c) -target_link_libraries(de codec2) - -add_executable(tfifo tfifo.c ../src/fifo.c) -target_link_libraries(tfifo codec2 ${CMAKE_THREAD_LIBS_INIT}) - -add_executable(raw2h raw2h.c) -target_link_libraries(raw2h codec2) - -add_definitions(-D__UNITTEST__) -add_executable(c2validate c2validate.c) -target_link_libraries(c2validate codec2) diff --git a/codec2/unittest/Makefile.am b/codec2/unittest/Makefile.am deleted file mode 100644 index 998446fb..00000000 --- a/codec2/unittest/Makefile.am +++ /dev/null @@ -1,114 +0,0 @@ -AM_CFLAGS = -I../src -fPIC -g -DFLOATING_POINT -DVAR_ARRAYS -O2 -Wall -AUTOMAKE_OPTS = gnu -NAME = libcodec2 -AM_CPPFLAGS = $(AM_CFLAGS) - -noinst_PROGRAMS = genres genlsp extract vqtrain vqtrainjnd tnlp tinterp tquant vq_train_jvm scalarlsptest tfdmdv t48_8 lspsync create_interleaver tlspsens vqtrainph genphdata genampdata polar2rect vqtrainsp tprede pre de tfifo raw2h c2validate - -genres_SOURCES = genres.c ../src/lpc.c -genres_LDADD = $(lib_LTLIBRARIES) -genres_LDFLAGS = $(LIBS) - -genlsp_SOURCES = genlsp.c ../src/lpc.c ../src/lsp.c -genlsp_LDADD = $(lib_LTLIBRARIES) -genlsp_LDFLAGS = $(LIBS) - -extract_SOURCES = extract.c -extract_LDADD = $(lib_LTLIBRARIES) -extract_LDFLAGS = $(LIBS) - -vqtrain_SOURCES = vqtrain.c -vqtrain_LDADD = $(lib_LTLIBRARIES) -vqtrain_LDFLAGS = $(LIBS) - -vqtrainjnd_SOURCES = vqtrainjnd.c -vqtrainjnd_LDADD = $(lib_LTLIBRARIES) -vqtrainjnd_LDFLAGS = $(LIBS) - -vqtrainph_SOURCES = vqtrainph.c -vqtrainph_LDADD = $(lib_LTLIBRARIES) -vqtrainph_LDFLAGS = $(LIBS) - -vqtrainsp_SOURCES = vqtrainsp.c -vqtrainsp_LDADD = $(lib_LTLIBRARIES) -vqtrainsp_LDFLAGS = $(LIBS) - -genphdata_SOURCES = genphdata.c -genphdata_LDADD = $(lib_LTLIBRARIES) -genphdata_LDFLAGS = $(LIBS) - -genampdata_SOURCES = genampdata.c -genampdata_LDADD = $(lib_LTLIBRARIES) -genampdata_LDFLAGS = $(LIBS) - -polar2rect_SOURCES = polar2rect.c -polar2rect_LDADD = $(lib_LTLIBRARIES) -polar2rect_LDFLAGS = $(LIBS) - -vq_train_jvm_SOURCES = vq_train_jvm.c -vq_train_jvm_LDADD = $(lib_LTLIBRARIES) -vq_train_jvm_LDFLAGS = $(LIBS) - -CODEBOOKS = ../src/codebook.c ../src/codebookd.c ../src/codebookvq.c ../src/codebookjnd.c ../src/codebookdt.c ../src/codebookjvm.c ../src/codebookvqanssi.c ../src/codebookge.c - -tnlp_SOURCES = tnlp.c ../src/sine.c ../src/nlp.c ../src/kiss_fft.c ../src/dump.c -tnlp_LDADD = $(lib_LTLIBRARIES) -tnlp_LDFLAGS = $(LIBS) - -tinterp_SOURCES = tinterp.c ../src/sine.c ../src/kiss_fft.c ../src/interp.c ../src/lpc.c ../src/lsp.c ../src/quantise.c $(CODEBOOKS) ../src/dump.c -tinterp_LDADD = $(lib_LTLIBRARIES) -tinterp_LDFLAGS = $(LIBS) - -tquant_SOURCES = tquant.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c $(CODEBOOKS) -tquant_LDADD = $(lib_LTLIBRARIES) -tquant_LDFLAGS = $(LIBS) - -scalarlsptest_SOURCES = scalarlsptest.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c $(CODEBOOKS) -scalarlsptest_LDADD = $(lib_LTLIBRARIES) -scalarlsptest_LDFLAGS = $(LIBS) - -tfdmdv_SOURCES = tfdmdv.c ../src/fdmdv.c ../src/kiss_fft.c ../src/octave.c -tfdmdv_LDADD = $(lib_LTLIBRARIES) -tfdmdv_LDFLAGS = $(LIBS) - -t48_8_SOURCES = t48_8.c ../src/fdmdv.c ../src/kiss_fft.c -t48_8_LDADD = $(lib_LTLIBRARIES) -t48_8_LDFLAGS = $(LIBS) - -lspsync_SOURCES = lspsync.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c \ -../src/codec2.c ../src/sine.c ../src/nlp.c ../src/postfilter.c ../src/phase.c ../src/interp.c ../src/pack.c $(CODEBOOKS) -lspsync_LDADD = $(lib_LTLIBRARIES) -lspsync_LDFLAGS = $(LIBS) - -create_interleaver_SOURCES = create_interleaver.c -create_interleaver_LDADD = $(lib_LTLIBRARIES) -create_interleaver_LDFLAGS = $(LIBS) - -tlspsens_SOURCES = tlspsens.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c ../src/codec2.c ../src/sine.c ../src/nlp.c ../src/pack.c ../src/interp.c ../src/postfilter.c ../src/phase.c $(CODEBOOKS) -tlspsens_LDADD = $(lib_LTLIBRARIES) -tlspsens_LDFLAGS = $(LIBS) - -tprede_SOURCES = tprede.c ../src/lpc.c -tprede_LDADD = $(lib_LTLIBRARIES) -tprede_LDFLAGS = $(LIBS) - -pre_SOURCES = pre.c ../src/lpc.c -pre_LDADD = $(lib_LTLIBRARIES) -pre_LDFLAGS = $(LIBS) - -de_SOURCES = de.c ../src/lpc.c -de_LDADD = $(lib_LTLIBRARIES) -de_LDFLAGS = $(LIBS) - -tfifo_SOURCES = tfifo.c ../src/fifo.c -tfifo_LDADD = $(lib_LTLIBRARIES) -lpthread -tfifo_LDFLAGS = $(LIBS) - -raw2h_SOURCES = raw2h.c -raw2h_LDADD = $(lib_LTLIBRARIES) -raw2h_LDFLAGS = $(LIBS) - -c2validate_CFLAGS = -D__UNITTEST__ -c2validate_SOURCES = c2validate.c -c2validate_LDADD = $(lib_LTLIBRARIES) ../src/libcodec2.la -c2validate_LDFLAGS = $(LIBS) \ No newline at end of file diff --git a/codec2/unittest/Makefile.in b/codec2/unittest/Makefile.in deleted file mode 100644 index aac2791c..00000000 --- a/codec2/unittest/Makefile.in +++ /dev/null @@ -1,1090 +0,0 @@ -# Makefile.in generated by automake 1.9.6 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = .. -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = @INSTALL@ -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -noinst_PROGRAMS = genres$(EXEEXT) genlsp$(EXEEXT) extract$(EXEEXT) \ - vqtrain$(EXEEXT) vqtrainjnd$(EXEEXT) tnlp$(EXEEXT) \ - tinterp$(EXEEXT) tquant$(EXEEXT) vq_train_jvm$(EXEEXT) \ - scalarlsptest$(EXEEXT) tfdmdv$(EXEEXT) t48_8$(EXEEXT) \ - lspsync$(EXEEXT) create_interleaver$(EXEEXT) tlspsens$(EXEEXT) \ - vqtrainph$(EXEEXT) genphdata$(EXEEXT) genampdata$(EXEEXT) \ - polar2rect$(EXEEXT) vqtrainsp$(EXEEXT) tprede$(EXEEXT) \ - pre$(EXEEXT) de$(EXEEXT) tfifo$(EXEEXT) raw2h$(EXEEXT) \ - c2validate$(EXEEXT) -subdir = unittest -DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.in -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = -PROGRAMS = $(noinst_PROGRAMS) -am_c2validate_OBJECTS = c2validate-c2validate.$(OBJEXT) -c2validate_OBJECTS = $(am_c2validate_OBJECTS) -c2validate_DEPENDENCIES = ../src/libcodec2.la -am_create_interleaver_OBJECTS = create_interleaver.$(OBJEXT) -create_interleaver_OBJECTS = $(am_create_interleaver_OBJECTS) -create_interleaver_DEPENDENCIES = -am_de_OBJECTS = de.$(OBJEXT) lpc.$(OBJEXT) -de_OBJECTS = $(am_de_OBJECTS) -de_DEPENDENCIES = -am_extract_OBJECTS = extract.$(OBJEXT) -extract_OBJECTS = $(am_extract_OBJECTS) -extract_DEPENDENCIES = -am_genampdata_OBJECTS = genampdata.$(OBJEXT) -genampdata_OBJECTS = $(am_genampdata_OBJECTS) -genampdata_DEPENDENCIES = -am_genlsp_OBJECTS = genlsp.$(OBJEXT) lpc.$(OBJEXT) lsp.$(OBJEXT) -genlsp_OBJECTS = $(am_genlsp_OBJECTS) -genlsp_DEPENDENCIES = -am_genphdata_OBJECTS = genphdata.$(OBJEXT) -genphdata_OBJECTS = $(am_genphdata_OBJECTS) -genphdata_DEPENDENCIES = -am_genres_OBJECTS = genres.$(OBJEXT) lpc.$(OBJEXT) -genres_OBJECTS = $(am_genres_OBJECTS) -genres_DEPENDENCIES = -am__objects_1 = codebook.$(OBJEXT) codebookd.$(OBJEXT) \ - codebookvq.$(OBJEXT) codebookjnd.$(OBJEXT) \ - codebookdt.$(OBJEXT) codebookjvm.$(OBJEXT) \ - codebookvqanssi.$(OBJEXT) codebookge.$(OBJEXT) -am_lspsync_OBJECTS = lspsync.$(OBJEXT) quantise.$(OBJEXT) \ - lpc.$(OBJEXT) lsp.$(OBJEXT) dump.$(OBJEXT) kiss_fft.$(OBJEXT) \ - codec2.$(OBJEXT) sine.$(OBJEXT) nlp.$(OBJEXT) \ - postfilter.$(OBJEXT) phase.$(OBJEXT) interp.$(OBJEXT) \ - pack.$(OBJEXT) $(am__objects_1) -lspsync_OBJECTS = $(am_lspsync_OBJECTS) -lspsync_DEPENDENCIES = -am_polar2rect_OBJECTS = polar2rect.$(OBJEXT) -polar2rect_OBJECTS = $(am_polar2rect_OBJECTS) -polar2rect_DEPENDENCIES = -am_pre_OBJECTS = pre.$(OBJEXT) lpc.$(OBJEXT) -pre_OBJECTS = $(am_pre_OBJECTS) -pre_DEPENDENCIES = -am_raw2h_OBJECTS = raw2h.$(OBJEXT) -raw2h_OBJECTS = $(am_raw2h_OBJECTS) -raw2h_DEPENDENCIES = -am_scalarlsptest_OBJECTS = scalarlsptest.$(OBJEXT) quantise.$(OBJEXT) \ - lpc.$(OBJEXT) lsp.$(OBJEXT) dump.$(OBJEXT) kiss_fft.$(OBJEXT) \ - $(am__objects_1) -scalarlsptest_OBJECTS = $(am_scalarlsptest_OBJECTS) -scalarlsptest_DEPENDENCIES = -am_t48_8_OBJECTS = t48_8.$(OBJEXT) fdmdv.$(OBJEXT) kiss_fft.$(OBJEXT) -t48_8_OBJECTS = $(am_t48_8_OBJECTS) -t48_8_DEPENDENCIES = -am_tfdmdv_OBJECTS = tfdmdv.$(OBJEXT) fdmdv.$(OBJEXT) \ - kiss_fft.$(OBJEXT) octave.$(OBJEXT) -tfdmdv_OBJECTS = $(am_tfdmdv_OBJECTS) -tfdmdv_DEPENDENCIES = -am_tfifo_OBJECTS = tfifo.$(OBJEXT) fifo.$(OBJEXT) -tfifo_OBJECTS = $(am_tfifo_OBJECTS) -tfifo_DEPENDENCIES = -am_tinterp_OBJECTS = tinterp.$(OBJEXT) sine.$(OBJEXT) \ - kiss_fft.$(OBJEXT) interp.$(OBJEXT) lpc.$(OBJEXT) \ - lsp.$(OBJEXT) quantise.$(OBJEXT) $(am__objects_1) \ - dump.$(OBJEXT) -tinterp_OBJECTS = $(am_tinterp_OBJECTS) -tinterp_DEPENDENCIES = -am_tlspsens_OBJECTS = tlspsens.$(OBJEXT) quantise.$(OBJEXT) \ - lpc.$(OBJEXT) lsp.$(OBJEXT) dump.$(OBJEXT) kiss_fft.$(OBJEXT) \ - codec2.$(OBJEXT) sine.$(OBJEXT) nlp.$(OBJEXT) pack.$(OBJEXT) \ - interp.$(OBJEXT) postfilter.$(OBJEXT) phase.$(OBJEXT) \ - $(am__objects_1) -tlspsens_OBJECTS = $(am_tlspsens_OBJECTS) -tlspsens_DEPENDENCIES = -am_tnlp_OBJECTS = tnlp.$(OBJEXT) sine.$(OBJEXT) nlp.$(OBJEXT) \ - kiss_fft.$(OBJEXT) dump.$(OBJEXT) -tnlp_OBJECTS = $(am_tnlp_OBJECTS) -tnlp_DEPENDENCIES = -am_tprede_OBJECTS = tprede.$(OBJEXT) lpc.$(OBJEXT) -tprede_OBJECTS = $(am_tprede_OBJECTS) -tprede_DEPENDENCIES = -am_tquant_OBJECTS = tquant.$(OBJEXT) quantise.$(OBJEXT) lpc.$(OBJEXT) \ - lsp.$(OBJEXT) dump.$(OBJEXT) kiss_fft.$(OBJEXT) \ - $(am__objects_1) -tquant_OBJECTS = $(am_tquant_OBJECTS) -tquant_DEPENDENCIES = -am_vq_train_jvm_OBJECTS = vq_train_jvm.$(OBJEXT) -vq_train_jvm_OBJECTS = $(am_vq_train_jvm_OBJECTS) -vq_train_jvm_DEPENDENCIES = -am_vqtrain_OBJECTS = vqtrain.$(OBJEXT) -vqtrain_OBJECTS = $(am_vqtrain_OBJECTS) -vqtrain_DEPENDENCIES = -am_vqtrainjnd_OBJECTS = vqtrainjnd.$(OBJEXT) -vqtrainjnd_OBJECTS = $(am_vqtrainjnd_OBJECTS) -vqtrainjnd_DEPENDENCIES = -am_vqtrainph_OBJECTS = vqtrainph.$(OBJEXT) -vqtrainph_OBJECTS = $(am_vqtrainph_OBJECTS) -vqtrainph_DEPENDENCIES = -am_vqtrainsp_OBJECTS = vqtrainsp.$(OBJEXT) -vqtrainsp_OBJECTS = $(am_vqtrainsp_OBJECTS) -vqtrainsp_DEPENDENCIES = -DEFAULT_INCLUDES = -I. -I$(srcdir) -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(c2validate_SOURCES) $(create_interleaver_SOURCES) \ - $(de_SOURCES) $(extract_SOURCES) $(genampdata_SOURCES) \ - $(genlsp_SOURCES) $(genphdata_SOURCES) $(genres_SOURCES) \ - $(lspsync_SOURCES) $(polar2rect_SOURCES) $(pre_SOURCES) \ - $(raw2h_SOURCES) $(scalarlsptest_SOURCES) $(t48_8_SOURCES) \ - $(tfdmdv_SOURCES) $(tfifo_SOURCES) $(tinterp_SOURCES) \ - $(tlspsens_SOURCES) $(tnlp_SOURCES) $(tprede_SOURCES) \ - $(tquant_SOURCES) $(vq_train_jvm_SOURCES) $(vqtrain_SOURCES) \ - $(vqtrainjnd_SOURCES) $(vqtrainph_SOURCES) \ - $(vqtrainsp_SOURCES) -DIST_SOURCES = $(c2validate_SOURCES) $(create_interleaver_SOURCES) \ - $(de_SOURCES) $(extract_SOURCES) $(genampdata_SOURCES) \ - $(genlsp_SOURCES) $(genphdata_SOURCES) $(genres_SOURCES) \ - $(lspsync_SOURCES) $(polar2rect_SOURCES) $(pre_SOURCES) \ - $(raw2h_SOURCES) $(scalarlsptest_SOURCES) $(t48_8_SOURCES) \ - $(tfdmdv_SOURCES) $(tfifo_SOURCES) $(tinterp_SOURCES) \ - $(tlspsens_SOURCES) $(tnlp_SOURCES) $(tprede_SOURCES) \ - $(tquant_SOURCES) $(vq_train_jvm_SOURCES) $(vqtrain_SOURCES) \ - $(vqtrainjnd_SOURCES) $(vqtrainph_SOURCES) \ - $(vqtrainsp_SOURCES) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMDEP_FALSE = @AMDEP_FALSE@ -AMDEP_TRUE = @AMDEP_TRUE@ -AMTAR = @AMTAR@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GREP = @GREP@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ -am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -AM_CFLAGS = -I../src -fPIC -g -DFLOATING_POINT -DVAR_ARRAYS -O2 -Wall -AUTOMAKE_OPTS = gnu -NAME = libcodec2 -AM_CPPFLAGS = $(AM_CFLAGS) -genres_SOURCES = genres.c ../src/lpc.c -genres_LDADD = $(lib_LTLIBRARIES) -genres_LDFLAGS = $(LIBS) -genlsp_SOURCES = genlsp.c ../src/lpc.c ../src/lsp.c -genlsp_LDADD = $(lib_LTLIBRARIES) -genlsp_LDFLAGS = $(LIBS) -extract_SOURCES = extract.c -extract_LDADD = $(lib_LTLIBRARIES) -extract_LDFLAGS = $(LIBS) -vqtrain_SOURCES = vqtrain.c -vqtrain_LDADD = $(lib_LTLIBRARIES) -vqtrain_LDFLAGS = $(LIBS) -vqtrainjnd_SOURCES = vqtrainjnd.c -vqtrainjnd_LDADD = $(lib_LTLIBRARIES) -vqtrainjnd_LDFLAGS = $(LIBS) -vqtrainph_SOURCES = vqtrainph.c -vqtrainph_LDADD = $(lib_LTLIBRARIES) -vqtrainph_LDFLAGS = $(LIBS) -vqtrainsp_SOURCES = vqtrainsp.c -vqtrainsp_LDADD = $(lib_LTLIBRARIES) -vqtrainsp_LDFLAGS = $(LIBS) -genphdata_SOURCES = genphdata.c -genphdata_LDADD = $(lib_LTLIBRARIES) -genphdata_LDFLAGS = $(LIBS) -genampdata_SOURCES = genampdata.c -genampdata_LDADD = $(lib_LTLIBRARIES) -genampdata_LDFLAGS = $(LIBS) -polar2rect_SOURCES = polar2rect.c -polar2rect_LDADD = $(lib_LTLIBRARIES) -polar2rect_LDFLAGS = $(LIBS) -vq_train_jvm_SOURCES = vq_train_jvm.c -vq_train_jvm_LDADD = $(lib_LTLIBRARIES) -vq_train_jvm_LDFLAGS = $(LIBS) -CODEBOOKS = ../src/codebook.c ../src/codebookd.c ../src/codebookvq.c ../src/codebookjnd.c ../src/codebookdt.c ../src/codebookjvm.c ../src/codebookvqanssi.c ../src/codebookge.c -tnlp_SOURCES = tnlp.c ../src/sine.c ../src/nlp.c ../src/kiss_fft.c ../src/dump.c -tnlp_LDADD = $(lib_LTLIBRARIES) -tnlp_LDFLAGS = $(LIBS) -tinterp_SOURCES = tinterp.c ../src/sine.c ../src/kiss_fft.c ../src/interp.c ../src/lpc.c ../src/lsp.c ../src/quantise.c $(CODEBOOKS) ../src/dump.c -tinterp_LDADD = $(lib_LTLIBRARIES) -tinterp_LDFLAGS = $(LIBS) -tquant_SOURCES = tquant.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c $(CODEBOOKS) -tquant_LDADD = $(lib_LTLIBRARIES) -tquant_LDFLAGS = $(LIBS) -scalarlsptest_SOURCES = scalarlsptest.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c $(CODEBOOKS) -scalarlsptest_LDADD = $(lib_LTLIBRARIES) -scalarlsptest_LDFLAGS = $(LIBS) -tfdmdv_SOURCES = tfdmdv.c ../src/fdmdv.c ../src/kiss_fft.c ../src/octave.c -tfdmdv_LDADD = $(lib_LTLIBRARIES) -tfdmdv_LDFLAGS = $(LIBS) -t48_8_SOURCES = t48_8.c ../src/fdmdv.c ../src/kiss_fft.c -t48_8_LDADD = $(lib_LTLIBRARIES) -t48_8_LDFLAGS = $(LIBS) -lspsync_SOURCES = lspsync.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c \ -../src/codec2.c ../src/sine.c ../src/nlp.c ../src/postfilter.c ../src/phase.c ../src/interp.c ../src/pack.c $(CODEBOOKS) - -lspsync_LDADD = $(lib_LTLIBRARIES) -lspsync_LDFLAGS = $(LIBS) -create_interleaver_SOURCES = create_interleaver.c -create_interleaver_LDADD = $(lib_LTLIBRARIES) -create_interleaver_LDFLAGS = $(LIBS) -tlspsens_SOURCES = tlspsens.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c ../src/codec2.c ../src/sine.c ../src/nlp.c ../src/pack.c ../src/interp.c ../src/postfilter.c ../src/phase.c $(CODEBOOKS) -tlspsens_LDADD = $(lib_LTLIBRARIES) -tlspsens_LDFLAGS = $(LIBS) -tprede_SOURCES = tprede.c ../src/lpc.c -tprede_LDADD = $(lib_LTLIBRARIES) -tprede_LDFLAGS = $(LIBS) -pre_SOURCES = pre.c ../src/lpc.c -pre_LDADD = $(lib_LTLIBRARIES) -pre_LDFLAGS = $(LIBS) -de_SOURCES = de.c ../src/lpc.c -de_LDADD = $(lib_LTLIBRARIES) -de_LDFLAGS = $(LIBS) -tfifo_SOURCES = tfifo.c ../src/fifo.c -tfifo_LDADD = $(lib_LTLIBRARIES) -lpthread -tfifo_LDFLAGS = $(LIBS) -raw2h_SOURCES = raw2h.c -raw2h_LDADD = $(lib_LTLIBRARIES) -raw2h_LDFLAGS = $(LIBS) -c2validate_CFLAGS = -D__UNITTEST__ -c2validate_SOURCES = c2validate.c -c2validate_LDADD = $(lib_LTLIBRARIES) ../src/libcodec2.la -c2validate_LDFLAGS = $(LIBS) -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu unittest/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu unittest/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; for p in $$list; do \ - f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f $$p $$f"; \ - rm -f $$p $$f ; \ - done -c2validate$(EXEEXT): $(c2validate_OBJECTS) $(c2validate_DEPENDENCIES) - @rm -f c2validate$(EXEEXT) - $(LINK) $(c2validate_LDFLAGS) $(c2validate_OBJECTS) $(c2validate_LDADD) $(LIBS) -create_interleaver$(EXEEXT): $(create_interleaver_OBJECTS) $(create_interleaver_DEPENDENCIES) - @rm -f create_interleaver$(EXEEXT) - $(LINK) $(create_interleaver_LDFLAGS) $(create_interleaver_OBJECTS) $(create_interleaver_LDADD) $(LIBS) -de$(EXEEXT): $(de_OBJECTS) $(de_DEPENDENCIES) - @rm -f de$(EXEEXT) - $(LINK) $(de_LDFLAGS) $(de_OBJECTS) $(de_LDADD) $(LIBS) -extract$(EXEEXT): $(extract_OBJECTS) $(extract_DEPENDENCIES) - @rm -f extract$(EXEEXT) - $(LINK) $(extract_LDFLAGS) $(extract_OBJECTS) $(extract_LDADD) $(LIBS) -genampdata$(EXEEXT): $(genampdata_OBJECTS) $(genampdata_DEPENDENCIES) - @rm -f genampdata$(EXEEXT) - $(LINK) $(genampdata_LDFLAGS) $(genampdata_OBJECTS) $(genampdata_LDADD) $(LIBS) -genlsp$(EXEEXT): $(genlsp_OBJECTS) $(genlsp_DEPENDENCIES) - @rm -f genlsp$(EXEEXT) - $(LINK) $(genlsp_LDFLAGS) $(genlsp_OBJECTS) $(genlsp_LDADD) $(LIBS) -genphdata$(EXEEXT): $(genphdata_OBJECTS) $(genphdata_DEPENDENCIES) - @rm -f genphdata$(EXEEXT) - $(LINK) $(genphdata_LDFLAGS) $(genphdata_OBJECTS) $(genphdata_LDADD) $(LIBS) -genres$(EXEEXT): $(genres_OBJECTS) $(genres_DEPENDENCIES) - @rm -f genres$(EXEEXT) - $(LINK) $(genres_LDFLAGS) $(genres_OBJECTS) $(genres_LDADD) $(LIBS) -lspsync$(EXEEXT): $(lspsync_OBJECTS) $(lspsync_DEPENDENCIES) - @rm -f lspsync$(EXEEXT) - $(LINK) $(lspsync_LDFLAGS) $(lspsync_OBJECTS) $(lspsync_LDADD) $(LIBS) -polar2rect$(EXEEXT): $(polar2rect_OBJECTS) $(polar2rect_DEPENDENCIES) - @rm -f polar2rect$(EXEEXT) - $(LINK) $(polar2rect_LDFLAGS) $(polar2rect_OBJECTS) $(polar2rect_LDADD) $(LIBS) -pre$(EXEEXT): $(pre_OBJECTS) $(pre_DEPENDENCIES) - @rm -f pre$(EXEEXT) - $(LINK) $(pre_LDFLAGS) $(pre_OBJECTS) $(pre_LDADD) $(LIBS) -raw2h$(EXEEXT): $(raw2h_OBJECTS) $(raw2h_DEPENDENCIES) - @rm -f raw2h$(EXEEXT) - $(LINK) $(raw2h_LDFLAGS) $(raw2h_OBJECTS) $(raw2h_LDADD) $(LIBS) -scalarlsptest$(EXEEXT): $(scalarlsptest_OBJECTS) $(scalarlsptest_DEPENDENCIES) - @rm -f scalarlsptest$(EXEEXT) - $(LINK) $(scalarlsptest_LDFLAGS) $(scalarlsptest_OBJECTS) $(scalarlsptest_LDADD) $(LIBS) -t48_8$(EXEEXT): $(t48_8_OBJECTS) $(t48_8_DEPENDENCIES) - @rm -f t48_8$(EXEEXT) - $(LINK) $(t48_8_LDFLAGS) $(t48_8_OBJECTS) $(t48_8_LDADD) $(LIBS) -tfdmdv$(EXEEXT): $(tfdmdv_OBJECTS) $(tfdmdv_DEPENDENCIES) - @rm -f tfdmdv$(EXEEXT) - $(LINK) $(tfdmdv_LDFLAGS) $(tfdmdv_OBJECTS) $(tfdmdv_LDADD) $(LIBS) -tfifo$(EXEEXT): $(tfifo_OBJECTS) $(tfifo_DEPENDENCIES) - @rm -f tfifo$(EXEEXT) - $(LINK) $(tfifo_LDFLAGS) $(tfifo_OBJECTS) $(tfifo_LDADD) $(LIBS) -tinterp$(EXEEXT): $(tinterp_OBJECTS) $(tinterp_DEPENDENCIES) - @rm -f tinterp$(EXEEXT) - $(LINK) $(tinterp_LDFLAGS) $(tinterp_OBJECTS) $(tinterp_LDADD) $(LIBS) -tlspsens$(EXEEXT): $(tlspsens_OBJECTS) $(tlspsens_DEPENDENCIES) - @rm -f tlspsens$(EXEEXT) - $(LINK) $(tlspsens_LDFLAGS) $(tlspsens_OBJECTS) $(tlspsens_LDADD) $(LIBS) -tnlp$(EXEEXT): $(tnlp_OBJECTS) $(tnlp_DEPENDENCIES) - @rm -f tnlp$(EXEEXT) - $(LINK) $(tnlp_LDFLAGS) $(tnlp_OBJECTS) $(tnlp_LDADD) $(LIBS) -tprede$(EXEEXT): $(tprede_OBJECTS) $(tprede_DEPENDENCIES) - @rm -f tprede$(EXEEXT) - $(LINK) $(tprede_LDFLAGS) $(tprede_OBJECTS) $(tprede_LDADD) $(LIBS) -tquant$(EXEEXT): $(tquant_OBJECTS) $(tquant_DEPENDENCIES) - @rm -f tquant$(EXEEXT) - $(LINK) $(tquant_LDFLAGS) $(tquant_OBJECTS) $(tquant_LDADD) $(LIBS) -vq_train_jvm$(EXEEXT): $(vq_train_jvm_OBJECTS) $(vq_train_jvm_DEPENDENCIES) - @rm -f vq_train_jvm$(EXEEXT) - $(LINK) $(vq_train_jvm_LDFLAGS) $(vq_train_jvm_OBJECTS) $(vq_train_jvm_LDADD) $(LIBS) -vqtrain$(EXEEXT): $(vqtrain_OBJECTS) $(vqtrain_DEPENDENCIES) - @rm -f vqtrain$(EXEEXT) - $(LINK) $(vqtrain_LDFLAGS) $(vqtrain_OBJECTS) $(vqtrain_LDADD) $(LIBS) -vqtrainjnd$(EXEEXT): $(vqtrainjnd_OBJECTS) $(vqtrainjnd_DEPENDENCIES) - @rm -f vqtrainjnd$(EXEEXT) - $(LINK) $(vqtrainjnd_LDFLAGS) $(vqtrainjnd_OBJECTS) $(vqtrainjnd_LDADD) $(LIBS) -vqtrainph$(EXEEXT): $(vqtrainph_OBJECTS) $(vqtrainph_DEPENDENCIES) - @rm -f vqtrainph$(EXEEXT) - $(LINK) $(vqtrainph_LDFLAGS) $(vqtrainph_OBJECTS) $(vqtrainph_LDADD) $(LIBS) -vqtrainsp$(EXEEXT): $(vqtrainsp_OBJECTS) $(vqtrainsp_DEPENDENCIES) - @rm -f vqtrainsp$(EXEEXT) - $(LINK) $(vqtrainsp_LDFLAGS) $(vqtrainsp_OBJECTS) $(vqtrainsp_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c2validate-c2validate.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebook.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebookd.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebookdt.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebookge.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebookjnd.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebookjvm.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebookvq.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codebookvqanssi.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codec2.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/create_interleaver.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/de.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dump.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extract.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdmdv.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fifo.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genampdata.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genlsp.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genphdata.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genres.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interp.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kiss_fft.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lpc.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lsp.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lspsync.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nlp.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/octave.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pack.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/phase.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polar2rect.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/postfilter.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pre.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/quantise.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raw2h.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scalarlsptest.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sine.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t48_8.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tfdmdv.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tfifo.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tinterp.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tlspsens.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tnlp.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tprede.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tquant.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vq_train_jvm.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vqtrain.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vqtrainjnd.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vqtrainph.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vqtrainsp.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< - -c2validate-c2validate.o: c2validate.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(c2validate_CFLAGS) $(CFLAGS) -MT c2validate-c2validate.o -MD -MP -MF "$(DEPDIR)/c2validate-c2validate.Tpo" -c -o c2validate-c2validate.o `test -f 'c2validate.c' || echo '$(srcdir)/'`c2validate.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/c2validate-c2validate.Tpo" "$(DEPDIR)/c2validate-c2validate.Po"; else rm -f "$(DEPDIR)/c2validate-c2validate.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='c2validate.c' object='c2validate-c2validate.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(c2validate_CFLAGS) $(CFLAGS) -c -o c2validate-c2validate.o `test -f 'c2validate.c' || echo '$(srcdir)/'`c2validate.c - -c2validate-c2validate.obj: c2validate.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(c2validate_CFLAGS) $(CFLAGS) -MT c2validate-c2validate.obj -MD -MP -MF "$(DEPDIR)/c2validate-c2validate.Tpo" -c -o c2validate-c2validate.obj `if test -f 'c2validate.c'; then $(CYGPATH_W) 'c2validate.c'; else $(CYGPATH_W) '$(srcdir)/c2validate.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/c2validate-c2validate.Tpo" "$(DEPDIR)/c2validate-c2validate.Po"; else rm -f "$(DEPDIR)/c2validate-c2validate.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='c2validate.c' object='c2validate-c2validate.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(c2validate_CFLAGS) $(CFLAGS) -c -o c2validate-c2validate.obj `if test -f 'c2validate.c'; then $(CYGPATH_W) 'c2validate.c'; else $(CYGPATH_W) '$(srcdir)/c2validate.c'; fi` - -lpc.o: ../src/lpc.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lpc.o -MD -MP -MF "$(DEPDIR)/lpc.Tpo" -c -o lpc.o `test -f '../src/lpc.c' || echo '$(srcdir)/'`../src/lpc.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lpc.Tpo" "$(DEPDIR)/lpc.Po"; else rm -f "$(DEPDIR)/lpc.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/lpc.c' object='lpc.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lpc.o `test -f '../src/lpc.c' || echo '$(srcdir)/'`../src/lpc.c - -lpc.obj: ../src/lpc.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lpc.obj -MD -MP -MF "$(DEPDIR)/lpc.Tpo" -c -o lpc.obj `if test -f '../src/lpc.c'; then $(CYGPATH_W) '../src/lpc.c'; else $(CYGPATH_W) '$(srcdir)/../src/lpc.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lpc.Tpo" "$(DEPDIR)/lpc.Po"; else rm -f "$(DEPDIR)/lpc.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/lpc.c' object='lpc.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lpc.obj `if test -f '../src/lpc.c'; then $(CYGPATH_W) '../src/lpc.c'; else $(CYGPATH_W) '$(srcdir)/../src/lpc.c'; fi` - -lsp.o: ../src/lsp.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lsp.o -MD -MP -MF "$(DEPDIR)/lsp.Tpo" -c -o lsp.o `test -f '../src/lsp.c' || echo '$(srcdir)/'`../src/lsp.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lsp.Tpo" "$(DEPDIR)/lsp.Po"; else rm -f "$(DEPDIR)/lsp.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/lsp.c' object='lsp.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lsp.o `test -f '../src/lsp.c' || echo '$(srcdir)/'`../src/lsp.c - -lsp.obj: ../src/lsp.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lsp.obj -MD -MP -MF "$(DEPDIR)/lsp.Tpo" -c -o lsp.obj `if test -f '../src/lsp.c'; then $(CYGPATH_W) '../src/lsp.c'; else $(CYGPATH_W) '$(srcdir)/../src/lsp.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lsp.Tpo" "$(DEPDIR)/lsp.Po"; else rm -f "$(DEPDIR)/lsp.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/lsp.c' object='lsp.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lsp.obj `if test -f '../src/lsp.c'; then $(CYGPATH_W) '../src/lsp.c'; else $(CYGPATH_W) '$(srcdir)/../src/lsp.c'; fi` - -quantise.o: ../src/quantise.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT quantise.o -MD -MP -MF "$(DEPDIR)/quantise.Tpo" -c -o quantise.o `test -f '../src/quantise.c' || echo '$(srcdir)/'`../src/quantise.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/quantise.Tpo" "$(DEPDIR)/quantise.Po"; else rm -f "$(DEPDIR)/quantise.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/quantise.c' object='quantise.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o quantise.o `test -f '../src/quantise.c' || echo '$(srcdir)/'`../src/quantise.c - -quantise.obj: ../src/quantise.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT quantise.obj -MD -MP -MF "$(DEPDIR)/quantise.Tpo" -c -o quantise.obj `if test -f '../src/quantise.c'; then $(CYGPATH_W) '../src/quantise.c'; else $(CYGPATH_W) '$(srcdir)/../src/quantise.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/quantise.Tpo" "$(DEPDIR)/quantise.Po"; else rm -f "$(DEPDIR)/quantise.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/quantise.c' object='quantise.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o quantise.obj `if test -f '../src/quantise.c'; then $(CYGPATH_W) '../src/quantise.c'; else $(CYGPATH_W) '$(srcdir)/../src/quantise.c'; fi` - -dump.o: ../src/dump.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dump.o -MD -MP -MF "$(DEPDIR)/dump.Tpo" -c -o dump.o `test -f '../src/dump.c' || echo '$(srcdir)/'`../src/dump.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/dump.Tpo" "$(DEPDIR)/dump.Po"; else rm -f "$(DEPDIR)/dump.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/dump.c' object='dump.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dump.o `test -f '../src/dump.c' || echo '$(srcdir)/'`../src/dump.c - -dump.obj: ../src/dump.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dump.obj -MD -MP -MF "$(DEPDIR)/dump.Tpo" -c -o dump.obj `if test -f '../src/dump.c'; then $(CYGPATH_W) '../src/dump.c'; else $(CYGPATH_W) '$(srcdir)/../src/dump.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/dump.Tpo" "$(DEPDIR)/dump.Po"; else rm -f "$(DEPDIR)/dump.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/dump.c' object='dump.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dump.obj `if test -f '../src/dump.c'; then $(CYGPATH_W) '../src/dump.c'; else $(CYGPATH_W) '$(srcdir)/../src/dump.c'; fi` - -kiss_fft.o: ../src/kiss_fft.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT kiss_fft.o -MD -MP -MF "$(DEPDIR)/kiss_fft.Tpo" -c -o kiss_fft.o `test -f '../src/kiss_fft.c' || echo '$(srcdir)/'`../src/kiss_fft.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/kiss_fft.Tpo" "$(DEPDIR)/kiss_fft.Po"; else rm -f "$(DEPDIR)/kiss_fft.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/kiss_fft.c' object='kiss_fft.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o kiss_fft.o `test -f '../src/kiss_fft.c' || echo '$(srcdir)/'`../src/kiss_fft.c - -kiss_fft.obj: ../src/kiss_fft.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT kiss_fft.obj -MD -MP -MF "$(DEPDIR)/kiss_fft.Tpo" -c -o kiss_fft.obj `if test -f '../src/kiss_fft.c'; then $(CYGPATH_W) '../src/kiss_fft.c'; else $(CYGPATH_W) '$(srcdir)/../src/kiss_fft.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/kiss_fft.Tpo" "$(DEPDIR)/kiss_fft.Po"; else rm -f "$(DEPDIR)/kiss_fft.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/kiss_fft.c' object='kiss_fft.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o kiss_fft.obj `if test -f '../src/kiss_fft.c'; then $(CYGPATH_W) '../src/kiss_fft.c'; else $(CYGPATH_W) '$(srcdir)/../src/kiss_fft.c'; fi` - -codec2.o: ../src/codec2.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codec2.o -MD -MP -MF "$(DEPDIR)/codec2.Tpo" -c -o codec2.o `test -f '../src/codec2.c' || echo '$(srcdir)/'`../src/codec2.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codec2.Tpo" "$(DEPDIR)/codec2.Po"; else rm -f "$(DEPDIR)/codec2.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codec2.c' object='codec2.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codec2.o `test -f '../src/codec2.c' || echo '$(srcdir)/'`../src/codec2.c - -codec2.obj: ../src/codec2.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codec2.obj -MD -MP -MF "$(DEPDIR)/codec2.Tpo" -c -o codec2.obj `if test -f '../src/codec2.c'; then $(CYGPATH_W) '../src/codec2.c'; else $(CYGPATH_W) '$(srcdir)/../src/codec2.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codec2.Tpo" "$(DEPDIR)/codec2.Po"; else rm -f "$(DEPDIR)/codec2.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codec2.c' object='codec2.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codec2.obj `if test -f '../src/codec2.c'; then $(CYGPATH_W) '../src/codec2.c'; else $(CYGPATH_W) '$(srcdir)/../src/codec2.c'; fi` - -sine.o: ../src/sine.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sine.o -MD -MP -MF "$(DEPDIR)/sine.Tpo" -c -o sine.o `test -f '../src/sine.c' || echo '$(srcdir)/'`../src/sine.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/sine.Tpo" "$(DEPDIR)/sine.Po"; else rm -f "$(DEPDIR)/sine.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/sine.c' object='sine.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sine.o `test -f '../src/sine.c' || echo '$(srcdir)/'`../src/sine.c - -sine.obj: ../src/sine.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sine.obj -MD -MP -MF "$(DEPDIR)/sine.Tpo" -c -o sine.obj `if test -f '../src/sine.c'; then $(CYGPATH_W) '../src/sine.c'; else $(CYGPATH_W) '$(srcdir)/../src/sine.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/sine.Tpo" "$(DEPDIR)/sine.Po"; else rm -f "$(DEPDIR)/sine.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/sine.c' object='sine.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sine.obj `if test -f '../src/sine.c'; then $(CYGPATH_W) '../src/sine.c'; else $(CYGPATH_W) '$(srcdir)/../src/sine.c'; fi` - -nlp.o: ../src/nlp.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nlp.o -MD -MP -MF "$(DEPDIR)/nlp.Tpo" -c -o nlp.o `test -f '../src/nlp.c' || echo '$(srcdir)/'`../src/nlp.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/nlp.Tpo" "$(DEPDIR)/nlp.Po"; else rm -f "$(DEPDIR)/nlp.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/nlp.c' object='nlp.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nlp.o `test -f '../src/nlp.c' || echo '$(srcdir)/'`../src/nlp.c - -nlp.obj: ../src/nlp.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nlp.obj -MD -MP -MF "$(DEPDIR)/nlp.Tpo" -c -o nlp.obj `if test -f '../src/nlp.c'; then $(CYGPATH_W) '../src/nlp.c'; else $(CYGPATH_W) '$(srcdir)/../src/nlp.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/nlp.Tpo" "$(DEPDIR)/nlp.Po"; else rm -f "$(DEPDIR)/nlp.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/nlp.c' object='nlp.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nlp.obj `if test -f '../src/nlp.c'; then $(CYGPATH_W) '../src/nlp.c'; else $(CYGPATH_W) '$(srcdir)/../src/nlp.c'; fi` - -postfilter.o: ../src/postfilter.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT postfilter.o -MD -MP -MF "$(DEPDIR)/postfilter.Tpo" -c -o postfilter.o `test -f '../src/postfilter.c' || echo '$(srcdir)/'`../src/postfilter.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/postfilter.Tpo" "$(DEPDIR)/postfilter.Po"; else rm -f "$(DEPDIR)/postfilter.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/postfilter.c' object='postfilter.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o postfilter.o `test -f '../src/postfilter.c' || echo '$(srcdir)/'`../src/postfilter.c - -postfilter.obj: ../src/postfilter.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT postfilter.obj -MD -MP -MF "$(DEPDIR)/postfilter.Tpo" -c -o postfilter.obj `if test -f '../src/postfilter.c'; then $(CYGPATH_W) '../src/postfilter.c'; else $(CYGPATH_W) '$(srcdir)/../src/postfilter.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/postfilter.Tpo" "$(DEPDIR)/postfilter.Po"; else rm -f "$(DEPDIR)/postfilter.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/postfilter.c' object='postfilter.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o postfilter.obj `if test -f '../src/postfilter.c'; then $(CYGPATH_W) '../src/postfilter.c'; else $(CYGPATH_W) '$(srcdir)/../src/postfilter.c'; fi` - -phase.o: ../src/phase.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT phase.o -MD -MP -MF "$(DEPDIR)/phase.Tpo" -c -o phase.o `test -f '../src/phase.c' || echo '$(srcdir)/'`../src/phase.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/phase.Tpo" "$(DEPDIR)/phase.Po"; else rm -f "$(DEPDIR)/phase.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/phase.c' object='phase.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o phase.o `test -f '../src/phase.c' || echo '$(srcdir)/'`../src/phase.c - -phase.obj: ../src/phase.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT phase.obj -MD -MP -MF "$(DEPDIR)/phase.Tpo" -c -o phase.obj `if test -f '../src/phase.c'; then $(CYGPATH_W) '../src/phase.c'; else $(CYGPATH_W) '$(srcdir)/../src/phase.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/phase.Tpo" "$(DEPDIR)/phase.Po"; else rm -f "$(DEPDIR)/phase.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/phase.c' object='phase.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o phase.obj `if test -f '../src/phase.c'; then $(CYGPATH_W) '../src/phase.c'; else $(CYGPATH_W) '$(srcdir)/../src/phase.c'; fi` - -interp.o: ../src/interp.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interp.o -MD -MP -MF "$(DEPDIR)/interp.Tpo" -c -o interp.o `test -f '../src/interp.c' || echo '$(srcdir)/'`../src/interp.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/interp.Tpo" "$(DEPDIR)/interp.Po"; else rm -f "$(DEPDIR)/interp.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/interp.c' object='interp.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interp.o `test -f '../src/interp.c' || echo '$(srcdir)/'`../src/interp.c - -interp.obj: ../src/interp.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT interp.obj -MD -MP -MF "$(DEPDIR)/interp.Tpo" -c -o interp.obj `if test -f '../src/interp.c'; then $(CYGPATH_W) '../src/interp.c'; else $(CYGPATH_W) '$(srcdir)/../src/interp.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/interp.Tpo" "$(DEPDIR)/interp.Po"; else rm -f "$(DEPDIR)/interp.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/interp.c' object='interp.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o interp.obj `if test -f '../src/interp.c'; then $(CYGPATH_W) '../src/interp.c'; else $(CYGPATH_W) '$(srcdir)/../src/interp.c'; fi` - -pack.o: ../src/pack.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pack.o -MD -MP -MF "$(DEPDIR)/pack.Tpo" -c -o pack.o `test -f '../src/pack.c' || echo '$(srcdir)/'`../src/pack.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/pack.Tpo" "$(DEPDIR)/pack.Po"; else rm -f "$(DEPDIR)/pack.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/pack.c' object='pack.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pack.o `test -f '../src/pack.c' || echo '$(srcdir)/'`../src/pack.c - -pack.obj: ../src/pack.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pack.obj -MD -MP -MF "$(DEPDIR)/pack.Tpo" -c -o pack.obj `if test -f '../src/pack.c'; then $(CYGPATH_W) '../src/pack.c'; else $(CYGPATH_W) '$(srcdir)/../src/pack.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/pack.Tpo" "$(DEPDIR)/pack.Po"; else rm -f "$(DEPDIR)/pack.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/pack.c' object='pack.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pack.obj `if test -f '../src/pack.c'; then $(CYGPATH_W) '../src/pack.c'; else $(CYGPATH_W) '$(srcdir)/../src/pack.c'; fi` - -codebook.o: ../src/codebook.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebook.o -MD -MP -MF "$(DEPDIR)/codebook.Tpo" -c -o codebook.o `test -f '../src/codebook.c' || echo '$(srcdir)/'`../src/codebook.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebook.Tpo" "$(DEPDIR)/codebook.Po"; else rm -f "$(DEPDIR)/codebook.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebook.c' object='codebook.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebook.o `test -f '../src/codebook.c' || echo '$(srcdir)/'`../src/codebook.c - -codebook.obj: ../src/codebook.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebook.obj -MD -MP -MF "$(DEPDIR)/codebook.Tpo" -c -o codebook.obj `if test -f '../src/codebook.c'; then $(CYGPATH_W) '../src/codebook.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebook.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebook.Tpo" "$(DEPDIR)/codebook.Po"; else rm -f "$(DEPDIR)/codebook.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebook.c' object='codebook.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebook.obj `if test -f '../src/codebook.c'; then $(CYGPATH_W) '../src/codebook.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebook.c'; fi` - -codebookd.o: ../src/codebookd.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookd.o -MD -MP -MF "$(DEPDIR)/codebookd.Tpo" -c -o codebookd.o `test -f '../src/codebookd.c' || echo '$(srcdir)/'`../src/codebookd.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookd.Tpo" "$(DEPDIR)/codebookd.Po"; else rm -f "$(DEPDIR)/codebookd.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookd.c' object='codebookd.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookd.o `test -f '../src/codebookd.c' || echo '$(srcdir)/'`../src/codebookd.c - -codebookd.obj: ../src/codebookd.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookd.obj -MD -MP -MF "$(DEPDIR)/codebookd.Tpo" -c -o codebookd.obj `if test -f '../src/codebookd.c'; then $(CYGPATH_W) '../src/codebookd.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookd.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookd.Tpo" "$(DEPDIR)/codebookd.Po"; else rm -f "$(DEPDIR)/codebookd.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookd.c' object='codebookd.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookd.obj `if test -f '../src/codebookd.c'; then $(CYGPATH_W) '../src/codebookd.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookd.c'; fi` - -codebookvq.o: ../src/codebookvq.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookvq.o -MD -MP -MF "$(DEPDIR)/codebookvq.Tpo" -c -o codebookvq.o `test -f '../src/codebookvq.c' || echo '$(srcdir)/'`../src/codebookvq.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookvq.Tpo" "$(DEPDIR)/codebookvq.Po"; else rm -f "$(DEPDIR)/codebookvq.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookvq.c' object='codebookvq.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookvq.o `test -f '../src/codebookvq.c' || echo '$(srcdir)/'`../src/codebookvq.c - -codebookvq.obj: ../src/codebookvq.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookvq.obj -MD -MP -MF "$(DEPDIR)/codebookvq.Tpo" -c -o codebookvq.obj `if test -f '../src/codebookvq.c'; then $(CYGPATH_W) '../src/codebookvq.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookvq.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookvq.Tpo" "$(DEPDIR)/codebookvq.Po"; else rm -f "$(DEPDIR)/codebookvq.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookvq.c' object='codebookvq.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookvq.obj `if test -f '../src/codebookvq.c'; then $(CYGPATH_W) '../src/codebookvq.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookvq.c'; fi` - -codebookjnd.o: ../src/codebookjnd.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookjnd.o -MD -MP -MF "$(DEPDIR)/codebookjnd.Tpo" -c -o codebookjnd.o `test -f '../src/codebookjnd.c' || echo '$(srcdir)/'`../src/codebookjnd.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookjnd.Tpo" "$(DEPDIR)/codebookjnd.Po"; else rm -f "$(DEPDIR)/codebookjnd.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookjnd.c' object='codebookjnd.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookjnd.o `test -f '../src/codebookjnd.c' || echo '$(srcdir)/'`../src/codebookjnd.c - -codebookjnd.obj: ../src/codebookjnd.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookjnd.obj -MD -MP -MF "$(DEPDIR)/codebookjnd.Tpo" -c -o codebookjnd.obj `if test -f '../src/codebookjnd.c'; then $(CYGPATH_W) '../src/codebookjnd.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookjnd.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookjnd.Tpo" "$(DEPDIR)/codebookjnd.Po"; else rm -f "$(DEPDIR)/codebookjnd.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookjnd.c' object='codebookjnd.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookjnd.obj `if test -f '../src/codebookjnd.c'; then $(CYGPATH_W) '../src/codebookjnd.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookjnd.c'; fi` - -codebookdt.o: ../src/codebookdt.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookdt.o -MD -MP -MF "$(DEPDIR)/codebookdt.Tpo" -c -o codebookdt.o `test -f '../src/codebookdt.c' || echo '$(srcdir)/'`../src/codebookdt.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookdt.Tpo" "$(DEPDIR)/codebookdt.Po"; else rm -f "$(DEPDIR)/codebookdt.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookdt.c' object='codebookdt.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookdt.o `test -f '../src/codebookdt.c' || echo '$(srcdir)/'`../src/codebookdt.c - -codebookdt.obj: ../src/codebookdt.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookdt.obj -MD -MP -MF "$(DEPDIR)/codebookdt.Tpo" -c -o codebookdt.obj `if test -f '../src/codebookdt.c'; then $(CYGPATH_W) '../src/codebookdt.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookdt.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookdt.Tpo" "$(DEPDIR)/codebookdt.Po"; else rm -f "$(DEPDIR)/codebookdt.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookdt.c' object='codebookdt.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookdt.obj `if test -f '../src/codebookdt.c'; then $(CYGPATH_W) '../src/codebookdt.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookdt.c'; fi` - -codebookjvm.o: ../src/codebookjvm.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookjvm.o -MD -MP -MF "$(DEPDIR)/codebookjvm.Tpo" -c -o codebookjvm.o `test -f '../src/codebookjvm.c' || echo '$(srcdir)/'`../src/codebookjvm.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookjvm.Tpo" "$(DEPDIR)/codebookjvm.Po"; else rm -f "$(DEPDIR)/codebookjvm.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookjvm.c' object='codebookjvm.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookjvm.o `test -f '../src/codebookjvm.c' || echo '$(srcdir)/'`../src/codebookjvm.c - -codebookjvm.obj: ../src/codebookjvm.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookjvm.obj -MD -MP -MF "$(DEPDIR)/codebookjvm.Tpo" -c -o codebookjvm.obj `if test -f '../src/codebookjvm.c'; then $(CYGPATH_W) '../src/codebookjvm.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookjvm.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookjvm.Tpo" "$(DEPDIR)/codebookjvm.Po"; else rm -f "$(DEPDIR)/codebookjvm.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookjvm.c' object='codebookjvm.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookjvm.obj `if test -f '../src/codebookjvm.c'; then $(CYGPATH_W) '../src/codebookjvm.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookjvm.c'; fi` - -codebookvqanssi.o: ../src/codebookvqanssi.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookvqanssi.o -MD -MP -MF "$(DEPDIR)/codebookvqanssi.Tpo" -c -o codebookvqanssi.o `test -f '../src/codebookvqanssi.c' || echo '$(srcdir)/'`../src/codebookvqanssi.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookvqanssi.Tpo" "$(DEPDIR)/codebookvqanssi.Po"; else rm -f "$(DEPDIR)/codebookvqanssi.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookvqanssi.c' object='codebookvqanssi.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookvqanssi.o `test -f '../src/codebookvqanssi.c' || echo '$(srcdir)/'`../src/codebookvqanssi.c - -codebookvqanssi.obj: ../src/codebookvqanssi.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookvqanssi.obj -MD -MP -MF "$(DEPDIR)/codebookvqanssi.Tpo" -c -o codebookvqanssi.obj `if test -f '../src/codebookvqanssi.c'; then $(CYGPATH_W) '../src/codebookvqanssi.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookvqanssi.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookvqanssi.Tpo" "$(DEPDIR)/codebookvqanssi.Po"; else rm -f "$(DEPDIR)/codebookvqanssi.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookvqanssi.c' object='codebookvqanssi.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookvqanssi.obj `if test -f '../src/codebookvqanssi.c'; then $(CYGPATH_W) '../src/codebookvqanssi.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookvqanssi.c'; fi` - -codebookge.o: ../src/codebookge.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookge.o -MD -MP -MF "$(DEPDIR)/codebookge.Tpo" -c -o codebookge.o `test -f '../src/codebookge.c' || echo '$(srcdir)/'`../src/codebookge.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookge.Tpo" "$(DEPDIR)/codebookge.Po"; else rm -f "$(DEPDIR)/codebookge.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookge.c' object='codebookge.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookge.o `test -f '../src/codebookge.c' || echo '$(srcdir)/'`../src/codebookge.c - -codebookge.obj: ../src/codebookge.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT codebookge.obj -MD -MP -MF "$(DEPDIR)/codebookge.Tpo" -c -o codebookge.obj `if test -f '../src/codebookge.c'; then $(CYGPATH_W) '../src/codebookge.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookge.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/codebookge.Tpo" "$(DEPDIR)/codebookge.Po"; else rm -f "$(DEPDIR)/codebookge.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/codebookge.c' object='codebookge.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o codebookge.obj `if test -f '../src/codebookge.c'; then $(CYGPATH_W) '../src/codebookge.c'; else $(CYGPATH_W) '$(srcdir)/../src/codebookge.c'; fi` - -fdmdv.o: ../src/fdmdv.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT fdmdv.o -MD -MP -MF "$(DEPDIR)/fdmdv.Tpo" -c -o fdmdv.o `test -f '../src/fdmdv.c' || echo '$(srcdir)/'`../src/fdmdv.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/fdmdv.Tpo" "$(DEPDIR)/fdmdv.Po"; else rm -f "$(DEPDIR)/fdmdv.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/fdmdv.c' object='fdmdv.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o fdmdv.o `test -f '../src/fdmdv.c' || echo '$(srcdir)/'`../src/fdmdv.c - -fdmdv.obj: ../src/fdmdv.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT fdmdv.obj -MD -MP -MF "$(DEPDIR)/fdmdv.Tpo" -c -o fdmdv.obj `if test -f '../src/fdmdv.c'; then $(CYGPATH_W) '../src/fdmdv.c'; else $(CYGPATH_W) '$(srcdir)/../src/fdmdv.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/fdmdv.Tpo" "$(DEPDIR)/fdmdv.Po"; else rm -f "$(DEPDIR)/fdmdv.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/fdmdv.c' object='fdmdv.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o fdmdv.obj `if test -f '../src/fdmdv.c'; then $(CYGPATH_W) '../src/fdmdv.c'; else $(CYGPATH_W) '$(srcdir)/../src/fdmdv.c'; fi` - -octave.o: ../src/octave.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT octave.o -MD -MP -MF "$(DEPDIR)/octave.Tpo" -c -o octave.o `test -f '../src/octave.c' || echo '$(srcdir)/'`../src/octave.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/octave.Tpo" "$(DEPDIR)/octave.Po"; else rm -f "$(DEPDIR)/octave.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/octave.c' object='octave.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o octave.o `test -f '../src/octave.c' || echo '$(srcdir)/'`../src/octave.c - -octave.obj: ../src/octave.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT octave.obj -MD -MP -MF "$(DEPDIR)/octave.Tpo" -c -o octave.obj `if test -f '../src/octave.c'; then $(CYGPATH_W) '../src/octave.c'; else $(CYGPATH_W) '$(srcdir)/../src/octave.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/octave.Tpo" "$(DEPDIR)/octave.Po"; else rm -f "$(DEPDIR)/octave.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/octave.c' object='octave.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o octave.obj `if test -f '../src/octave.c'; then $(CYGPATH_W) '../src/octave.c'; else $(CYGPATH_W) '$(srcdir)/../src/octave.c'; fi` - -fifo.o: ../src/fifo.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT fifo.o -MD -MP -MF "$(DEPDIR)/fifo.Tpo" -c -o fifo.o `test -f '../src/fifo.c' || echo '$(srcdir)/'`../src/fifo.c; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/fifo.Tpo" "$(DEPDIR)/fifo.Po"; else rm -f "$(DEPDIR)/fifo.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/fifo.c' object='fifo.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o fifo.o `test -f '../src/fifo.c' || echo '$(srcdir)/'`../src/fifo.c - -fifo.obj: ../src/fifo.c -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT fifo.obj -MD -MP -MF "$(DEPDIR)/fifo.Tpo" -c -o fifo.obj `if test -f '../src/fifo.c'; then $(CYGPATH_W) '../src/fifo.c'; else $(CYGPATH_W) '$(srcdir)/../src/fifo.c'; fi`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/fifo.Tpo" "$(DEPDIR)/fifo.Po"; else rm -f "$(DEPDIR)/fifo.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/fifo.c' object='fifo.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o fifo.obj `if test -f '../src/fifo.c'; then $(CYGPATH_W) '../src/fifo.c'; else $(CYGPATH_W) '$(srcdir)/../src/fifo.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -rm -f libtool -uninstall-info-am: - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ - list='$(DISTFILES)'; for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ - esac; \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkdir_p) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-libtool distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: - -install-exec-am: - -install-info: install-info-am - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-info-am - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-noinstPROGRAMS ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-exec \ - install-exec-am install-info install-info-am install-man \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am \ - uninstall-info-am - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/codec2/unittest/README b/codec2/unittest/README deleted file mode 100644 index 0e8776b7..00000000 --- a/codec2/unittest/README +++ /dev/null @@ -1,43 +0,0 @@ -README -for codec2/unittest -Created David Rowe 31 July 2012 - -Training (experimental) sparse phase VQs: - -1/ In ../src/phase.c phase_experiment() enable: - - print_sparse_pred_error() - - and 'make' c2sim (in src) - -2/ Run over a training database: - - $ ./c2sim /xhome1/codec2/samples/train.spc --phaseexp > train_phtrain.txt - - a) check stats in Octave: - octave> load ../src/train_phtrain.txt - octave> std(nonzeros(train_phtrain(:,1:20))) - octave> hist(nonzeros(train_phtrain(:,1:20)),20) -3/ Extract and convert to floats vector you wish to train for example - first 20 (out of MAX_AMP == 80): - - $ ./extract ../src/train_phtrain.txt train_phtrain.flt 1 20 - -4/ Convert to rectangular: - - $ ./polar2rect train_phtrain.flt train_phtrainr.flt - -5/ Run this program: - - $ ./vqtrainph train_phtrainr.flt 20 1024 vq.txt - - Ouput is vq.txt - -Tests ------ - -+ build up insmallest possible stesp -+ impl errors v alg errors -+ use actual phase data as codebook -+ test vq with rand phases first or known data - diff --git a/codec2/unittest/c2validate.c b/codec2/unittest/c2validate.c deleted file mode 100644 index 5906017d..00000000 --- a/codec2/unittest/c2validate.c +++ /dev/null @@ -1,103 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: c2validate.c - AUTHOR......: David Rowe - DATE CREATED: 10 April 2013 - - Encodes and decodes an array of speech samples using Codec 2 and compares - it to a previously stored output to validate Codec operation. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2013 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2.1, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include "codec2.h" -#ifdef __UNITTEST__ -#include "hts1a.h" -#include "hts1a_1300.h" -#endif - -#include -#include -#include -#ifdef __EMBEDDED__ -#include "gdb_stdio.h" -#define fopen gdb_stdio_fopen -#define fwrite gdb_stdio_fwrite -#define fclose gdb_stdio_fclose -#endif - -int c2validate(int mode, short input_samples[], short output_samples[], char outfile[], int nsamples) -{ - struct CODEC2 *codec2; - short *pinput, *poutput, *outbuf; - unsigned char *bits; - int nsam, nbit; - int nframes, i, result, j; - FILE *fout; - - codec2 = codec2_create(mode); - nsam = codec2_samples_per_frame(codec2); - outbuf = (short*)malloc(nsam*sizeof(short)); - nbit = codec2_bits_per_frame(codec2); - bits = (unsigned char*)malloc(nbit*sizeof(char)); - if (strlen(outfile)) - fout = fopen(outfile, "wb"); - else - fout = NULL; - - nframes = nsamples/nsam; - pinput = input_samples; - poutput = output_samples; - result = 1; - - for(i=0; i. -*/ - -#ifndef __C2VALIDATE__ - -int c2validate(int mode, short input_samples[], short output_samples[], char outfile[], int nsamples); - -#endif diff --git a/codec2/unittest/create_interleaver.c b/codec2/unittest/create_interleaver.c deleted file mode 100644 index 39ff99c0..00000000 --- a/codec2/unittest/create_interleaver.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - create_interleaver.c - David Rowe - May 27 2012 - - Creates an interleaver for Codec 2. -*/ - -#include -#include -#include - -int main(int argc, char * argv[]) { - int m,i, src_bit, dest_bit; - FILE *f; - int *interleaver; - - if (argc != 3) { - printf("usage: %s InterleaverBits InterleaverFile\n", argv[0]); - exit(1); - } - - m = atoi(argv[1]); - f = fopen(argv[2],"wt"); - assert(f != NULL); - - - interleaver = (int*)malloc(m*sizeof(int)); - assert(interleaver != NULL); - for(i=0; i -#include -#include -#include -#include -#include -#include "lpc.h" - -#define N 80 - -int main(int argc, char *argv[]) { - FILE *fin, *fout; - short buf[N]; - float Sn[N], Sn_de[N]; - float de_mem = 0.0; - int i; - - if (argc != 3) { - printf("usage: de InputRawSpeechFile OutputRawSpeechFile\n"); - printf("e.g de input.raw output.raw"); - exit(1); - } - - if (strcmp(argv[1], "-") == 0) fin = stdin; - else if ( (fin = fopen(argv[1],"rb")) == NULL ) { - fprintf(stderr, "Error opening input speech file: %s: %s.\n", - argv[1], strerror(errno)); - exit(1); - } - - if (strcmp(argv[2], "-") == 0) fout = stdout; - else if ( (fout = fopen(argv[2],"wb")) == NULL ) { - fprintf(stderr, "Error opening output speech file: %s: %s.\n", - argv[2], strerror(errno)); - exit(1); - } - - while(fread(buf, sizeof(short), N, fin) == N) { - for(i=0; i. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAX_STR 1024 -#define LEN_TARGET_NAME_RESPONSE 14 -#define N 160 - -/* message parsing state machine states */ - -#define MSGSTATE_HDR1 0 -#define MSGSTATE_HDR2 1 -#define MSGSTATE_DATA 2 - -#define LENGTH_MASK 0x1FFF /* mask for message length */ -#define TYPE_MASK 0xE0 /* mask for upper byte of header */ -#define TYPE_C 0x20 /* compressed speech from target */ -#define TYPE_UC 0x40 /* uncompressed speech from target */ - -#define MAX_MSG_LEN 8192 - -/* Control items sent to DV Dongle */ - -char target_name[] = {0x04, 0x20, 0x01, 0x00}; - -/* note [2] appears to be in error, specifies run as 0x02, stop as 0x01 */ - -char run_state_stop[] = {0x05, 0x00, 0x18, 0x00, 0x00}; -char run_state_run[] = {0x05, 0x00, 0x18, 0x00, 0x01}; - -/* Control item codes from DV Dongle */ - -char data_item_0[] = {0x42, 0x81}; -char data_item_1[] = {0x32, 0xa0}; -char run_state[] = {0x05, 0x00}; -char idle[] = {0x00, 0x00}; - -typedef struct { - short header; - char power; - char control1; - short rate[5]; - short unused[3]; - short dtmf; - short control2; - short channel_data[12]; -} COMPRESSED; - -COMPRESSED c_in; -COMPRESSED c_out; -FILE *fin, *fout, *f; -int fd, c_msg, uc_msg; - -int initport(int fd) { - struct termios options; - - // Set the options for the port... - - cfmakeraw(&options); - cfsetispeed(&options, B230400); - cfsetospeed(&options, B230400); - options.c_cflag |= (CLOCAL | CREAD); - tcsetattr(fd, TCSANOW, &options); - - return 1; -} - -int getbaud(int fd) { - struct termios termAttr; - int inputSpeed = -1; - speed_t baudRate; - - tcgetattr(fd, &termAttr); - - /* Get the input speed */ - - baudRate = cfgetispeed(&termAttr); - switch (baudRate) { - case B0: inputSpeed = 0; break; - case B50: inputSpeed = 50; break; - case B110: inputSpeed = 110; break; - case B134: inputSpeed = 134; break; - case B150: inputSpeed = 150; break; - case B200: inputSpeed = 200; break; - case B300: inputSpeed = 300; break; - case B600: inputSpeed = 600; break; - case B1200: inputSpeed = 1200; break; - case B1800: inputSpeed = 1800; break; - case B2400: inputSpeed = 2400; break; - case B4800: inputSpeed = 4800; break; - case B9600: inputSpeed = 9600; break; - case B19200: inputSpeed = 19200; break; - case B38400: inputSpeed = 38400; break; - case B57600: inputSpeed = 38400; break; - case B115200: inputSpeed = 38400; break; - case B230400: inputSpeed = 230400; break; - } - - return inputSpeed; -} - -void write_dongle(int fd, char *data, int len) { - int n; - //printf(" writing %d bytes\n", len); - n = write(fd, data, len); - if (n < 0) { - perror("write failed"); - exit(1); - } -} - -void read_dongle(int fd, char *data, int len) { - int n; - //printf(" reading %d bytes \n", len); - - n = read(fd, data, len); - if (n < 0) { - perror("read failed"); - exit(1); - } - //printf(" read %d bytes\n", len); -} - -void parse_message(int msg_type, int msg_len, char msg_data[]) { - short buf[N]; - COMPRESSED *c_out; - - //printf("msg_type: 0x%02x msg_len: %d\n", msg_type, msg_len); - - /* echo compressed speech frames back to target */ - - if (msg_type == TYPE_C) { - c_out = (COMPRESSED*)msg_data; -#ifdef TMP - printf("control1 0x%04x\n", c_out->control1 & 0xff); - printf("rate[0] 0x%04x\n", c_out->rate[0]); - printf("rate[1] 0x%04x\n", c_out->rate[1]); - printf("rate[2] 0x%04x\n", c_out->rate[2]); - printf("rate[3] 0x%04x\n", c_out->rate[3]); - printf("rate[4] 0x%04x\n", c_out->rate[4]); - printf("control2 0x%04x\n", c_out->control2 & 0xffff); - printf("cd[0] 0x%04x\n", c_out->channel_data[0] & 0xffff); - printf("cd[1] 0x%04x\n", c_out->channel_data[1] & 0xffff); - printf("cd[2] 0x%04x\n", c_out->channel_data[2] & 0xffff); - printf("cd[3] 0x%04x\n", c_out->channel_data[3] & 0xffff); - printf("cd[4] 0x%04x\n", c_out->channel_data[4] & 0xffff); - printf("cd[5] 0x%04x\n", c_out->channel_data[5] & 0xffff); - printf("cd[6] 0x%04x\n", c_out->channel_data[6] & 0xffff); - printf("uc_msg %d\n", uc_msg); -#endif - printf("bit errors %d\n", c_out->unused[2]); - memcpy(&c_in.channel_data, - &c_out->channel_data, - sizeof(c_in.channel_data)); - - write_dongle(fd, data_item_1, sizeof(data_item_1)); - write_dongle(fd, (char*)&c_in, sizeof(c_in)); - - c_msg++; - } - - /* write speech buffers to disk */ - - if (msg_type == TYPE_UC) { - - if (fout != NULL) { - fwrite(msg_data, sizeof(char), msg_len-2, fout); - printf("msg_len %d\n", msg_len); - } - - if (fin != NULL) - fread(buf, sizeof(short), N, fin); - else - memset(buf, 0, sizeof(buf)); - - write_dongle(fd, data_item_0, sizeof(data_item_0)); - write_dongle(fd, (char*)buf, sizeof(buf)); - - uc_msg++; - } -} - -int main(int argc, char **argv) { - char response[MAX_STR]; - int i; - int state, next_state; - short header; - int msg_type, msg_length; - char msg_data[MAX_MSG_LEN]; - int n, length; - int r; - - char data; - - f = fopen("/tmp/log.txt", "wt"); - assert(f != NULL); - - /* open and configure serial port */ - - fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY); - if (fd == -1) { - perror("open_port: Unable to open /dev/ttyS0 - "); - exit(1); - } else { - fcntl(fd, F_SETFL, 0); - } - - initport(fd); - - fin = NULL; - if (argc >= 2) { - fin = fopen(argv[1],"rb"); - assert(fin != NULL); - } - fout = NULL; - if (argc == 3) { - fout = fopen(argv[2],"wb"); - assert(fout != NULL); - } - - /* check DV Dongle is alive */ - - write_dongle(fd, target_name, sizeof(target_name)); - read_dongle(fd, response, LEN_TARGET_NAME_RESPONSE); - if (strcmp(&response[4],"DV Dongle") != 0) { - printf("DV Dongle not responding\n"); - exit(1); - } - printf("Found DV Dongle....\n"); - - c_in.header = 0x13ec; - c_in.power = 0x0; - c_in.control1 = 0x0; - -#define RATE2000 -#ifdef RATE2000 - c_in.rate[0] = 0x0028; /* 2000 bit/s, no FEC */ - c_in.rate[1] = 0x0000; - c_in.rate[2] = 0x0000; - c_in.rate[3] = 0x0000; - c_in.rate[4] = 0x6248; -#endif - -#ifdef RATE3600_1200 - c_in.rate[0] = 0x5048; /* 3600 bit/s, 1200 bit/s FEC */ - c_in.rate[1] = 0x0001; - c_in.rate[2] = 0x0000; - c_in.rate[3] = 0x2412; - c_in.rate[4] = 0x6860; -#endif - - c_in.unused[0] = 0x0; - c_in.unused[1] = 0x0; - c_in.unused[2] = 0x0; - c_in.dtmf = 0x00ff; - c_in.control2 = 0x8000; - - /* put codec in run mode */ - - write_dongle(fd, run_state_run, sizeof(run_state_run)); - //write_dongle(fd, data_item_1, sizeof(data_item_1)); - //write_dongle(fd, (char*)&c_in, sizeof(c_in)); - - state = MSGSTATE_HDR1; - header = msg_type = msg_length = n = length = 0; - c_msg = uc_msg = 0; - - for(i=0; i<100000; i++) { - /* - We can only reliably read one byte at a time. Until I - realised this there was "much wailing and gnashing of - teeth". Trying to read() n bytes read() returns n but may - actually reads some number between 1 and n. So it may only - read 1 byte int data[] but return n. - */ - r = read(fd, &data, 1); - assert(r == 1); - - /* used state machine design from ambetest103.zip, SerialPort.cpp */ - - next_state = state; - switch(state) { - case MSGSTATE_HDR1: - header = data; - next_state = MSGSTATE_HDR2; - break; - case MSGSTATE_HDR2: - header |= data<<8; - msg_length = header & LENGTH_MASK; - msg_type = header & TYPE_MASK; - //printf("%0x %d\n", msg_type, msg_length); - if (length == 2) { - parse_message(msg_type, msg_length, msg_data); - next_state = MSGSTATE_HDR1; - } - else { - if (msg_length == 0x0) - length = 8192; - else - length = msg_length - 2; - n = 0; - next_state = MSGSTATE_DATA; - } - break; - case MSGSTATE_DATA: - msg_data[n++] = data; - length--; - if (length == 0) { - parse_message(msg_type, msg_length, msg_data); - next_state = MSGSTATE_HDR1; - } - break; - } - state = next_state; - } - - printf("finished, c_msg = %d uc_msg = %d\n", c_msg, uc_msg); - - write_dongle(fd, run_state_stop, sizeof(run_state_stop)); - - close(fd); - if (fin != NULL) - fclose(fin); - if (fout != NULL) - fclose(fout); - fclose(f); - - return 0; -} diff --git a/codec2/unittest/extract.c b/codec2/unittest/extract.c deleted file mode 100644 index 2812d55e..00000000 --- a/codec2/unittest/extract.c +++ /dev/null @@ -1,126 +0,0 @@ -/*--------------------------------------------------------------------------*\ - - FILE........: extract.c - AUTHOR......: David Rowe - DATE CREATED: 23/2/95 - - This program extracts a float file of vectors from a text file - of vectors. The float files are easier to process quickly - during VQ training. A subset of the text file VQ may be - extracted to faciltate split VQ of scaler VQ design. - -\*--------------------------------------------------------------------------*/ - -/* - Copyright (C) 2009 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#define MAX_STR 2048 /* maximum string length */ - -#include -#include -#include -#include -#include - -void scan_line(FILE *fp, float f[], int n); - -int main(int argc, char *argv[]) { - FILE *ftext; /* text file of vectors */ - FILE *ffloat; /* float file of vectors */ - int st,en; /* start and end values of vector to copy */ - float *buf; /* ptr to vector read from ftext */ - long lines; /* lines read so far */ - - if (argc != 5) { - printf("usage: %s TextFile FloatFile start(1 .. 10) end(1 .. 10)\n", argv[0]); - exit(1); - } - - /* read command line arguments and open files */ - - ftext = fopen(argv[1],"rt"); - if (ftext == NULL) { - printf("Error opening text file: %s\n",argv[1]); - exit(1); - } - - ffloat = fopen(argv[2],"wb"); - if (ffloat == NULL) { - printf("Error opening float file: %s\n",argv[2]); - exit(1); - } - - st = atoi(argv[3]); - en = atoi(argv[4]); - - buf = (float*)malloc(en*sizeof(float)); - if (buf == NULL) { - printf("Error in malloc()\n"); - exit(1); - } - - lines = 0; - while(!feof(ftext)) { - scan_line(ftext, buf, en); - if (!feof(ftext)) { - fwrite(&buf[st-1], sizeof(float), en-st+1, ffloat); - printf("\r%ld lines",++lines); - } - } - printf("\n"); - - /* clean up and exit */ - - free(buf); - fclose(ftext); - fclose(ffloat); - - return 0; -} - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: scan_line() - - AUTHOR......: David Rowe - DATE CREATED: 20/2/95 - - This function reads a vector of floats from a line in a text file. - -\*---------------------------------------------------------------------------*/ - -void scan_line(FILE *fp, float f[], int n) -/* FILE *fp; file ptr to text file */ -/* float f[]; array of floats to return */ -/* int n; number of floats in line */ -{ - char s[MAX_STR]; - char *ps,*pe; - int i; - - memset(s, 0, MAX_STR); - ps = pe = fgets(s,MAX_STR,fp); - if (ps == NULL) - return; - for(i=0; i quantized - - The first column is the log2 of the pitch compared to the lowest freq, - so log2(wo/pi*4000/50) where wo is the frequency your patch outputs. The - second column is the energy in dB, so 10*log10(1e-4+E) -*/ - -/* - Copyright (C) 2012 Jean-Marc Valin - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include - -#include -#include -#include - -#define MIN(a,b) ((a)<(b)?(a):(b)) -//#define COEF 0.0 - -static float COEF[2] = {0.8, 0.9}; -//static float COEF[2] = {0.0, 0.}; - -#define MAX_ENTRIES 16384 - -void compute_weights2(const float *x, const float *xp, float *w, int ndim) -{ - w[0] = 30; - w[1] = 1; - if (x[1]<0) - { - w[0] *= .6; - w[1] *= .3; - } - if (x[1]<-10) - { - w[0] *= .3; - w[1] *= .3; - } - /* Higher weight if pitch is stable */ - if (fabs(x[0]-xp[0])<.2) - { - w[0] *= 2; - w[1] *= 1.5; - } else if (fabs(x[0]-xp[0])>.5) /* Lower if not stable */ - { - w[0] *= .5; - } - - /* Lower weight for low energy */ - if (x[1] < xp[1]-10) - { - w[1] *= .5; - } - if (x[1] < xp[1]-20) - { - w[1] *= .5; - } - - //w[0] = 30; - //w[1] = 1; - - /* Square the weights because it's applied on the squared error */ - w[0] *= w[0]; - w[1] *= w[1]; - -} - -int find_nearest_weighted(const float *codebook, int nb_entries, float *x, const float *w, int ndim) -{ - int i, j; - float min_dist = 1e15; - int nearest = 0; - - for (i=0;i -#include -#include -#include -#include -#include -#include "../src/defines.h" - -typedef struct { - float real; - float imag; -} COMP; - -#define NVEC 200000 -#define D 2 -#define E 8 - -int main(void) { - FILE *f=fopen("testamp.flt", "wb"); - int i, j, m, L, index; - float amp, noisey_amp, pitch, Wo; - float sparse_pe[MAX_AMP]; - - #ifdef TEST1 - /* D fixed amplitude vectors of E elements long, - with D=2, E=8: - - $ ./vqtrainsp testamp.flt 2 8 test.txt - - test.txt should be same as training data. - */ - for(i=0; i. -*/ - -#define P 12 /* LP order */ -#define LSP_DELTA1 0.01 /* grid spacing for LSP root searches */ -#define NW 279 /* frame size in samples */ -#define N 80 /* frame to frame shift */ -#define THRESH 40.0 /* threshold energy/sample for frame inclusion */ -#define PI 3.141592654 /* mathematical constant */ - -#include -#include -#include -#include -#include "lpc.h" /* LPC analysis functions */ -#include "lsp.h" /* LSP encode/decode functions */ - -int switch_present(sw,argc,argv) - char sw[]; /* switch in string form */ - int argc; /* number of command line arguments */ - char *argv[]; /* array of command line arguments in string form */ -{ - int i; /* loop variable */ - - for(i=1; i THRESH) { - af++; - printf("Active Frame: %ld unstables: %d\n",af, unstables); - - find_aks(Sn, ak, NW, P, &Eres); - roots = lpc_to_lsp(ak, P , lsp, 5, LSP_DELTA1); - if (roots == P) { - if (lspd) { - if (log) { - fprintf(flsp,"%f ",log10(lsp[0])); - for(i=1; i -#include -#include -#include -#include -#include -#include "../src/defines.h" - -typedef struct { - float real; - float imag; -} COMP; - -#define NVEC 100000 -#define D 2 -#define E 8 - -int main(void) { - FILE *f=fopen("testph.flt", "wb"); - int i, m, L, index; - float angle, noisey_angle, pitch, Wo; - COMP c; - COMP sparse_pe[MAX_AMP]; - - #ifdef TEST1 - for(i=0; i. -*/ - -#include -#include -#include - -#define N 160 -#define P 10 - -int main(int argc, char *argv[]) -{ - FILE *fin,*fres; /* input and output files */ - short buf[N]; /* buffer of 16 bit speech samples */ - float Sn[P+N]; /* input speech samples */ - float res[N]; /* residual after LPC filtering */ - float E; - float ak[P+1]; /* LP coeffs */ - - int frames; /* frames processed so far */ - int i; /* loop variables */ - - if (argc < 3) { - printf("usage: %s InputFile ResidualFile\n", argv[0]); - exit(1); - } - - /* Open files */ - - if ((fin = fopen(argv[1],"rb")) == NULL) { - printf("Error opening input file: %s\n",argv[1]); - exit(0); - } - - if ((fres = fopen(argv[2],"wb")) == NULL) { - printf("Error opening output residual file: %s\n",argv[2]); - exit(0); - } - - /* Initialise */ - - frames = 0; - for(i=0; i -#include -#include -#include "codec2.h" -#include "defines.h" -#include "quantise.h" - -#define F 6 /* look at LSP ordering in F-1 frames */ -#define CORRECT_OFFSET 10 /* LSPs start 10 bits int frame qt 2400 bit/s */ - - -static int check_candidate(char bits[], int offset) -{ - int i; - int lsp_indexes[LPC_ORD]; - float lsps[LPC_ORD]; - unsigned int nbit = offset; - int swaps; - - for(i=0; i -#include -#include -#include - -#define TWO_PI 6.283185307 -#define FS 8000.0 -#define AMP 10000.0 - -int main(int argc, char *argv[]) { - FILE *f; - int i,n; - float freq, length; - short *buf; - - if (argc != 4) { - printf("usage: %s outputFile frequencyHz lengthSecs\n", argv[0]); - exit(1); - } - - f = fopen(argv[1] ,"wb"); - freq = atof(argv[2]); - length = atof(argv[3]); - n = length*FS; - buf = (short*)malloc(sizeof(short)*n); - assert(buf != NULL); - - for(i=0; i -#include -#include -#include - -typedef struct { - float real; - float imag; -} COMP; - -int main(int argc, char *argv[]) { - FILE *fpolar; - FILE *frect; - float polar; - COMP rect; - - if (argc != 3) { - printf("usage: %s polarFile rectFile\n", argv[0]); - exit(0); - } - - fpolar = fopen(argv[1], "rb"); - assert(fpolar != NULL); - frect = fopen(argv[2], "wb"); - assert(frect != NULL); - - while (fread(&polar, sizeof(float), 1, fpolar) != 0) { - if (polar == 0.0) { - /* this values indicates the VQ training should ignore - this vector element. It's not a valid phase as it - doesn't have mangitude of 1.0 */ - rect.real = 0.0; - rect.imag = 0.0; - } - else { - rect.real = cos(polar); - rect.imag = sin(polar); - } - fwrite(&rect, sizeof(COMP), 1, frect); - } - - fclose(fpolar); - fclose(frect); - - return 0; -} diff --git a/codec2/unittest/pre.c b/codec2/unittest/pre.c deleted file mode 100644 index 49e5c99c..00000000 --- a/codec2/unittest/pre.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - pre.c - David Rowe - Sep 26 2012 - - Takes audio from a file, pre-emphasises, and sends to output file. -*/ - -#include -#include -#include -#include -#include -#include -#include "lpc.h" - -#define N 80 - -int main(int argc, char*argv[]) { - FILE *fin, *fout; - short buf[N]; - float Sn[N], Sn_pre[N]; - float pre_mem = 0.0; - int i; - - if (argc != 3) { - printf("usage: pre InputRawSpeechFile OutputRawSpeechFile\n"); - printf("e.g pre input.raw output.raw"); - exit(1); - } - - if (strcmp(argv[1], "-") == 0) fin = stdin; - else if ( (fin = fopen(argv[1],"rb")) == NULL ) { - fprintf(stderr, "Error opening input speech file: %s: %s.\n", - argv[1], strerror(errno)); - exit(1); - } - - if (strcmp(argv[2], "-") == 0) fout = stdout; - else if ( (fout = fopen(argv[2],"wb")) == NULL ) { - fprintf(stderr, "Error opening output speech file: %s: %s.\n", - argv[2], strerror(errno)); - exit(1); - } - - while(fread(buf, sizeof(short), N, fin) == N) { - for(i=0; i -#include -#include -#include - -int main(int argc, char *argv[]) { - FILE *fraw, *fheader; - int i, samples, ret; - short sam; - - if (argc != 5) { - printf("usage: %s inputRawFile outputHeaderFile arrayName samples\n", argv[0]); - exit(1); - } - - fraw = fopen(argv[1] ,"rb"); - assert(fraw != NULL); - fheader = fopen(argv[2],"wt"); - assert(fheader != NULL); - samples = atoi(argv[4]); - - fprintf(fheader, "short %s[] = {\n", argv[3]); - for(i=0; i. -*/ - -#include -#include -#include - -#include "defines.h" -#include "quantise.h" - -/*---------------------------------------------------------------------------*\ - - MAIN - -\*---------------------------------------------------------------------------*/ - -int main(int argc, char *argv[]) -{ - FILE *ftrain; /* LSP training data text file */ - float lsp[LPC_ORD]; /* LSP input vector in rads */ - float lsp_hz[LPC_ORD]; /* LSP input vector in Hz */ - int vectors; /* number LSP vectors processed */ - int k,m; /* LSP vector order and codebook size */ - int index; - float wt[1]; /* weighting (not used here for scalars) */ - const float *cb; /* LSP quantiser codebook */ - int i, ret; - float total_se; - - if (argc < 2) { - printf("usage: %s InputFile\n", argv[0]); - exit(1); - } - - if ((ftrain = fopen(argv[1],"rt")) == NULL) { - printf("Error opening input file: %s\n",argv[1]); - exit(0); - } - - total_se = 0.0; - vectors = 0; - wt[0] = 1.0; - - /* Main loop */ - - while(!feof(ftrain)) { - - /* Read LSP input vector speech */ - - for (i=0; i. -*/ - -#define MAX_N 2048 /* maximum DFT size */ - -#include -#include "four1.h" -#include "comp.h" -#include "sd.h" - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: spectral_dist() - - AUTHOR......: David Rowe - DATE CREATED: 20/7/93 - - This function returns the soectral distoertion between two - sets of LPCs. - -\*---------------------------------------------------------------------------*/ - -float spectral_dist(float ak1[], float ak2[], int p, int n) -/* float ak1[]; unquantised set of p+1 LPCs */ -/* float ak2[]; quantised set of p+1 LPCs */ -/* int p; LP order */ -/* int n; DFT size to use for SD calculations (power of 2) */ -{ - COMP A1[MAX_N]; /* DFT of ak1[] */ - COMP A2[MAX_N]; /* DFT of ak2[] */ - float P1,P2; /* power of current bin */ - float sd; - int i; - - for(i=0; i. -*/ - -#ifndef __SD__ -#define __SD__ - -float spectral_dist(float ak1[], float ak2[], int p, int n); - -#endif /* __SD__ */ diff --git a/codec2/unittest/speexlsptest.c b/codec2/unittest/speexlsptest.c deleted file mode 100644 index 3350894a..00000000 --- a/codec2/unittest/speexlsptest.c +++ /dev/null @@ -1,176 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: speexlsptest.c - AUTHOR......: David Rowe - DATE CREATED: 24/8/09 - - Test LPC to LSP conversion and quantisation using Speex LSP quantiser. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2009 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include -#include -#include - -#define N 160 -#define P 10 - -#define LPC_FLOOR 0.0002 /* autocorrelation floor */ -#define LSP_DELTA1 0.2 /* grid spacing for LSP root searches */ -#define NDFT 256 /* DFT size for SD calculation */ - -/* Speex lag window */ - -const float lag_window[11] = { - 1.00000, 0.99716, 0.98869, 0.97474, 0.95554, 0.93140, 0.90273, 0.86998, - 0.83367, 0.79434, 0.75258 -}; - -/*---------------------------------------------------------------------------*\ - - find_aks_for_lsp() - - This function takes a frame of samples, and determines the linear - prediction coefficients for that frame of samples. Modified version of - find_aks from lpc.c to include autocorrelation noise floor and lag window - to match Speex processing steps prior to LSP conversion. - -\*---------------------------------------------------------------------------*/ - -void find_aks_for_lsp( - float Sn[], /* Nsam samples with order sample memory */ - float a[], /* order+1 LPCs with first coeff 1.0 */ - int Nsam, /* number of input speech samples */ - int order, /* order of the LPC analysis */ - float *E /* residual energy */ -) -{ - float Wn[N]; /* windowed frame of Nsam speech samples */ - float R[P+1]; /* order+1 autocorrelation values of Sn[] */ - int i; - - hanning_window(Sn,Wn,Nsam); - - autocorrelate(Wn,R,Nsam,order); - R[0] += LPC_FLOOR; - assert(order == 10); /* lag window only defined for order == 10 */ - for(i=0; i<=order; i++) - R[i] *= lag_window[i]; - levinson_durbin(R,a,order); - - *E = 0.0; - for(i=0; i<=order; i++) - *E += a[i]*R[i]; - if (*E < 0.0) - *E = 1E-12; -} - -/*---------------------------------------------------------------------------*\ - - MAIN - -\*---------------------------------------------------------------------------*/ - -int main(int argc, char *argv[]) -{ - FILE *fin; /* input speech files */ - short buf[N]; /* buffer of 16 bit speech samples */ - float Sn[P+N]; /* input speech samples */ - float E; - float ak[P+1]; /* LP coeffs */ - float ak_[P+1]; /* quantised LP coeffs */ - float lsp[P]; - float lsp_[P]; /* quantised LSPs */ - int roots; /* number of LSP roots found */ - int frames; /* frames processed so far */ - int i; /* loop variables */ - - SpeexBits bits; - - float sd; /* SD for this frame */ - float totsd; /* accumulated SD so far */ - int gt2,gt4; /* number of frames > 2 and 4 dB SD */ - int unstables; /* number of unstable LSP frames */ - - if (argc < 2) { - printf("usage: %s InputFile\n", argv[0]); - exit(0); - } - - /* Open files */ - - if ((fin = fopen(argv[1],"rb")) == NULL) { - printf("Error opening input file: %s\n",argv[1]); - exit(0); - } - - /* Initialise */ - - frames = 0; - for(i=0; i 2.0) gt2++; - if (sd > 4.0) gt4++; - totsd += sd; - } - else - unstables++; - } - - fclose(fin); - - printf("frames = %d Av sd = %3.2f dB", frames, totsd/frames); - printf(" >2 dB %3.2f%% >4 dB %3.2f%% unstables: %d\n",gt2*100.0/frames, - gt4*100.0/frames, unstables); - - return 0; -} - diff --git a/codec2/unittest/t48_8.c b/codec2/unittest/t48_8.c deleted file mode 100644 index 61a1bfa2..00000000 --- a/codec2/unittest/t48_8.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - t48_8.c - David Rowe - May 10 2012 - - Unit test for 48 to 8 kHz sample rate conversion functions. I - evaluated output by plotting using Octave and looking for jaggies: - - pl("../unittest/out48.raw",1,3000) - pl("../unittest/out8.raw",1,3000) - - Listening to it also shows up anything nasty: - - $ play -s -2 -r 48000 out48.raw - $ play -s -2 -r 8000 out8.raw - - */ - -#include -#include -#include -#include -#include "codec2_fdmdv.h" - -#define N8 160 /* procssing buffer size at 8 kHz */ -#define N48 (N8*FDMDV_OS) -#define MEM8 (FDMDV_OS_TAPS/FDMDV_OS) -#define FRAMES 50 -#define TWO_PI 6.283185307 -#define FS 8000 - -#define SINE - -int main() { - float in8k[MEM8 + N8]; - float out48k[N48]; - short out48k_short[N48]; - FILE *f48; - - float in48k[FDMDV_OS_TAPS + N48]; - float out8k[N48]; - short out8k_short[N8]; - FILE *f8; - - int i,f,t,t1; - float freq = 800.0; - - f48 = fopen("out48.raw", "wb"); - assert(f48 != NULL); - f8 = fopen("out8.raw", "wb"); - assert(f8 != NULL); - - /* clear filter memories */ - - for(i=0; i. -*/ - -#include -#include -#include -#include -#include -#include "defines.h" -#include "comp.h" -#include "codec2.h" -#include "quantise.h" -#include "interp.h" - -/* CODEC2 struct copies from codec2.c to help with testing */ - -struct CODEC2 { - int mode; - float w[M]; /* time domain hamming window */ - COMP W[FFT_ENC]; /* DFT of w[] */ - float Pn[2*N]; /* trapezoidal synthesis window */ - float Sn[M]; /* input speech */ - float hpf_states[2]; /* high pass filter states */ - void *nlp; /* pitch predictor states */ - float Sn_[2*N]; /* synthesised output speech */ - float ex_phase; /* excitation model phase track */ - float bg_est; /* background noise estimate for post filter */ - float prev_Wo; /* previous frame's pitch estimate */ - MODEL prev_model; /* previous frame's model parameters */ - float prev_lsps_[LPC_ORD]; /* previous frame's LSPs */ - float prev_energy; /* previous frame's LPC energy */ -}; - -void analyse_one_frame(struct CODEC2 *c2, MODEL *model, short speech[]); -void synthesise_one_frame(struct CODEC2 *c2, short speech[], MODEL *model, float ak[]); - -int test1() -{ - FILE *fin, *fout; - short buf[N]; - struct CODEC2 *c2; - MODEL model; - float ak[LPC_ORD+1]; - float lsps[LPC_ORD]; - - c2 = codec2_create(CODEC2_MODE_2400); - - fin = fopen("../raw/hts1a.raw", "rb"); - assert(fin != NULL); - fout = fopen("hts1a_test.raw", "wb"); - assert(fout != NULL); - - while(fread(buf, sizeof(short), N, fin) == N) { - analyse_one_frame(c2, &model, buf); - speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); - synthesise_one_frame(c2, buf, &model, ak); - fwrite(buf, sizeof(short), N, fout); - } - - codec2_destroy(c2); - - fclose(fin); - fclose(fout); - - return 0; -} - -int test2() -{ - FILE *fin, *fout; - short buf[2*N]; - struct CODEC2 *c2; - MODEL model, model_interp; - float ak[LPC_ORD+1]; - int voiced1, voiced2; - int lsp_indexes[LPC_ORD]; - int energy_index; - int Wo_index; - char *bits; - int nbit; - int i; - float lsps[LPC_ORD]; - float e; - - c2 = codec2_create(CODEC2_MODE_2400); - bits = (char*)malloc(codec2_bits_per_frame(c2)); - assert(bits != NULL); - fin = fopen("../raw/hts1a.raw", "rb"); - assert(fin != NULL); - fout = fopen("hts1a_test.raw", "wb"); - assert(fout != NULL); - - while(fread(buf, sizeof(short), 2*N, fin) == 2*N) { - /* first 10ms analysis frame - we just want voicing */ - - analyse_one_frame(c2, &model, buf); - voiced1 = model.voiced; - - /* second 10ms analysis frame */ - - analyse_one_frame(c2, &model, &buf[N]); - voiced2 = model.voiced; - - Wo_index = encode_Wo(model.Wo); - e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); - encode_lsps_scalar(lsp_indexes, lsps, LPC_ORD); - energy_index = encode_energy(e); - nbit = 0; - pack((unsigned char*)bits, (unsigned *)&nbit, Wo_index, WO_BITS); - for(i=0; iprev_model, &model); - - synthesise_one_frame(c2, buf, &model_interp, ak); - synthesise_one_frame(c2, &buf[N], &model, ak); - - memcpy(&c2->prev_model, &model, sizeof(MODEL)); - fwrite(buf, sizeof(short), 2*N, fout); - } - - free(bits); - codec2_destroy(c2); - - fclose(fin); - fclose(fout); - - return 0; -} - -int test3() -{ - FILE *fin, *fout, *fbits; - short buf1[2*N]; - short buf2[2*N]; - char *bits; - struct CODEC2 *c2; - - c2 = codec2_create(CODEC2_MODE_2400); - int numBits = codec2_bits_per_frame(c2); - int numBytes = (numBits+7)>>3; - - bits = (char*)malloc(numBytes); - - fin = fopen("../raw/hts1a.raw", "rb"); - assert(fin != NULL); - fout = fopen("hts1a_test.raw", "wb"); - assert(fout != NULL); - fbits = fopen("hts1a_test3.bit", "wb"); - assert(fout != NULL); - - while(fread(buf1, sizeof(short), 2*N, fin) == 2*N) { - codec2_encode(c2, (void*)bits, buf1); - fwrite(bits, sizeof(char), numBytes, fbits); - codec2_decode(c2, buf2, (void*)bits); - fwrite(buf2, sizeof(short), numBytes, fout); - } - - free(bits); - codec2_destroy(c2); - - fclose(fin); - fclose(fout); - fclose(fbits); - - return 0; -} - -int main() { - test3(); - return 0; -} diff --git a/codec2/unittest/tcontphase.c b/codec2/unittest/tcontphase.c deleted file mode 100644 index 6761bac8..00000000 --- a/codec2/unittest/tcontphase.c +++ /dev/null @@ -1,186 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: tcontphase.c - AUTHOR......: David Rowe - DATE CREATED: 11/9/09 - - Test program for developing continuous phase track synthesis algorithm. - However while developing this it was discovered that synthesis_mixed() - worked just as well. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2009 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#define N 80 /* frame size */ -#define F 160 /* frames to synthesis */ -#define P 10 /* LPC order */ - -#include -#include -#include -#include -#include "sine.h" -#include "dump.h" -#include "synth.h" -#include "phase.h" - -int frames; - -float ak[] = { - 1.000000, --1.455836, - 1.361841, --0.879267, - 0.915985, --1.002202, - 0.944103, --0.743094, - 1.053356, --0.817491, - 0.431222 -}; - - -/*---------------------------------------------------------------------------*\ - - switch_present() - - Searches the command line arguments for a "switch". If the switch is - found, returns the command line argument where it ws found, else returns - NULL. - -\*---------------------------------------------------------------------------*/ - -int switch_present(sw,argc,argv) - char sw[]; /* switch in string form */ - int argc; /* number of command line arguments */ - char *argv[]; /* array of command line arguments in string form */ -{ - int i; /* loop variable */ - - for(i=1; i. -*/ - -#include -#include -#include -#include -#include - -#include "fdmdv_internal.h" -#include "codec2_fdmdv.h" -#include "octave.h" - -#define FRAMES 25 -#define CHANNEL_BUF_SIZE (10*M) - -extern float pilot_coeff[]; - -int main(int argc, char *argv[]) -{ - struct FDMDV *fdmdv; - int tx_bits[FDMDV_BITS_PER_FRAME]; - COMP tx_symbols[FDMDV_NC+1]; - COMP tx_baseband[NC+1][M]; - COMP tx_fdm[M]; - float channel[CHANNEL_BUF_SIZE]; - int channel_count; - COMP rx_fdm[M+M/P]; - float foff_coarse; - int nin, next_nin; - COMP rx_fdm_fcorr[M+M/P]; - COMP rx_baseband[NC+1][M+M/P]; - COMP rx_filt[NC+1][P+1]; - float rx_timing; - float env[NT*P]; - COMP rx_symbols[FDMDV_NC+1]; - int rx_bits[FDMDV_BITS_PER_FRAME]; - float foff_fine; - int sync_bit, reliable_sync_bit; - - int tx_bits_log[FDMDV_BITS_PER_FRAME*FRAMES]; - COMP tx_symbols_log[(FDMDV_NC+1)*FRAMES]; - COMP tx_baseband_log[(NC+1)][M*FRAMES]; - COMP tx_fdm_log[M*FRAMES]; - COMP pilot_baseband1_log[NPILOTBASEBAND*FRAMES]; - COMP pilot_baseband2_log[NPILOTBASEBAND*FRAMES]; - COMP pilot_lpf1_log[NPILOTLPF*FRAMES]; - COMP pilot_lpf2_log[NPILOTLPF*FRAMES]; - COMP S1_log[MPILOTFFT*FRAMES]; - COMP S2_log[MPILOTFFT*FRAMES]; - float foff_coarse_log[FRAMES]; - float foff_log[FRAMES]; - COMP rx_baseband_log[(NC+1)][(M+M/P)*FRAMES]; - int rx_baseband_log_col_index; - COMP rx_filt_log[NC+1][(P+1)*FRAMES]; - int rx_filt_log_col_index; - float env_log[NT*P*FRAMES]; - float rx_timing_log[FRAMES]; - COMP rx_symbols_log[FDMDV_NC+1][FRAMES]; - COMP phase_difference_log[FDMDV_NC+1][FRAMES]; - float sig_est_log[FDMDV_NC+1][FRAMES]; - float noise_est_log[FDMDV_NC+1][FRAMES]; - int rx_bits_log[FDMDV_BITS_PER_FRAME*FRAMES]; - float foff_fine_log[FRAMES]; - int sync_bit_log[FRAMES]; - int sync_log[FRAMES]; - int nin_log[FRAMES]; - - FILE *fout; - int f,c,i,j; - - fdmdv = fdmdv_create(FDMDV_NC); - next_nin = M; - channel_count = 0; - - rx_baseband_log_col_index = 0; - rx_filt_log_col_index = 0; - - printf("sizeof FDMDV states: %d bytes\n", sizeof(struct FDMDV)); - - for(f=0; fprev_tx_symbols, tx_bits, &fdmdv->tx_pilot_bit, 0); - memcpy(fdmdv->prev_tx_symbols, tx_symbols, sizeof(COMP)*(FDMDV_NC+1)); - tx_filter(tx_baseband, FDMDV_NC, tx_symbols, fdmdv->tx_filter_memory); - fdm_upconvert(tx_fdm, FDMDV_NC, tx_baseband, fdmdv->phase_tx, fdmdv->freq); - - /* --------------------------------------------------------*\ - Channel - \*---------------------------------------------------------*/ - - nin = next_nin; - /* - if (f == 2) - nin = 120; - if (f == 3) - nin = 200; - if ((f !=2) && (f != 3)) - nin = M; - */ - nin = M; - /* add M tx samples to end of buffer */ - - assert((channel_count + M) < CHANNEL_BUF_SIZE); - for(i=0; isync = 0; - if (fdmdv->sync == 0) - fdmdv->foff = foff_coarse; - fdmdv_freq_shift(rx_fdm_fcorr, rx_fdm, foff_coarse, &fdmdv->foff_phase_rect, nin); - - /* baseband processing */ - - fdm_downconvert(rx_baseband, FDMDV_NC, rx_fdm_fcorr, fdmdv->phase_rx, fdmdv->freq, nin); - rx_filter(rx_filt, FDMDV_NC, rx_baseband, fdmdv->rx_filter_memory, nin); - rx_timing = rx_est_timing(rx_symbols, FDMDV_NC, rx_filt, rx_baseband, fdmdv->rx_filter_mem_timing, env, fdmdv->rx_baseband_mem_timing, nin); - foff_fine = qpsk_to_bits(rx_bits, &sync_bit, FDMDV_NC, fdmdv->phase_difference, fdmdv->prev_rx_symbols, rx_symbols, 0); - //for(i=0; iprev_rx_symbols[i].real, fdmdv->prev_rx_symbols[i].imag, fdmdv->phase_difference[i].real, fdmdv->phase_difference[i].imag); - //if (f==1) - // exit(0); - snr_update(fdmdv->sig_est, fdmdv->noise_est, FDMDV_NC, fdmdv->phase_difference); - memcpy(fdmdv->prev_rx_symbols, rx_symbols, sizeof(COMP)*(FDMDV_NC+1)); - - next_nin = M; - - if (rx_timing > 2*M/P) - next_nin += M/P; - - if (rx_timing < 0) - next_nin -= M/P; - - fdmdv->sync = freq_state(&reliable_sync_bit, sync_bit, &fdmdv->fest_state, &fdmdv->timer, fdmdv->sync_mem); - fdmdv->foff -= TRACK_COEFF*foff_fine; - - /* --------------------------------------------------------*\ - Log each vector - \*---------------------------------------------------------*/ - - memcpy(&tx_bits_log[FDMDV_BITS_PER_FRAME*f], tx_bits, sizeof(int)*FDMDV_BITS_PER_FRAME); - memcpy(&tx_symbols_log[(FDMDV_NC+1)*f], tx_symbols, sizeof(COMP)*(FDMDV_NC+1)); - for(c=0; cpilot_baseband1, sizeof(COMP)*NPILOTBASEBAND); - memcpy(&pilot_baseband2_log[f*NPILOTBASEBAND], fdmdv->pilot_baseband2, sizeof(COMP)*NPILOTBASEBAND); - memcpy(&pilot_lpf1_log[f*NPILOTLPF], fdmdv->pilot_lpf1, sizeof(COMP)*NPILOTLPF); - memcpy(&pilot_lpf2_log[f*NPILOTLPF], fdmdv->pilot_lpf2, sizeof(COMP)*NPILOTLPF); - memcpy(&S1_log[f*MPILOTFFT], fdmdv->S1, sizeof(COMP)*MPILOTFFT); - memcpy(&S2_log[f*MPILOTFFT], fdmdv->S2, sizeof(COMP)*MPILOTFFT); - foff_coarse_log[f] = foff_coarse; - foff_log[f] = fdmdv->foff; - - /* rx down conversion */ - - for(c=0; cphase_difference[c]; - } - - /* qpsk_to_bits() */ - - memcpy(&rx_bits_log[FDMDV_BITS_PER_FRAME*f], rx_bits, sizeof(int)*FDMDV_BITS_PER_FRAME); - for(c=0; csig_est[c]; - noise_est_log[c][f] = fdmdv->noise_est[c]; - } - foff_fine_log[f] = foff_fine; - sync_bit_log[f] = sync_bit; - - sync_log[f] = fdmdv->sync; - } - - - /*---------------------------------------------------------*\ - Dump logs to Octave file for evaluation - by tfdmdv.m Octave script - \*---------------------------------------------------------*/ - - fout = fopen("tfdmdv_out.txt","wt"); - assert(fout != NULL); - fprintf(fout, "# Created by tfdmdv.c\n"); - octave_save_int(fout, "tx_bits_log_c", tx_bits_log, 1, FDMDV_BITS_PER_FRAME*FRAMES); - octave_save_complex(fout, "tx_symbols_log_c", tx_symbols_log, 1, (FDMDV_NC+1)*FRAMES, (FDMDV_NC+1)*FRAMES); - octave_save_complex(fout, "tx_baseband_log_c", (COMP*)tx_baseband_log, (FDMDV_NC+1), M*FRAMES, M*FRAMES); - octave_save_complex(fout, "tx_fdm_log_c", (COMP*)tx_fdm_log, 1, M*FRAMES, M*FRAMES); - octave_save_complex(fout, "pilot_lut_c", (COMP*)fdmdv->pilot_lut, 1, NPILOT_LUT, NPILOT_LUT); - octave_save_complex(fout, "pilot_baseband1_log_c", pilot_baseband1_log, 1, NPILOTBASEBAND*FRAMES, NPILOTBASEBAND*FRAMES); - octave_save_complex(fout, "pilot_baseband2_log_c", pilot_baseband2_log, 1, NPILOTBASEBAND*FRAMES, NPILOTBASEBAND*FRAMES); - octave_save_float(fout, "pilot_coeff_c", pilot_coeff, 1, NPILOTCOEFF, NPILOTCOEFF); - octave_save_complex(fout, "pilot_lpf1_log_c", pilot_lpf1_log, 1, NPILOTLPF*FRAMES, NPILOTLPF*FRAMES); - octave_save_complex(fout, "pilot_lpf2_log_c", pilot_lpf2_log, 1, NPILOTLPF*FRAMES, NPILOTLPF*FRAMES); - octave_save_complex(fout, "S1_log_c", S1_log, 1, MPILOTFFT*FRAMES, MPILOTFFT*FRAMES); - octave_save_complex(fout, "S2_log_c", S2_log, 1, MPILOTFFT*FRAMES, MPILOTFFT*FRAMES); - octave_save_float(fout, "foff_log_c", foff_log, 1, FRAMES, FRAMES); - octave_save_float(fout, "foff_coarse_log_c", foff_coarse_log, 1, FRAMES, FRAMES); - octave_save_complex(fout, "rx_baseband_log_c", (COMP*)rx_baseband_log, (FDMDV_NC+1), rx_baseband_log_col_index, (M+M/P)*FRAMES); - octave_save_complex(fout, "rx_filt_log_c", (COMP*)rx_filt_log, (FDMDV_NC+1), rx_filt_log_col_index, (P+1)*FRAMES); - octave_save_float(fout, "env_log_c", env_log, 1, NT*P*FRAMES, NT*P*FRAMES); - octave_save_float(fout, "rx_timing_log_c", rx_timing_log, 1, FRAMES, FRAMES); - octave_save_complex(fout, "rx_symbols_log_c", (COMP*)rx_symbols_log, (FDMDV_NC+1), FRAMES, FRAMES); - octave_save_complex(fout, "phase_difference_log_c", (COMP*)phase_difference_log, (FDMDV_NC+1), FRAMES, FRAMES); - octave_save_float(fout, "sig_est_log_c", (float*)sig_est_log, (FDMDV_NC+1), FRAMES, FRAMES); - octave_save_float(fout, "noise_est_log_c", (float*)noise_est_log, (FDMDV_NC+1), FRAMES, FRAMES); - octave_save_int(fout, "rx_bits_log_c", rx_bits_log, 1, FDMDV_BITS_PER_FRAME*FRAMES); - octave_save_float(fout, "foff_fine_log_c", foff_fine_log, 1, FRAMES, FRAMES); - octave_save_int(fout, "sync_bit_log_c", sync_bit_log, 1, FRAMES); - octave_save_int(fout, "sync_log_c", sync_log, 1, FRAMES); - octave_save_int(fout, "nin_log_c", nin_log, 1, FRAMES); - fclose(fout); - - fdmdv_destroy(fdmdv); - - return 0; -} - diff --git a/codec2/unittest/tfifo.c b/codec2/unittest/tfifo.c deleted file mode 100644 index 12e0d2b6..00000000 --- a/codec2/unittest/tfifo.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - tfifo.c - David Rowe - Nov 19 2012 - - Takes FIFOs, in particular thread safety. -*/ - -#include -#include -#include -#include "codec2_fifo.h" - -#define FIFO_SZ 1024 -#define WRITE_SZ 10 -#define READ_SZ 8 -#define N_MAX 100 -#define LOOPS 1000000 - -int run_thread = 1; -struct FIFO *f; - -void writer(void); -void *writer_thread(void *data); -pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - -#define USE_THREADS -//#define USE_MUTEX - -int main() { - pthread_t awriter_thread; - int i,j; - short read_buf[READ_SZ]; - int n_out = 0; - int sucess; - - f = fifo_create(FIFO_SZ); - #ifdef USE_THREADS - pthread_create(&awriter_thread, NULL, writer_thread, NULL); - #endif - - for(i=0; i WRITE_SZ) { - for(i=0; i. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "defines.h" -#include "sine.h" -#include "interp.h" - -void make_amp(MODEL *model, float f0, float cdB, float mdBHz) -{ - int i; - float mdBrad = mdBHz*FS/TWO_PI; - - model->Wo = f0*TWO_PI/FS; - model->L = PI/model->Wo; - for(i=0; i<=model->L; i++) - model->A[i] = pow(10.0,(cdB + (float)i*model->Wo*mdBrad)/20.0); - model->voiced = 1; -} - -void write_amp(char file[], MODEL *model) -{ - FILE *f; - int i; - - f = fopen(file,"wt"); - for(i=1; i<=model->L; i++) - fprintf(f, "%f\t%f\n", model->Wo*i, model->A[i]); - fclose(f); -} - -const char *get_next_float(const char *s, float *num) -{ - const char *p = s; - char tmp[MAX_STR]; - - while(*p && !isspace(*p)) - p++; - assert((p-s) < (int)(sizeof(tmp)-1)); - memcpy(tmp, s, p-s); - tmp[p-s] = 0; - *num = atof(tmp); - - return p+1; -} - -const char *get_next_int(const char *s, int *num) -{ - const char *p = s; - char tmp[MAX_STR]; - - while(*p && !isspace(*p)) - p++; - assert((p-s) < (int)(sizeof(tmp)-1)); - memcpy(tmp, s, p-s); - tmp[p-s] = 0; - *num = atoi(tmp); - - return p+1; -} - -void load_amp(MODEL *model, const char * file, int frame) -{ - FILE *f; - int i; - char s[1024]; - const char *ps; - - f = fopen(file,"rt"); - assert(f); - - for(i=0; iWo); - ps = get_next_int(ps, &model->L); - for(i=1; i<=model->L; i++) - ps = get_next_float(ps, &model->A[i]); - - fclose(f); -} - -void load_or_make_amp(MODEL *model, - const char * filename, int frame, - float f0, float cdB, float mdBHz) -{ - struct stat buf; - int rc = stat(filename, &buf); - if (rc || !S_ISREG(buf.st_mode) || ((buf.st_mode & S_IRUSR) != S_IRUSR)) - { - make_amp(model, f0, cdB, mdBHz); - } - else - { - load_amp(model, filename, frame); - } -} -int main() { - MODEL prev, next, interp; - - load_or_make_amp(&prev, - "../src/hts1a_model.txt", 32, - 50.0, 60.0, 6E-3); - load_or_make_amp(&next, - "../src/hts1a_model.txt", 34, - 50.0, 40.0, 6E-3); - - interp.voiced = 1; - interpolate(&interp, &prev, &next); - - write_amp("tinterp_prev.txt", &prev); - write_amp("tinterp_interp.txt", &interp); - write_amp("tinterp_next.txt", &next); - - return 0; -} diff --git a/codec2/unittest/tlspsens.c b/codec2/unittest/tlspsens.c deleted file mode 100644 index a53a66cd..00000000 --- a/codec2/unittest/tlspsens.c +++ /dev/null @@ -1,127 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: tlspsens.c - AUTHOR......: David Rowe - DATE CREATED: 31 May 2012 - - Testing bit error sensitivity of LSP bits, first step in devising an unequal - error protection scheme. - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2012 David Rowe - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - -#include -#include -#include -#include -#include -#include "defines.h" -#include "comp.h" -#include "codec2.h" -#include "quantise.h" -#include "interp.h" -#include "codec2_internal.h" - -float run_a_test(char raw_file_name[], int bit_to_corrupt) -{ - FILE *fin; - short buf[N]; - struct CODEC2 *c2; - kiss_fft_cfg fft_fwd_cfg; - MODEL model; - float ak[LPC_ORD+1]; - float lsps[LPC_ORD], e; - int lsp_indexes[LPC_ORD], found_bit; - float snr, snr_sum; - int frames, i, mask, index; - - c2 = codec2_create(CODEC2_MODE_2400); - fft_fwd_cfg = kiss_fft_alloc(FFT_ENC, 0, NULL, NULL); - - fin = fopen(raw_file_name, "rb"); - assert(fin != NULL); - - /* find bit we are corrupting */ - - found_bit = 0; - for(i=0; i lsp_bits(i)) - bit_to_corrupt -= lsp_bits(i); - else { - index = i; - mask = (1 << bit_to_corrupt); - printf(" index: %d bit: %d mask: 0x%x ", index, bit_to_corrupt, mask); - found_bit = 1; - } - } - } - assert(found_bit == 1); - - /* OK test a sample file, flipping bit */ - - snr_sum = 0.0; - frames = 0; - while(fread(buf, sizeof(short), N, fin) == N) { - analyse_one_frame(c2, &model, buf); - e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD); - encode_lsps_scalar(lsp_indexes, lsps, LPC_ORD); - - /* find and flip bit we are testing */ - - lsp_indexes[index] ^= mask; - - /* decode LSPs and measure SNR */ - - decode_lsps_scalar(lsps, lsp_indexes, LPC_ORD); - check_lsp_order(lsps, LPC_ORD); - bw_expand_lsps(lsps, LPC_ORD, 50.0, 100.0); - lsp_to_lpc(lsps, ak, LPC_ORD); - aks_to_M2(fft_fwd_cfg, ak, LPC_ORD, &model, e, &snr, 0, 0, 1, 1, LPCPF_BETA, LPCPF_GAMMA); - snr_sum += snr; - frames++; - } - - codec2_destroy(c2); - - fclose(fin); - - return snr_sum/frames; -} - -int main(int argc, char *argv[]) { - int i; - int total_lsp_bits = 0; - float snr; - - if (argc != 2) { - printf("usage: %s RawFile\n", argv[0]); - exit(1); - } - - for(i=0; i. -*/ - -#define N 80 /* frame size */ -#define M 320 /* pitch analysis window size */ -#define PITCH_MIN 20 -#define PITCH_MAX 160 -#define TNLP - -#include -#include -#include -#include - -#include "defines.h" -#include "dump.h" -#include "sine.h" -#include "nlp.h" -#include "kiss_fft.h" - -int frames; - -/*---------------------------------------------------------------------------*\ - - switch_present() - - Searches the command line arguments for a "switch". If the switch is - found, returns the command line argument where it ws found, else returns - NULL. - -\*---------------------------------------------------------------------------*/ - -int switch_present(sw,argc,argv) - char sw[]; /* switch in string form */ - int argc; /* number of command line arguments */ - char *argv[]; /* array of command line arguments in string form */ -{ - int i; /* loop variable */ - - for(i=1; i -#include -#include -#include -#include "lpc.h" - -#define N 10 -#define F 10 - -int main() { - FILE *fprede; - float Sn[N], Sn_pre[N], Sn_de[N]; - float pre_mem = 0.0, de_mem = 0.0; - int i, f; - - fprede = fopen("prede.txt", "wt"); - assert(fprede != NULL); - - for(i=0; i. -*/ - -#include -#include -#include -#include -#include - -#include "defines.h" -#include "dump.h" -#include "quantise.h" - -int test_Wo_quant(); -int test_lsp_quant(); -int test_lsp(int lsp_number, int levels, float max_error_hz); -int test_energy_quant(int levels, float max_error_dB); - -int main() { - quantise_init(); - test_Wo_quant(); - test_lsp_quant(); - test_energy_quant(E_LEVELS, 0.5*(E_MAX_DB - E_MIN_DB)/E_LEVELS); - - return 0; -} - -int test_lsp_quant() { - test_lsp( 1, 16, 12.5); - test_lsp( 2, 16, 12.5); - test_lsp( 3, 16, 25); - test_lsp( 4, 16, 50); - test_lsp( 5, 16, 50); - test_lsp( 6, 16, 50); - test_lsp( 7, 16, 50); - test_lsp( 8, 8, 50); - test_lsp( 9, 8, 50); - test_lsp(10, 4, 100); - - return 0; -} - -int test_energy_quant(int levels, float max_error_dB) { - FILE *fe; - float e,e_dec, error, low_e, high_e; - int index, index_in, index_out, i; - - /* check 1:1 match between input and output levels */ - - for(i=0; i max_error_dB) { - printf("error: %f %f\n", error, max_error_dB); - exit(0); - } - } - - fclose(fe); - return 0; -} - -int test_lsp(int lsp_number, int levels, float max_error_hz) { - float lsp[LPC_ORD]; - int indexes_in[LPC_ORD]; - int indexes_out[LPC_ORD]; - int indexes[LPC_ORD]; - int i; - float lowf, highf, f, error; - char s[MAX_STR]; - FILE *flsp; - float max_error_rads; - - lsp_number--; - max_error_rads = max_error_hz*TWO_PI/FS; - - for(i=0; i max_error_rads) { - printf("%d error: %f %f\n", lsp_number+1, error, max_error_rads); - exit(0); - } - } - - fclose(flsp); - - printf("OK\n"); - - return 0; -} - -int test_Wo_quant() { - int c; - FILE *f; - float Wo,Wo_dec, error, step_size; - int index, index_in, index_out; - - /* output Wo quant curve for plotting */ - - f = fopen("quant_pitch.txt","wt"); - - for(Wo=0.9*(TWO_PI/P_MAX); Wo<=1.1*(TWO_PI/P_MIN); Wo += 0.001) { - index = encode_Wo(Wo); - fprintf(f, "%f %d\n", Wo, index); - } - - fclose(f); - - /* check for all Wo codes we get 1:1 match between encoder - and decoder Wo levels */ - - for(c=0; c (step_size/2.0)) { - printf("error: %f step_size/2: %f\n", error, step_size/2.0); - exit(0); - } - fprintf(f,"%f\n",error); - } - printf("OK\n"); - - fclose(f); - return 0; -} diff --git a/codec2/unittest/tsrc.c b/codec2/unittest/tsrc.c deleted file mode 100644 index 0c2c604a..00000000 --- a/codec2/unittest/tsrc.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - tsrc.c - David Rowe - Sat Nov 3 2012 - - Unit test for libresample code. - - */ - -#include -#include -#include -#include -#include - -#define N8 160 /* processing buffer size at 8 kHz */ -#define N48 ((int)N8*(48000/8000)) /* buf size assuming 48k max sample rate */ - -int main(int argc, char *argv[]) { - FILE *f8k, *fout; - short in8k_short[N8]; - float in8k[N8]; - float out[N48]; - short out_short[N48]; - SRC_STATE *src; - SRC_DATA data; - int error; - - if (argc != 4) { - printf("usage %s inputRawFile OutputRawFile OutputSamplerate\n", argv[0]); - exit(0); - } - - f8k = fopen(argv[1], "rb"); - assert(f8k != NULL); - - fout = fopen(argv[2], "wb"); - assert(fout != NULL); - - src = src_new(SRC_SINC_FASTEST, 1, &error); - assert(src != NULL); - - data.data_in = in8k; - data.data_out = out; - data.input_frames = N8; - data.output_frames = N48; - data.end_of_input = 0; - data.src_ratio = atof(argv[3])/8000; - printf("%f\n", data.src_ratio); - - while(fread(in8k_short, sizeof(short), N8, f8k) == N8) { - src_short_to_float_array(in8k_short, in8k, N8); - src_process(src, &data); - printf("%d %d\n", (int)data.output_frames , (int)data.output_frames_gen); - assert(data.output_frames_gen <= N48); - src_float_to_short_array(out, out_short, data.output_frames_gen); - fwrite(out_short, sizeof(short), data.output_frames_gen, fout); - } - - fclose(fout); - fclose(f8k); - - return 0; -} diff --git a/codec2/unittest/vq_train_jvm.c b/codec2/unittest/vq_train_jvm.c deleted file mode 100755 index 9da091e0..00000000 --- a/codec2/unittest/vq_train_jvm.c +++ /dev/null @@ -1,486 +0,0 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: vq_train_jvm.c - AUTHOR......: Jean-Marc Valin - DATE CREATED: 21 Jan 2012 - - Multi-stage Vector Quantoser training program developed by Jean-Marc at - linux.conf.au 2012. Minor mods by David Rowe - -\*---------------------------------------------------------------------------*/ - -/* - Copyright (C) 2012 Jean-Marc Valin - - All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 2, as - published by the Free Software Foundation. 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 Lesser General Public License - along with this program; if not, see . -*/ - - -#ifdef VALGRIND -#include -#endif - -#include -#include -#include -#include - -#define MIN(a,b) ((a)<(b)?(a):(b)) -#define COEF 0.0f -#define MAX_ENTRIES 16384 - -void compute_weights(const float *x, float *w, int ndim) -{ - int i; - w[0] = MIN(x[0], x[1]-x[0]); - for (i=1;i. -*/ - -/*-----------------------------------------------------------------------*\ - - INCLUDES - -\*-----------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -/*-----------------------------------------------------------------------*\ - - DEFINES - -\*-----------------------------------------------------------------------*/ - -#define DELTAQ 0.01 /* quiting distortion */ -#define MAX_STR 80 /* maximum string length */ - -/*-----------------------------------------------------------------------*\ - - FUNCTION PROTOTYPES - -\*-----------------------------------------------------------------------*/ - -void zero(float v[], int k); -void acc(float v1[], float v2[], int k); -void norm(float v[], int k, long n); -long quantise(float cb[], float vec[], int k, int m, float *se); - -/*-----------------------------------------------------------------------* \ - - MAIN - -\*-----------------------------------------------------------------------*/ - -int main(int argc, char *argv[]) { - long k,m; /* dimension and codebook size */ - float *vec; /* current vector */ - float *cb; /* vector codebook */ - float *cent; /* centroids for each codebook entry */ - long *n; /* number of vectors in this interval */ - long J; /* number of vectors in training set */ - long i,j; - long ind; /* index of current vector */ - float se; /* squared error for this iteration */ - float Dn,Dn_1; /* current and previous iterations distortion */ - float delta; /* improvement in distortion */ - FILE *ftrain; /* file containing training set */ - FILE *fvq; /* file containing vector quantiser */ - int ret; - - /* Interpret command line arguments */ - - if (argc != 5) { - printf("usage: %s TrainFile K(dimension) M(codebook size) VQFile\n", argv[0]); - exit(1); - } - - /* Open training file */ - - ftrain = fopen(argv[1],"rb"); - if (ftrain == NULL) { - printf("Error opening training database file: %s\n",argv[1]); - exit(1); - } - - /* determine k and m, and allocate arrays */ - - k = atol(argv[2]); - m = atol(argv[3]); - printf("dimension K=%ld number of entries M=%ld\n", k, m); - vec = (float*)malloc(sizeof(float)*k); - cb = (float*)malloc(sizeof(float)*k*m); - cent = (float*)malloc(sizeof(float)*k*m); - n = (long*)malloc(sizeof(long)*m); - if (cb == NULL || cb == NULL || cent == NULL || vec == NULL) { - printf("Error in malloc.\n"); - exit(1); - } - - /* determine size of training set */ - - J = 0; - while(fread(vec, sizeof(float), k, ftrain) == (size_t)k) - J++; - printf("J=%ld entries in training set\n", J); - - /* set up initial codebook state from samples of training set */ - - rewind(ftrain); - ret = fread(cb, sizeof(float), k*m, ftrain); - - /* main loop */ - - Dn = 1E32; - j = 1; - do { - Dn_1 = Dn; - - /* zero centroids */ - - for(i=0; i DELTAQ) - for(i=0; i DELTAQ); - - /* save codebook to disk */ - - fvq = fopen(argv[4],"wt"); - if (fvq == NULL) { - printf("Error opening VQ file: %s\n",argv[4]); - exit(1); - } - - fprintf(fvq,"%ld %ld\n",k,m); - for(j=0; j. -*/ - -/*-----------------------------------------------------------------------*\ - - INCLUDES - -\*-----------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include - -/*-----------------------------------------------------------------------*\ - - DEFINES - -\*-----------------------------------------------------------------------*/ - -#define PI 3.141592654 /* mathematical constant */ -#define MAX_POP 10 - -/*-----------------------------------------------------------------------*\ - - FUNCTION PROTOTYPES - -\*-----------------------------------------------------------------------*/ - -void zero(float v[], int k); -void acc(float v1[], float v2[], int k); -void norm(float v[], int k, long n); -void locate_lsps_jnd_steps(float lsps[], float step, int k); - -/*-----------------------------------------------------------------------* \ - - MAIN - -\*-----------------------------------------------------------------------*/ - -int main(int argc, char *argv[]) { - int k; /* dimension and codebook size */ - float *vec; /* current vector */ - int *n; /* number of vectors in this interval */ - int J; /* number of vectors in training set */ - int i,j; - FILE *ftrain; /* file containing training set */ - float *train; /* training database */ - //float *pend_train; /* last entry */ - float *pt; - int ntrain, match, vec_exists, vec_index=0, entry; - int popular[MAX_POP], pop_thresh; - FILE *fvq; - float jnd; - - /* Interpret command line arguments */ - - if (argc != 6) { - printf("usage: %s TrainFile K(dimension) JND popThresh VQFile\n", - argv[0]); - exit(1); - } - - /* Open training file */ - - ftrain = fopen(argv[1],"rb"); - if (ftrain == NULL) { - printf("Error opening training database file: %s\n",argv[1]); - exit(1); - } - - /* determine k and m, and allocate arrays */ - - k = atol(argv[2]); - jnd = atof(argv[3]); - pop_thresh = atol(argv[4]); - printf("dimension K=%d popThresh=%d JND=%3.1f Hz\n", - k, pop_thresh, jnd); - vec = (float*)malloc(sizeof(float)*k); - if (vec == NULL) { - printf("Error in malloc.\n"); - exit(1); - } - - /* determine size of training set */ - - J = 0; - while(fread(vec, sizeof(float), k, ftrain) == (size_t)k) - J++; - printf("J=%d entries in training set\n", J); - train = (float*)malloc(sizeof(float)*k*J); - if (train == NULL) { - printf("Error in malloc.\n"); - exit(1); - } - printf("training array is %d bytes\n", sizeof(float)*k*J); - - n = (int*)malloc(sizeof(int)*J); - if (n == NULL) { - printf("Error in malloc.\n"); - exit(1); - } - for(i=0; i pop_thresh) { - for(j=0; j. -*/ - -/*-----------------------------------------------------------------------*\ - - INCLUDES - -\*-----------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -typedef struct { - float real; - float imag; -} COMP; - -/*-----------------------------------------------------------------------* \ - - DEFINES - -\*-----------------------------------------------------------------------*/ - -#define DELTAQ 0.01 /* quiting distortion */ -#define MAX_STR 80 /* maximum string length */ -#define PI 3.141592654 - -/*-----------------------------------------------------------------------*\ - - FUNCTION PROTOTYPES - -\*-----------------------------------------------------------------------*/ - -void zero(COMP v[], int d); -void acc(COMP v1[], COMP v2[], int d); -void norm(COMP v[], int k); -int quantise(COMP cb[], COMP vec[], int d, int e, float *se); -void print_vec(COMP cb[], int d, int e); - -/*-----------------------------------------------------------------------* \ - - MAIN - -\*-----------------------------------------------------------------------*/ - -int main(int argc, char *argv[]) { - int d,e; /* dimension and codebook size */ - COMP *vec; /* current vector */ - COMP *cb; /* vector codebook */ - COMP *cent; /* centroids for each codebook entry */ - int *n; /* number of vectors in this interval */ - int J; /* number of vectors in training set */ - int ind; /* index of current vector */ - float se; /* total squared error for this iteration */ - float var; /* variance */ - float var_1; /* previous variance */ - float delta; /* improvement in distortion */ - FILE *ftrain; /* file containing training set */ - FILE *fvq; /* file containing vector quantiser */ - int ret; - int i,j, finished, iterations; - float b; /* equivalent number of bits */ - float improvement; - float sd_vec, sd_element, sd_theory, bits_theory; - int var_n; - - /* Interpret command line arguments */ - - if (argc != 5) { - printf("usage: %s TrainFile D(dimension) E(number of entries) VQFile\n", argv[0]); - exit(1); - } - - /* Open training file */ - - ftrain = fopen(argv[1],"rb"); - if (ftrain == NULL) { - printf("Error opening training database file: %s\n",argv[1]); - exit(1); - } - - /* determine k and m, and allocate arrays */ - - d = atoi(argv[2]); - e = atoi(argv[3]); - printf("\n"); - printf("dimension D=%d number of entries E=%d\n", d, e); - vec = (COMP*)malloc(sizeof(COMP)*d); - cb = (COMP*)malloc(sizeof(COMP)*d*e); - cent = (COMP*)malloc(sizeof(COMP)*d*e); - n = (int*)malloc(sizeof(int)*e); - if (cb == NULL || cb == NULL || cent == NULL || vec == NULL) { - printf("Error in malloc.\n"); - exit(1); - } - - /* determine size of training set */ - - J = 0; - var_n = 0; - while(fread(vec, sizeof(COMP), d, ftrain) == (size_t)d) { - for(j=0; j 1) { - if (var > 0.0) { - delta = (var_1 - var)/var; - } - else - delta = 0; - if (delta < DELTAQ) - finished = 1; - } - - if (!finished) { - /* determine new codebook from centroids */ - - for(i=0; i. -*/ - -/*-----------------------------------------------------------------------*\ - - INCLUDES - -\*-----------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -typedef struct { - float real; - float imag; -} COMP; - -/*-----------------------------------------------------------------------* \ - - DEFINES - -\*-----------------------------------------------------------------------*/ - -#define DELTAQ 0.01 /* quiting distortion */ -#define MAX_STR 80 /* maximum string length */ - -/*-----------------------------------------------------------------------*\ - - FUNCTION PROTOTYPES - -\*-----------------------------------------------------------------------*/ - -void zero(float v[], int d); -void acc(float v1[], float v2[], int d); -void norm(float v[], int k, int n[]); -int quantise(float cb[], float vec[], int d, int e, float *se); -void print_vec(float cb[], int d, int e); -void split(float cb[], int d, int b); -int gain_shape_quantise(float cb[], float vec[], int d, int e, float *se, float *best_gain); - -/*-----------------------------------------------------------------------* \ - - MAIN - -\*-----------------------------------------------------------------------*/ - -int main(int argc, char *argv[]) { - int d,e; /* dimension and codebook size */ - float *vec; /* current vector */ - float *cb; /* vector codebook */ - float *cent; /* centroids for each codebook entry */ - int *n; /* number of vectors in this interval */ - int J; /* number of vectors in training set */ - int ind; /* index of current vector */ - float se; /* total squared error for this iteration */ - float var; /* variance */ - float var_1; /* previous variance */ - float delta; /* improvement in distortion */ - FILE *ftrain; /* file containing training set */ - FILE *fvq; /* file containing vector quantiser */ - int ret; - int i,j, finished, iterations; - float sd; - int var_n, bits, b, levels; - - /* Interpret command line arguments */ - - if (argc < 5) { - printf("usage: %s TrainFile D(dimension) B(number of bits) VQFile [error.txt file]\n", argv[0]); - exit(1); - } - - /* Open training file */ - - ftrain = fopen(argv[1],"rb"); - if (ftrain == NULL) { - printf("Error opening training database file: %s\n",argv[1]); - exit(1); - } - - /* determine k and m, and allocate arrays */ - - d = atoi(argv[2]); - bits = atoi(argv[3]); - e = 1< 1) { - if (var > 0.0) { - delta = (var_1 - var)/var; - } - else - delta = 0; - if (delta < DELTAQ) - finished = 1; - } - - if (!finished) { - /* determine new codebook from centroids */ - - for(i=0; i -O coff -i -o ") - # These are DLOPEN'ed and can't be automatically pulled in by dependency. - foreach(RUNTIME - hamlib-adat.dll - hamlib-alinco.dll - hamlib-amsat.dll - hamlib-aor.dll - hamlib-ars.dll - hamlib-celestron.dll - hamlib-drake.dll - hamlib-dummy.dll - hamlib-easycomm.dll - hamlib-flexradio.dll - hamlib-fodtrack.dll - hamlib-gs232a.dll - hamlib-heathkit.dll - hamlib-icom.dll - hamlib-jrc.dll - hamlib-kachina.dll - hamlib-kenwood.dll - hamlib-kit.dll - hamlib-lowe.dll - hamlib-m2.dll - hamlib-pcr.dll - hamlib-prm80.dll - hamlib-racal.dll - hamlib-rft.dll - hamlib-rotorez.dll - hamlib-rs.dll - hamlib-sartek.dll - hamlib-skanti.dll - hamlib-spid.dll - hamlib-tapr.dll - hamlib-tentec.dll - hamlib-ts7400.dll - hamlib-tuner.dll - hamlib-uniden.dll - hamlib-winradio.dll - hamlib-wj.dll - hamlib-yaesu.dll) - message(STATUS "Checking for ${RUNTIME}") - find_library(${RUNTIME}_LIB ${RUNTIME} - PATH_SUFFIXES hamlib) - message(STATUS "runtime found: ${${RUNTIME}_LIB}") - list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${${RUNTIME}_LIB}) - endforeach() - include(InstallRequiredSystemLibraries) -endif(MINGW) - -# Math library is automatic on MinGW -if(UNIX) - set(CMAKE_REQUIRED_INCLUDES math.h) - set(CMAKE_REQUIRED_LIBRARIES m) -endif(UNIX) - -# Find some standard headers and functions. -include(CheckIncludeFiles) -check_include_files("limits.h" HAVE_LIMITS_H) -check_include_files("stddef.h" HAVE_STDDEF_H) -check_include_files("stdlib.h" HAVE_STDLIB_H) -check_include_files("string.h" HAVE_STRING_H) - -include(CheckTypeSize) -check_type_size("int" SIZEOF_INT) - -include(CheckFunctionExists) -check_function_exists(floor HAVE_FLOOR) -check_function_exists(memset HAVE_MEMSET) -check_function_exists(pow HAVE_POW) -check_function_exists(sqrt HAVE_SQRT) - -# fdmdv2_main.h requires patching to find config.h as it current looks in the -# source directory and the generated file goes in the binary directory. -configure_file ("${PROJECT_SOURCE_DIR}/cmake/config.h.in" - "${PROJECT_BINARY_DIR}/config.h" ) -include_directories(${PROJECT_BINARY_DIR}) -add_definitions(-DHAVE_CONFIG_H) - -# Pthread Library -find_package(Threads REQUIRED) -message(STATUS "Threads library flags: ${CMAKE_THREAD_LIBS_INIT}") - -# -# Find codec2 -# -if(NOT USE_STATIC_CODEC2) - message(STATUS "Looking for codec2...") - find_package(codec2 CONFIG QUIET) - if(codec2_FOUND) - get_target_property(CODEC2_BRARY codec2 LOCATION) - message(STATUS " codec2 library: ${CODEC2_LIBRARY}") - message(STATUS " codec2 headers: ${codec2_INCLUDE_DIRS}") - else() - # Try to find manually - find_path(CODEC2_INCLUDE_DIRS codec2.h - PATH_SUFFIXES codec2) - find_library(CODEC2_LIBRARY NAMES codec2) - if(CODEC2_LIBRARY AND CODEC2_INCLUDE_DIRS) - message(STATUS " codec2 library: ${CODEC2_LIBRARY}") - message(STATUS " codec2 headers: ${CODEC2_INCLUDE_DIRS}") - list(APPEND FREEDV_LINK_LIBS ${CODEC2_LIBRARY}) - include_directories(${CODEC2_INCLUDE_DIRS}) - else() - message(FATAL_ERROR "codec2 library not found. -Linux: -Codec2 may not be in your distribution so build yourself or use the cmake option to build statically into FreeDV. -Windws: -It's easiest to use the cmake option: USE_STATIC_CODEC2" - ) - endif() - endif() -else(NOT USE_STATIC_CODEC2) - message(STATUS "Will attempt static build of codec2.") - include(cmake/BuildCodec2.cmake) -endif(NOT USE_STATIC_CODEC2) - -# -# Find or build portaudio Library -# -if(NOT USE_STATIC_PORTAUDIO) - message(STATUS "Looking for portaudio...") - find_package(Portaudio REQUIRED) - if(PORTAUDIO_FOUND) - message(STATUS " portaudio library: ${PORTAUDIO_LIBRARIES}") - message(STATUS " portaudio headers: ${PORTAUDIO_INCLUDE_DIRS}") - list(APPEND FREEDV_LINK_LIBS ${PORTAUDIO_LIBRARIES}) - include_directories(${PORTAUDIO_INCLUDE_DIRS}) - else() - message(FATAL_ERROR "portaudio library not found. -On Linux systems try installing: - portaudio-devel (RPM based systems) - libportaudio-dev (DEB based systems) -On Windows it's easiest to use the cmake option: USE_STATIC_PORTAUDIO" - ) - endif() - if(NOT ${PORTAUDIO_VERSION} EQUAL 19) - message(WARNING "Portaudio versions other than 19 are known to have issues. You have been warned!") - endif() -else(NOT USE_STATIC_PORTAUDIO) - message(STATUS "Will attempt static build of portaudio.") - include(cmake/BuildPortaudio.cmake) -endif(NOT USE_STATIC_PORTAUDIO) - -# -# Hamlib library -# -message(STATUS "Looking for hamlib...") -find_path(HAMLIB_INCLUDE_DIR hamlib/rig.h) -find_library(HAMLIB_LIBRARY hamlib) -message(STATUS "Hamlib library: ${HAMLIB_LIBRARY}") -message(STATUS "Hamlib headers: ${HAMLIB_INCLUDE_DIR}") -if(HAMLIB_LIBRARY AND HAMLIB_INCLUDE_DIR) - message(STATUS "Hamlib library found.") - include_directories(${HAMLIB_INCLUDE_DIR}) - list(APPEND FREEDV_LINK_LIBS ${HAMLIB_LIBRARY}) -else(HAMLIB_LIBRARY AND HAMLIB_INCLUDE_DIR) - message(FATAL_ERROR "hamlib not found. -On Linux systems try installing: - hamlib-devel (RPM based systems) - libhamlib-dev (DEB based systems)" - ) -endif(HAMLIB_LIBRARY AND HAMLIB_INCLUDE_DIR) - - -# -# Samplerate Library -# -if(NOT USE_STATIC_SAMPLERATE) - message(STATUS "Looking for samplerate...") - find_library(LIBSAMPLERATE samplerate) - find_path(LIBSAMPLERATE_INCLUDE_DIR samplerate.h) - message(STATUS " samplerate library: ${LIBSAMPLERATE}") - message(STATUS " samplerate headers: ${LIBSAMPLERATE_INCLUDE_DIR}") - if(LIBSAMPLERATE AND LIBSAMPLERATE_INCLUDE_DIR) - list(APPEND FREEDV_LINK_LIBS ${LIBSAMPLERATE}) - include_directories(${LIBSAMPLERATE_INCLUDE_DIR}) - else(LIBSTAMPLERATE AND LIBSAMPLERATE_INCLUDE_DIR) - message(FATAL_ERROR "samplerate library not found. -On Linux systems try installing: - samplerate-devel (RPM based systems) - libsamplerate-dev (DEB based systems) -On Windows it's easiest to use the cmake option: USE_STATIC_SAMPLERATE" - ) - endif(LIBSAMPLERATE AND LIBSAMPLERATE_INCLUDE_DIR) -else(NOT USE_STATIC_SAMPLERATE) - message(STATUS "Will attempt static build of samplerate.") - include(cmake/BuildSamplerate.cmake) -endif(NOT USE_STATIC_SAMPLERATE) - -# -# Find sox library -# -if(NOT USE_STATIC_SOX) - message(STATUS "Looking for sox...") - find_library(LIBSOX_LIBRARY sox) - find_path(LIBSOX_INCLUDE_DIR NAMES sox/sox.h sox.h) - message(STATUS " sox library: ${LIBSOX_LIBRARY}") - message(STATUS " sox headers: ${LIBSOX_INCLUDE_DIR}") - if(LIBSOX_LIBRARY AND LIBSOX_INCLUDE_DIR) - list(APPEND FREEDV_LINK_LIBS ${LIBSOX_LIBRARY}) - include_directories(${LIBSOX_INCLUDE_DIR}) - else(LIBSOX_LIBRARY AND LIBSOX_INCLUDE_DIR) - message(FATAL_ERROR "sox library not found. -On Linux systems try installing: - sox-devel (RPM based systems) - libsox-dev (DEB based systems) -On Windows it's easiest to use the cmake option: USE_STATIC_SOX" - ) - endif(LIBSOX_LIBRARY AND LIBSOX_INCLUDE_DIR) -else(NOT USE_STATIC_SOX) - message(STATUS "Will attempt static build of sox.") - include(cmake/BuildSox.cmake) -endif(NOT USE_STATIC_SOX) - -# -# sndfile Library -# -if(NOT USE_STATIC_SNDFILE) - message(STATUS "Looking for sndfile...") - find_library(LIBSNDFILE sndfile) - find_path(LIBSNDFILE_INCLUDE_DIR sndfile.h) - message(STATUS " sndfile library: ${LIBSNDFILE}") - message(STATUS " sndfile headers: ${LIBSNDFILE_INCLUDE_DIR}") - if(LIBSNDFILE AND LIBSNDFILE_INCLUDE_DIR) - list(APPEND FREEDV_LINK_LIBS ${LIBSNDFILE}) - else(LIBSNDFILE AND LIBSNDFILE_INCLUDE_DIR) - message(FATAL_ERROR "sndfile library not found. -On Linux systems try installing: - libsndfile-devel (RPM based systems) - libsndfile-dev (DEB based systems) -On Windows it's easiest to use the cmake option: USE_STATIC_SNDFILE" - ) - endif(LIBSNDFILE AND LIBSNDFILE_INCLUDE_DIR) -else(NOT USE_STATIC_SNDFILE) - message(STATUS "Will attempt static build of sndfile.") - include(cmake/BuildSndfile.cmake) -endif(NOT USE_STATIC_SNDFILE) - -# -# Find wxWidgets -# -if(NOT BOOTSTRAP_WXWIDGETS) - set(WXCONFIG "" CACHE FILEPATH "Location of wx-config binary.") - set(WXRC "" CACHE FILEPATH "Location of wxrc binary.") -endif(NOT BOOTSTRAP_WXWIDGETS) -#if(BOOTSTRAP_WXWIDGETS) -# set(WXCONFIG "${CMAKE_BINARY_DIR}/external/dist/bin/wx-config") -# set(WXRC "${CMAKE_BINARY_DIR}/external/dist/bin/wxrc") -# list(APPEND FREEDV_STATIC_DEPS wxWidgets) -#endif(BOOTSTRAP_WXWIDGETS) -message(STATUS "Looking for wxWidgets...") -if(WXCONFIG) - message(STATUS "wx-config: ${WXCONFIG}") - set(wxWidgets_CONFIG_EXECUTABLE ${WXCONFIG}) -endif(WXCONFIG) -if(WXRC) - message(STATUS "wxrc: ${WXRC}") - set(wxWidgets_wxrc_EXECUTABLE ${WXRC}) -endif(WXRC) -set(WX_VERSION_MIN 3.0.0) -find_package(wxWidgets REQUIRED core base aui html net adv) -execute_process(COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" --version - OUTPUT_VARIABLE WX_VERSION) -string(STRIP ${WX_VERSION} WX_VERSION) -if(WX_VERSION VERSION_EQUAL ${WX_VERSION_MIN} - OR WX_VERSION VERSION_GREATER ${WX_VERSION_MIN}) - message(STATUS "wxWidgets version: ${WX_VERSION}") -else() - message(FATAL_ERROR "wxWidgets must be installed on your system. -Please check that wx-config is in path, the directory -where wxWidgets libraries are installed (returned by -'wx-config --libs' or 'wx-config --static --libs' command) -is in LD_LIBRARY_PATH or equivalent variable and -wxWidgets version is ${WX_VERSION_MIN} or above.") -endif() -if(wxWidgets_FOUND) - include("${wxWidgets_USE_FILE}") - list(APPEND FREEDV_LINK_LIBS ${wxWidgets_LIBRARIES}) -endif(wxWidgets_FOUND) - - -# Freedv -add_subdirectory(src) - -# Icons and desktop file -add_subdirectory(contrib) - -message(STATUS "Build type will be: ${CMAKE_BUILD_TYPE}") - -# -# Cpack NSIS configuration for Windows. -# -if(WIN32) - # Detect if we're doing a 32-bit or 64-bit windows build. - if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) - set(CMAKE_CL_64 TRUE) - endif() - if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug") - set(CPACK_STRIP_FILES TRUE) - endif() - - configure_file(cmake/GetDependencies.cmake.in cmake/GetDependencies.cmake - @ONLY - ) - install(SCRIPT ${CMAKE_BINARY_DIR}/cmake/GetDependencies.cmake) - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "HF Digital Voice for Radio Amateurs") - set(CPACK_PACKAGE_VENDOR "CMake") - set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") - set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") - set(CPACK_PACKAGE_VERSION_MAJOR ${FREEDV_VERSION_MAJOR}) - set(CPACK_PACKAGE_VERSION_MINOR ${FREEDV_VERSION_MINOR}) - if(FREEDV_VERSION_PATCH) - set(CPACK_PACKAGE_VERSION_PATCH ${FREEDV_VERSION_PATCH}) - else() - set(CPACK_PACKAGE_VERSION_PATCH "0") - endif() - set(CPACK_PACKAGE_INSTALL_DIRECTORY "FreeDV") - set(CPACK_PACKAGE_EXECUTABLES freedv;FreeDV) - set(CPACK_STRIP_FILES TRUE) - # NSIS specific settings - set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\freedv.exe") - set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}") - set(CPACK_NSIS_PACKAGE_NAME "FreeDV") - set(CPACK_NSIS_URL_INFO_ABOUT "http://freedv.org") - set(CPACK_NSIS_MODIFY_PATH OFF) - set(CPACK_NSIS_MENU_LINKS "http://freedv.org" "FreeDV Homepage") - include(CPack) -endif(WIN32) - -endif(BOOTSTRAP_WXWIDGETS AND NOT EXISTS ${WXCONFIG}) diff --git a/fdmdv2/COPYING b/fdmdv2/COPYING deleted file mode 100644 index cfd4e991..00000000 --- a/fdmdv2/COPYING +++ /dev/null @@ -1,502 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 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. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -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 and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, 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 library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete 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 distribute a copy of this License along with the -Library. - - 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 Library or any portion -of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -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 Library, 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 Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you 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. - - If distribution of 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 satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be 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. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library 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. - - 9. 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 Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -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 with -this License. - - 11. 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 Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library 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 Library. - -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. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library 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. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser 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 Library -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 Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -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 - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "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 -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. 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 LIBRARY 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 -LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, see - . - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/fdmdv2/ChangeLog b/fdmdv2/ChangeLog deleted file mode 100644 index 6cc9eb6c..00000000 --- a/fdmdv2/ChangeLog +++ /dev/null @@ -1,1819 +0,0 @@ ------------------------------------------------------------------------- -r1317 | hobbes1069 | 2013-06-13 10:40:39 -0500 (Thu, 13 Jun 2013) | 1 line - -Update wxWidgets bootstrap process to be more simple and other tweaks to USE_STATIC_... options. ------------------------------------------------------------------------- -r1312 | hobbes1069 | 2013-06-07 13:17:05 -0500 (Fri, 07 Jun 2013) | 1 line - -Use version.h for settign version info. ------------------------------------------------------------------------- -r1311 | shenki | 2013-06-06 19:55:20 -0500 (Thu, 06 Jun 2013) | 5 lines - -Add libctb to the list of libraries to build - -It will not be downloaded nor built with the current configuration. -Thanks to Curt, WE7U on the codec2 mailing list for discovering this one. - ------------------------------------------------------------------------- -r1310 | shenki | 2013-06-06 04:00:35 -0500 (Thu, 06 Jun 2013) | 2 lines - -Move init of sox outside of assert calls - ------------------------------------------------------------------------- -r1306 | hobbes1069 | 2013-06-02 11:50:41 -0500 (Sun, 02 Jun 2013) | 1 line - -Update version in cmake config. ------------------------------------------------------------------------- -r1305 | hobbes1069 | 2013-06-02 08:01:51 -0500 (Sun, 02 Jun 2013) | 1 line - -Put the file in the right place... ------------------------------------------------------------------------- -r1304 | hobbes1069 | 2013-06-02 07:59:53 -0500 (Sun, 02 Jun 2013) | 1 line - -Add freedv.rc which allows embedding the freedv icon in the windows executable. ------------------------------------------------------------------------- -r1303 | drowe67 | 2013-06-01 19:19:57 -0500 (Sat, 01 Jun 2013) | 1 line - -serial & Hamlib PTT tested OK on Linux ------------------------------------------------------------------------- -r1300 | drowe67 | 2013-05-31 17:20:06 -0500 (Fri, 31 May 2013) | 1 line - -hooked up serial port logic, still to test and debug ------------------------------------------------------------------------- -r1297 | drowe67 | 2013-05-30 19:50:52 -0500 (Thu, 30 May 2013) | 1 line - -restored serial PTT dilaog, yet to hook up actual logic to use it ------------------------------------------------------------------------- -r1296 | drowe67 | 2013-05-29 21:11:07 -0500 (Wed, 29 May 2013) | 1 line - -made filter dialog a little larger as ok/cancel wasbing cropped ------------------------------------------------------------------------- -r1295 | hobbes1069 | 2013-05-29 20:36:45 -0500 (Wed, 29 May 2013) | 1 line - -Move golay23 into codec2 library. ------------------------------------------------------------------------- -r1294 | hobbes1069 | 2013-05-29 15:06:55 -0500 (Wed, 29 May 2013) | 1 line - -Additional hamlib cmake config cleanup. ------------------------------------------------------------------------- -r1293 | hobbes1069 | 2013-05-28 19:55:57 -0500 (Tue, 28 May 2013) | 1 line - -Add cmake checks for hamlib and more fixes for updated source names. ------------------------------------------------------------------------- -r1292 | hobbes1069 | 2013-05-28 19:15:28 -0500 (Tue, 28 May 2013) | 1 line - -Update cmake config for renamed source files. ------------------------------------------------------------------------- -r1291 | drowe67 | 2013-05-28 01:45:26 -0500 (Tue, 28 May 2013) | 1 line - -cleaned up some unused files ------------------------------------------------------------------------- -r1289 | drowe67 | 2013-05-27 19:37:30 -0500 (Mon, 27 May 2013) | 1 line - -minor tweaks to README, remove dunused automake stuff, and tweaked help-about for donations ------------------------------------------------------------------------- -r1288 | drowe67 | 2013-05-27 18:35:32 -0500 (Mon, 27 May 2013) | 1 line - -managedto get Win32 building with hamlib win32 binaries instead of building hamlib myself ------------------------------------------------------------------------- -r1287 | drowe67 | 2013-05-27 17:33:38 -0500 (Mon, 27 May 2013) | 1 line - -first pass at building with hamlib, but cantget hamlib to build ------------------------------------------------------------------------- -r1286 | drowe67 | 2013-05-27 15:50:41 -0500 (Mon, 27 May 2013) | 1 line - -filer dialog now fits on 800x600 without clipping ------------------------------------------------------------------------- -r1285 | drowe67 | 2013-05-27 15:46:49 -0500 (Mon, 27 May 2013) | 1 line - -after some sizer frustration with ptt dlg, rename commport to ptt ------------------------------------------------------------------------- -r1284 | shenki | 2013-05-27 05:41:58 -0500 (Mon, 27 May 2013) | 4 lines - -Add hamlib related files - -These were missing from the previous commit. Oops! - ------------------------------------------------------------------------- -r1283 | shenki | 2013-05-27 05:17:32 -0500 (Mon, 27 May 2013) | 13 lines - -Add hamlib support for push to talk - -This removes libctb in favour of hamlib. It has been tested with 1.2.15.3 of -hamlib with a IC-7200. - -The rig is configured using it's own dialog Tools -> PTT Config. The only -options available are the rig model and serial port, the rest of the options -are obtained from the rig definition in hamlib. - -FreeDV will open the configured serial port on startup. When it cannot find -the radio, an error dialog will be displayed. Spacebar can be used to toggle -TX/RX. - ------------------------------------------------------------------------- -r1268 | drowe67 | 2013-05-23 18:00:55 -0500 (Thu, 23 May 2013) | 1 line - -added options dialog, bumped version ------------------------------------------------------------------------- -r1267 | drowe67 | 2013-05-23 09:24:58 -0500 (Thu, 23 May 2013) | 1 line - -make 1600 default and re-arranged to fit 800x600 netbook layout ------------------------------------------------------------------------- -r1253 | wittend99 | 2013-05-20 16:23:52 -0500 (Mon, 20 May 2013) | 1 line - -Personal test project ------------------------------------------------------------------------- -r1252 | wittend99 | 2013-05-20 16:22:44 -0500 (Mon, 20 May 2013) | 1 line - -Personal test stuff ------------------------------------------------------------------------- -r1251 | wittend99 | 2013-05-20 16:21:24 -0500 (Mon, 20 May 2013) | 1 line - - ------------------------------------------------------------------------- -r1250 | shenki | 2013-05-18 23:08:22 -0500 (Sat, 18 May 2013) | 7 lines - -Allow building against the system sox library - -Provide SYSTEM_SOX=y to build against the system libsox instead -of downloading, building and linking staticly. - -The default of linking staticly remains the same. - ------------------------------------------------------------------------- -r1249 | hobbes1069 | 2013-05-17 09:53:07 -0500 (Fri, 17 May 2013) | 1 line - -Forgot to svn add the readme. ------------------------------------------------------------------------- -r1248 | hobbes1069 | 2013-05-17 09:51:38 -0500 (Fri, 17 May 2013) | 2 lines - -Major cmake config overhall for freedv mingw build. Add freedv icon to installer and start menu entry. Add README.cmake for codec2-dev. - ------------------------------------------------------------------------- -r1246 | hobbes1069 | 2013-05-10 18:54:16 -0500 (Fri, 10 May 2013) | 1 line - -Workaround for location of config.h ------------------------------------------------------------------------- -r1245 | hobbes1069 | 2013-05-09 15:44:20 -0500 (Thu, 09 May 2013) | 1 line - -Fix internal building of Codec2. Fix finding libraries under MinGW. ------------------------------------------------------------------------- -r1244 | hobbes1069 | 2013-05-08 14:38:44 -0500 (Wed, 08 May 2013) | 1 line - -CMake configuration tweaks for wxWidgets bootstrap build option and update of README.cmake. ------------------------------------------------------------------------- -r1243 | hobbes1069 | 2013-05-07 09:13:02 -0500 (Tue, 07 May 2013) | 1 line - -Fix typo in cmake config, add README.cmake. ------------------------------------------------------------------------- -r1242 | hobbes1069 | 2013-05-07 09:07:47 -0500 (Tue, 07 May 2013) | 1 line - -Add missing BuildCodec2.cmake ------------------------------------------------------------------------- -r1241 | wittend99 | 2013-05-06 12:17:19 -0500 (Mon, 06 May 2013) | 1 line - -Pushing changes to force windows builds to use a configuration file rather than the registry. ------------------------------------------------------------------------- -r1240 | wittend99 | 2013-05-06 12:14:34 -0500 (Mon, 06 May 2013) | 1 line - -Just changes to my personal IDE workspace. Irrelevant to everyone but me -DMW ------------------------------------------------------------------------- -r1239 | hobbes1069 | 2013-05-06 10:49:31 -0500 (Mon, 06 May 2013) | 1 line - -Add cmake configuration for contrib dir. ------------------------------------------------------------------------- -r1238 | hobbes1069 | 2013-05-06 10:48:37 -0500 (Mon, 06 May 2013) | 1 line - -CMake configuration updates. More detailed error messages. Icon and desktop installation for Linux. WIN32 CPack tweaks. ------------------------------------------------------------------------- -r1237 | wittend99 | 2013-04-26 08:13:11 -0500 (Fri, 26 Apr 2013) | 1 line - -Reversing commits made in error... ------------------------------------------------------------------------- -r1236 | wittend99 | 2013-04-26 08:09:05 -0500 (Fri, 26 Apr 2013) | 1 line - - ------------------------------------------------------------------------- -r1235 | hobbes1069 | 2013-04-24 14:34:37 -0500 (Wed, 24 Apr 2013) | 1 line - -Update cmake configuration including building static builds of most dependencies. Update codec2 build to include basic cpack configuration. ------------------------------------------------------------------------- -r1234 | hobbes1069 | 2013-04-19 14:26:53 -0500 (Fri, 19 Apr 2013) | 1 line - -Major updates to cmake configuration for both codec2-dev and fdmdv2. Preliminary cpack NSIS configuration for codec2 windows installer. ------------------------------------------------------------------------- -r1232 | hobbes1069 | 2013-04-15 09:35:41 -0500 (Mon, 15 Apr 2013) | 1 line - -Commit inital cmake configuration, *nix and windows icon, and *nix desktop file. ------------------------------------------------------------------------- -r1231 | wittend99 | 2013-03-26 10:53:46 -0500 (Tue, 26 Mar 2013) | 1 line - - ------------------------------------------------------------------------- -r1230 | wittend99 | 2013-03-26 10:31:07 -0500 (Tue, 26 Mar 2013) | 1 line - -Updating my personal resting configuration. ------------------------------------------------------------------------- -r1229 | wittend99 | 2013-03-26 10:22:42 -0500 (Tue, 26 Mar 2013) | 1 line - -Reduce minimum size of the top level frame to let it be used on 1024 x 600 displays. ------------------------------------------------------------------------- -r1228 | wittend99 | 2013-03-26 10:22:07 -0500 (Tue, 26 Mar 2013) | 1 line - -Reduce minimum size of the top level frame to let it be used on 1024 x 600 displays. ------------------------------------------------------------------------- -r1227 | drowe67 | 2013-03-25 15:33:49 -0500 (Mon, 25 Mar 2013) | 1 line - -checked in Stuarts patches 1 thru 4 ------------------------------------------------------------------------- -r1226 | wittend99 | 2013-03-24 17:21:11 -0500 (Sun, 24 Mar 2013) | 1 line - -Removed comment ------------------------------------------------------------------------- -r1224 | drowe67 | 2013-03-24 00:47:15 -0500 (Sun, 24 Mar 2013) | 1 line - -prototype 1600 wide mode ------------------------------------------------------------------------- -r1223 | drowe67 | 2013-03-22 17:51:40 -0500 (Fri, 22 Mar 2013) | 1 line - -disabled a few extraneous test modes for v0.96 release ------------------------------------------------------------------------- -r1221 | drowe67 | 2013-03-19 22:51:21 -0500 (Tue, 19 Mar 2013) | 1 line - -bump version ------------------------------------------------------------------------- -r1219 | drowe67 | 2013-03-19 20:35:29 -0500 (Tue, 19 Mar 2013) | 1 line - -made test frames count high error rate frames to get a more accurate result ------------------------------------------------------------------------- -r1218 | drowe67 | 2013-03-19 20:21:35 -0500 (Tue, 19 Mar 2013) | 1 line - -integrated and tested more reliable odd/even frame sync, I think it's an improvement on 4dB poor channel ------------------------------------------------------------------------- -r1213 | drowe67 | 2013-03-18 02:30:28 -0500 (Mon, 18 Mar 2013) | 1 line - -removed clip, added new 1600 bit/s mode (1300+FEC) ------------------------------------------------------------------------- -r1205 | drowe67 | 2013-03-08 22:00:48 -0600 (Fri, 08 Mar 2013) | 1 line - -support for clipping of tx waveform ------------------------------------------------------------------------- -r1204 | drowe67 | 2013-03-08 17:59:51 -0600 (Fri, 08 Mar 2013) | 1 line - -normalised tx power across modes ------------------------------------------------------------------------- -r1203 | drowe67 | 2013-03-08 14:49:30 -0600 (Fri, 08 Mar 2013) | 1 line - -Support in Windows Makefile for golay module ------------------------------------------------------------------------- -r1202 | drowe67 | 2013-03-08 01:45:10 -0600 (Fri, 08 Mar 2013) | 1 line - -changed version number ------------------------------------------------------------------------- -r1201 | drowe67 | 2013-03-08 01:24:29 -0600 (Fri, 08 Mar 2013) | 1 line - -first pass at bit error patterns being plotted ------------------------------------------------------------------------- -r1199 | drowe67 | 2013-03-07 21:15:29 -0600 (Thu, 07 Mar 2013) | 1 line - -added multi-channel support to plot scalar, tested OK with 1 channel ------------------------------------------------------------------------- -r1198 | drowe67 | 2013-03-07 20:40:11 -0600 (Thu, 07 Mar 2013) | 1 line - -BER tx and tx working OK, tested with some simulated AWGN and CCIR files ------------------------------------------------------------------------- -r1197 | drowe67 | 2013-03-07 01:37:11 -0600 (Thu, 07 Mar 2013) | 1 line - -FEC on 2000 mode implemented but not tested with errors (yet) ------------------------------------------------------------------------- -r1196 | drowe67 | 2013-03-07 01:23:02 -0600 (Thu, 07 Mar 2013) | 1 line - -2000 bit/s mode seems to be transmitting OK ------------------------------------------------------------------------- -r1194 | drowe67 | 2013-03-07 00:49:11 -0600 (Thu, 07 Mar 2013) | 1 line - -both 1400 and 1600 modes working in loopback, needed to test 1400V0.91 against a V0.91 release ------------------------------------------------------------------------- -r1189 | drowe67 | 2013-03-06 22:18:54 -0600 (Wed, 06 Mar 2013) | 1 line - -added mode radio-buttons to front page of GUI ------------------------------------------------------------------------- -r1155 | wittend99 | 2012-12-30 16:41:15 -0600 (Sun, 30 Dec 2012) | 1 line - -Trivial updates, looking for uninitialized variables and other loose ends. ------------------------------------------------------------------------- -r1154 | wittend99 | 2012-12-29 17:28:53 -0600 (Sat, 29 Dec 2012) | 1 line - -Add files README.osx and freedv_osx_port.patch.gz, update credits.txt file. Not much else. ------------------------------------------------------------------------- -r1153 | wittend99 | 2012-12-29 13:10:49 -0600 (Sat, 29 Dec 2012) | 1 line - - ------------------------------------------------------------------------- -r1152 | drowe67 | 2012-12-23 18:14:07 -0600 (Sun, 23 Dec 2012) | 1 line - -first pass at autotools build system, thanks Patrick, not tested at this stage, Makefile.linux still works ------------------------------------------------------------------------- -r1151 | drowe67 | 2012-12-22 01:29:28 -0600 (Sat, 22 Dec 2012) | 1 line - -changed changed fifo.h and fdmdv.h to more unique names codec2_fifo.h & codec2_fdmdv.h ------------------------------------------------------------------------- -r1145 | wittend99 | 2012-12-16 20:43:05 -0600 (Sun, 16 Dec 2012) | 1 line - -Unversion some pieces unintentionally added by restructuring. ------------------------------------------------------------------------- -r1144 | wittend99 | 2012-12-16 20:40:23 -0600 (Sun, 16 Dec 2012) | 1 line - -Added a msvc folder to build for a future MS C++ build. ------------------------------------------------------------------------- -r1143 | wittend99 | 2012-12-16 20:33:05 -0600 (Sun, 16 Dec 2012) | 1 line - -Move all Codelite-Mingw build environment from ./build to ./build/codelite ------------------------------------------------------------------------- -r1142 | wittend99 | 2012-12-16 20:04:21 -0600 (Sun, 16 Dec 2012) | 1 line - -Add codelite subfolder. ------------------------------------------------------------------------- -r1141 | wittend99 | 2012-12-16 19:56:46 -0600 (Sun, 16 Dec 2012) | 1 line - -Work on moving multiple unrelated classes out of fdmdv_main.cpp, cleanup dead code. ------------------------------------------------------------------------- -r1140 | drowe67 | 2012-12-16 16:57:25 -0600 (Sun, 16 Dec 2012) | 1 line - -disabled jack with portaudio based on mailing list feedback, thanks guys ------------------------------------------------------------------------- -r1139 | drowe67 | 2012-12-16 00:24:46 -0600 (Sun, 16 Dec 2012) | 1 line - -typo in README.linux ------------------------------------------------------------------------- -r1138 | drowe67 | 2012-12-16 00:22:52 -0600 (Sun, 16 Dec 2012) | 1 line - -2nd pass at generic Makefile.linux ------------------------------------------------------------------------- -r1137 | drowe67 | 2012-12-15 17:28:45 -0600 (Sat, 15 Dec 2012) | 1 line - -experimental new makefile for Linux that downloads and builds most of the libraries we need, tested on Ubuntu 9.1 and 10.04 ------------------------------------------------------------------------- -r1136 | drowe67 | 2012-12-15 06:14:13 -0600 (Sat, 15 Dec 2012) | 1 line - -makefile modified for Ubuntu 10.04 ------------------------------------------------------------------------- -r1135 | drowe67 | 2012-12-15 05:41:44 -0600 (Sat, 15 Dec 2012) | 1 line - -experimental Linux makefile, about to test on Ubuntu 10.04 ------------------------------------------------------------------------- -r1134 | wittend99 | 2012-12-14 15:36:21 -0600 (Fri, 14 Dec 2012) | 1 line - -Comment out the event handlers which were connected to the wrong check boxes in the PTT dialog. This _should_ have no effect on behavior because the event handlers in question were unused in the current code. ------------------------------------------------------------------------- -r1133 | wittend99 | 2012-12-12 19:11:14 -0600 (Wed, 12 Dec 2012) | 1 line - - ------------------------------------------------------------------------- -r1132 | wittend99 | 2012-12-11 08:43:05 -0600 (Tue, 11 Dec 2012) | 1 line - - ------------------------------------------------------------------------- -r1131 | drowe67 | 2012-12-10 18:31:12 -0600 (Mon, 10 Dec 2012) | 1 line - -added some debug code to trap reported sox lib errors ------------------------------------------------------------------------- -r1130 | wittend99 | 2012-12-10 18:05:18 -0600 (Mon, 10 Dec 2012) | 2 lines - -Moved version.h from /fdmdv2 to /fdmdv2/src. -Removed four orphaned lib files from /fdmdv2 ------------------------------------------------------------------------- -r1129 | wittend99 | 2012-12-10 17:37:17 -0600 (Mon, 10 Dec 2012) | 2 lines - -Renamed (finally) OnTogBtnTXClick to OnTogBtnPTT globally. -Removed fdmdv2-doc/* for now - to reduce traffic for first time users. Probably to be replaced with freedv-doc when useful content stabilizes. ------------------------------------------------------------------------- -r1128 | drowe67 | 2012-12-09 23:36:38 -0600 (Sun, 09 Dec 2012) | 1 line - -small edits to README.Linux ------------------------------------------------------------------------- -r1127 | drowe67 | 2012-12-09 23:33:18 -0600 (Sun, 09 Dec 2012) | 1 line - -after testing half duplex on Windows ------------------------------------------------------------------------- -r1126 | drowe67 | 2012-12-09 23:09:11 -0600 (Sun, 09 Dec 2012) | 1 line - -first pass at half duplex, still testing ------------------------------------------------------------------------- -r1125 | wittend99 | 2012-12-09 19:55:45 -0600 (Sun, 09 Dec 2012) | 1 line - - ------------------------------------------------------------------------- -r1124 | drowe67 | 2012-12-06 18:14:53 -0600 (Thu, 06 Dec 2012) | 1 line - -analog 6dB boost on mic, some experiments with waterfall blue colors, using 200-2800Hz for waterfall max AGC level, and updated Linux compile notes ------------------------------------------------------------------------- -r1123 | drowe67 | 2012-12-05 21:04:43 -0600 (Wed, 05 Dec 2012) | 1 line - -added V0.9 Beta version code and support for future versioning via version.txt ------------------------------------------------------------------------- -r1122 | drowe67 | 2012-12-05 15:06:24 -0600 (Wed, 05 Dec 2012) | 1 line - -added Codec 2 build instructions to README.Win32 ------------------------------------------------------------------------- -r1121 | wittend99 | 2012-12-05 09:22:25 -0600 (Wed, 05 Dec 2012) | 1 line - -More work on PTT button. ------------------------------------------------------------------------- -r1120 | drowe67 | 2012-12-04 18:37:25 -0600 (Tue, 04 Dec 2012) | 1 line - -fix for File-Exit, works under Linux ------------------------------------------------------------------------- -r1119 | wittend99 | 2012-12-04 15:27:23 -0600 (Tue, 04 Dec 2012) | 1 line - -Improve layout of PTT dialog layout under Linux ------------------------------------------------------------------------- -r1118 | drowe67 | 2012-12-04 00:52:27 -0600 (Tue, 04 Dec 2012) | 1 line - -removed a few prints and #ifdefed out the display of txid/rxid buttons for now as feature wont be implemented for the beta ------------------------------------------------------------------------- -r1117 | wittend99 | 2012-12-03 22:27:26 -0600 (Mon, 03 Dec 2012) | 1 line - - ------------------------------------------------------------------------- -r1116 | wittend99 | 2012-12-03 21:41:59 -0600 (Mon, 03 Dec 2012) | 1 line - - ------------------------------------------------------------------------- -r1115 | wittend99 | 2012-12-03 21:39:40 -0600 (Mon, 03 Dec 2012) | 1 line - - ------------------------------------------------------------------------- -r1114 | drowe67 | 2012-12-02 23:42:18 -0600 (Sun, 02 Dec 2012) | 1 line - -better shut down of EQ states to prevent bombing with sound card error ------------------------------------------------------------------------- -r1113 | drowe67 | 2012-12-02 23:31:12 -0600 (Sun, 02 Dec 2012) | 1 line - -speaker eq states now being preserved and can take eqs in and out at run time ------------------------------------------------------------------------- -r1112 | drowe67 | 2012-12-02 19:41:38 -0600 (Sun, 02 Dec 2012) | 1 line - -real time EQ adjustment working, designing filters on the fly, but still a few GUI and context save/restore bugs ------------------------------------------------------------------------- -r1111 | drowe67 | 2012-12-02 04:39:21 -0600 (Sun, 02 Dec 2012) | 1 line - -EQ enable and separate default buttons, ready to wire up real time code ------------------------------------------------------------------------- -r1110 | drowe67 | 2012-12-02 03:18:22 -0600 (Sun, 02 Dec 2012) | 1 line - -make axis labels dissapear if windows small enough to make text overlap ------------------------------------------------------------------------- -r1109 | drowe67 | 2012-12-01 20:48:07 -0600 (Sat, 01 Dec 2012) | 1 line - -first pass at speaker eq controls ------------------------------------------------------------------------- -r1108 | drowe67 | 2012-12-01 20:26:13 -0600 (Sat, 01 Dec 2012) | 1 line - -some tweaks to mic in filter ------------------------------------------------------------------------- -r1107 | drowe67 | 2012-12-01 18:01:07 -0600 (Sat, 01 Dec 2012) | 1 line - -3 band equaliser for Mic In working on dialog, not connected to actual real time speech yet ------------------------------------------------------------------------- -r1106 | drowe67 | 2012-12-01 02:38:43 -0600 (Sat, 01 Dec 2012) | 1 line - -fixed some registry probs on Win32, read & write formats were different. Think its OK now ------------------------------------------------------------------------- -r1105 | drowe67 | 2012-12-01 01:46:36 -0600 (Sat, 01 Dec 2012) | 1 line - -reduced filter dialog size ------------------------------------------------------------------------- -r1104 | drowe67 | 2012-12-01 00:07:39 -0600 (Sat, 01 Dec 2012) | 1 line - -instructions for building sox on Win32 and modified win32 makefile for sox ------------------------------------------------------------------------- -r1103 | wittend99 | 2012-11-30 22:20:24 -0600 (Fri, 30 Nov 2012) | 1 line - -Fix some things about PTT. ------------------------------------------------------------------------- -r1102 | drowe67 | 2012-11-30 22:06:23 -0600 (Fri, 30 Nov 2012) | 1 line - -first pass at real time update of MicIn spectrum in response to slider ------------------------------------------------------------------------- -r1095 | drowe67 | 2012-11-30 19:56:34 -0600 (Fri, 30 Nov 2012) | 1 line - -reduced size of filter dialog so it fits on 800 high screens... ------------------------------------------------------------------------- -r1094 | drowe67 | 2012-11-30 19:09:11 -0600 (Fri, 30 Nov 2012) | 1 line - -equaliser: one slider partially connected ------------------------------------------------------------------------- -r1093 | wittend99 | 2012-11-30 18:52:49 -0600 (Fri, 30 Nov 2012) | 1 line - - ------------------------------------------------------------------------- -r1092 | drowe67 | 2012-11-30 18:02:09 -0600 (Fri, 30 Nov 2012) | 1 line - -wrote and unit tested library to use sox biqaud filter ------------------------------------------------------------------------- -r1091 | wittend99 | 2012-11-30 14:29:40 -0600 (Fri, 30 Nov 2012) | 1 line - - ------------------------------------------------------------------------- -r1090 | wittend99 | 2012-11-29 20:39:08 -0600 (Thu, 29 Nov 2012) | 1 line - -No more segfault, problem was not in this code. Fixes to the PTT signal polarity, should work now, but not properly tested. ------------------------------------------------------------------------- -r1088 | drowe67 | 2012-11-29 18:36:46 -0600 (Thu, 29 Nov 2012) | 1 line - -Win32 makefile and install notes for libctb ------------------------------------------------------------------------- -r1086 | drowe67 | 2012-11-29 17:30:25 -0600 (Thu, 29 Nov 2012) | 1 line - -modified Linux makefile for libctb, added build instructions for libctb ------------------------------------------------------------------------- -r1085 | wittend99 | 2012-11-29 16:22:25 -0600 (Thu, 29 Nov 2012) | 1 line - -I should have noted - this and the previous commit give me a segfault when the audio processing runs. ------------------------------------------------------------------------- -r1084 | wittend99 | 2012-11-29 16:18:52 -0600 (Thu, 29 Nov 2012) | 1 line - - ------------------------------------------------------------------------- -r1083 | drowe67 | 2012-11-26 23:03:09 -0600 (Mon, 26 Nov 2012) | 1 line - -rewrote callsign system along fdmdv1 lines ------------------------------------------------------------------------- -r1082 | drowe67 | 2012-11-26 21:39:17 -0600 (Mon, 26 Nov 2012) | 1 line - -rescaled waterfall and spectrum to be 300Hz wide, as per fdmdv1 ------------------------------------------------------------------------- -r1080 | drowe67 | 2012-11-26 20:41:12 -0600 (Mon, 26 Nov 2012) | 1 line - -added play file to From Radio option ------------------------------------------------------------------------- -r1079 | drowe67 | 2012-11-26 19:24:40 -0600 (Mon, 26 Nov 2012) | 1 line - -automatic scaling of spectrogram, and toggling color mapping. Think it works better but need to try on real signals ------------------------------------------------------------------------- -r1078 | drowe67 | 2012-11-26 16:48:17 -0600 (Mon, 26 Nov 2012) | 1 line - -implemented level guage on tx & rx inclduing too high warning ------------------------------------------------------------------------- -r1077 | drowe67 | 2012-11-26 14:43:08 -0600 (Mon, 26 Nov 2012) | 1 line - -number of secords to record from radio hard coded for Win32 as I cant read number of secs from dialog ctrl ------------------------------------------------------------------------- -r1073 | drowe67 | 2012-11-26 00:03:20 -0600 (Mon, 26 Nov 2012) | 1 line - -receive data now doing something sensible, but I think rxid window is too big ------------------------------------------------------------------------- -r1070 | wittend99 | 2012-11-25 20:37:41 -0600 (Sun, 25 Nov 2012) | 1 line - - ------------------------------------------------------------------------- -r1069 | drowe67 | 2012-11-25 18:23:24 -0600 (Sun, 25 Nov 2012) | 1 line - -first pass with data, can send messages and printf to screen. Need to think about silence thresholds/time outs ------------------------------------------------------------------------- -r1066 | drowe67 | 2012-11-25 03:34:47 -0600 (Sun, 25 Nov 2012) | 1 line - -tx id callback working on Linux ------------------------------------------------------------------------- -r1065 | drowe67 | 2012-11-25 03:28:31 -0600 (Sun, 25 Nov 2012) | 1 line - -started hooking up controls for tx and rx data experiments ------------------------------------------------------------------------- -r1064 | drowe67 | 2012-11-25 03:27:04 -0600 (Sun, 25 Nov 2012) | 1 line - -modified varicode decoder to retain state between calls so it can be interrupted half way thru decoding one character ------------------------------------------------------------------------- -r1063 | drowe67 | 2012-11-25 00:01:27 -0600 (Sun, 25 Nov 2012) | 1 line - -Filter dialog all hooked up to Codec, still requires testing ------------------------------------------------------------------------- -r1062 | wittend99 | 2012-11-24 20:38:37 -0600 (Sat, 24 Nov 2012) | 1 line - -Work on PTT control dialog. Not finished... ------------------------------------------------------------------------- -r1060 | drowe67 | 2012-11-24 18:00:28 -0600 (Sat, 24 Nov 2012) | 1 line - -basic filter dialog screen working, after usual pain with sizers ------------------------------------------------------------------------- -r1059 | drowe67 | 2012-11-24 16:03:07 -0600 (Sat, 24 Nov 2012) | 1 line - -added filter dialog, it displays OK but doesn't do anything yet. test OK under Linux ------------------------------------------------------------------------- -r1058 | drowe67 | 2012-11-24 05:02:48 -0600 (Sat, 24 Nov 2012) | 1 line - -varicode encoding and decoding, passes unittest ------------------------------------------------------------------------- -r1056 | drowe67 | 2012-11-23 17:27:07 -0600 (Fri, 23 Nov 2012) | 1 line - -minor tweaks to scatter scaling ------------------------------------------------------------------------- -r1055 | drowe67 | 2012-11-23 17:04:43 -0600 (Fri, 23 Nov 2012) | 1 line - -automatic scaling of scatter diagram, quite nice to watch ------------------------------------------------------------------------- -r1054 | drowe67 | 2012-11-23 16:39:17 -0600 (Fri, 23 Nov 2012) | 1 line - -higher resn FFT, red tuning line, automatic page switching on tx/rx, works OK on Linux ------------------------------------------------------------------------- -r1052 | drowe67 | 2012-11-23 13:51:46 -0600 (Fri, 23 Nov 2012) | 1 line - -modified Makefiles for DW cleanup, modified waterfall to handle slow waterfall updates where DT nmaps to less than one vertical pixel. Waterfall now covers 30 seconds. Works OK on Linux ------------------------------------------------------------------------- -r1051 | wittend99 | 2012-11-23 10:24:35 -0600 (Fri, 23 Nov 2012) | 1 line - -Removed unnecessary or distracting Files, C++ Classes, members, and unimplemented code. ------------------------------------------------------------------------- -r1050 | wittend99 | 2012-11-23 10:01:05 -0600 (Fri, 23 Nov 2012) | 1 line - - ------------------------------------------------------------------------- -r1049 | wittend99 | 2012-11-23 09:59:26 -0600 (Fri, 23 Nov 2012) | 1 line - - ------------------------------------------------------------------------- -r1048 | drowe67 | 2012-11-23 04:41:31 -0600 (Fri, 23 Nov 2012) | 1 line - -wired up squelch, added slow SNR option, works OK on Linux, need to test on Win32 ------------------------------------------------------------------------- -r1046 | drowe67 | 2012-11-22 13:39:05 -0600 (Thu, 22 Nov 2012) | 1 line - -modified split so tx doesn't change, version number in program title on main window, edited to-do ------------------------------------------------------------------------- -r1045 | drowe67 | 2012-11-21 17:28:54 -0600 (Wed, 21 Nov 2012) | 1 line - -click tune with split and tx logic, works OK on Linux ------------------------------------------------------------------------- -r1043 | drowe67 | 2012-11-20 23:31:22 -0600 (Tue, 20 Nov 2012) | 1 line - -tx and rx click tune, tied together (non split) ------------------------------------------------------------------------- -r1042 | drowe67 | 2012-11-20 22:57:41 -0600 (Tue, 20 Nov 2012) | 1 line - -rx click tune using globals resulted in a cleaner design although I would prefer not to have used globals. Maybe passing the address of the freq offset in the waterfall/spectrum constructor would have ben cleaner ------------------------------------------------------------------------- -r1041 | drowe67 | 2012-11-20 22:32:21 -0600 (Tue, 20 Nov 2012) | 1 line - -first pass at click to tune for rx. It works OK, but the communication of the click freq sucks so I might try re-writing that bit ------------------------------------------------------------------------- -r1040 | drowe67 | 2012-11-20 04:07:13 -0600 (Tue, 20 Nov 2012) | 1 line - -looks up svn revision from the Internet ------------------------------------------------------------------------- -r1039 | drowe67 | 2012-11-20 02:58:55 -0600 (Tue, 20 Nov 2012) | 1 line - -attemp at support for svn revsion under windows ------------------------------------------------------------------------- -r1038 | drowe67 | 2012-11-20 02:53:47 -0600 (Tue, 20 Nov 2012) | 1 line - -testing adding svn revision to about (yet again) ------------------------------------------------------------------------- -r1037 | drowe67 | 2012-11-20 02:52:51 -0600 (Tue, 20 Nov 2012) | 1 line - -testing adding svn revision to about (and again) ------------------------------------------------------------------------- -r1036 | drowe67 | 2012-11-20 02:45:28 -0600 (Tue, 20 Nov 2012) | 1 line - -testing adding svn revision to about (again) ------------------------------------------------------------------------- -r1035 | drowe67 | 2012-11-20 02:44:30 -0600 (Tue, 20 Nov 2012) | 1 line - -testing adding svn revision to about ------------------------------------------------------------------------- -r1034 | wittend99 | 2012-11-19 21:55:22 -0600 (Mon, 19 Nov 2012) | 1 line - -Modified the header comment block of all files to indicate GPL license. ------------------------------------------------------------------------- -r1033 | drowe67 | 2012-11-19 20:49:53 -0600 (Mon, 19 Nov 2012) | 1 line - -removed tx & rx loopback, as they no longer necc ------------------------------------------------------------------------- -r1032 | drowe67 | 2012-11-19 20:37:44 -0600 (Mon, 19 Nov 2012) | 1 line - -added record from radio feature, works OK on wave and raw files, can demod/decode aved files using command line tools ------------------------------------------------------------------------- -r1031 | drowe67 | 2012-11-19 04:14:34 -0600 (Mon, 19 Nov 2012) | 1 line - -wav and raw at the same time, can't position loop checkbox correctly... ------------------------------------------------------------------------- -r1030 | drowe67 | 2012-11-19 03:56:56 -0600 (Mon, 19 Nov 2012) | 1 line - -added some todos to readme.linux, added play file to mic in feature ------------------------------------------------------------------------- -r1024 | drowe67 | 2012-11-18 21:49:16 -0600 (Sun, 18 Nov 2012) | 1 line - -changed labels on audo config test, fifo header file change ------------------------------------------------------------------------- -r1023 | wittend99 | 2012-11-18 21:20:58 -0600 (Sun, 18 Nov 2012) | 1 line - - ------------------------------------------------------------------------- -r1016 | drowe67 | 2012-11-17 22:26:06 -0600 (Sat, 17 Nov 2012) | 1 line - -tried static text fields for API tab of audio config dlg ------------------------------------------------------------------------- -r1015 | drowe67 | 2012-11-17 17:03:02 -0600 (Sat, 17 Nov 2012) | 1 line - -was a bit unstable under ubuntu/alsa so added some mutex protection around fifo access that is shared by callsbacks and tx/rx processing threads. Alsa now seems more stable. ------------------------------------------------------------------------- -r1014 | drowe67 | 2012-11-17 16:07:23 -0600 (Sat, 17 Nov 2012) | 1 line - -experimental thread based tx/rx processing. Seems more stable on Windows and works better with Rig Blaster despite dirfting tx/rx sample clock. Still some start up transients, i.e. loss of sync in first few seconds and occasionally thereafter ------------------------------------------------------------------------- -r1001 | drowe67 | 2012-11-16 20:11:54 -0600 (Fri, 16 Nov 2012) | 1 line - -moved tx and rx processing to OnIdle, using device-defined buffer sizes for portaudio callbacks. Still testing. ------------------------------------------------------------------------- -r978 | drowe67 | 2012-11-15 22:08:38 -0600 (Thu, 15 Nov 2012) | 1 line - -experimental support for mono record devices such as the rig blaster, still testing ------------------------------------------------------------------------- -r970 | drowe67 | 2012-11-14 05:12:26 -0600 (Wed, 14 Nov 2012) | 1 line - -made sample rate combo box wider ------------------------------------------------------------------------- -r969 | drowe67 | 2012-11-14 02:17:13 -0600 (Wed, 14 Nov 2012) | 1 line - -nicer layout with test feature ------------------------------------------------------------------------- -r968 | drowe67 | 2012-11-13 16:34:42 -0600 (Tue, 13 Nov 2012) | 1 line - -test feature for all 4 audio devices, tested OK on Ubuntu 9.10, needs work on the layout ------------------------------------------------------------------------- -r967 | drowe67 | 2012-11-13 02:18:53 -0600 (Tue, 13 Nov 2012) | 1 line - -first pass at a test tool for audio config dialog that plots input to a little screen. Just rx in at this stage. Some indication that it is occasionally unstable. Might need to convert to async/callback model ------------------------------------------------------------------------- -r966 | drowe67 | 2012-11-12 17:03:04 -0600 (Mon, 12 Nov 2012) | 1 line - -Sync indicator now works for Windows, but isn't multicolour like on Linux. As it is implemented with a radio button, unfortunately the user can press it. ------------------------------------------------------------------------- -r965 | drowe67 | 2012-11-12 16:23:18 -0600 (Mon, 12 Nov 2012) | 1 line - -minor tweaks to SNR positioning ------------------------------------------------------------------------- -r964 | drowe67 | 2012-11-12 15:43:36 -0600 (Mon, 12 Nov 2012) | 1 line - -Testing wxlogdebug and added device number to device name in config dialog to help ID devices with the same name under Windows ------------------------------------------------------------------------- -r963 | drowe67 | 2012-11-12 14:22:51 -0600 (Mon, 12 Nov 2012) | 1 line - -added some notes to Linux README ------------------------------------------------------------------------- -r962 | wittend99 | 2012-11-12 13:53:33 -0600 (Mon, 12 Nov 2012) | 1 line - - ------------------------------------------------------------------------- -r961 | drowe67 | 2012-11-11 22:40:02 -0600 (Sun, 11 Nov 2012) | 1 line - -small sample rate selection bug ------------------------------------------------------------------------- -r960 | drowe67 | 2012-11-11 22:30:48 -0600 (Sun, 11 Nov 2012) | 1 line - -fixed bug, can now run soudn card1 at 44kHz ------------------------------------------------------------------------- -r959 | drowe67 | 2012-11-11 19:34:32 -0600 (Sun, 11 Nov 2012) | 1 line - -After testing on an Alsa based Ubuntu 10 machine: tweaked layout, added dynamic sample rate list generation to dlg_audioconfig, refactored a few routines that got messy, and separated portaudio device number from list box index to support non-duplex devices ------------------------------------------------------------------------- -r958 | drowe67 | 2012-11-11 15:58:29 -0600 (Sun, 11 Nov 2012) | 1 line - -improved detection of erros due to removed sound card ------------------------------------------------------------------------- -r957 | drowe67 | 2012-11-11 04:05:21 -0600 (Sun, 11 Nov 2012) | 1 line - -disable Audio Config dialog when running ------------------------------------------------------------------------- -r956 | drowe67 | 2012-11-10 19:22:01 -0600 (Sat, 10 Nov 2012) | 1 line - -first pass at connecting audio config dialog to rest of system. Can configure single and dual card systems on Unbuntu 9.10. Still a few situations that can crash system ------------------------------------------------------------------------- -r955 | drowe67 | 2012-11-08 22:38:02 -0600 (Thu, 08 Nov 2012) | 1 line - -removed some accel key debug warnings on start up ------------------------------------------------------------------------- -r954 | drowe67 | 2012-11-08 21:16:52 -0600 (Thu, 08 Nov 2012) | 1 line - -peristent storing of squelch levels to config file ------------------------------------------------------------------------- -r953 | drowe67 | 2012-11-08 20:43:55 -0600 (Thu, 08 Nov 2012) | 1 line - -wired up analog mode ------------------------------------------------------------------------- -r952 | drowe67 | 2012-11-08 20:29:35 -0600 (Thu, 08 Nov 2012) | 1 line - -removed ALC ------------------------------------------------------------------------- -r951 | drowe67 | 2012-11-08 19:56:45 -0600 (Thu, 08 Nov 2012) | 1 line - -positioned squelch and snr static text correctly and stays centred ------------------------------------------------------------------------- -r950 | drowe67 | 2012-11-07 22:19:29 -0600 (Wed, 07 Nov 2012) | 1 line - -playing with squelch slider, but not happy with layout ------------------------------------------------------------------------- -r949 | drowe67 | 2012-11-07 19:35:43 -0600 (Wed, 07 Nov 2012) | 1 line - -hooked up sync LED, changed SNR text box to static text to prevent it getting focus ------------------------------------------------------------------------- -r948 | drowe67 | 2012-11-07 17:14:42 -0600 (Wed, 07 Nov 2012) | 1 line - -formatting, and added freq shifter in front of demod to suport click tune feature ------------------------------------------------------------------------- -r944 | wittend99 | 2012-11-07 13:09:14 -0600 (Wed, 07 Nov 2012) | 1 line - -Remove dependencies in Icon files in dlg_audiooptions.*. Eliminated use of icons for now. They were ugly anyway. Dialog returns the string form of the chosen interface, and not the if # for now. This can be trivially changed. ------------------------------------------------------------------------- -r939 | wittend99 | 2012-11-06 20:09:35 -0600 (Tue, 06 Nov 2012) | 1 line - -Changed dlg_audio.* to dlg_audiooptions.*, changed other dlg code, altered makefiles. ------------------------------------------------------------------------- -r938 | wittend99 | 2012-11-06 08:18:21 -0600 (Tue, 06 Nov 2012) | 1 line - - ------------------------------------------------------------------------- -r937 | drowe67 | 2012-11-05 18:47:29 -0600 (Mon, 05 Nov 2012) | 1 line - -Added editor set up instructions to avoid problems with tabs ------------------------------------------------------------------------- -r936 | drowe67 | 2012-11-05 17:58:54 -0600 (Mon, 05 Nov 2012) | 1 line - -changed Davids emacs to use spaces rather than tabs ------------------------------------------------------------------------- -r935 | wittend99 | 2012-11-05 13:22:16 -0600 (Mon, 05 Nov 2012) | 1 line - - ------------------------------------------------------------------------- -r934 | drowe67 | 2012-11-05 02:20:38 -0600 (Mon, 05 Nov 2012) | 1 line - -Added libresample ------------------------------------------------------------------------- -r933 | drowe67 | 2012-11-05 02:18:35 -0600 (Mon, 05 Nov 2012) | 1 line - -added libsamplerate ------------------------------------------------------------------------- -r932 | drowe67 | 2012-11-05 01:46:54 -0600 (Mon, 05 Nov 2012) | 1 line - -SNR text box and bar graph hooked up ------------------------------------------------------------------------- -r931 | drowe67 | 2012-11-04 23:25:34 -0600 (Sun, 04 Nov 2012) | 1 line - -building up soundcard auto detect code ------------------------------------------------------------------------- -r930 | drowe67 | 2012-11-04 23:04:49 -0600 (Sun, 04 Nov 2012) | 1 line - -improved speech plots with a better decimation algorithm ------------------------------------------------------------------------- -r928 | drowe67 | 2012-11-04 18:23:51 -0600 (Sun, 04 Nov 2012) | 1 line - -added experimental waveform plots, the idea is to usethm as a tool to adjust levels. Not sure if they are useful yet... ------------------------------------------------------------------------- -r927 | drowe67 | 2012-11-04 17:11:29 -0600 (Sun, 04 Nov 2012) | 1 line - -first pass at plot-scalar working to produce timing and frequency offset plots ------------------------------------------------------------------------- -r926 | drowe67 | 2012-11-03 17:15:48 -0500 (Sat, 03 Nov 2012) | 1 line - -cleaned up some code after adjusting demod sample rate slip ------------------------------------------------------------------------- -r924 | drowe67 | 2012-11-03 16:30:41 -0500 (Sat, 03 Nov 2012) | 1 line - -refactored sample rate conversion code to clean up sound card 1 call back, works OK ------------------------------------------------------------------------- -r923 | wittend99 | 2012-11-03 10:57:11 -0500 (Sat, 03 Nov 2012) | 1 line - - ------------------------------------------------------------------------- -r922 | drowe67 | 2012-11-03 02:53:32 -0500 (Sat, 03 Nov 2012) | 1 line - -shutdown codec for libresample states ------------------------------------------------------------------------- -r921 | drowe67 | 2012-11-03 01:32:20 -0500 (Sat, 03 Nov 2012) | 1 line - -libresample used for all 4 sample rate conversions, but needs clean up into functions. ------------------------------------------------------------------------- -r920 | drowe67 | 2012-11-03 01:13:21 -0500 (Sat, 03 Nov 2012) | 1 line - -partial port to libresample, using 48kHz for one sound card and 44.1kHz for another ------------------------------------------------------------------------- -r918 | drowe67 | 2012-11-02 01:26:16 -0500 (Fri, 02 Nov 2012) | 1 line - -debug version while testing different headphones ------------------------------------------------------------------------- -r917 | drowe67 | 2012-11-01 21:56:57 -0500 (Thu, 01 Nov 2012) | 1 line - -working better with new headphones - about to remove some debug printfs ------------------------------------------------------------------------- -r916 | drowe67 | 2012-11-01 19:02:56 -0500 (Thu, 01 Nov 2012) | 1 line - -debug version, looking for reason mic audio is getting corrupted ------------------------------------------------------------------------- -r915 | wittend99 | 2012-11-01 17:31:35 -0500 (Thu, 01 Nov 2012) | 1 line - - ------------------------------------------------------------------------- -r902 | drowe67 | 2012-10-30 20:58:52 -0500 (Tue, 30 Oct 2012) | 1 line - -modified for independant in and output portaudio devices to suit Win32. ------------------------------------------------------------------------- -r901 | drowe67 | 2012-10-30 19:18:00 -0500 (Tue, 30 Oct 2012) | 1 line - -first pass at full duplex working ... two sound card, tx looped back to rx audio, can hear what I am saying in headset. Still some stability issues ------------------------------------------------------------------------- -r900 | drowe67 | 2012-10-30 18:40:11 -0500 (Tue, 30 Oct 2012) | 1 line - -have tx process doing something with one sound card - it sends a signal that I can loop back to rx with good quality scatter diagram. Next stage is to enable the 2nd sound card ------------------------------------------------------------------------- -r899 | drowe67 | 2012-10-30 01:18:02 -0500 (Tue, 30 Oct 2012) | 1 line - -first attempt at support for two sound cardsand tx processing. Debugging tx side ------------------------------------------------------------------------- -r888 | drowe67 | 2012-10-28 22:29:37 -0500 (Sun, 28 Oct 2012) | 1 line - -replaced buffers in rx callback with fifos to ease porting to two sound cards ------------------------------------------------------------------------- -r873 | wittend99 | 2012-10-28 18:14:06 -0500 (Sun, 28 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r855 | drowe67 | 2012-10-28 03:31:55 -0500 (Sun, 28 Oct 2012) | 1 line - -changed portaudio buffer size to make OSS work a little better on Ububtu 9.10 - but still cant adjust mic gain ------------------------------------------------------------------------- -r831 | drowe67 | 2012-10-27 00:36:22 -0500 (Sat, 27 Oct 2012) | 1 line - -Fixed Waterfall/Spectrum axis labels on windows. Rx loop also decodes modem signals OK, sounds good, no clicks or pops! ------------------------------------------------------------------------- -r829 | drowe67 | 2012-10-26 18:47:18 -0500 (Fri, 26 Oct 2012) | 1 line - -Davids R's first version building on Win32 ------------------------------------------------------------------------- -r825 | wittend99 | 2012-10-25 17:05:20 -0500 (Thu, 25 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r816 | wittend99 | 2012-10-25 14:34:02 -0500 (Thu, 25 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r815 | wittend99 | 2012-10-25 14:27:38 -0500 (Thu, 25 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r814 | wittend99 | 2012-10-25 14:23:10 -0500 (Thu, 25 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r813 | wittend99 | 2012-10-25 13:45:14 -0500 (Thu, 25 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r812 | wittend99 | 2012-10-25 13:39:14 -0500 (Thu, 25 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r811 | wittend99 | 2012-10-25 08:50:56 -0500 (Thu, 25 Oct 2012) | 1 line - -Just update my IDE configuration probably of no interest to anyone but me. DMW ------------------------------------------------------------------------- -r804 | wittend99 | 2012-10-24 10:30:04 -0500 (Wed, 24 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r803 | drowe67 | 2012-10-24 03:14:35 -0500 (Wed, 24 Oct 2012) | 1 line - -first pass at a working scatter plot - haven't tested on real modem signals yet ------------------------------------------------------------------------- -r802 | drowe67 | 2012-10-23 19:50:22 -0500 (Tue, 23 Oct 2012) | 1 line - -renamed a few variables for consistency, spectrum now working ------------------------------------------------------------------------- -r801 | drowe67 | 2012-10-23 19:20:06 -0500 (Tue, 23 Oct 2012) | 1 line - -fixed axis labels on waterfall and tweaked those on spectrum ------------------------------------------------------------------------- -r800 | wittend99 | 2012-10-23 17:12:37 -0500 (Tue, 23 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r799 | wittend99 | 2012-10-23 17:07:13 -0500 (Tue, 23 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r798 | drowe67 | 2012-10-23 16:03:44 -0500 (Tue, 23 Oct 2012) | 1 line - -spectrum plot drawGraticule() working OK with nice labels ------------------------------------------------------------------------- -r797 | drowe67 | 2012-10-23 05:05:13 -0500 (Tue, 23 Oct 2012) | 1 line - -added some code to handle resizing better, and fact OnSize can't be relied upon to be called for bit map allocation ------------------------------------------------------------------------- -r796 | drowe67 | 2012-10-23 04:37:49 -0500 (Tue, 23 Oct 2012) | 1 line - -cleaned up a little, made var names consistent with plot spectrum ------------------------------------------------------------------------- -r795 | drowe67 | 2012-10-23 04:26:30 -0500 (Tue, 23 Oct 2012) | 1 line - -fixed wrong window dimensions, was reading past endof array and writing past end of bit map ------------------------------------------------------------------------- -r794 | wittend99 | 2012-10-22 10:46:47 -0500 (Mon, 22 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r793 | wittend99 | 2012-10-22 10:31:13 -0500 (Mon, 22 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r792 | wittend99 | 2012-10-22 10:21:49 -0500 (Mon, 22 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r791 | wittend99 | 2012-10-22 10:20:43 -0500 (Mon, 22 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r790 | wittend99 | 2012-10-22 10:11:26 -0500 (Mon, 22 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r789 | wittend99 | 2012-10-22 10:10:00 -0500 (Mon, 22 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r788 | wittend99 | 2012-10-22 10:09:37 -0500 (Mon, 22 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r787 | drowe67 | 2012-10-21 20:35:43 -0500 (Sun, 21 Oct 2012) | 1 line - -spent a few hours trying to debug Stop not erasing bottom 25% of Waterfall, but haven't fixed bug. Leaving for now ------------------------------------------------------------------------- -r786 | drowe67 | 2012-10-20 18:59:33 -0500 (Sat, 20 Oct 2012) | 1 line - -waterfall working at slow update rate on Linux, some visual bugs on stop & restart ------------------------------------------------------------------------- -r785 | drowe67 | 2012-10-20 17:58:04 -0500 (Sat, 20 Oct 2012) | 1 line - -related timer period to update interval of Waterfall ------------------------------------------------------------------------- -r784 | drowe67 | 2012-10-20 17:56:42 -0500 (Sat, 20 Oct 2012) | 1 line - -removed debug printfs ------------------------------------------------------------------------- -r783 | drowe67 | 2012-10-20 17:50:34 -0500 (Sat, 20 Oct 2012) | 1 line - -free g_RxInBuf on Stop ------------------------------------------------------------------------- -r782 | drowe67 | 2012-10-19 21:29:23 -0500 (Fri, 19 Oct 2012) | 1 line - -bottom line of spectrogram working at 500ms period ------------------------------------------------------------------------- -r781 | drowe67 | 2012-10-19 18:22:35 -0500 (Fri, 19 Oct 2012) | 1 line - -bitmap test pattern working ------------------------------------------------------------------------- -r780 | drowe67 | 2012-10-19 16:43:56 -0500 (Fri, 19 Oct 2012) | 1 line - -libsndfile support ------------------------------------------------------------------------- -r779 | wittend99 | 2012-10-19 16:28:59 -0500 (Fri, 19 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r778 | wittend99 | 2012-10-19 07:54:57 -0500 (Fri, 19 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r777 | drowe67 | 2012-10-18 23:50:43 -0500 (Thu, 18 Oct 2012) | 1 line - -initial cjeck in of wxWdigets image test dir ------------------------------------------------------------------------- -r766 | wittend99 | 2012-10-17 07:53:44 -0500 (Wed, 17 Oct 2012) | 2 lines - -minimal changes. - ------------------------------------------------------------------------- -r765 | wittend99 | 2012-10-16 12:25:48 -0500 (Tue, 16 Oct 2012) | 1 line - -Updating doxygen documentation and removing some unnecessary junk that has accumulated. ------------------------------------------------------------------------- -r764 | wittend99 | 2012-10-16 10:32:32 -0500 (Tue, 16 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r763 | wittend99 | 2012-10-16 10:17:09 -0500 (Tue, 16 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r762 | wittend99 | 2012-10-16 10:16:45 -0500 (Tue, 16 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r761 | wittend99 | 2012-10-15 21:01:27 -0500 (Mon, 15 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r760 | wittend99 | 2012-10-15 20:29:25 -0500 (Mon, 15 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r759 | wittend99 | 2012-10-15 20:28:47 -0500 (Mon, 15 Oct 2012) | 1 line - - ------------------------------------------------------------------------- -r757 | drowe67 | 2012-10-15 16:19:49 -0500 (Mon, 15 Oct 2012) | 1 line - -main demod processing loop runs without crashing ------------------------------------------------------------------------- -r752 | drowe67 | 2012-10-14 22:59:03 -0500 (Sun, 14 Oct 2012) | 1 line - -added a fifo buffer to interface between framesPerBufferof portaudio and the buffer size we need for modem processing. Basic audio loopback working now ------------------------------------------------------------------------- -r748 | drowe67 | 2012-10-13 16:50:57 -0500 (Sat, 13 Oct 2012) | 1 line - -build instructions for Linux ------------------------------------------------------------------------- -r747 | drowe67 | 2012-10-13 02:25:50 -0500 (Sat, 13 Oct 2012) | 1 line - -temp. disabled timer and rx callback to stabilise, can start/stop without crashing now ------------------------------------------------------------------------- -r746 | drowe67 | 2012-10-13 01:32:03 -0500 (Sat, 13 Oct 2012) | 1 line - -re-orged linux Makefile a little ------------------------------------------------------------------------- -r745 | wittend99 | 2012-10-12 16:49:51 -0500 (Fri, 12 Oct 2012) | 1 line - -Convert line endings to UNIX style for readability. ------------------------------------------------------------------------- -r744 | drowe67 | 2012-10-11 19:53:06 -0500 (Thu, 11 Oct 2012) | 1 line - -changed syntax of extern g_avmag to fix segfault ------------------------------------------------------------------------- -r743 | drowe67 | 2012-10-11 18:29:14 -0500 (Thu, 11 Oct 2012) | 1 line - -added setColour to prevent bombing on Linux ------------------------------------------------------------------------- -r742 | drowe67 | 2012-10-11 00:16:50 -0500 (Thu, 11 Oct 2012) | 1 line - -first pass at Makefile for Linux ------------------------------------------------------------------------- -r740 | wittend99 | 2012-10-09 22:31:50 -0500 (Tue, 09 Oct 2012) | 1 line - -Killer bug. Data point array not initialized? ------------------------------------------------------------------------- -r739 | wittend99 | 2012-10-08 08:29:38 -0500 (Mon, 08 Oct 2012) | 1 line - -Receive side connected, segfault still to be tracked down. ------------------------------------------------------------------------- -r738 | wittend99 | 2012-10-06 14:16:25 -0500 (Sat, 06 Oct 2012) | 1 line - -Various incremental advances. Not 'there' yet. ------------------------------------------------------------------------- -r731 | wittend99 | 2012-09-19 12:21:32 -0500 (Wed, 19 Sep 2012) | 1 line - - ------------------------------------------------------------------------- -r730 | wittend99 | 2012-09-19 12:11:30 -0500 (Wed, 19 Sep 2012) | 1 line - - ------------------------------------------------------------------------- -r716 | wittend99 | 2012-09-17 13:16:46 -0500 (Mon, 17 Sep 2012) | 1 line - - ------------------------------------------------------------------------- -r712 | wittend99 | 2012-09-14 18:26:51 -0500 (Fri, 14 Sep 2012) | 1 line - - ------------------------------------------------------------------------- -r676 | wittend99 | 2012-09-11 15:10:16 -0500 (Tue, 11 Sep 2012) | 1 line - - ------------------------------------------------------------------------- -r675 | wittend99 | 2012-09-11 14:58:36 -0500 (Tue, 11 Sep 2012) | 1 line - - ------------------------------------------------------------------------- -r674 | wittend99 | 2012-09-11 14:51:11 -0500 (Tue, 11 Sep 2012) | 1 line - -no longer needed. ------------------------------------------------------------------------- -r673 | wittend99 | 2012-09-11 14:49:55 -0500 (Tue, 11 Sep 2012) | 1 line - -no longer needed. ------------------------------------------------------------------------- -r672 | wittend99 | 2012-09-11 14:44:56 -0500 (Tue, 11 Sep 2012) | 1 line - - ------------------------------------------------------------------------- -r671 | wittend99 | 2012-09-11 14:36:45 -0500 (Tue, 11 Sep 2012) | 1 line - - ------------------------------------------------------------------------- -r670 | wittend99 | 2012-09-11 12:13:28 -0500 (Tue, 11 Sep 2012) | 1 line - - ------------------------------------------------------------------------- -r667 | wittend99 | 2012-09-10 11:45:37 -0500 (Mon, 10 Sep 2012) | 1 line - - ------------------------------------------------------------------------- -r666 | wittend99 | 2012-09-10 11:25:14 -0500 (Mon, 10 Sep 2012) | 1 line - -Beginning to add some code documentation using Doxygen. ------------------------------------------------------------------------- -r663 | wittend99 | 2012-09-04 21:54:00 -0500 (Tue, 04 Sep 2012) | 1 line - - ------------------------------------------------------------------------- -r662 | wittend99 | 2012-09-04 21:47:34 -0500 (Tue, 04 Sep 2012) | 1 line - - ------------------------------------------------------------------------- -r660 | wittend99 | 2012-09-04 15:44:29 -0500 (Tue, 04 Sep 2012) | 1 line - - ------------------------------------------------------------------------- -r659 | wittend99 | 2012-09-04 15:43:00 -0500 (Tue, 04 Sep 2012) | 1 line - - ------------------------------------------------------------------------- -r658 | wittend99 | 2012-09-04 15:40:24 -0500 (Tue, 04 Sep 2012) | 1 line - - ------------------------------------------------------------------------- -r647 | wittend99 | 2012-08-28 23:03:56 -0500 (Tue, 28 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r646 | wittend99 | 2012-08-28 22:54:54 -0500 (Tue, 28 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r645 | wittend99 | 2012-08-28 22:50:53 -0500 (Tue, 28 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r643 | wittend99 | 2012-08-27 12:01:45 -0500 (Mon, 27 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r639 | wittend99 | 2012-08-24 14:01:17 -0500 (Fri, 24 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r638 | wittend99 | 2012-08-24 14:00:49 -0500 (Fri, 24 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r637 | wittend99 | 2012-08-24 13:56:48 -0500 (Fri, 24 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r636 | wittend99 | 2012-08-22 12:33:04 -0500 (Wed, 22 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r634 | wittend99 | 2012-08-21 16:29:09 -0500 (Tue, 21 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r633 | wittend99 | 2012-08-21 13:26:23 -0500 (Tue, 21 Aug 2012) | 1 line - -Working to get an Autotools build in place. ------------------------------------------------------------------------- -r632 | wittend99 | 2012-08-20 15:09:21 -0500 (Mon, 20 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r631 | wittend99 | 2012-08-20 14:54:14 -0500 (Mon, 20 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r630 | wittend99 | 2012-08-20 14:53:49 -0500 (Mon, 20 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r629 | wittend99 | 2012-08-20 14:52:31 -0500 (Mon, 20 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r628 | wittend99 | 2012-08-20 14:43:10 -0500 (Mon, 20 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r627 | wittend99 | 2012-08-17 15:57:31 -0500 (Fri, 17 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r626 | wittend99 | 2012-08-17 15:50:27 -0500 (Fri, 17 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r625 | wittend99 | 2012-08-17 15:50:00 -0500 (Fri, 17 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r624 | wittend99 | 2012-08-17 15:48:58 -0500 (Fri, 17 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r623 | wittend99 | 2012-08-17 15:43:19 -0500 (Fri, 17 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r622 | wittend99 | 2012-08-17 15:42:13 -0500 (Fri, 17 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r621 | wittend99 | 2012-08-17 15:20:38 -0500 (Fri, 17 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r620 | wittend99 | 2012-08-17 15:18:55 -0500 (Fri, 17 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r619 | wittend99 | 2012-08-17 15:18:39 -0500 (Fri, 17 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r618 | wittend99 | 2012-08-17 15:18:24 -0500 (Fri, 17 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r617 | wittend99 | 2012-08-17 15:10:20 -0500 (Fri, 17 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r616 | wittend99 | 2012-08-17 15:07:18 -0500 (Fri, 17 Aug 2012) | 1 line - -For variant versions ------------------------------------------------------------------------- -r615 | wittend99 | 2012-08-17 15:05:10 -0500 (Fri, 17 Aug 2012) | 1 line - -Moved to ./3rdparty ------------------------------------------------------------------------- -r614 | wittend99 | 2012-08-17 15:03:59 -0500 (Fri, 17 Aug 2012) | 1 line - -Moved to ./3rdparty ------------------------------------------------------------------------- -r613 | wittend99 | 2012-08-17 15:02:47 -0500 (Fri, 17 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r612 | wittend99 | 2012-08-14 21:31:28 -0500 (Tue, 14 Aug 2012) | 1 line - - ------------------------------------------------------------------------- -r589 | wittend99 | 2012-07-15 15:45:52 -0500 (Sun, 15 Jul 2012) | 1 line - - ------------------------------------------------------------------------- -r588 | wittend99 | 2012-07-15 15:44:30 -0500 (Sun, 15 Jul 2012) | 1 line - - ------------------------------------------------------------------------- -r571 | wittend99 | 2012-06-18 10:10:40 -0500 (Mon, 18 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r570 | wittend99 | 2012-06-18 10:07:01 -0500 (Mon, 18 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r569 | wittend99 | 2012-06-18 10:06:26 -0500 (Mon, 18 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r568 | wittend99 | 2012-06-18 10:04:56 -0500 (Mon, 18 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r567 | wittend99 | 2012-06-18 10:04:10 -0500 (Mon, 18 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r566 | wittend99 | 2012-06-18 09:16:14 -0500 (Mon, 18 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r565 | wittend99 | 2012-06-18 09:13:02 -0500 (Mon, 18 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r564 | wittend99 | 2012-06-18 09:10:53 -0500 (Mon, 18 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r563 | wittend99 | 2012-06-18 09:08:49 -0500 (Mon, 18 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r562 | wittend99 | 2012-06-18 08:54:08 -0500 (Mon, 18 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r561 | wittend99 | 2012-06-18 08:52:45 -0500 (Mon, 18 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r560 | wittend99 | 2012-06-18 08:52:08 -0500 (Mon, 18 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r559 | wittend99 | 2012-06-18 08:51:00 -0500 (Mon, 18 Jun 2012) | 1 line - -Update svn:ignore ------------------------------------------------------------------------- -r558 | wittend99 | 2012-06-18 08:45:24 -0500 (Mon, 18 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r557 | wittend99 | 2012-06-18 08:44:06 -0500 (Mon, 18 Jun 2012) | 1 line - -Some cleanup ------------------------------------------------------------------------- -r556 | wittend99 | 2012-06-17 10:05:25 -0500 (Sun, 17 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r555 | wittend99 | 2012-06-17 10:03:12 -0500 (Sun, 17 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r554 | wittend99 | 2012-06-17 10:02:44 -0500 (Sun, 17 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r553 | wittend99 | 2012-06-17 10:00:29 -0500 (Sun, 17 Jun 2012) | 1 line - -Bunches of work on portaudio, still not done. Added fdmdvBasic tor testing, it is the same as the main app without the graphic spectrum display. It may not be useful for without the waterfall display for tuning. ------------------------------------------------------------------------- -r551 | wittend99 | 2012-06-15 09:26:24 -0500 (Fri, 15 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r550 | wittend99 | 2012-06-15 09:25:06 -0500 (Fri, 15 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r549 | wittend99 | 2012-06-15 09:20:30 -0500 (Fri, 15 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r548 | wittend99 | 2012-06-15 09:19:41 -0500 (Fri, 15 Jun 2012) | 1 line - -experiments ------------------------------------------------------------------------- -r547 | wittend99 | 2012-06-15 09:18:07 -0500 (Fri, 15 Jun 2012) | 1 line - -update build from codec2-dev 545 ------------------------------------------------------------------------- -r546 | wittend99 | 2012-06-12 07:30:44 -0500 (Tue, 12 Jun 2012) | 1 line - - ------------------------------------------------------------------------- -r521 | wittend99 | 2012-05-30 21:53:15 -0500 (Wed, 30 May 2012) | 1 line - -Still working on the audio dialog, mostly. ------------------------------------------------------------------------- -r520 | wittend99 | 2012-05-29 22:43:11 -0500 (Tue, 29 May 2012) | 1 line - -Work on portaudio dialog, misc. cleanup. ------------------------------------------------------------------------- -r518 | wittend99 | 2012-05-29 18:27:43 -0500 (Tue, 29 May 2012) | 1 line - - ------------------------------------------------------------------------- -r517 | wittend99 | 2012-05-29 18:26:27 -0500 (Tue, 29 May 2012) | 1 line - - ------------------------------------------------------------------------- -r516 | wittend99 | 2012-05-29 18:07:56 -0500 (Tue, 29 May 2012) | 1 line - - ------------------------------------------------------------------------- -r515 | wittend99 | 2012-05-29 17:53:59 -0500 (Tue, 29 May 2012) | 1 line - - ------------------------------------------------------------------------- -r514 | wittend99 | 2012-05-29 17:53:42 -0500 (Tue, 29 May 2012) | 1 line - - ------------------------------------------------------------------------- -r513 | wittend99 | 2012-05-29 17:53:00 -0500 (Tue, 29 May 2012) | 1 line - - ------------------------------------------------------------------------- -r512 | wittend99 | 2012-05-29 17:50:22 -0500 (Tue, 29 May 2012) | 1 line - - ------------------------------------------------------------------------- -r511 | wittend99 | 2012-05-29 17:49:51 -0500 (Tue, 29 May 2012) | 1 line - - ------------------------------------------------------------------------- -r510 | wittend99 | 2012-05-29 17:49:13 -0500 (Tue, 29 May 2012) | 1 line - - ------------------------------------------------------------------------- -r509 | wittend99 | 2012-05-29 17:48:28 -0500 (Tue, 29 May 2012) | 1 line - - ------------------------------------------------------------------------- -r508 | wittend99 | 2012-05-29 17:47:54 -0500 (Tue, 29 May 2012) | 1 line - - ------------------------------------------------------------------------- -r507 | wittend99 | 2012-05-29 17:35:24 -0500 (Tue, 29 May 2012) | 1 line - - ------------------------------------------------------------------------- -r505 | wittend99 | 2012-05-27 12:34:55 -0500 (Sun, 27 May 2012) | 1 line - - ------------------------------------------------------------------------- -r504 | wittend99 | 2012-05-27 10:44:30 -0500 (Sun, 27 May 2012) | 1 line - - ------------------------------------------------------------------------- -r503 | wittend99 | 2012-05-27 10:41:44 -0500 (Sun, 27 May 2012) | 1 line - - ------------------------------------------------------------------------- -r502 | wittend99 | 2012-05-26 22:10:12 -0500 (Sat, 26 May 2012) | 1 line - - ------------------------------------------------------------------------- -r501 | wittend99 | 2012-05-26 21:53:08 -0500 (Sat, 26 May 2012) | 1 line - -fdmdv2dll builds, as yet untested though. ------------------------------------------------------------------------- -r500 | wittend99 | 2012-05-26 09:05:50 -0500 (Sat, 26 May 2012) | 1 line - - ------------------------------------------------------------------------- -r499 | wittend99 | 2012-05-26 08:31:29 -0500 (Sat, 26 May 2012) | 1 line - -changed this to fdmdv2dll ------------------------------------------------------------------------- -r498 | wittend99 | 2012-05-26 08:30:03 -0500 (Sat, 26 May 2012) | 1 line - -Attempting to clean up the project. ------------------------------------------------------------------------- -r497 | wittend99 | 2012-05-26 08:26:01 -0500 (Sat, 26 May 2012) | 1 line - - ------------------------------------------------------------------------- -r495 | wittend99 | 2012-05-26 07:59:29 -0500 (Sat, 26 May 2012) | 1 line - - ------------------------------------------------------------------------- -r494 | wittend99 | 2012-05-26 07:17:59 -0500 (Sat, 26 May 2012) | 1 line - - ------------------------------------------------------------------------- -r493 | wittend99 | 2012-05-26 07:17:28 -0500 (Sat, 26 May 2012) | 1 line - - ------------------------------------------------------------------------- -r491 | wittend99 | 2012-05-24 18:46:43 -0500 (Thu, 24 May 2012) | 1 line - - ------------------------------------------------------------------------- -r486 | wittend99 | 2012-05-21 21:23:11 -0500 (Mon, 21 May 2012) | 1 line - - ------------------------------------------------------------------------- -r485 | wittend99 | 2012-05-19 20:58:55 -0500 (Sat, 19 May 2012) | 1 line - - ------------------------------------------------------------------------- -r480 | wittend99 | 2012-05-17 21:16:32 -0500 (Thu, 17 May 2012) | 1 line - - ------------------------------------------------------------------------- -r479 | wittend99 | 2012-05-17 21:10:59 -0500 (Thu, 17 May 2012) | 1 line - - ------------------------------------------------------------------------- -r478 | wittend99 | 2012-05-17 21:09:48 -0500 (Thu, 17 May 2012) | 1 line - - ------------------------------------------------------------------------- -r477 | wittend99 | 2012-05-17 21:08:19 -0500 (Thu, 17 May 2012) | 1 line - - ------------------------------------------------------------------------- -r476 | wittend99 | 2012-05-17 21:07:58 -0500 (Thu, 17 May 2012) | 1 line - - ------------------------------------------------------------------------- -r475 | wittend99 | 2012-05-17 21:06:15 -0500 (Thu, 17 May 2012) | 1 line - -Catching up before things get into a snarl. ------------------------------------------------------------------------- -r474 | wittend99 | 2012-05-17 13:06:55 -0500 (Thu, 17 May 2012) | 1 line - -More basic required library files. ------------------------------------------------------------------------- -r473 | wittend99 | 2012-05-17 12:54:14 -0500 (Thu, 17 May 2012) | 1 line - - ------------------------------------------------------------------------- -r472 | wittend99 | 2012-05-17 10:08:08 -0500 (Thu, 17 May 2012) | 1 line - - ------------------------------------------------------------------------- -r471 | wittend99 | 2012-05-17 10:03:24 -0500 (Thu, 17 May 2012) | 1 line - -More work with portaudiocpp ------------------------------------------------------------------------- -r470 | wittend99 | 2012-05-15 21:31:30 -0500 (Tue, 15 May 2012) | 1 line - - ------------------------------------------------------------------------- -r469 | wittend99 | 2012-05-15 14:11:26 -0500 (Tue, 15 May 2012) | 1 line - -synching things up... ------------------------------------------------------------------------- -r468 | wittend99 | 2012-05-15 14:07:29 -0500 (Tue, 15 May 2012) | 1 line - - ------------------------------------------------------------------------- -r467 | wittend99 | 2012-05-15 08:47:57 -0500 (Tue, 15 May 2012) | 1 line - -Fun with portaudio! ------------------------------------------------------------------------- -r466 | wittend99 | 2012-05-15 08:44:43 -0500 (Tue, 15 May 2012) | 1 line - - ------------------------------------------------------------------------- -r465 | wittend99 | 2012-05-15 08:44:23 -0500 (Tue, 15 May 2012) | 1 line - - ------------------------------------------------------------------------- -r464 | wittend99 | 2012-05-15 08:44:02 -0500 (Tue, 15 May 2012) | 1 line - - ------------------------------------------------------------------------- -r463 | wittend99 | 2012-05-15 08:42:49 -0500 (Tue, 15 May 2012) | 1 line - - ------------------------------------------------------------------------- -r462 | wittend99 | 2012-05-14 20:25:56 -0500 (Mon, 14 May 2012) | 1 line - - ------------------------------------------------------------------------- -r460 | wittend99 | 2012-05-13 20:04:35 -0500 (Sun, 13 May 2012) | 1 line - - ------------------------------------------------------------------------- -r459 | wittend99 | 2012-05-13 19:55:29 -0500 (Sun, 13 May 2012) | 1 line - -built libs and headers for linking ------------------------------------------------------------------------- -r458 | wittend99 | 2012-05-13 19:51:07 -0500 (Sun, 13 May 2012) | 1 line - - ------------------------------------------------------------------------- -r456 | wittend99 | 2012-05-13 19:25:07 -0500 (Sun, 13 May 2012) | 1 line - - ------------------------------------------------------------------------- -r455 | wittend99 | 2012-05-13 19:13:32 -0500 (Sun, 13 May 2012) | 1 line - -Notes about building portaudio for fdmdv2. ------------------------------------------------------------------------- -r453 | wittend99 | 2012-05-13 16:19:57 -0500 (Sun, 13 May 2012) | 1 line - -portaudio portable audio framework ------------------------------------------------------------------------- -r452 | wittend99 | 2012-05-13 16:10:42 -0500 (Sun, 13 May 2012) | 1 line - - ------------------------------------------------------------------------- -r451 | wittend99 | 2012-05-13 15:49:44 -0500 (Sun, 13 May 2012) | 1 line - -remove incorrect paths ------------------------------------------------------------------------- -r450 | wittend99 | 2012-05-13 15:49:03 -0500 (Sun, 13 May 2012) | 1 line - -Workspace for the Codelite IDE ------------------------------------------------------------------------- -r449 | wittend99 | 2012-05-13 15:48:16 -0500 (Sun, 13 May 2012) | 1 line - -fixup some paths ------------------------------------------------------------------------- -r448 | wittend99 | 2012-05-13 15:44:49 -0500 (Sun, 13 May 2012) | 1 line - -project file for Codelite ------------------------------------------------------------------------- -r447 | wittend99 | 2012-05-13 14:43:58 -0500 (Sun, 13 May 2012) | 1 line - -Potentially for use for rig control ------------------------------------------------------------------------- -r446 | wittend99 | 2012-05-13 14:32:29 -0500 (Sun, 13 May 2012) | 1 line - -Possible rs-232 Comm library for use if needed. Born of frustration with existing options. After all these years isn't there a decent, usable, documented cross-platform library somewhere? ------------------------------------------------------------------------- -r445 | wittend99 | 2012-05-13 14:20:14 -0500 (Sun, 13 May 2012) | 1 line - -A copy of libsndfile.dll built for Win32 using MinGW + MSYS on Win7 ------------------------------------------------------------------------- -r444 | wittend99 | 2012-05-13 14:17:16 -0500 (Sun, 13 May 2012) | 1 line - -Just running notes about where ideas and code have come from. ------------------------------------------------------------------------- -r443 | wittend99 | 2012-05-13 14:10:56 -0500 (Sun, 13 May 2012) | 1 line - -Class declarations for the spectrum and waterfall classes. ------------------------------------------------------------------------- -r442 | wittend99 | 2012-05-13 14:08:16 -0500 (Sun, 13 May 2012) | 1 line - -Intended to be a superclass to the waterfall and spectrum plot classes. Currently the UI just instantiates one directly derived for each window in the wxNotebook display. ------------------------------------------------------------------------- -r441 | wittend99 | 2012-05-13 14:03:07 -0500 (Sun, 13 May 2012) | 1 line - - ------------------------------------------------------------------------- -r440 | wittend99 | 2012-05-13 11:30:57 -0500 (Sun, 13 May 2012) | 1 line - -UI Project 'main' header ------------------------------------------------------------------------- -r439 | wittend99 | 2012-05-13 11:30:12 -0500 (Sun, 13 May 2012) | 1 line - -UI project 'main' module ------------------------------------------------------------------------- -r438 | wittend99 | 2012-05-13 11:28:34 -0500 (Sun, 13 May 2012) | 1 line - -Workspace for CodeLite ------------------------------------------------------------------------- -r437 | wittend99 | 2012-05-13 11:03:53 -0500 (Sun, 13 May 2012) | 1 line - -An XRC definition of the UI window classes. Can be used by wxWidgets, but is just for reference in this project. ------------------------------------------------------------------------- -r436 | wittend99 | 2012-05-13 11:01:37 -0500 (Sun, 13 May 2012) | 1 line - -wxFormbuilder generated Python version of the UI classes, included just for grins (for now) ------------------------------------------------------------------------- -r435 | wittend99 | 2012-05-13 10:59:09 -0500 (Sun, 13 May 2012) | 1 line - -wxFormbuilder generated UI class declarations. (topframe.* are all generated classes. Don' Edit!) ------------------------------------------------------------------------- -r434 | wittend99 | 2012-05-13 10:56:34 -0500 (Sun, 13 May 2012) | 1 line - -Defines the top level frame window for the UI as well as the dialogs. the MainFrame classs and all of the dialog classes inherit from this. ------------------------------------------------------------------------- -r433 | wittend99 | 2012-05-13 10:53:43 -0500 (Sun, 13 May 2012) | 1 line - -wxFormbuilder Project File used to create the top-level UI and the dialogs. Probably requires wxFormbuilder v. 3.3.2-beta or above. This generates topframe.h, topframe.cpp, (and topframe.py, topframe.xrc for experimentation). Use this with care. ------------------------------------------------------------------------- -r432 | wittend99 | 2012-05-13 10:45:54 -0500 (Sun, 13 May 2012) | 1 line - -Sound file Read/Write library ------------------------------------------------------------------------- -r431 | wittend99 | 2012-05-13 10:39:42 -0500 (Sun, 13 May 2012) | 1 line - -sample rate conversion library aka "Secret Rabbit Code" ------------------------------------------------------------------------- -r430 | wittend99 | 2012-05-13 10:31:45 -0500 (Sun, 13 May 2012) | 1 line - -General Program Options Dialog Header ------------------------------------------------------------------------- -r429 | wittend99 | 2012-05-13 10:30:39 -0500 (Sun, 13 May 2012) | 1 line - -General Program Options Dialog ------------------------------------------------------------------------- -r428 | wittend99 | 2012-05-13 10:29:55 -0500 (Sun, 13 May 2012) | 1 line - -Comm Ports Dialog Header ------------------------------------------------------------------------- -r427 | wittend99 | 2012-05-13 10:29:07 -0500 (Sun, 13 May 2012) | 1 line - -Comm Ports Dialog ------------------------------------------------------------------------- -r426 | wittend99 | 2012-05-13 10:27:58 -0500 (Sun, 13 May 2012) | 1 line - -Audio Dialog Header ------------------------------------------------------------------------- -r425 | wittend99 | 2012-05-13 10:27:22 -0500 (Sun, 13 May 2012) | 1 line - -Audio Dialog ------------------------------------------------------------------------- -r424 | wittend99 | 2012-05-13 10:26:11 -0500 (Sun, 13 May 2012) | 1 line - -help>About Header ------------------------------------------------------------------------- -r423 | wittend99 | 2012-05-13 10:25:24 -0500 (Sun, 13 May 2012) | 1 line - -help>About Dialog. ------------------------------------------------------------------------- -r422 | wittend99 | 2012-05-13 10:23:55 -0500 (Sun, 13 May 2012) | 1 line - -wxWidgets DLL file used for Win32 build. ------------------------------------------------------------------------- -r421 | wittend99 | 2012-05-13 10:08:46 -0500 (Sun, 13 May 2012) | 1 line - -A folder for fdmdv-2 UI work. ------------------------------------------------------------------------- diff --git a/fdmdv2/DEBIAN_DEVEL.sh b/fdmdv2/DEBIAN_DEVEL.sh deleted file mode 100644 index 71cf970c..00000000 --- a/fdmdv2/DEBIAN_DEVEL.sh +++ /dev/null @@ -1 +0,0 @@ -apt-get install cmake gcc g++ libportaudio-dev libhamlib-dev libsamplerate-dev libsndfile-dev libsox-dev libgtk-3-dev libasound-dev diff --git a/fdmdv2/DEBIAN_RUNTIME.sh b/fdmdv2/DEBIAN_RUNTIME.sh deleted file mode 100644 index 239945fb..00000000 --- a/fdmdv2/DEBIAN_RUNTIME.sh +++ /dev/null @@ -1 +0,0 @@ -apt-get install libportaudio2 libhamlib2 libsamplerate0 libsndfile1 libsox2 libgtk-3-0 libasound2 diff --git a/fdmdv2/Desktop.ini b/fdmdv2/Desktop.ini deleted file mode 100644 index ae60713d..00000000 Binary files a/fdmdv2/Desktop.ini and /dev/null differ diff --git a/fdmdv2/INSTALL b/fdmdv2/INSTALL deleted file mode 100644 index 2d82cd66..00000000 --- a/fdmdv2/INSTALL +++ /dev/null @@ -1,74 +0,0 @@ -The CMake configuration for FDMDV2 (FreeDV) is the primary build method at -this time and has been thouroughly tested on Fedora Linux and will likely work -well on most *nix systems and has many advanages over the autotools config. - -It should also work on Windows environments but only the mingw-w64 is tested -to work using the MSYS2 environment. Others may work but you're on your own. - -- Builds against system libraries (by default). -- Or optionally download, build, and statically link with required libraries on - an individual basis. See USE_STATIC_??? options. - NOTE: We need test reports on mingw/Windows, not all dependencies will build. -- Has experimental NSIS packaing support for Windows (WIN32) targets. *nix - systems should rely on 'make install' or tradional packaing methods as the - packages (RPM & DEB) created by CPack are questionable. - -================================== - Building and installing on Linux -================================== - -To perform a cmake build create a directory anywhere underneath (or outside of) -the source directory. - -Linux command line example: - -$ cd /path/to/fdmdv2 -$ mkdir build_linux -$ cd build_linux -$ cmake ../ (defaults to /usr/local, use CMAKE_INSTALL_PREFIX to override) -(if no errors) -$ make -(as root) -$ make install - -==================================== - Building and installing on Windows -==================================== - -The windows build is similar to linux and follows the same basic workflow. - -Only MinGW is supported. While it is likely possible to perform a pure MinGW -build, installing MSYS will make your life easier. - -CMake may not automatically detect that you're in the MSYS environment. If this -occurs you need to pass cmake the proper generator: - -cmake -G"MSYS Makefiles" [other options] - -=============================== - Bootstrapping wxWidgets build -=============================== - -If wxWidgets (>= 3.0) is not available then one option is to have CMake boot- -strap the build for FreeDV. - -This is required because the tool wx-config is used to get the correct compiler -and linker flags of the wxWidgets components needed by FreeDV. Since this is -normally done at configure time, not during "make", it is not possible for CMake -to have this information prior to building wxWidgets. - -In order to work around this issue you can "bootstrap" the wxWidgets build using -the CMake option, "BOOTSTRAP_WXWIDGETS". wxWidgets will be built using static -libraries. - -NOTE: This forces "USE_STATIC_WXWIDGETS" to be true internally regarless of the -value set manually. - -(from any prefered directory outside of the source) -$ cmake -DBOOTSTRAP_WXWIDGETS=TRUE -$ make -(wxWidgets is downloaded and built) -$ cmake . -$ make -(if all goes well, as root) -$ make install diff --git a/fdmdv2/NEWS b/fdmdv2/NEWS deleted file mode 100644 index e69de29b..00000000 diff --git a/fdmdv2/README b/fdmdv2/README deleted file mode 100644 index e69de29b..00000000 diff --git a/fdmdv2/README.txt b/fdmdv2/README.txt deleted file mode 100644 index f54ff34c..00000000 --- a/fdmdv2/README.txt +++ /dev/null @@ -1,114 +0,0 @@ -================================== - Building and installing on Linux -================================== - -Quickstart 1 ------------ - -Builds static versions of wxWidgets, portaudio, codec2-dev, which are commonly -missing on many Linux systems, or of the wrong (older) version. - -Assuming the freedv-dev sources is checked out into ~/fdmdv2-dev: - -$ cd fdmdv2-dev -$ mkdir build_linux -$ cd build_linux -$ cmake -DBOOTSTRAP_WXWIDGETS=TRUE ~/fdmdv2-dev -$ make -[wxWidgets builds] - -Then you can use your local codec-dev, something like: - -$ cmake cmake -DBOOTSTRAP_WXWIDGETS=TRUE -DCODEC2_INCLUDE_DIR=/home/david/codec2-dev/src -DCODEC2_LIBRARY=/home/david/codec2-dev/build_linux/src/libcodec2.so -DUSE_STATIC_CODEC2=FALSE -DUSE_STATIC_PORTAUDIO=TRUE -DUSE_STATIC_SOX=TRUE ../ - -OR build a local copy of codec2-dev: - -$ cmake cmake -DBOOTSTRAP_WXWIDGETS=TRUE -DUSE_STATIC_CODEC2=TRUE -DUSE_STATIC_PORTAUDIO=TRUE -DUSE_STATIC_SOX=TRUE ../ - -$ make -[FreeDV builds] -$ ./src/freedv - -Note: add "-DCMAKE_BUILD_TYPE=Debug" the list above for debug (gcc -g) buildthat include source line numbers. - -Quickstart 2 ------------- - -Assuming you have all the dependant libraries: - -$ cd /path/to/fdmdv2 -$ mkdir build_linux -$ cd build_linux -$ cmake ../ (defaults to /usr/local, use CMAKE_INSTALL_PREFIX to override) -(if no errors) -$ make -(as root) -$ make install - -==================================== - Building and installing on Windows -==================================== - -The windows build is similar to linux and follows the same basic workflow. - -Only MinGW is supported. While it is likely possible to perform a pure MinGW -build, installing MSYS will make your life easier. - -CMake may not automatically detect that you're in the MSYS environment. If this -occurs you need to pass cmake the proper generator: - -cmake -G"MSYS Makefiles" [other options] - -=============================== - Bootstrapping wxWidgets build -=============================== - -If wxWidgets (>= 3.0) is not available then one option is to have CMake boot- -strap the build for FreeDV. - -This is required because the tool wx-config is used to get the correct compiler -and linker flags of the wxWidgets components needed by FreeDV. Since this is -normally done at configure time, not during "make", it is not possible for CMake -or have this information prior to building wxWidgets. - -In order to work around this issue you can "bootstrap" the wxWidgets build using -the CMake option, "BOOTSTRAP_WXWIDGETS". wxWidgets will be built using static -libraries. - -NOTE: This forces "USE_STATIC_WXWIDGETS" to be true internally regarless of the -value set manually. - -(from any prefered, but empty directory outside of the source) -$ cmake -DBOOTSTRAP_WXWIDGETS=TRUE /path/to/fdmdv2 -$ make -(wxWidgets is downloaded and built) -$ cmake . -$ make -(if all goes well, as root) -$ make install - -==================================== - Building and installing on OSX -==================================== - -==================================== - Building and installing on FreeBSD -==================================== - -As per "Quickstart 2" above but change build_linux to build_freebsd - -======= -Editing -======= - -Please make sure your text editor does not insert tabs, and -used indents of 4 spaces. The following .emacs code was used to -configure emacs: - -(setq-default indent-tabs-mode nil) - -(add-hook 'c-mode-common-hook - (function (lambda () - (setq c-basic-offset 4) - ))) - diff --git a/fdmdv2/Release/.gitignore b/fdmdv2/Release/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/fdmdv2/branches/0.97/.clang/.gitignore b/fdmdv2/branches/0.97/.clang/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/fdmdv2/branches/0.97/AUTHORS b/fdmdv2/branches/0.97/AUTHORS new file mode 100644 index 00000000..e69de29b diff --git a/fdmdv2/branches/0.97/CMakeLists.txt b/fdmdv2/branches/0.97/CMakeLists.txt new file mode 100644 index 00000000..fd61d525 --- /dev/null +++ b/fdmdv2/branches/0.97/CMakeLists.txt @@ -0,0 +1,461 @@ +# +# FreeDV - HF Digital Voice for Radio Amateurs +# +# CMake configuration contributed by Richard Shaw (KF5OIM) +# Please report questions, comments, problems, or patches to the freetel +# mailing list: https://lists.sourceforge.net/lists/listinfo/freetel-codec2 +# + +cmake_minimum_required(VERSION 2.8) + +# Prevent in-source builds to protect automake/autoconf config. +# If an in-source build is attempted, you will still need to clean up a few +# files manually. +set(CMAKE_DISABLE_SOURCE_CHANGES ON) +set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) +if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") + message(FATAL_ERROR "In-source builds in ${CMAKE_BINARY_DIR} are not " + "allowed, please remove ./CMakeCache.txt and ./CMakeFiles/, create a " + "separate build directory and run cmake from there.") +endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") + +# Set local module path. +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") + +project(FreeDV) + +# +# Parse FreeDV version from src/version.h +# +file(READ "${CMAKE_SOURCE_DIR}/src/version.h" _VERSION_H) +string(REGEX REPLACE ".*FREEDV_VERSION_MAJOR ([0-9]+).*" "\\1" + FREEDV_VERSION_MAJOR "${_VERSION_H}") +string(REGEX REPLACE ".*FREEDV_VERSION_MINOR ([0-9]+).*" "\\1" + FREEDV_VERSION_MINOR "${_VERSION_H}") +string(REGEX REPLACE ".*FREEDV_VERSION_PATCH ([0-9]+).*" "\\1" + FREEDV_VERSION_PATCH "${_VERSION_H}") +set(FREEDV_VERSION "${FREEDV_VERSION_MAJOR}.${FREEDV_VERSION_MINOR}") +if(FREEDV_VERSION_PATCH) + set(FREEDV_VERSION ${FREEDV_VERSION}.${FREEDV_VERSION_PATCH}) +endif(FREEDV_VERSION_PATCH) + +message(STATUS "FreeDV version: ${FREEDV_VERSION}") + +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") + message(STATUS "Build type not specified, defaulting to ${CMAKE_BUILD_TYPE}") +endif(NOT CMAKE_BUILD_TYPE) + + +# Work around for not using a svn working copy. +add_definitions(-D_NO_AUTOTOOLS_) +find_program(SVNVERSION_PATH svnversion) +if(SVNVERSION_PATH) + execute_process(COMMAND ${SVNVERSION_PATH} . + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE SVN_REVISION_RESULT + OUTPUT_VARIABLE SVN_CURRENT_REVISION + ERROR_QUIET + ) +else() + set(SVN_REVISION_RESULT 1) +endif() +if(SVN_REVISION_RESULT EQUAL 0) +string(STRIP ${SVN_CURRENT_REVISION} SVN_REVISION) +add_definitions(-DSVN_REVISION="${SVN_REVISION}") +else() +add_definitions(-DSVN_REVISION="Unversioned directory") +endif() + + +# Set default build flags. +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + +# +# Setup cmake options +# +set(USE_STATIC_DEPS FALSE CACHE BOOL + "Download and build static libraries instead of system libraries.") +set(USE_STATIC_PORTAUDIO FALSE CACHE BOOL + "Download and build static portaudio instead of the system library.") +set(USE_STATIC_SNDFILE FALSE CACHE BOOL + "Download and build static sndfile instead of the system library.") +set(USE_STATIC_SAMPLERATE FALSE CACHE BOOL + "Download and build static samplerate instead of the system library.") +set(USE_STATIC_SOX FALSE CACHE BOOL + "Download and build static sox instead of the system library.") +set(USE_STATIC_CODEC2 FALSE CACHE BOOL + "Download and build static codec2 instead of the system library.") +set(BOOTSTRAP_WXWIDGETS FALSE CACHE BOOL + "Download and build static wxWidgets instead of the system library.") + +if(USE_STATIC_DEPS) + set(USE_STATIC_PORTAUDIO TRUE FORCE) + set(USE_STATIC_SNDFILE TRUE FORCE) + set(USE_STATIC_SAMPLERATE TRUE FORCE) + set(USE_STATIC_SOX TRUE FORCE) + set(USE_STATIC_CODEC2 TRUE FORCE) +endif(USE_STATIC_DEPS) + +# +# Pull in external wxWidgets target if performing static build. +# +if(BOOTSTRAP_WXWIDGETS) + message(STATUS "Adding wxWidgets build target...") + include(cmake/BuildWxWidgets.cmake) +endif(BOOTSTRAP_WXWIDGETS) + +# +# Perform bootstrap build of wxWidgets +# +if(BOOTSTRAP_WXWIDGETS AND NOT EXISTS ${WXCONFIG}) + message(STATUS "Will perform bootstrap build of wxWidgets. + After make step completes, re-run cmake and make again to perform FreeDV build.") +# +# Continue normal build if not bootstrapping wxWidgets or is already built. +# +else(BOOTSTRAP_WXWIDGETS AND NOT EXISTS ${WXCONFIG}) + + +# +# Various hacks and work arounds for building under MinGW. +# +if(MINGW) + message(STATUS "System is MinGW.") + # This sets up the exe icon for windows under mingw. + set(RES_FILES "") + set(RES_FILES "${CMAKE_SOURCE_DIR}/contrib/freedv.rc") + set(CMAKE_RC_COMPILER_INIT windres) + enable_language(RC) + set(CMAKE_RC_COMPILE_OBJECT + " -O coff -i -o ") + # These are DLOPEN'ed and can't be automatically pulled in by dependency. + foreach(RUNTIME + hamlib-adat.dll + hamlib-alinco.dll + hamlib-amsat.dll + hamlib-aor.dll + hamlib-ars.dll + hamlib-celestron.dll + hamlib-drake.dll + hamlib-dummy.dll + hamlib-easycomm.dll + hamlib-flexradio.dll + hamlib-fodtrack.dll + hamlib-gs232a.dll + hamlib-heathkit.dll + hamlib-icom.dll + hamlib-jrc.dll + hamlib-kachina.dll + hamlib-kenwood.dll + hamlib-kit.dll + hamlib-lowe.dll + hamlib-m2.dll + hamlib-pcr.dll + hamlib-prm80.dll + hamlib-racal.dll + hamlib-rft.dll + hamlib-rotorez.dll + hamlib-rs.dll + hamlib-sartek.dll + hamlib-skanti.dll + hamlib-spid.dll + hamlib-tapr.dll + hamlib-tentec.dll + hamlib-ts7400.dll + hamlib-tuner.dll + hamlib-uniden.dll + hamlib-winradio.dll + hamlib-wj.dll + hamlib-yaesu.dll) + message(STATUS "Checking for ${RUNTIME}") + find_library(${RUNTIME}_LIB ${RUNTIME} + PATH_SUFFIXES hamlib) + message(STATUS "runtime found: ${${RUNTIME}_LIB}") + list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${${RUNTIME}_LIB}) + endforeach() + include(InstallRequiredSystemLibraries) +endif(MINGW) + +# Math library is automatic on MinGW +if(UNIX) + set(CMAKE_REQUIRED_INCLUDES math.h) + set(CMAKE_REQUIRED_LIBRARIES m) +endif(UNIX) + +# Find some standard headers and functions. +include(CheckIncludeFiles) +check_include_files("limits.h" HAVE_LIMITS_H) +check_include_files("stddef.h" HAVE_STDDEF_H) +check_include_files("stdlib.h" HAVE_STDLIB_H) +check_include_files("string.h" HAVE_STRING_H) + +include(CheckTypeSize) +check_type_size("int" SIZEOF_INT) + +include(CheckFunctionExists) +check_function_exists(floor HAVE_FLOOR) +check_function_exists(memset HAVE_MEMSET) +check_function_exists(pow HAVE_POW) +check_function_exists(sqrt HAVE_SQRT) + +# fdmdv2_main.h requires patching to find config.h as it current looks in the +# source directory and the generated file goes in the binary directory. +configure_file ("${PROJECT_SOURCE_DIR}/cmake/config.h.in" + "${PROJECT_BINARY_DIR}/config.h" ) +include_directories(${PROJECT_BINARY_DIR}) +add_definitions(-DHAVE_CONFIG_H) + +# Pthread Library +find_package(Threads REQUIRED) +message(STATUS "Threads library flags: ${CMAKE_THREAD_LIBS_INIT}") + +# +# Find codec2 +# +if(NOT USE_STATIC_CODEC2) + message(STATUS "Looking for codec2...") + find_package(codec2 CONFIG QUIET) + if(codec2_FOUND) + get_target_property(CODEC2_BRARY codec2 LOCATION) + message(STATUS " codec2 library: ${CODEC2_LIBRARY}") + message(STATUS " codec2 headers: ${codec2_INCLUDE_DIRS}") + else() + # Try to find manually + find_path(CODEC2_INCLUDE_DIRS codec2.h + PATH_SUFFIXES codec2) + find_library(CODEC2_LIBRARY NAMES codec2) + if(CODEC2_LIBRARY AND CODEC2_INCLUDE_DIRS) + message(STATUS " codec2 library: ${CODEC2_LIBRARY}") + message(STATUS " codec2 headers: ${CODEC2_INCLUDE_DIRS}") + list(APPEND FREEDV_LINK_LIBS ${CODEC2_LIBRARY}) + include_directories(${CODEC2_INCLUDE_DIRS}) + else() + message(FATAL_ERROR "codec2 library not found. +Linux: +Codec2 may not be in your distribution so build yourself or use the cmake option to build statically into FreeDV. +Windws: +It's easiest to use the cmake option: USE_STATIC_CODEC2" + ) + endif() + endif() +else(NOT USE_STATIC_CODEC2) + message(STATUS "Will attempt static build of codec2.") + include(cmake/BuildCodec2.cmake) +endif(NOT USE_STATIC_CODEC2) + +# +# Find or build portaudio Library +# +if(NOT USE_STATIC_PORTAUDIO) + message(STATUS "Looking for portaudio...") + find_package(Portaudio REQUIRED) + if(PORTAUDIO_FOUND) + message(STATUS " portaudio library: ${PORTAUDIO_LIBRARIES}") + message(STATUS " portaudio headers: ${PORTAUDIO_INCLUDE_DIRS}") + list(APPEND FREEDV_LINK_LIBS ${PORTAUDIO_LIBRARIES}) + include_directories(${PORTAUDIO_INCLUDE_DIRS}) + else() + message(FATAL_ERROR "portaudio library not found. +On Linux systems try installing: + portaudio-devel (RPM based systems) + libportaudio-dev (DEB based systems) +On Windows it's easiest to use the cmake option: USE_STATIC_PORTAUDIO" + ) + endif() + if(NOT ${PORTAUDIO_VERSION} EQUAL 19) + message(WARNING "Portaudio versions other than 19 are known to have issues. You have been warned!") + endif() +else(NOT USE_STATIC_PORTAUDIO) + message(STATUS "Will attempt static build of portaudio.") + include(cmake/BuildPortaudio.cmake) +endif(NOT USE_STATIC_PORTAUDIO) + +# +# Hamlib library +# +message(STATUS "Looking for hamlib...") +find_path(HAMLIB_INCLUDE_DIR hamlib/rig.h) +find_library(HAMLIB_LIBRARY hamlib) +message(STATUS "Hamlib library: ${HAMLIB_LIBRARY}") +message(STATUS "Hamlib headers: ${HAMLIB_INCLUDE_DIR}") +if(HAMLIB_LIBRARY AND HAMLIB_INCLUDE_DIR) + message(STATUS "Hamlib library found.") + include_directories(${HAMLIB_INCLUDE_DIR}) + list(APPEND FREEDV_LINK_LIBS ${HAMLIB_LIBRARY}) +else(HAMLIB_LIBRARY AND HAMLIB_INCLUDE_DIR) + message(FATAL_ERROR "hamlib not found. +On Linux systems try installing: + hamlib-devel (RPM based systems) + libhamlib-dev (DEB based systems)" + ) +endif(HAMLIB_LIBRARY AND HAMLIB_INCLUDE_DIR) + + +# +# Samplerate Library +# +if(NOT USE_STATIC_SAMPLERATE) + message(STATUS "Looking for samplerate...") + find_library(LIBSAMPLERATE samplerate) + find_path(LIBSAMPLERATE_INCLUDE_DIR samplerate.h) + message(STATUS " samplerate library: ${LIBSAMPLERATE}") + message(STATUS " samplerate headers: ${LIBSAMPLERATE_INCLUDE_DIR}") + if(LIBSAMPLERATE AND LIBSAMPLERATE_INCLUDE_DIR) + list(APPEND FREEDV_LINK_LIBS ${LIBSAMPLERATE}) + include_directories(${LIBSAMPLERATE_INCLUDE_DIR}) + else(LIBSTAMPLERATE AND LIBSAMPLERATE_INCLUDE_DIR) + message(FATAL_ERROR "samplerate library not found. +On Linux systems try installing: + samplerate-devel (RPM based systems) + libsamplerate-dev (DEB based systems) +On Windows it's easiest to use the cmake option: USE_STATIC_SAMPLERATE" + ) + endif(LIBSAMPLERATE AND LIBSAMPLERATE_INCLUDE_DIR) +else(NOT USE_STATIC_SAMPLERATE) + message(STATUS "Will attempt static build of samplerate.") + include(cmake/BuildSamplerate.cmake) +endif(NOT USE_STATIC_SAMPLERATE) + +# +# Find sox library +# +if(NOT USE_STATIC_SOX) + message(STATUS "Looking for sox...") + find_library(LIBSOX_LIBRARY sox) + find_path(LIBSOX_INCLUDE_DIR NAMES sox/sox.h sox.h) + message(STATUS " sox library: ${LIBSOX_LIBRARY}") + message(STATUS " sox headers: ${LIBSOX_INCLUDE_DIR}") + if(LIBSOX_LIBRARY AND LIBSOX_INCLUDE_DIR) + list(APPEND FREEDV_LINK_LIBS ${LIBSOX_LIBRARY}) + include_directories(${LIBSOX_INCLUDE_DIR}) + else(LIBSOX_LIBRARY AND LIBSOX_INCLUDE_DIR) + message(FATAL_ERROR "sox library not found. +On Linux systems try installing: + sox-devel (RPM based systems) + libsox-dev (DEB based systems) +On Windows it's easiest to use the cmake option: USE_STATIC_SOX" + ) + endif(LIBSOX_LIBRARY AND LIBSOX_INCLUDE_DIR) +else(NOT USE_STATIC_SOX) + message(STATUS "Will attempt static build of sox.") + include(cmake/BuildSox.cmake) +endif(NOT USE_STATIC_SOX) + +# +# sndfile Library +# +if(NOT USE_STATIC_SNDFILE) + message(STATUS "Looking for sndfile...") + find_library(LIBSNDFILE sndfile) + find_path(LIBSNDFILE_INCLUDE_DIR sndfile.h) + message(STATUS " sndfile library: ${LIBSNDFILE}") + message(STATUS " sndfile headers: ${LIBSNDFILE_INCLUDE_DIR}") + if(LIBSNDFILE AND LIBSNDFILE_INCLUDE_DIR) + list(APPEND FREEDV_LINK_LIBS ${LIBSNDFILE}) + else(LIBSNDFILE AND LIBSNDFILE_INCLUDE_DIR) + message(FATAL_ERROR "sndfile library not found. +On Linux systems try installing: + libsndfile-devel (RPM based systems) + libsndfile-dev (DEB based systems) +On Windows it's easiest to use the cmake option: USE_STATIC_SNDFILE" + ) + endif(LIBSNDFILE AND LIBSNDFILE_INCLUDE_DIR) +else(NOT USE_STATIC_SNDFILE) + message(STATUS "Will attempt static build of sndfile.") + include(cmake/BuildSndfile.cmake) +endif(NOT USE_STATIC_SNDFILE) + +# +# Find wxWidgets +# +if(NOT BOOTSTRAP_WXWIDGETS) + set(WXCONFIG "" CACHE FILEPATH "Location of wx-config binary.") + set(WXRC "" CACHE FILEPATH "Location of wxrc binary.") +endif(NOT BOOTSTRAP_WXWIDGETS) +#if(BOOTSTRAP_WXWIDGETS) +# set(WXCONFIG "${CMAKE_BINARY_DIR}/external/dist/bin/wx-config") +# set(WXRC "${CMAKE_BINARY_DIR}/external/dist/bin/wxrc") +# list(APPEND FREEDV_STATIC_DEPS wxWidgets) +#endif(BOOTSTRAP_WXWIDGETS) +message(STATUS "Looking for wxWidgets...") +if(WXCONFIG) + message(STATUS "wx-config: ${WXCONFIG}") + set(wxWidgets_CONFIG_EXECUTABLE ${WXCONFIG}) +endif(WXCONFIG) +if(WXRC) + message(STATUS "wxrc: ${WXRC}") + set(wxWidgets_wxrc_EXECUTABLE ${WXRC}) +endif(WXRC) +set(WX_VERSION_MIN 3.0.0) +find_package(wxWidgets REQUIRED core base aui html net adv) +execute_process(COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" --version + OUTPUT_VARIABLE WX_VERSION) +string(STRIP ${WX_VERSION} WX_VERSION) +if(WX_VERSION VERSION_EQUAL ${WX_VERSION_MIN} + OR WX_VERSION VERSION_GREATER ${WX_VERSION_MIN}) + message(STATUS "wxWidgets version: ${WX_VERSION}") +else() + message(FATAL_ERROR "wxWidgets must be installed on your system. +Please check that wx-config is in path, the directory +where wxWidgets libraries are installed (returned by +'wx-config --libs' or 'wx-config --static --libs' command) +is in LD_LIBRARY_PATH or equivalent variable and +wxWidgets version is ${WX_VERSION_MIN} or above.") +endif() +if(wxWidgets_FOUND) + include("${wxWidgets_USE_FILE}") + list(APPEND FREEDV_LINK_LIBS ${wxWidgets_LIBRARIES}) +endif(wxWidgets_FOUND) + + +# Freedv +add_subdirectory(src) + +# Icons and desktop file +add_subdirectory(contrib) + +message(STATUS "Build type will be: ${CMAKE_BUILD_TYPE}") + +# +# Cpack NSIS configuration for Windows. +# +if(WIN32) + # Detect if we're doing a 32-bit or 64-bit windows build. + if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) + set(CMAKE_CL_64 TRUE) + endif() + if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(CPACK_STRIP_FILES TRUE) + endif() + + configure_file(cmake/GetDependencies.cmake.in cmake/GetDependencies.cmake + @ONLY + ) + install(SCRIPT ${CMAKE_BINARY_DIR}/cmake/GetDependencies.cmake) + set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "HF Digital Voice for Radio Amateurs") + set(CPACK_PACKAGE_VENDOR "CMake") + set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") + set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") + set(CPACK_PACKAGE_VERSION_MAJOR ${FREEDV_VERSION_MAJOR}) + set(CPACK_PACKAGE_VERSION_MINOR ${FREEDV_VERSION_MINOR}) + if(FREEDV_VERSION_PATCH) + set(CPACK_PACKAGE_VERSION_PATCH ${FREEDV_VERSION_PATCH}) + else() + set(CPACK_PACKAGE_VERSION_PATCH "0") + endif() + set(CPACK_PACKAGE_INSTALL_DIRECTORY "FreeDV") + set(CPACK_PACKAGE_EXECUTABLES freedv;FreeDV) + set(CPACK_STRIP_FILES TRUE) + # NSIS specific settings + set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\freedv.exe") + set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}") + set(CPACK_NSIS_PACKAGE_NAME "FreeDV") + set(CPACK_NSIS_URL_INFO_ABOUT "http://freedv.org") + set(CPACK_NSIS_MODIFY_PATH OFF) + set(CPACK_NSIS_MENU_LINKS "http://freedv.org" "FreeDV Homepage") + include(CPack) +endif(WIN32) + +endif(BOOTSTRAP_WXWIDGETS AND NOT EXISTS ${WXCONFIG}) diff --git a/fdmdv2/branches/0.97/COPYING b/fdmdv2/branches/0.97/COPYING new file mode 100644 index 00000000..cfd4e991 --- /dev/null +++ b/fdmdv2/branches/0.97/COPYING @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 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. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +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 and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, 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 library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete 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 distribute a copy of this License along with the +Library. + + 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 Library or any portion +of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +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 Library, 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 Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you 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. + + If distribution of 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 satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be 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. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library 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. + + 9. 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 Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +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 with +this License. + + 11. 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 Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library 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 Library. + +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. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library 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. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser 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 Library +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 Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +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 + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "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 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. 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 LIBRARY 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 +LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, see + . + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/fdmdv2/branches/0.97/ChangeLog b/fdmdv2/branches/0.97/ChangeLog new file mode 100644 index 00000000..6cc9eb6c --- /dev/null +++ b/fdmdv2/branches/0.97/ChangeLog @@ -0,0 +1,1819 @@ +------------------------------------------------------------------------ +r1317 | hobbes1069 | 2013-06-13 10:40:39 -0500 (Thu, 13 Jun 2013) | 1 line + +Update wxWidgets bootstrap process to be more simple and other tweaks to USE_STATIC_... options. +------------------------------------------------------------------------ +r1312 | hobbes1069 | 2013-06-07 13:17:05 -0500 (Fri, 07 Jun 2013) | 1 line + +Use version.h for settign version info. +------------------------------------------------------------------------ +r1311 | shenki | 2013-06-06 19:55:20 -0500 (Thu, 06 Jun 2013) | 5 lines + +Add libctb to the list of libraries to build + +It will not be downloaded nor built with the current configuration. +Thanks to Curt, WE7U on the codec2 mailing list for discovering this one. + +------------------------------------------------------------------------ +r1310 | shenki | 2013-06-06 04:00:35 -0500 (Thu, 06 Jun 2013) | 2 lines + +Move init of sox outside of assert calls + +------------------------------------------------------------------------ +r1306 | hobbes1069 | 2013-06-02 11:50:41 -0500 (Sun, 02 Jun 2013) | 1 line + +Update version in cmake config. +------------------------------------------------------------------------ +r1305 | hobbes1069 | 2013-06-02 08:01:51 -0500 (Sun, 02 Jun 2013) | 1 line + +Put the file in the right place... +------------------------------------------------------------------------ +r1304 | hobbes1069 | 2013-06-02 07:59:53 -0500 (Sun, 02 Jun 2013) | 1 line + +Add freedv.rc which allows embedding the freedv icon in the windows executable. +------------------------------------------------------------------------ +r1303 | drowe67 | 2013-06-01 19:19:57 -0500 (Sat, 01 Jun 2013) | 1 line + +serial & Hamlib PTT tested OK on Linux +------------------------------------------------------------------------ +r1300 | drowe67 | 2013-05-31 17:20:06 -0500 (Fri, 31 May 2013) | 1 line + +hooked up serial port logic, still to test and debug +------------------------------------------------------------------------ +r1297 | drowe67 | 2013-05-30 19:50:52 -0500 (Thu, 30 May 2013) | 1 line + +restored serial PTT dilaog, yet to hook up actual logic to use it +------------------------------------------------------------------------ +r1296 | drowe67 | 2013-05-29 21:11:07 -0500 (Wed, 29 May 2013) | 1 line + +made filter dialog a little larger as ok/cancel wasbing cropped +------------------------------------------------------------------------ +r1295 | hobbes1069 | 2013-05-29 20:36:45 -0500 (Wed, 29 May 2013) | 1 line + +Move golay23 into codec2 library. +------------------------------------------------------------------------ +r1294 | hobbes1069 | 2013-05-29 15:06:55 -0500 (Wed, 29 May 2013) | 1 line + +Additional hamlib cmake config cleanup. +------------------------------------------------------------------------ +r1293 | hobbes1069 | 2013-05-28 19:55:57 -0500 (Tue, 28 May 2013) | 1 line + +Add cmake checks for hamlib and more fixes for updated source names. +------------------------------------------------------------------------ +r1292 | hobbes1069 | 2013-05-28 19:15:28 -0500 (Tue, 28 May 2013) | 1 line + +Update cmake config for renamed source files. +------------------------------------------------------------------------ +r1291 | drowe67 | 2013-05-28 01:45:26 -0500 (Tue, 28 May 2013) | 1 line + +cleaned up some unused files +------------------------------------------------------------------------ +r1289 | drowe67 | 2013-05-27 19:37:30 -0500 (Mon, 27 May 2013) | 1 line + +minor tweaks to README, remove dunused automake stuff, and tweaked help-about for donations +------------------------------------------------------------------------ +r1288 | drowe67 | 2013-05-27 18:35:32 -0500 (Mon, 27 May 2013) | 1 line + +managedto get Win32 building with hamlib win32 binaries instead of building hamlib myself +------------------------------------------------------------------------ +r1287 | drowe67 | 2013-05-27 17:33:38 -0500 (Mon, 27 May 2013) | 1 line + +first pass at building with hamlib, but cantget hamlib to build +------------------------------------------------------------------------ +r1286 | drowe67 | 2013-05-27 15:50:41 -0500 (Mon, 27 May 2013) | 1 line + +filer dialog now fits on 800x600 without clipping +------------------------------------------------------------------------ +r1285 | drowe67 | 2013-05-27 15:46:49 -0500 (Mon, 27 May 2013) | 1 line + +after some sizer frustration with ptt dlg, rename commport to ptt +------------------------------------------------------------------------ +r1284 | shenki | 2013-05-27 05:41:58 -0500 (Mon, 27 May 2013) | 4 lines + +Add hamlib related files + +These were missing from the previous commit. Oops! + +------------------------------------------------------------------------ +r1283 | shenki | 2013-05-27 05:17:32 -0500 (Mon, 27 May 2013) | 13 lines + +Add hamlib support for push to talk + +This removes libctb in favour of hamlib. It has been tested with 1.2.15.3 of +hamlib with a IC-7200. + +The rig is configured using it's own dialog Tools -> PTT Config. The only +options available are the rig model and serial port, the rest of the options +are obtained from the rig definition in hamlib. + +FreeDV will open the configured serial port on startup. When it cannot find +the radio, an error dialog will be displayed. Spacebar can be used to toggle +TX/RX. + +------------------------------------------------------------------------ +r1268 | drowe67 | 2013-05-23 18:00:55 -0500 (Thu, 23 May 2013) | 1 line + +added options dialog, bumped version +------------------------------------------------------------------------ +r1267 | drowe67 | 2013-05-23 09:24:58 -0500 (Thu, 23 May 2013) | 1 line + +make 1600 default and re-arranged to fit 800x600 netbook layout +------------------------------------------------------------------------ +r1253 | wittend99 | 2013-05-20 16:23:52 -0500 (Mon, 20 May 2013) | 1 line + +Personal test project +------------------------------------------------------------------------ +r1252 | wittend99 | 2013-05-20 16:22:44 -0500 (Mon, 20 May 2013) | 1 line + +Personal test stuff +------------------------------------------------------------------------ +r1251 | wittend99 | 2013-05-20 16:21:24 -0500 (Mon, 20 May 2013) | 1 line + + +------------------------------------------------------------------------ +r1250 | shenki | 2013-05-18 23:08:22 -0500 (Sat, 18 May 2013) | 7 lines + +Allow building against the system sox library + +Provide SYSTEM_SOX=y to build against the system libsox instead +of downloading, building and linking staticly. + +The default of linking staticly remains the same. + +------------------------------------------------------------------------ +r1249 | hobbes1069 | 2013-05-17 09:53:07 -0500 (Fri, 17 May 2013) | 1 line + +Forgot to svn add the readme. +------------------------------------------------------------------------ +r1248 | hobbes1069 | 2013-05-17 09:51:38 -0500 (Fri, 17 May 2013) | 2 lines + +Major cmake config overhall for freedv mingw build. Add freedv icon to installer and start menu entry. Add README.cmake for codec2-dev. + +------------------------------------------------------------------------ +r1246 | hobbes1069 | 2013-05-10 18:54:16 -0500 (Fri, 10 May 2013) | 1 line + +Workaround for location of config.h +------------------------------------------------------------------------ +r1245 | hobbes1069 | 2013-05-09 15:44:20 -0500 (Thu, 09 May 2013) | 1 line + +Fix internal building of Codec2. Fix finding libraries under MinGW. +------------------------------------------------------------------------ +r1244 | hobbes1069 | 2013-05-08 14:38:44 -0500 (Wed, 08 May 2013) | 1 line + +CMake configuration tweaks for wxWidgets bootstrap build option and update of README.cmake. +------------------------------------------------------------------------ +r1243 | hobbes1069 | 2013-05-07 09:13:02 -0500 (Tue, 07 May 2013) | 1 line + +Fix typo in cmake config, add README.cmake. +------------------------------------------------------------------------ +r1242 | hobbes1069 | 2013-05-07 09:07:47 -0500 (Tue, 07 May 2013) | 1 line + +Add missing BuildCodec2.cmake +------------------------------------------------------------------------ +r1241 | wittend99 | 2013-05-06 12:17:19 -0500 (Mon, 06 May 2013) | 1 line + +Pushing changes to force windows builds to use a configuration file rather than the registry. +------------------------------------------------------------------------ +r1240 | wittend99 | 2013-05-06 12:14:34 -0500 (Mon, 06 May 2013) | 1 line + +Just changes to my personal IDE workspace. Irrelevant to everyone but me -DMW +------------------------------------------------------------------------ +r1239 | hobbes1069 | 2013-05-06 10:49:31 -0500 (Mon, 06 May 2013) | 1 line + +Add cmake configuration for contrib dir. +------------------------------------------------------------------------ +r1238 | hobbes1069 | 2013-05-06 10:48:37 -0500 (Mon, 06 May 2013) | 1 line + +CMake configuration updates. More detailed error messages. Icon and desktop installation for Linux. WIN32 CPack tweaks. +------------------------------------------------------------------------ +r1237 | wittend99 | 2013-04-26 08:13:11 -0500 (Fri, 26 Apr 2013) | 1 line + +Reversing commits made in error... +------------------------------------------------------------------------ +r1236 | wittend99 | 2013-04-26 08:09:05 -0500 (Fri, 26 Apr 2013) | 1 line + + +------------------------------------------------------------------------ +r1235 | hobbes1069 | 2013-04-24 14:34:37 -0500 (Wed, 24 Apr 2013) | 1 line + +Update cmake configuration including building static builds of most dependencies. Update codec2 build to include basic cpack configuration. +------------------------------------------------------------------------ +r1234 | hobbes1069 | 2013-04-19 14:26:53 -0500 (Fri, 19 Apr 2013) | 1 line + +Major updates to cmake configuration for both codec2-dev and fdmdv2. Preliminary cpack NSIS configuration for codec2 windows installer. +------------------------------------------------------------------------ +r1232 | hobbes1069 | 2013-04-15 09:35:41 -0500 (Mon, 15 Apr 2013) | 1 line + +Commit inital cmake configuration, *nix and windows icon, and *nix desktop file. +------------------------------------------------------------------------ +r1231 | wittend99 | 2013-03-26 10:53:46 -0500 (Tue, 26 Mar 2013) | 1 line + + +------------------------------------------------------------------------ +r1230 | wittend99 | 2013-03-26 10:31:07 -0500 (Tue, 26 Mar 2013) | 1 line + +Updating my personal resting configuration. +------------------------------------------------------------------------ +r1229 | wittend99 | 2013-03-26 10:22:42 -0500 (Tue, 26 Mar 2013) | 1 line + +Reduce minimum size of the top level frame to let it be used on 1024 x 600 displays. +------------------------------------------------------------------------ +r1228 | wittend99 | 2013-03-26 10:22:07 -0500 (Tue, 26 Mar 2013) | 1 line + +Reduce minimum size of the top level frame to let it be used on 1024 x 600 displays. +------------------------------------------------------------------------ +r1227 | drowe67 | 2013-03-25 15:33:49 -0500 (Mon, 25 Mar 2013) | 1 line + +checked in Stuarts patches 1 thru 4 +------------------------------------------------------------------------ +r1226 | wittend99 | 2013-03-24 17:21:11 -0500 (Sun, 24 Mar 2013) | 1 line + +Removed comment +------------------------------------------------------------------------ +r1224 | drowe67 | 2013-03-24 00:47:15 -0500 (Sun, 24 Mar 2013) | 1 line + +prototype 1600 wide mode +------------------------------------------------------------------------ +r1223 | drowe67 | 2013-03-22 17:51:40 -0500 (Fri, 22 Mar 2013) | 1 line + +disabled a few extraneous test modes for v0.96 release +------------------------------------------------------------------------ +r1221 | drowe67 | 2013-03-19 22:51:21 -0500 (Tue, 19 Mar 2013) | 1 line + +bump version +------------------------------------------------------------------------ +r1219 | drowe67 | 2013-03-19 20:35:29 -0500 (Tue, 19 Mar 2013) | 1 line + +made test frames count high error rate frames to get a more accurate result +------------------------------------------------------------------------ +r1218 | drowe67 | 2013-03-19 20:21:35 -0500 (Tue, 19 Mar 2013) | 1 line + +integrated and tested more reliable odd/even frame sync, I think it's an improvement on 4dB poor channel +------------------------------------------------------------------------ +r1213 | drowe67 | 2013-03-18 02:30:28 -0500 (Mon, 18 Mar 2013) | 1 line + +removed clip, added new 1600 bit/s mode (1300+FEC) +------------------------------------------------------------------------ +r1205 | drowe67 | 2013-03-08 22:00:48 -0600 (Fri, 08 Mar 2013) | 1 line + +support for clipping of tx waveform +------------------------------------------------------------------------ +r1204 | drowe67 | 2013-03-08 17:59:51 -0600 (Fri, 08 Mar 2013) | 1 line + +normalised tx power across modes +------------------------------------------------------------------------ +r1203 | drowe67 | 2013-03-08 14:49:30 -0600 (Fri, 08 Mar 2013) | 1 line + +Support in Windows Makefile for golay module +------------------------------------------------------------------------ +r1202 | drowe67 | 2013-03-08 01:45:10 -0600 (Fri, 08 Mar 2013) | 1 line + +changed version number +------------------------------------------------------------------------ +r1201 | drowe67 | 2013-03-08 01:24:29 -0600 (Fri, 08 Mar 2013) | 1 line + +first pass at bit error patterns being plotted +------------------------------------------------------------------------ +r1199 | drowe67 | 2013-03-07 21:15:29 -0600 (Thu, 07 Mar 2013) | 1 line + +added multi-channel support to plot scalar, tested OK with 1 channel +------------------------------------------------------------------------ +r1198 | drowe67 | 2013-03-07 20:40:11 -0600 (Thu, 07 Mar 2013) | 1 line + +BER tx and tx working OK, tested with some simulated AWGN and CCIR files +------------------------------------------------------------------------ +r1197 | drowe67 | 2013-03-07 01:37:11 -0600 (Thu, 07 Mar 2013) | 1 line + +FEC on 2000 mode implemented but not tested with errors (yet) +------------------------------------------------------------------------ +r1196 | drowe67 | 2013-03-07 01:23:02 -0600 (Thu, 07 Mar 2013) | 1 line + +2000 bit/s mode seems to be transmitting OK +------------------------------------------------------------------------ +r1194 | drowe67 | 2013-03-07 00:49:11 -0600 (Thu, 07 Mar 2013) | 1 line + +both 1400 and 1600 modes working in loopback, needed to test 1400V0.91 against a V0.91 release +------------------------------------------------------------------------ +r1189 | drowe67 | 2013-03-06 22:18:54 -0600 (Wed, 06 Mar 2013) | 1 line + +added mode radio-buttons to front page of GUI +------------------------------------------------------------------------ +r1155 | wittend99 | 2012-12-30 16:41:15 -0600 (Sun, 30 Dec 2012) | 1 line + +Trivial updates, looking for uninitialized variables and other loose ends. +------------------------------------------------------------------------ +r1154 | wittend99 | 2012-12-29 17:28:53 -0600 (Sat, 29 Dec 2012) | 1 line + +Add files README.osx and freedv_osx_port.patch.gz, update credits.txt file. Not much else. +------------------------------------------------------------------------ +r1153 | wittend99 | 2012-12-29 13:10:49 -0600 (Sat, 29 Dec 2012) | 1 line + + +------------------------------------------------------------------------ +r1152 | drowe67 | 2012-12-23 18:14:07 -0600 (Sun, 23 Dec 2012) | 1 line + +first pass at autotools build system, thanks Patrick, not tested at this stage, Makefile.linux still works +------------------------------------------------------------------------ +r1151 | drowe67 | 2012-12-22 01:29:28 -0600 (Sat, 22 Dec 2012) | 1 line + +changed changed fifo.h and fdmdv.h to more unique names codec2_fifo.h & codec2_fdmdv.h +------------------------------------------------------------------------ +r1145 | wittend99 | 2012-12-16 20:43:05 -0600 (Sun, 16 Dec 2012) | 1 line + +Unversion some pieces unintentionally added by restructuring. +------------------------------------------------------------------------ +r1144 | wittend99 | 2012-12-16 20:40:23 -0600 (Sun, 16 Dec 2012) | 1 line + +Added a msvc folder to build for a future MS C++ build. +------------------------------------------------------------------------ +r1143 | wittend99 | 2012-12-16 20:33:05 -0600 (Sun, 16 Dec 2012) | 1 line + +Move all Codelite-Mingw build environment from ./build to ./build/codelite +------------------------------------------------------------------------ +r1142 | wittend99 | 2012-12-16 20:04:21 -0600 (Sun, 16 Dec 2012) | 1 line + +Add codelite subfolder. +------------------------------------------------------------------------ +r1141 | wittend99 | 2012-12-16 19:56:46 -0600 (Sun, 16 Dec 2012) | 1 line + +Work on moving multiple unrelated classes out of fdmdv_main.cpp, cleanup dead code. +------------------------------------------------------------------------ +r1140 | drowe67 | 2012-12-16 16:57:25 -0600 (Sun, 16 Dec 2012) | 1 line + +disabled jack with portaudio based on mailing list feedback, thanks guys +------------------------------------------------------------------------ +r1139 | drowe67 | 2012-12-16 00:24:46 -0600 (Sun, 16 Dec 2012) | 1 line + +typo in README.linux +------------------------------------------------------------------------ +r1138 | drowe67 | 2012-12-16 00:22:52 -0600 (Sun, 16 Dec 2012) | 1 line + +2nd pass at generic Makefile.linux +------------------------------------------------------------------------ +r1137 | drowe67 | 2012-12-15 17:28:45 -0600 (Sat, 15 Dec 2012) | 1 line + +experimental new makefile for Linux that downloads and builds most of the libraries we need, tested on Ubuntu 9.1 and 10.04 +------------------------------------------------------------------------ +r1136 | drowe67 | 2012-12-15 06:14:13 -0600 (Sat, 15 Dec 2012) | 1 line + +makefile modified for Ubuntu 10.04 +------------------------------------------------------------------------ +r1135 | drowe67 | 2012-12-15 05:41:44 -0600 (Sat, 15 Dec 2012) | 1 line + +experimental Linux makefile, about to test on Ubuntu 10.04 +------------------------------------------------------------------------ +r1134 | wittend99 | 2012-12-14 15:36:21 -0600 (Fri, 14 Dec 2012) | 1 line + +Comment out the event handlers which were connected to the wrong check boxes in the PTT dialog. This _should_ have no effect on behavior because the event handlers in question were unused in the current code. +------------------------------------------------------------------------ +r1133 | wittend99 | 2012-12-12 19:11:14 -0600 (Wed, 12 Dec 2012) | 1 line + + +------------------------------------------------------------------------ +r1132 | wittend99 | 2012-12-11 08:43:05 -0600 (Tue, 11 Dec 2012) | 1 line + + +------------------------------------------------------------------------ +r1131 | drowe67 | 2012-12-10 18:31:12 -0600 (Mon, 10 Dec 2012) | 1 line + +added some debug code to trap reported sox lib errors +------------------------------------------------------------------------ +r1130 | wittend99 | 2012-12-10 18:05:18 -0600 (Mon, 10 Dec 2012) | 2 lines + +Moved version.h from /fdmdv2 to /fdmdv2/src. +Removed four orphaned lib files from /fdmdv2 +------------------------------------------------------------------------ +r1129 | wittend99 | 2012-12-10 17:37:17 -0600 (Mon, 10 Dec 2012) | 2 lines + +Renamed (finally) OnTogBtnTXClick to OnTogBtnPTT globally. +Removed fdmdv2-doc/* for now - to reduce traffic for first time users. Probably to be replaced with freedv-doc when useful content stabilizes. +------------------------------------------------------------------------ +r1128 | drowe67 | 2012-12-09 23:36:38 -0600 (Sun, 09 Dec 2012) | 1 line + +small edits to README.Linux +------------------------------------------------------------------------ +r1127 | drowe67 | 2012-12-09 23:33:18 -0600 (Sun, 09 Dec 2012) | 1 line + +after testing half duplex on Windows +------------------------------------------------------------------------ +r1126 | drowe67 | 2012-12-09 23:09:11 -0600 (Sun, 09 Dec 2012) | 1 line + +first pass at half duplex, still testing +------------------------------------------------------------------------ +r1125 | wittend99 | 2012-12-09 19:55:45 -0600 (Sun, 09 Dec 2012) | 1 line + + +------------------------------------------------------------------------ +r1124 | drowe67 | 2012-12-06 18:14:53 -0600 (Thu, 06 Dec 2012) | 1 line + +analog 6dB boost on mic, some experiments with waterfall blue colors, using 200-2800Hz for waterfall max AGC level, and updated Linux compile notes +------------------------------------------------------------------------ +r1123 | drowe67 | 2012-12-05 21:04:43 -0600 (Wed, 05 Dec 2012) | 1 line + +added V0.9 Beta version code and support for future versioning via version.txt +------------------------------------------------------------------------ +r1122 | drowe67 | 2012-12-05 15:06:24 -0600 (Wed, 05 Dec 2012) | 1 line + +added Codec 2 build instructions to README.Win32 +------------------------------------------------------------------------ +r1121 | wittend99 | 2012-12-05 09:22:25 -0600 (Wed, 05 Dec 2012) | 1 line + +More work on PTT button. +------------------------------------------------------------------------ +r1120 | drowe67 | 2012-12-04 18:37:25 -0600 (Tue, 04 Dec 2012) | 1 line + +fix for File-Exit, works under Linux +------------------------------------------------------------------------ +r1119 | wittend99 | 2012-12-04 15:27:23 -0600 (Tue, 04 Dec 2012) | 1 line + +Improve layout of PTT dialog layout under Linux +------------------------------------------------------------------------ +r1118 | drowe67 | 2012-12-04 00:52:27 -0600 (Tue, 04 Dec 2012) | 1 line + +removed a few prints and #ifdefed out the display of txid/rxid buttons for now as feature wont be implemented for the beta +------------------------------------------------------------------------ +r1117 | wittend99 | 2012-12-03 22:27:26 -0600 (Mon, 03 Dec 2012) | 1 line + + +------------------------------------------------------------------------ +r1116 | wittend99 | 2012-12-03 21:41:59 -0600 (Mon, 03 Dec 2012) | 1 line + + +------------------------------------------------------------------------ +r1115 | wittend99 | 2012-12-03 21:39:40 -0600 (Mon, 03 Dec 2012) | 1 line + + +------------------------------------------------------------------------ +r1114 | drowe67 | 2012-12-02 23:42:18 -0600 (Sun, 02 Dec 2012) | 1 line + +better shut down of EQ states to prevent bombing with sound card error +------------------------------------------------------------------------ +r1113 | drowe67 | 2012-12-02 23:31:12 -0600 (Sun, 02 Dec 2012) | 1 line + +speaker eq states now being preserved and can take eqs in and out at run time +------------------------------------------------------------------------ +r1112 | drowe67 | 2012-12-02 19:41:38 -0600 (Sun, 02 Dec 2012) | 1 line + +real time EQ adjustment working, designing filters on the fly, but still a few GUI and context save/restore bugs +------------------------------------------------------------------------ +r1111 | drowe67 | 2012-12-02 04:39:21 -0600 (Sun, 02 Dec 2012) | 1 line + +EQ enable and separate default buttons, ready to wire up real time code +------------------------------------------------------------------------ +r1110 | drowe67 | 2012-12-02 03:18:22 -0600 (Sun, 02 Dec 2012) | 1 line + +make axis labels dissapear if windows small enough to make text overlap +------------------------------------------------------------------------ +r1109 | drowe67 | 2012-12-01 20:48:07 -0600 (Sat, 01 Dec 2012) | 1 line + +first pass at speaker eq controls +------------------------------------------------------------------------ +r1108 | drowe67 | 2012-12-01 20:26:13 -0600 (Sat, 01 Dec 2012) | 1 line + +some tweaks to mic in filter +------------------------------------------------------------------------ +r1107 | drowe67 | 2012-12-01 18:01:07 -0600 (Sat, 01 Dec 2012) | 1 line + +3 band equaliser for Mic In working on dialog, not connected to actual real time speech yet +------------------------------------------------------------------------ +r1106 | drowe67 | 2012-12-01 02:38:43 -0600 (Sat, 01 Dec 2012) | 1 line + +fixed some registry probs on Win32, read & write formats were different. Think its OK now +------------------------------------------------------------------------ +r1105 | drowe67 | 2012-12-01 01:46:36 -0600 (Sat, 01 Dec 2012) | 1 line + +reduced filter dialog size +------------------------------------------------------------------------ +r1104 | drowe67 | 2012-12-01 00:07:39 -0600 (Sat, 01 Dec 2012) | 1 line + +instructions for building sox on Win32 and modified win32 makefile for sox +------------------------------------------------------------------------ +r1103 | wittend99 | 2012-11-30 22:20:24 -0600 (Fri, 30 Nov 2012) | 1 line + +Fix some things about PTT. +------------------------------------------------------------------------ +r1102 | drowe67 | 2012-11-30 22:06:23 -0600 (Fri, 30 Nov 2012) | 1 line + +first pass at real time update of MicIn spectrum in response to slider +------------------------------------------------------------------------ +r1095 | drowe67 | 2012-11-30 19:56:34 -0600 (Fri, 30 Nov 2012) | 1 line + +reduced size of filter dialog so it fits on 800 high screens... +------------------------------------------------------------------------ +r1094 | drowe67 | 2012-11-30 19:09:11 -0600 (Fri, 30 Nov 2012) | 1 line + +equaliser: one slider partially connected +------------------------------------------------------------------------ +r1093 | wittend99 | 2012-11-30 18:52:49 -0600 (Fri, 30 Nov 2012) | 1 line + + +------------------------------------------------------------------------ +r1092 | drowe67 | 2012-11-30 18:02:09 -0600 (Fri, 30 Nov 2012) | 1 line + +wrote and unit tested library to use sox biqaud filter +------------------------------------------------------------------------ +r1091 | wittend99 | 2012-11-30 14:29:40 -0600 (Fri, 30 Nov 2012) | 1 line + + +------------------------------------------------------------------------ +r1090 | wittend99 | 2012-11-29 20:39:08 -0600 (Thu, 29 Nov 2012) | 1 line + +No more segfault, problem was not in this code. Fixes to the PTT signal polarity, should work now, but not properly tested. +------------------------------------------------------------------------ +r1088 | drowe67 | 2012-11-29 18:36:46 -0600 (Thu, 29 Nov 2012) | 1 line + +Win32 makefile and install notes for libctb +------------------------------------------------------------------------ +r1086 | drowe67 | 2012-11-29 17:30:25 -0600 (Thu, 29 Nov 2012) | 1 line + +modified Linux makefile for libctb, added build instructions for libctb +------------------------------------------------------------------------ +r1085 | wittend99 | 2012-11-29 16:22:25 -0600 (Thu, 29 Nov 2012) | 1 line + +I should have noted - this and the previous commit give me a segfault when the audio processing runs. +------------------------------------------------------------------------ +r1084 | wittend99 | 2012-11-29 16:18:52 -0600 (Thu, 29 Nov 2012) | 1 line + + +------------------------------------------------------------------------ +r1083 | drowe67 | 2012-11-26 23:03:09 -0600 (Mon, 26 Nov 2012) | 1 line + +rewrote callsign system along fdmdv1 lines +------------------------------------------------------------------------ +r1082 | drowe67 | 2012-11-26 21:39:17 -0600 (Mon, 26 Nov 2012) | 1 line + +rescaled waterfall and spectrum to be 300Hz wide, as per fdmdv1 +------------------------------------------------------------------------ +r1080 | drowe67 | 2012-11-26 20:41:12 -0600 (Mon, 26 Nov 2012) | 1 line + +added play file to From Radio option +------------------------------------------------------------------------ +r1079 | drowe67 | 2012-11-26 19:24:40 -0600 (Mon, 26 Nov 2012) | 1 line + +automatic scaling of spectrogram, and toggling color mapping. Think it works better but need to try on real signals +------------------------------------------------------------------------ +r1078 | drowe67 | 2012-11-26 16:48:17 -0600 (Mon, 26 Nov 2012) | 1 line + +implemented level guage on tx & rx inclduing too high warning +------------------------------------------------------------------------ +r1077 | drowe67 | 2012-11-26 14:43:08 -0600 (Mon, 26 Nov 2012) | 1 line + +number of secords to record from radio hard coded for Win32 as I cant read number of secs from dialog ctrl +------------------------------------------------------------------------ +r1073 | drowe67 | 2012-11-26 00:03:20 -0600 (Mon, 26 Nov 2012) | 1 line + +receive data now doing something sensible, but I think rxid window is too big +------------------------------------------------------------------------ +r1070 | wittend99 | 2012-11-25 20:37:41 -0600 (Sun, 25 Nov 2012) | 1 line + + +------------------------------------------------------------------------ +r1069 | drowe67 | 2012-11-25 18:23:24 -0600 (Sun, 25 Nov 2012) | 1 line + +first pass with data, can send messages and printf to screen. Need to think about silence thresholds/time outs +------------------------------------------------------------------------ +r1066 | drowe67 | 2012-11-25 03:34:47 -0600 (Sun, 25 Nov 2012) | 1 line + +tx id callback working on Linux +------------------------------------------------------------------------ +r1065 | drowe67 | 2012-11-25 03:28:31 -0600 (Sun, 25 Nov 2012) | 1 line + +started hooking up controls for tx and rx data experiments +------------------------------------------------------------------------ +r1064 | drowe67 | 2012-11-25 03:27:04 -0600 (Sun, 25 Nov 2012) | 1 line + +modified varicode decoder to retain state between calls so it can be interrupted half way thru decoding one character +------------------------------------------------------------------------ +r1063 | drowe67 | 2012-11-25 00:01:27 -0600 (Sun, 25 Nov 2012) | 1 line + +Filter dialog all hooked up to Codec, still requires testing +------------------------------------------------------------------------ +r1062 | wittend99 | 2012-11-24 20:38:37 -0600 (Sat, 24 Nov 2012) | 1 line + +Work on PTT control dialog. Not finished... +------------------------------------------------------------------------ +r1060 | drowe67 | 2012-11-24 18:00:28 -0600 (Sat, 24 Nov 2012) | 1 line + +basic filter dialog screen working, after usual pain with sizers +------------------------------------------------------------------------ +r1059 | drowe67 | 2012-11-24 16:03:07 -0600 (Sat, 24 Nov 2012) | 1 line + +added filter dialog, it displays OK but doesn't do anything yet. test OK under Linux +------------------------------------------------------------------------ +r1058 | drowe67 | 2012-11-24 05:02:48 -0600 (Sat, 24 Nov 2012) | 1 line + +varicode encoding and decoding, passes unittest +------------------------------------------------------------------------ +r1056 | drowe67 | 2012-11-23 17:27:07 -0600 (Fri, 23 Nov 2012) | 1 line + +minor tweaks to scatter scaling +------------------------------------------------------------------------ +r1055 | drowe67 | 2012-11-23 17:04:43 -0600 (Fri, 23 Nov 2012) | 1 line + +automatic scaling of scatter diagram, quite nice to watch +------------------------------------------------------------------------ +r1054 | drowe67 | 2012-11-23 16:39:17 -0600 (Fri, 23 Nov 2012) | 1 line + +higher resn FFT, red tuning line, automatic page switching on tx/rx, works OK on Linux +------------------------------------------------------------------------ +r1052 | drowe67 | 2012-11-23 13:51:46 -0600 (Fri, 23 Nov 2012) | 1 line + +modified Makefiles for DW cleanup, modified waterfall to handle slow waterfall updates where DT nmaps to less than one vertical pixel. Waterfall now covers 30 seconds. Works OK on Linux +------------------------------------------------------------------------ +r1051 | wittend99 | 2012-11-23 10:24:35 -0600 (Fri, 23 Nov 2012) | 1 line + +Removed unnecessary or distracting Files, C++ Classes, members, and unimplemented code. +------------------------------------------------------------------------ +r1050 | wittend99 | 2012-11-23 10:01:05 -0600 (Fri, 23 Nov 2012) | 1 line + + +------------------------------------------------------------------------ +r1049 | wittend99 | 2012-11-23 09:59:26 -0600 (Fri, 23 Nov 2012) | 1 line + + +------------------------------------------------------------------------ +r1048 | drowe67 | 2012-11-23 04:41:31 -0600 (Fri, 23 Nov 2012) | 1 line + +wired up squelch, added slow SNR option, works OK on Linux, need to test on Win32 +------------------------------------------------------------------------ +r1046 | drowe67 | 2012-11-22 13:39:05 -0600 (Thu, 22 Nov 2012) | 1 line + +modified split so tx doesn't change, version number in program title on main window, edited to-do +------------------------------------------------------------------------ +r1045 | drowe67 | 2012-11-21 17:28:54 -0600 (Wed, 21 Nov 2012) | 1 line + +click tune with split and tx logic, works OK on Linux +------------------------------------------------------------------------ +r1043 | drowe67 | 2012-11-20 23:31:22 -0600 (Tue, 20 Nov 2012) | 1 line + +tx and rx click tune, tied together (non split) +------------------------------------------------------------------------ +r1042 | drowe67 | 2012-11-20 22:57:41 -0600 (Tue, 20 Nov 2012) | 1 line + +rx click tune using globals resulted in a cleaner design although I would prefer not to have used globals. Maybe passing the address of the freq offset in the waterfall/spectrum constructor would have ben cleaner +------------------------------------------------------------------------ +r1041 | drowe67 | 2012-11-20 22:32:21 -0600 (Tue, 20 Nov 2012) | 1 line + +first pass at click to tune for rx. It works OK, but the communication of the click freq sucks so I might try re-writing that bit +------------------------------------------------------------------------ +r1040 | drowe67 | 2012-11-20 04:07:13 -0600 (Tue, 20 Nov 2012) | 1 line + +looks up svn revision from the Internet +------------------------------------------------------------------------ +r1039 | drowe67 | 2012-11-20 02:58:55 -0600 (Tue, 20 Nov 2012) | 1 line + +attemp at support for svn revsion under windows +------------------------------------------------------------------------ +r1038 | drowe67 | 2012-11-20 02:53:47 -0600 (Tue, 20 Nov 2012) | 1 line + +testing adding svn revision to about (yet again) +------------------------------------------------------------------------ +r1037 | drowe67 | 2012-11-20 02:52:51 -0600 (Tue, 20 Nov 2012) | 1 line + +testing adding svn revision to about (and again) +------------------------------------------------------------------------ +r1036 | drowe67 | 2012-11-20 02:45:28 -0600 (Tue, 20 Nov 2012) | 1 line + +testing adding svn revision to about (again) +------------------------------------------------------------------------ +r1035 | drowe67 | 2012-11-20 02:44:30 -0600 (Tue, 20 Nov 2012) | 1 line + +testing adding svn revision to about +------------------------------------------------------------------------ +r1034 | wittend99 | 2012-11-19 21:55:22 -0600 (Mon, 19 Nov 2012) | 1 line + +Modified the header comment block of all files to indicate GPL license. +------------------------------------------------------------------------ +r1033 | drowe67 | 2012-11-19 20:49:53 -0600 (Mon, 19 Nov 2012) | 1 line + +removed tx & rx loopback, as they no longer necc +------------------------------------------------------------------------ +r1032 | drowe67 | 2012-11-19 20:37:44 -0600 (Mon, 19 Nov 2012) | 1 line + +added record from radio feature, works OK on wave and raw files, can demod/decode aved files using command line tools +------------------------------------------------------------------------ +r1031 | drowe67 | 2012-11-19 04:14:34 -0600 (Mon, 19 Nov 2012) | 1 line + +wav and raw at the same time, can't position loop checkbox correctly... +------------------------------------------------------------------------ +r1030 | drowe67 | 2012-11-19 03:56:56 -0600 (Mon, 19 Nov 2012) | 1 line + +added some todos to readme.linux, added play file to mic in feature +------------------------------------------------------------------------ +r1024 | drowe67 | 2012-11-18 21:49:16 -0600 (Sun, 18 Nov 2012) | 1 line + +changed labels on audo config test, fifo header file change +------------------------------------------------------------------------ +r1023 | wittend99 | 2012-11-18 21:20:58 -0600 (Sun, 18 Nov 2012) | 1 line + + +------------------------------------------------------------------------ +r1016 | drowe67 | 2012-11-17 22:26:06 -0600 (Sat, 17 Nov 2012) | 1 line + +tried static text fields for API tab of audio config dlg +------------------------------------------------------------------------ +r1015 | drowe67 | 2012-11-17 17:03:02 -0600 (Sat, 17 Nov 2012) | 1 line + +was a bit unstable under ubuntu/alsa so added some mutex protection around fifo access that is shared by callsbacks and tx/rx processing threads. Alsa now seems more stable. +------------------------------------------------------------------------ +r1014 | drowe67 | 2012-11-17 16:07:23 -0600 (Sat, 17 Nov 2012) | 1 line + +experimental thread based tx/rx processing. Seems more stable on Windows and works better with Rig Blaster despite dirfting tx/rx sample clock. Still some start up transients, i.e. loss of sync in first few seconds and occasionally thereafter +------------------------------------------------------------------------ +r1001 | drowe67 | 2012-11-16 20:11:54 -0600 (Fri, 16 Nov 2012) | 1 line + +moved tx and rx processing to OnIdle, using device-defined buffer sizes for portaudio callbacks. Still testing. +------------------------------------------------------------------------ +r978 | drowe67 | 2012-11-15 22:08:38 -0600 (Thu, 15 Nov 2012) | 1 line + +experimental support for mono record devices such as the rig blaster, still testing +------------------------------------------------------------------------ +r970 | drowe67 | 2012-11-14 05:12:26 -0600 (Wed, 14 Nov 2012) | 1 line + +made sample rate combo box wider +------------------------------------------------------------------------ +r969 | drowe67 | 2012-11-14 02:17:13 -0600 (Wed, 14 Nov 2012) | 1 line + +nicer layout with test feature +------------------------------------------------------------------------ +r968 | drowe67 | 2012-11-13 16:34:42 -0600 (Tue, 13 Nov 2012) | 1 line + +test feature for all 4 audio devices, tested OK on Ubuntu 9.10, needs work on the layout +------------------------------------------------------------------------ +r967 | drowe67 | 2012-11-13 02:18:53 -0600 (Tue, 13 Nov 2012) | 1 line + +first pass at a test tool for audio config dialog that plots input to a little screen. Just rx in at this stage. Some indication that it is occasionally unstable. Might need to convert to async/callback model +------------------------------------------------------------------------ +r966 | drowe67 | 2012-11-12 17:03:04 -0600 (Mon, 12 Nov 2012) | 1 line + +Sync indicator now works for Windows, but isn't multicolour like on Linux. As it is implemented with a radio button, unfortunately the user can press it. +------------------------------------------------------------------------ +r965 | drowe67 | 2012-11-12 16:23:18 -0600 (Mon, 12 Nov 2012) | 1 line + +minor tweaks to SNR positioning +------------------------------------------------------------------------ +r964 | drowe67 | 2012-11-12 15:43:36 -0600 (Mon, 12 Nov 2012) | 1 line + +Testing wxlogdebug and added device number to device name in config dialog to help ID devices with the same name under Windows +------------------------------------------------------------------------ +r963 | drowe67 | 2012-11-12 14:22:51 -0600 (Mon, 12 Nov 2012) | 1 line + +added some notes to Linux README +------------------------------------------------------------------------ +r962 | wittend99 | 2012-11-12 13:53:33 -0600 (Mon, 12 Nov 2012) | 1 line + + +------------------------------------------------------------------------ +r961 | drowe67 | 2012-11-11 22:40:02 -0600 (Sun, 11 Nov 2012) | 1 line + +small sample rate selection bug +------------------------------------------------------------------------ +r960 | drowe67 | 2012-11-11 22:30:48 -0600 (Sun, 11 Nov 2012) | 1 line + +fixed bug, can now run soudn card1 at 44kHz +------------------------------------------------------------------------ +r959 | drowe67 | 2012-11-11 19:34:32 -0600 (Sun, 11 Nov 2012) | 1 line + +After testing on an Alsa based Ubuntu 10 machine: tweaked layout, added dynamic sample rate list generation to dlg_audioconfig, refactored a few routines that got messy, and separated portaudio device number from list box index to support non-duplex devices +------------------------------------------------------------------------ +r958 | drowe67 | 2012-11-11 15:58:29 -0600 (Sun, 11 Nov 2012) | 1 line + +improved detection of erros due to removed sound card +------------------------------------------------------------------------ +r957 | drowe67 | 2012-11-11 04:05:21 -0600 (Sun, 11 Nov 2012) | 1 line + +disable Audio Config dialog when running +------------------------------------------------------------------------ +r956 | drowe67 | 2012-11-10 19:22:01 -0600 (Sat, 10 Nov 2012) | 1 line + +first pass at connecting audio config dialog to rest of system. Can configure single and dual card systems on Unbuntu 9.10. Still a few situations that can crash system +------------------------------------------------------------------------ +r955 | drowe67 | 2012-11-08 22:38:02 -0600 (Thu, 08 Nov 2012) | 1 line + +removed some accel key debug warnings on start up +------------------------------------------------------------------------ +r954 | drowe67 | 2012-11-08 21:16:52 -0600 (Thu, 08 Nov 2012) | 1 line + +peristent storing of squelch levels to config file +------------------------------------------------------------------------ +r953 | drowe67 | 2012-11-08 20:43:55 -0600 (Thu, 08 Nov 2012) | 1 line + +wired up analog mode +------------------------------------------------------------------------ +r952 | drowe67 | 2012-11-08 20:29:35 -0600 (Thu, 08 Nov 2012) | 1 line + +removed ALC +------------------------------------------------------------------------ +r951 | drowe67 | 2012-11-08 19:56:45 -0600 (Thu, 08 Nov 2012) | 1 line + +positioned squelch and snr static text correctly and stays centred +------------------------------------------------------------------------ +r950 | drowe67 | 2012-11-07 22:19:29 -0600 (Wed, 07 Nov 2012) | 1 line + +playing with squelch slider, but not happy with layout +------------------------------------------------------------------------ +r949 | drowe67 | 2012-11-07 19:35:43 -0600 (Wed, 07 Nov 2012) | 1 line + +hooked up sync LED, changed SNR text box to static text to prevent it getting focus +------------------------------------------------------------------------ +r948 | drowe67 | 2012-11-07 17:14:42 -0600 (Wed, 07 Nov 2012) | 1 line + +formatting, and added freq shifter in front of demod to suport click tune feature +------------------------------------------------------------------------ +r944 | wittend99 | 2012-11-07 13:09:14 -0600 (Wed, 07 Nov 2012) | 1 line + +Remove dependencies in Icon files in dlg_audiooptions.*. Eliminated use of icons for now. They were ugly anyway. Dialog returns the string form of the chosen interface, and not the if # for now. This can be trivially changed. +------------------------------------------------------------------------ +r939 | wittend99 | 2012-11-06 20:09:35 -0600 (Tue, 06 Nov 2012) | 1 line + +Changed dlg_audio.* to dlg_audiooptions.*, changed other dlg code, altered makefiles. +------------------------------------------------------------------------ +r938 | wittend99 | 2012-11-06 08:18:21 -0600 (Tue, 06 Nov 2012) | 1 line + + +------------------------------------------------------------------------ +r937 | drowe67 | 2012-11-05 18:47:29 -0600 (Mon, 05 Nov 2012) | 1 line + +Added editor set up instructions to avoid problems with tabs +------------------------------------------------------------------------ +r936 | drowe67 | 2012-11-05 17:58:54 -0600 (Mon, 05 Nov 2012) | 1 line + +changed Davids emacs to use spaces rather than tabs +------------------------------------------------------------------------ +r935 | wittend99 | 2012-11-05 13:22:16 -0600 (Mon, 05 Nov 2012) | 1 line + + +------------------------------------------------------------------------ +r934 | drowe67 | 2012-11-05 02:20:38 -0600 (Mon, 05 Nov 2012) | 1 line + +Added libresample +------------------------------------------------------------------------ +r933 | drowe67 | 2012-11-05 02:18:35 -0600 (Mon, 05 Nov 2012) | 1 line + +added libsamplerate +------------------------------------------------------------------------ +r932 | drowe67 | 2012-11-05 01:46:54 -0600 (Mon, 05 Nov 2012) | 1 line + +SNR text box and bar graph hooked up +------------------------------------------------------------------------ +r931 | drowe67 | 2012-11-04 23:25:34 -0600 (Sun, 04 Nov 2012) | 1 line + +building up soundcard auto detect code +------------------------------------------------------------------------ +r930 | drowe67 | 2012-11-04 23:04:49 -0600 (Sun, 04 Nov 2012) | 1 line + +improved speech plots with a better decimation algorithm +------------------------------------------------------------------------ +r928 | drowe67 | 2012-11-04 18:23:51 -0600 (Sun, 04 Nov 2012) | 1 line + +added experimental waveform plots, the idea is to usethm as a tool to adjust levels. Not sure if they are useful yet... +------------------------------------------------------------------------ +r927 | drowe67 | 2012-11-04 17:11:29 -0600 (Sun, 04 Nov 2012) | 1 line + +first pass at plot-scalar working to produce timing and frequency offset plots +------------------------------------------------------------------------ +r926 | drowe67 | 2012-11-03 17:15:48 -0500 (Sat, 03 Nov 2012) | 1 line + +cleaned up some code after adjusting demod sample rate slip +------------------------------------------------------------------------ +r924 | drowe67 | 2012-11-03 16:30:41 -0500 (Sat, 03 Nov 2012) | 1 line + +refactored sample rate conversion code to clean up sound card 1 call back, works OK +------------------------------------------------------------------------ +r923 | wittend99 | 2012-11-03 10:57:11 -0500 (Sat, 03 Nov 2012) | 1 line + + +------------------------------------------------------------------------ +r922 | drowe67 | 2012-11-03 02:53:32 -0500 (Sat, 03 Nov 2012) | 1 line + +shutdown codec for libresample states +------------------------------------------------------------------------ +r921 | drowe67 | 2012-11-03 01:32:20 -0500 (Sat, 03 Nov 2012) | 1 line + +libresample used for all 4 sample rate conversions, but needs clean up into functions. +------------------------------------------------------------------------ +r920 | drowe67 | 2012-11-03 01:13:21 -0500 (Sat, 03 Nov 2012) | 1 line + +partial port to libresample, using 48kHz for one sound card and 44.1kHz for another +------------------------------------------------------------------------ +r918 | drowe67 | 2012-11-02 01:26:16 -0500 (Fri, 02 Nov 2012) | 1 line + +debug version while testing different headphones +------------------------------------------------------------------------ +r917 | drowe67 | 2012-11-01 21:56:57 -0500 (Thu, 01 Nov 2012) | 1 line + +working better with new headphones - about to remove some debug printfs +------------------------------------------------------------------------ +r916 | drowe67 | 2012-11-01 19:02:56 -0500 (Thu, 01 Nov 2012) | 1 line + +debug version, looking for reason mic audio is getting corrupted +------------------------------------------------------------------------ +r915 | wittend99 | 2012-11-01 17:31:35 -0500 (Thu, 01 Nov 2012) | 1 line + + +------------------------------------------------------------------------ +r902 | drowe67 | 2012-10-30 20:58:52 -0500 (Tue, 30 Oct 2012) | 1 line + +modified for independant in and output portaudio devices to suit Win32. +------------------------------------------------------------------------ +r901 | drowe67 | 2012-10-30 19:18:00 -0500 (Tue, 30 Oct 2012) | 1 line + +first pass at full duplex working ... two sound card, tx looped back to rx audio, can hear what I am saying in headset. Still some stability issues +------------------------------------------------------------------------ +r900 | drowe67 | 2012-10-30 18:40:11 -0500 (Tue, 30 Oct 2012) | 1 line + +have tx process doing something with one sound card - it sends a signal that I can loop back to rx with good quality scatter diagram. Next stage is to enable the 2nd sound card +------------------------------------------------------------------------ +r899 | drowe67 | 2012-10-30 01:18:02 -0500 (Tue, 30 Oct 2012) | 1 line + +first attempt at support for two sound cardsand tx processing. Debugging tx side +------------------------------------------------------------------------ +r888 | drowe67 | 2012-10-28 22:29:37 -0500 (Sun, 28 Oct 2012) | 1 line + +replaced buffers in rx callback with fifos to ease porting to two sound cards +------------------------------------------------------------------------ +r873 | wittend99 | 2012-10-28 18:14:06 -0500 (Sun, 28 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r855 | drowe67 | 2012-10-28 03:31:55 -0500 (Sun, 28 Oct 2012) | 1 line + +changed portaudio buffer size to make OSS work a little better on Ububtu 9.10 - but still cant adjust mic gain +------------------------------------------------------------------------ +r831 | drowe67 | 2012-10-27 00:36:22 -0500 (Sat, 27 Oct 2012) | 1 line + +Fixed Waterfall/Spectrum axis labels on windows. Rx loop also decodes modem signals OK, sounds good, no clicks or pops! +------------------------------------------------------------------------ +r829 | drowe67 | 2012-10-26 18:47:18 -0500 (Fri, 26 Oct 2012) | 1 line + +Davids R's first version building on Win32 +------------------------------------------------------------------------ +r825 | wittend99 | 2012-10-25 17:05:20 -0500 (Thu, 25 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r816 | wittend99 | 2012-10-25 14:34:02 -0500 (Thu, 25 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r815 | wittend99 | 2012-10-25 14:27:38 -0500 (Thu, 25 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r814 | wittend99 | 2012-10-25 14:23:10 -0500 (Thu, 25 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r813 | wittend99 | 2012-10-25 13:45:14 -0500 (Thu, 25 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r812 | wittend99 | 2012-10-25 13:39:14 -0500 (Thu, 25 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r811 | wittend99 | 2012-10-25 08:50:56 -0500 (Thu, 25 Oct 2012) | 1 line + +Just update my IDE configuration probably of no interest to anyone but me. DMW +------------------------------------------------------------------------ +r804 | wittend99 | 2012-10-24 10:30:04 -0500 (Wed, 24 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r803 | drowe67 | 2012-10-24 03:14:35 -0500 (Wed, 24 Oct 2012) | 1 line + +first pass at a working scatter plot - haven't tested on real modem signals yet +------------------------------------------------------------------------ +r802 | drowe67 | 2012-10-23 19:50:22 -0500 (Tue, 23 Oct 2012) | 1 line + +renamed a few variables for consistency, spectrum now working +------------------------------------------------------------------------ +r801 | drowe67 | 2012-10-23 19:20:06 -0500 (Tue, 23 Oct 2012) | 1 line + +fixed axis labels on waterfall and tweaked those on spectrum +------------------------------------------------------------------------ +r800 | wittend99 | 2012-10-23 17:12:37 -0500 (Tue, 23 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r799 | wittend99 | 2012-10-23 17:07:13 -0500 (Tue, 23 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r798 | drowe67 | 2012-10-23 16:03:44 -0500 (Tue, 23 Oct 2012) | 1 line + +spectrum plot drawGraticule() working OK with nice labels +------------------------------------------------------------------------ +r797 | drowe67 | 2012-10-23 05:05:13 -0500 (Tue, 23 Oct 2012) | 1 line + +added some code to handle resizing better, and fact OnSize can't be relied upon to be called for bit map allocation +------------------------------------------------------------------------ +r796 | drowe67 | 2012-10-23 04:37:49 -0500 (Tue, 23 Oct 2012) | 1 line + +cleaned up a little, made var names consistent with plot spectrum +------------------------------------------------------------------------ +r795 | drowe67 | 2012-10-23 04:26:30 -0500 (Tue, 23 Oct 2012) | 1 line + +fixed wrong window dimensions, was reading past endof array and writing past end of bit map +------------------------------------------------------------------------ +r794 | wittend99 | 2012-10-22 10:46:47 -0500 (Mon, 22 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r793 | wittend99 | 2012-10-22 10:31:13 -0500 (Mon, 22 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r792 | wittend99 | 2012-10-22 10:21:49 -0500 (Mon, 22 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r791 | wittend99 | 2012-10-22 10:20:43 -0500 (Mon, 22 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r790 | wittend99 | 2012-10-22 10:11:26 -0500 (Mon, 22 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r789 | wittend99 | 2012-10-22 10:10:00 -0500 (Mon, 22 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r788 | wittend99 | 2012-10-22 10:09:37 -0500 (Mon, 22 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r787 | drowe67 | 2012-10-21 20:35:43 -0500 (Sun, 21 Oct 2012) | 1 line + +spent a few hours trying to debug Stop not erasing bottom 25% of Waterfall, but haven't fixed bug. Leaving for now +------------------------------------------------------------------------ +r786 | drowe67 | 2012-10-20 18:59:33 -0500 (Sat, 20 Oct 2012) | 1 line + +waterfall working at slow update rate on Linux, some visual bugs on stop & restart +------------------------------------------------------------------------ +r785 | drowe67 | 2012-10-20 17:58:04 -0500 (Sat, 20 Oct 2012) | 1 line + +related timer period to update interval of Waterfall +------------------------------------------------------------------------ +r784 | drowe67 | 2012-10-20 17:56:42 -0500 (Sat, 20 Oct 2012) | 1 line + +removed debug printfs +------------------------------------------------------------------------ +r783 | drowe67 | 2012-10-20 17:50:34 -0500 (Sat, 20 Oct 2012) | 1 line + +free g_RxInBuf on Stop +------------------------------------------------------------------------ +r782 | drowe67 | 2012-10-19 21:29:23 -0500 (Fri, 19 Oct 2012) | 1 line + +bottom line of spectrogram working at 500ms period +------------------------------------------------------------------------ +r781 | drowe67 | 2012-10-19 18:22:35 -0500 (Fri, 19 Oct 2012) | 1 line + +bitmap test pattern working +------------------------------------------------------------------------ +r780 | drowe67 | 2012-10-19 16:43:56 -0500 (Fri, 19 Oct 2012) | 1 line + +libsndfile support +------------------------------------------------------------------------ +r779 | wittend99 | 2012-10-19 16:28:59 -0500 (Fri, 19 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r778 | wittend99 | 2012-10-19 07:54:57 -0500 (Fri, 19 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r777 | drowe67 | 2012-10-18 23:50:43 -0500 (Thu, 18 Oct 2012) | 1 line + +initial cjeck in of wxWdigets image test dir +------------------------------------------------------------------------ +r766 | wittend99 | 2012-10-17 07:53:44 -0500 (Wed, 17 Oct 2012) | 2 lines + +minimal changes. + +------------------------------------------------------------------------ +r765 | wittend99 | 2012-10-16 12:25:48 -0500 (Tue, 16 Oct 2012) | 1 line + +Updating doxygen documentation and removing some unnecessary junk that has accumulated. +------------------------------------------------------------------------ +r764 | wittend99 | 2012-10-16 10:32:32 -0500 (Tue, 16 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r763 | wittend99 | 2012-10-16 10:17:09 -0500 (Tue, 16 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r762 | wittend99 | 2012-10-16 10:16:45 -0500 (Tue, 16 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r761 | wittend99 | 2012-10-15 21:01:27 -0500 (Mon, 15 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r760 | wittend99 | 2012-10-15 20:29:25 -0500 (Mon, 15 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r759 | wittend99 | 2012-10-15 20:28:47 -0500 (Mon, 15 Oct 2012) | 1 line + + +------------------------------------------------------------------------ +r757 | drowe67 | 2012-10-15 16:19:49 -0500 (Mon, 15 Oct 2012) | 1 line + +main demod processing loop runs without crashing +------------------------------------------------------------------------ +r752 | drowe67 | 2012-10-14 22:59:03 -0500 (Sun, 14 Oct 2012) | 1 line + +added a fifo buffer to interface between framesPerBufferof portaudio and the buffer size we need for modem processing. Basic audio loopback working now +------------------------------------------------------------------------ +r748 | drowe67 | 2012-10-13 16:50:57 -0500 (Sat, 13 Oct 2012) | 1 line + +build instructions for Linux +------------------------------------------------------------------------ +r747 | drowe67 | 2012-10-13 02:25:50 -0500 (Sat, 13 Oct 2012) | 1 line + +temp. disabled timer and rx callback to stabilise, can start/stop without crashing now +------------------------------------------------------------------------ +r746 | drowe67 | 2012-10-13 01:32:03 -0500 (Sat, 13 Oct 2012) | 1 line + +re-orged linux Makefile a little +------------------------------------------------------------------------ +r745 | wittend99 | 2012-10-12 16:49:51 -0500 (Fri, 12 Oct 2012) | 1 line + +Convert line endings to UNIX style for readability. +------------------------------------------------------------------------ +r744 | drowe67 | 2012-10-11 19:53:06 -0500 (Thu, 11 Oct 2012) | 1 line + +changed syntax of extern g_avmag to fix segfault +------------------------------------------------------------------------ +r743 | drowe67 | 2012-10-11 18:29:14 -0500 (Thu, 11 Oct 2012) | 1 line + +added setColour to prevent bombing on Linux +------------------------------------------------------------------------ +r742 | drowe67 | 2012-10-11 00:16:50 -0500 (Thu, 11 Oct 2012) | 1 line + +first pass at Makefile for Linux +------------------------------------------------------------------------ +r740 | wittend99 | 2012-10-09 22:31:50 -0500 (Tue, 09 Oct 2012) | 1 line + +Killer bug. Data point array not initialized? +------------------------------------------------------------------------ +r739 | wittend99 | 2012-10-08 08:29:38 -0500 (Mon, 08 Oct 2012) | 1 line + +Receive side connected, segfault still to be tracked down. +------------------------------------------------------------------------ +r738 | wittend99 | 2012-10-06 14:16:25 -0500 (Sat, 06 Oct 2012) | 1 line + +Various incremental advances. Not 'there' yet. +------------------------------------------------------------------------ +r731 | wittend99 | 2012-09-19 12:21:32 -0500 (Wed, 19 Sep 2012) | 1 line + + +------------------------------------------------------------------------ +r730 | wittend99 | 2012-09-19 12:11:30 -0500 (Wed, 19 Sep 2012) | 1 line + + +------------------------------------------------------------------------ +r716 | wittend99 | 2012-09-17 13:16:46 -0500 (Mon, 17 Sep 2012) | 1 line + + +------------------------------------------------------------------------ +r712 | wittend99 | 2012-09-14 18:26:51 -0500 (Fri, 14 Sep 2012) | 1 line + + +------------------------------------------------------------------------ +r676 | wittend99 | 2012-09-11 15:10:16 -0500 (Tue, 11 Sep 2012) | 1 line + + +------------------------------------------------------------------------ +r675 | wittend99 | 2012-09-11 14:58:36 -0500 (Tue, 11 Sep 2012) | 1 line + + +------------------------------------------------------------------------ +r674 | wittend99 | 2012-09-11 14:51:11 -0500 (Tue, 11 Sep 2012) | 1 line + +no longer needed. +------------------------------------------------------------------------ +r673 | wittend99 | 2012-09-11 14:49:55 -0500 (Tue, 11 Sep 2012) | 1 line + +no longer needed. +------------------------------------------------------------------------ +r672 | wittend99 | 2012-09-11 14:44:56 -0500 (Tue, 11 Sep 2012) | 1 line + + +------------------------------------------------------------------------ +r671 | wittend99 | 2012-09-11 14:36:45 -0500 (Tue, 11 Sep 2012) | 1 line + + +------------------------------------------------------------------------ +r670 | wittend99 | 2012-09-11 12:13:28 -0500 (Tue, 11 Sep 2012) | 1 line + + +------------------------------------------------------------------------ +r667 | wittend99 | 2012-09-10 11:45:37 -0500 (Mon, 10 Sep 2012) | 1 line + + +------------------------------------------------------------------------ +r666 | wittend99 | 2012-09-10 11:25:14 -0500 (Mon, 10 Sep 2012) | 1 line + +Beginning to add some code documentation using Doxygen. +------------------------------------------------------------------------ +r663 | wittend99 | 2012-09-04 21:54:00 -0500 (Tue, 04 Sep 2012) | 1 line + + +------------------------------------------------------------------------ +r662 | wittend99 | 2012-09-04 21:47:34 -0500 (Tue, 04 Sep 2012) | 1 line + + +------------------------------------------------------------------------ +r660 | wittend99 | 2012-09-04 15:44:29 -0500 (Tue, 04 Sep 2012) | 1 line + + +------------------------------------------------------------------------ +r659 | wittend99 | 2012-09-04 15:43:00 -0500 (Tue, 04 Sep 2012) | 1 line + + +------------------------------------------------------------------------ +r658 | wittend99 | 2012-09-04 15:40:24 -0500 (Tue, 04 Sep 2012) | 1 line + + +------------------------------------------------------------------------ +r647 | wittend99 | 2012-08-28 23:03:56 -0500 (Tue, 28 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r646 | wittend99 | 2012-08-28 22:54:54 -0500 (Tue, 28 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r645 | wittend99 | 2012-08-28 22:50:53 -0500 (Tue, 28 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r643 | wittend99 | 2012-08-27 12:01:45 -0500 (Mon, 27 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r639 | wittend99 | 2012-08-24 14:01:17 -0500 (Fri, 24 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r638 | wittend99 | 2012-08-24 14:00:49 -0500 (Fri, 24 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r637 | wittend99 | 2012-08-24 13:56:48 -0500 (Fri, 24 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r636 | wittend99 | 2012-08-22 12:33:04 -0500 (Wed, 22 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r634 | wittend99 | 2012-08-21 16:29:09 -0500 (Tue, 21 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r633 | wittend99 | 2012-08-21 13:26:23 -0500 (Tue, 21 Aug 2012) | 1 line + +Working to get an Autotools build in place. +------------------------------------------------------------------------ +r632 | wittend99 | 2012-08-20 15:09:21 -0500 (Mon, 20 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r631 | wittend99 | 2012-08-20 14:54:14 -0500 (Mon, 20 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r630 | wittend99 | 2012-08-20 14:53:49 -0500 (Mon, 20 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r629 | wittend99 | 2012-08-20 14:52:31 -0500 (Mon, 20 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r628 | wittend99 | 2012-08-20 14:43:10 -0500 (Mon, 20 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r627 | wittend99 | 2012-08-17 15:57:31 -0500 (Fri, 17 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r626 | wittend99 | 2012-08-17 15:50:27 -0500 (Fri, 17 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r625 | wittend99 | 2012-08-17 15:50:00 -0500 (Fri, 17 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r624 | wittend99 | 2012-08-17 15:48:58 -0500 (Fri, 17 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r623 | wittend99 | 2012-08-17 15:43:19 -0500 (Fri, 17 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r622 | wittend99 | 2012-08-17 15:42:13 -0500 (Fri, 17 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r621 | wittend99 | 2012-08-17 15:20:38 -0500 (Fri, 17 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r620 | wittend99 | 2012-08-17 15:18:55 -0500 (Fri, 17 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r619 | wittend99 | 2012-08-17 15:18:39 -0500 (Fri, 17 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r618 | wittend99 | 2012-08-17 15:18:24 -0500 (Fri, 17 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r617 | wittend99 | 2012-08-17 15:10:20 -0500 (Fri, 17 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r616 | wittend99 | 2012-08-17 15:07:18 -0500 (Fri, 17 Aug 2012) | 1 line + +For variant versions +------------------------------------------------------------------------ +r615 | wittend99 | 2012-08-17 15:05:10 -0500 (Fri, 17 Aug 2012) | 1 line + +Moved to ./3rdparty +------------------------------------------------------------------------ +r614 | wittend99 | 2012-08-17 15:03:59 -0500 (Fri, 17 Aug 2012) | 1 line + +Moved to ./3rdparty +------------------------------------------------------------------------ +r613 | wittend99 | 2012-08-17 15:02:47 -0500 (Fri, 17 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r612 | wittend99 | 2012-08-14 21:31:28 -0500 (Tue, 14 Aug 2012) | 1 line + + +------------------------------------------------------------------------ +r589 | wittend99 | 2012-07-15 15:45:52 -0500 (Sun, 15 Jul 2012) | 1 line + + +------------------------------------------------------------------------ +r588 | wittend99 | 2012-07-15 15:44:30 -0500 (Sun, 15 Jul 2012) | 1 line + + +------------------------------------------------------------------------ +r571 | wittend99 | 2012-06-18 10:10:40 -0500 (Mon, 18 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r570 | wittend99 | 2012-06-18 10:07:01 -0500 (Mon, 18 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r569 | wittend99 | 2012-06-18 10:06:26 -0500 (Mon, 18 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r568 | wittend99 | 2012-06-18 10:04:56 -0500 (Mon, 18 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r567 | wittend99 | 2012-06-18 10:04:10 -0500 (Mon, 18 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r566 | wittend99 | 2012-06-18 09:16:14 -0500 (Mon, 18 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r565 | wittend99 | 2012-06-18 09:13:02 -0500 (Mon, 18 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r564 | wittend99 | 2012-06-18 09:10:53 -0500 (Mon, 18 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r563 | wittend99 | 2012-06-18 09:08:49 -0500 (Mon, 18 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r562 | wittend99 | 2012-06-18 08:54:08 -0500 (Mon, 18 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r561 | wittend99 | 2012-06-18 08:52:45 -0500 (Mon, 18 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r560 | wittend99 | 2012-06-18 08:52:08 -0500 (Mon, 18 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r559 | wittend99 | 2012-06-18 08:51:00 -0500 (Mon, 18 Jun 2012) | 1 line + +Update svn:ignore +------------------------------------------------------------------------ +r558 | wittend99 | 2012-06-18 08:45:24 -0500 (Mon, 18 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r557 | wittend99 | 2012-06-18 08:44:06 -0500 (Mon, 18 Jun 2012) | 1 line + +Some cleanup +------------------------------------------------------------------------ +r556 | wittend99 | 2012-06-17 10:05:25 -0500 (Sun, 17 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r555 | wittend99 | 2012-06-17 10:03:12 -0500 (Sun, 17 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r554 | wittend99 | 2012-06-17 10:02:44 -0500 (Sun, 17 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r553 | wittend99 | 2012-06-17 10:00:29 -0500 (Sun, 17 Jun 2012) | 1 line + +Bunches of work on portaudio, still not done. Added fdmdvBasic tor testing, it is the same as the main app without the graphic spectrum display. It may not be useful for without the waterfall display for tuning. +------------------------------------------------------------------------ +r551 | wittend99 | 2012-06-15 09:26:24 -0500 (Fri, 15 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r550 | wittend99 | 2012-06-15 09:25:06 -0500 (Fri, 15 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r549 | wittend99 | 2012-06-15 09:20:30 -0500 (Fri, 15 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r548 | wittend99 | 2012-06-15 09:19:41 -0500 (Fri, 15 Jun 2012) | 1 line + +experiments +------------------------------------------------------------------------ +r547 | wittend99 | 2012-06-15 09:18:07 -0500 (Fri, 15 Jun 2012) | 1 line + +update build from codec2-dev 545 +------------------------------------------------------------------------ +r546 | wittend99 | 2012-06-12 07:30:44 -0500 (Tue, 12 Jun 2012) | 1 line + + +------------------------------------------------------------------------ +r521 | wittend99 | 2012-05-30 21:53:15 -0500 (Wed, 30 May 2012) | 1 line + +Still working on the audio dialog, mostly. +------------------------------------------------------------------------ +r520 | wittend99 | 2012-05-29 22:43:11 -0500 (Tue, 29 May 2012) | 1 line + +Work on portaudio dialog, misc. cleanup. +------------------------------------------------------------------------ +r518 | wittend99 | 2012-05-29 18:27:43 -0500 (Tue, 29 May 2012) | 1 line + + +------------------------------------------------------------------------ +r517 | wittend99 | 2012-05-29 18:26:27 -0500 (Tue, 29 May 2012) | 1 line + + +------------------------------------------------------------------------ +r516 | wittend99 | 2012-05-29 18:07:56 -0500 (Tue, 29 May 2012) | 1 line + + +------------------------------------------------------------------------ +r515 | wittend99 | 2012-05-29 17:53:59 -0500 (Tue, 29 May 2012) | 1 line + + +------------------------------------------------------------------------ +r514 | wittend99 | 2012-05-29 17:53:42 -0500 (Tue, 29 May 2012) | 1 line + + +------------------------------------------------------------------------ +r513 | wittend99 | 2012-05-29 17:53:00 -0500 (Tue, 29 May 2012) | 1 line + + +------------------------------------------------------------------------ +r512 | wittend99 | 2012-05-29 17:50:22 -0500 (Tue, 29 May 2012) | 1 line + + +------------------------------------------------------------------------ +r511 | wittend99 | 2012-05-29 17:49:51 -0500 (Tue, 29 May 2012) | 1 line + + +------------------------------------------------------------------------ +r510 | wittend99 | 2012-05-29 17:49:13 -0500 (Tue, 29 May 2012) | 1 line + + +------------------------------------------------------------------------ +r509 | wittend99 | 2012-05-29 17:48:28 -0500 (Tue, 29 May 2012) | 1 line + + +------------------------------------------------------------------------ +r508 | wittend99 | 2012-05-29 17:47:54 -0500 (Tue, 29 May 2012) | 1 line + + +------------------------------------------------------------------------ +r507 | wittend99 | 2012-05-29 17:35:24 -0500 (Tue, 29 May 2012) | 1 line + + +------------------------------------------------------------------------ +r505 | wittend99 | 2012-05-27 12:34:55 -0500 (Sun, 27 May 2012) | 1 line + + +------------------------------------------------------------------------ +r504 | wittend99 | 2012-05-27 10:44:30 -0500 (Sun, 27 May 2012) | 1 line + + +------------------------------------------------------------------------ +r503 | wittend99 | 2012-05-27 10:41:44 -0500 (Sun, 27 May 2012) | 1 line + + +------------------------------------------------------------------------ +r502 | wittend99 | 2012-05-26 22:10:12 -0500 (Sat, 26 May 2012) | 1 line + + +------------------------------------------------------------------------ +r501 | wittend99 | 2012-05-26 21:53:08 -0500 (Sat, 26 May 2012) | 1 line + +fdmdv2dll builds, as yet untested though. +------------------------------------------------------------------------ +r500 | wittend99 | 2012-05-26 09:05:50 -0500 (Sat, 26 May 2012) | 1 line + + +------------------------------------------------------------------------ +r499 | wittend99 | 2012-05-26 08:31:29 -0500 (Sat, 26 May 2012) | 1 line + +changed this to fdmdv2dll +------------------------------------------------------------------------ +r498 | wittend99 | 2012-05-26 08:30:03 -0500 (Sat, 26 May 2012) | 1 line + +Attempting to clean up the project. +------------------------------------------------------------------------ +r497 | wittend99 | 2012-05-26 08:26:01 -0500 (Sat, 26 May 2012) | 1 line + + +------------------------------------------------------------------------ +r495 | wittend99 | 2012-05-26 07:59:29 -0500 (Sat, 26 May 2012) | 1 line + + +------------------------------------------------------------------------ +r494 | wittend99 | 2012-05-26 07:17:59 -0500 (Sat, 26 May 2012) | 1 line + + +------------------------------------------------------------------------ +r493 | wittend99 | 2012-05-26 07:17:28 -0500 (Sat, 26 May 2012) | 1 line + + +------------------------------------------------------------------------ +r491 | wittend99 | 2012-05-24 18:46:43 -0500 (Thu, 24 May 2012) | 1 line + + +------------------------------------------------------------------------ +r486 | wittend99 | 2012-05-21 21:23:11 -0500 (Mon, 21 May 2012) | 1 line + + +------------------------------------------------------------------------ +r485 | wittend99 | 2012-05-19 20:58:55 -0500 (Sat, 19 May 2012) | 1 line + + +------------------------------------------------------------------------ +r480 | wittend99 | 2012-05-17 21:16:32 -0500 (Thu, 17 May 2012) | 1 line + + +------------------------------------------------------------------------ +r479 | wittend99 | 2012-05-17 21:10:59 -0500 (Thu, 17 May 2012) | 1 line + + +------------------------------------------------------------------------ +r478 | wittend99 | 2012-05-17 21:09:48 -0500 (Thu, 17 May 2012) | 1 line + + +------------------------------------------------------------------------ +r477 | wittend99 | 2012-05-17 21:08:19 -0500 (Thu, 17 May 2012) | 1 line + + +------------------------------------------------------------------------ +r476 | wittend99 | 2012-05-17 21:07:58 -0500 (Thu, 17 May 2012) | 1 line + + +------------------------------------------------------------------------ +r475 | wittend99 | 2012-05-17 21:06:15 -0500 (Thu, 17 May 2012) | 1 line + +Catching up before things get into a snarl. +------------------------------------------------------------------------ +r474 | wittend99 | 2012-05-17 13:06:55 -0500 (Thu, 17 May 2012) | 1 line + +More basic required library files. +------------------------------------------------------------------------ +r473 | wittend99 | 2012-05-17 12:54:14 -0500 (Thu, 17 May 2012) | 1 line + + +------------------------------------------------------------------------ +r472 | wittend99 | 2012-05-17 10:08:08 -0500 (Thu, 17 May 2012) | 1 line + + +------------------------------------------------------------------------ +r471 | wittend99 | 2012-05-17 10:03:24 -0500 (Thu, 17 May 2012) | 1 line + +More work with portaudiocpp +------------------------------------------------------------------------ +r470 | wittend99 | 2012-05-15 21:31:30 -0500 (Tue, 15 May 2012) | 1 line + + +------------------------------------------------------------------------ +r469 | wittend99 | 2012-05-15 14:11:26 -0500 (Tue, 15 May 2012) | 1 line + +synching things up... +------------------------------------------------------------------------ +r468 | wittend99 | 2012-05-15 14:07:29 -0500 (Tue, 15 May 2012) | 1 line + + +------------------------------------------------------------------------ +r467 | wittend99 | 2012-05-15 08:47:57 -0500 (Tue, 15 May 2012) | 1 line + +Fun with portaudio! +------------------------------------------------------------------------ +r466 | wittend99 | 2012-05-15 08:44:43 -0500 (Tue, 15 May 2012) | 1 line + + +------------------------------------------------------------------------ +r465 | wittend99 | 2012-05-15 08:44:23 -0500 (Tue, 15 May 2012) | 1 line + + +------------------------------------------------------------------------ +r464 | wittend99 | 2012-05-15 08:44:02 -0500 (Tue, 15 May 2012) | 1 line + + +------------------------------------------------------------------------ +r463 | wittend99 | 2012-05-15 08:42:49 -0500 (Tue, 15 May 2012) | 1 line + + +------------------------------------------------------------------------ +r462 | wittend99 | 2012-05-14 20:25:56 -0500 (Mon, 14 May 2012) | 1 line + + +------------------------------------------------------------------------ +r460 | wittend99 | 2012-05-13 20:04:35 -0500 (Sun, 13 May 2012) | 1 line + + +------------------------------------------------------------------------ +r459 | wittend99 | 2012-05-13 19:55:29 -0500 (Sun, 13 May 2012) | 1 line + +built libs and headers for linking +------------------------------------------------------------------------ +r458 | wittend99 | 2012-05-13 19:51:07 -0500 (Sun, 13 May 2012) | 1 line + + +------------------------------------------------------------------------ +r456 | wittend99 | 2012-05-13 19:25:07 -0500 (Sun, 13 May 2012) | 1 line + + +------------------------------------------------------------------------ +r455 | wittend99 | 2012-05-13 19:13:32 -0500 (Sun, 13 May 2012) | 1 line + +Notes about building portaudio for fdmdv2. +------------------------------------------------------------------------ +r453 | wittend99 | 2012-05-13 16:19:57 -0500 (Sun, 13 May 2012) | 1 line + +portaudio portable audio framework +------------------------------------------------------------------------ +r452 | wittend99 | 2012-05-13 16:10:42 -0500 (Sun, 13 May 2012) | 1 line + + +------------------------------------------------------------------------ +r451 | wittend99 | 2012-05-13 15:49:44 -0500 (Sun, 13 May 2012) | 1 line + +remove incorrect paths +------------------------------------------------------------------------ +r450 | wittend99 | 2012-05-13 15:49:03 -0500 (Sun, 13 May 2012) | 1 line + +Workspace for the Codelite IDE +------------------------------------------------------------------------ +r449 | wittend99 | 2012-05-13 15:48:16 -0500 (Sun, 13 May 2012) | 1 line + +fixup some paths +------------------------------------------------------------------------ +r448 | wittend99 | 2012-05-13 15:44:49 -0500 (Sun, 13 May 2012) | 1 line + +project file for Codelite +------------------------------------------------------------------------ +r447 | wittend99 | 2012-05-13 14:43:58 -0500 (Sun, 13 May 2012) | 1 line + +Potentially for use for rig control +------------------------------------------------------------------------ +r446 | wittend99 | 2012-05-13 14:32:29 -0500 (Sun, 13 May 2012) | 1 line + +Possible rs-232 Comm library for use if needed. Born of frustration with existing options. After all these years isn't there a decent, usable, documented cross-platform library somewhere? +------------------------------------------------------------------------ +r445 | wittend99 | 2012-05-13 14:20:14 -0500 (Sun, 13 May 2012) | 1 line + +A copy of libsndfile.dll built for Win32 using MinGW + MSYS on Win7 +------------------------------------------------------------------------ +r444 | wittend99 | 2012-05-13 14:17:16 -0500 (Sun, 13 May 2012) | 1 line + +Just running notes about where ideas and code have come from. +------------------------------------------------------------------------ +r443 | wittend99 | 2012-05-13 14:10:56 -0500 (Sun, 13 May 2012) | 1 line + +Class declarations for the spectrum and waterfall classes. +------------------------------------------------------------------------ +r442 | wittend99 | 2012-05-13 14:08:16 -0500 (Sun, 13 May 2012) | 1 line + +Intended to be a superclass to the waterfall and spectrum plot classes. Currently the UI just instantiates one directly derived for each window in the wxNotebook display. +------------------------------------------------------------------------ +r441 | wittend99 | 2012-05-13 14:03:07 -0500 (Sun, 13 May 2012) | 1 line + + +------------------------------------------------------------------------ +r440 | wittend99 | 2012-05-13 11:30:57 -0500 (Sun, 13 May 2012) | 1 line + +UI Project 'main' header +------------------------------------------------------------------------ +r439 | wittend99 | 2012-05-13 11:30:12 -0500 (Sun, 13 May 2012) | 1 line + +UI project 'main' module +------------------------------------------------------------------------ +r438 | wittend99 | 2012-05-13 11:28:34 -0500 (Sun, 13 May 2012) | 1 line + +Workspace for CodeLite +------------------------------------------------------------------------ +r437 | wittend99 | 2012-05-13 11:03:53 -0500 (Sun, 13 May 2012) | 1 line + +An XRC definition of the UI window classes. Can be used by wxWidgets, but is just for reference in this project. +------------------------------------------------------------------------ +r436 | wittend99 | 2012-05-13 11:01:37 -0500 (Sun, 13 May 2012) | 1 line + +wxFormbuilder generated Python version of the UI classes, included just for grins (for now) +------------------------------------------------------------------------ +r435 | wittend99 | 2012-05-13 10:59:09 -0500 (Sun, 13 May 2012) | 1 line + +wxFormbuilder generated UI class declarations. (topframe.* are all generated classes. Don' Edit!) +------------------------------------------------------------------------ +r434 | wittend99 | 2012-05-13 10:56:34 -0500 (Sun, 13 May 2012) | 1 line + +Defines the top level frame window for the UI as well as the dialogs. the MainFrame classs and all of the dialog classes inherit from this. +------------------------------------------------------------------------ +r433 | wittend99 | 2012-05-13 10:53:43 -0500 (Sun, 13 May 2012) | 1 line + +wxFormbuilder Project File used to create the top-level UI and the dialogs. Probably requires wxFormbuilder v. 3.3.2-beta or above. This generates topframe.h, topframe.cpp, (and topframe.py, topframe.xrc for experimentation). Use this with care. +------------------------------------------------------------------------ +r432 | wittend99 | 2012-05-13 10:45:54 -0500 (Sun, 13 May 2012) | 1 line + +Sound file Read/Write library +------------------------------------------------------------------------ +r431 | wittend99 | 2012-05-13 10:39:42 -0500 (Sun, 13 May 2012) | 1 line + +sample rate conversion library aka "Secret Rabbit Code" +------------------------------------------------------------------------ +r430 | wittend99 | 2012-05-13 10:31:45 -0500 (Sun, 13 May 2012) | 1 line + +General Program Options Dialog Header +------------------------------------------------------------------------ +r429 | wittend99 | 2012-05-13 10:30:39 -0500 (Sun, 13 May 2012) | 1 line + +General Program Options Dialog +------------------------------------------------------------------------ +r428 | wittend99 | 2012-05-13 10:29:55 -0500 (Sun, 13 May 2012) | 1 line + +Comm Ports Dialog Header +------------------------------------------------------------------------ +r427 | wittend99 | 2012-05-13 10:29:07 -0500 (Sun, 13 May 2012) | 1 line + +Comm Ports Dialog +------------------------------------------------------------------------ +r426 | wittend99 | 2012-05-13 10:27:58 -0500 (Sun, 13 May 2012) | 1 line + +Audio Dialog Header +------------------------------------------------------------------------ +r425 | wittend99 | 2012-05-13 10:27:22 -0500 (Sun, 13 May 2012) | 1 line + +Audio Dialog +------------------------------------------------------------------------ +r424 | wittend99 | 2012-05-13 10:26:11 -0500 (Sun, 13 May 2012) | 1 line + +help>About Header +------------------------------------------------------------------------ +r423 | wittend99 | 2012-05-13 10:25:24 -0500 (Sun, 13 May 2012) | 1 line + +help>About Dialog. +------------------------------------------------------------------------ +r422 | wittend99 | 2012-05-13 10:23:55 -0500 (Sun, 13 May 2012) | 1 line + +wxWidgets DLL file used for Win32 build. +------------------------------------------------------------------------ +r421 | wittend99 | 2012-05-13 10:08:46 -0500 (Sun, 13 May 2012) | 1 line + +A folder for fdmdv-2 UI work. +------------------------------------------------------------------------ diff --git a/fdmdv2/branches/0.97/DEBIAN_DEVEL.sh b/fdmdv2/branches/0.97/DEBIAN_DEVEL.sh new file mode 100644 index 00000000..71cf970c --- /dev/null +++ b/fdmdv2/branches/0.97/DEBIAN_DEVEL.sh @@ -0,0 +1 @@ +apt-get install cmake gcc g++ libportaudio-dev libhamlib-dev libsamplerate-dev libsndfile-dev libsox-dev libgtk-3-dev libasound-dev diff --git a/fdmdv2/branches/0.97/DEBIAN_RUNTIME.sh b/fdmdv2/branches/0.97/DEBIAN_RUNTIME.sh new file mode 100644 index 00000000..239945fb --- /dev/null +++ b/fdmdv2/branches/0.97/DEBIAN_RUNTIME.sh @@ -0,0 +1 @@ +apt-get install libportaudio2 libhamlib2 libsamplerate0 libsndfile1 libsox2 libgtk-3-0 libasound2 diff --git a/fdmdv2/branches/0.97/Desktop.ini b/fdmdv2/branches/0.97/Desktop.ini new file mode 100644 index 00000000..ae60713d Binary files /dev/null and b/fdmdv2/branches/0.97/Desktop.ini differ diff --git a/fdmdv2/branches/0.97/INSTALL b/fdmdv2/branches/0.97/INSTALL new file mode 100644 index 00000000..2d82cd66 --- /dev/null +++ b/fdmdv2/branches/0.97/INSTALL @@ -0,0 +1,74 @@ +The CMake configuration for FDMDV2 (FreeDV) is the primary build method at +this time and has been thouroughly tested on Fedora Linux and will likely work +well on most *nix systems and has many advanages over the autotools config. + +It should also work on Windows environments but only the mingw-w64 is tested +to work using the MSYS2 environment. Others may work but you're on your own. + +- Builds against system libraries (by default). +- Or optionally download, build, and statically link with required libraries on + an individual basis. See USE_STATIC_??? options. + NOTE: We need test reports on mingw/Windows, not all dependencies will build. +- Has experimental NSIS packaing support for Windows (WIN32) targets. *nix + systems should rely on 'make install' or tradional packaing methods as the + packages (RPM & DEB) created by CPack are questionable. + +================================== + Building and installing on Linux +================================== + +To perform a cmake build create a directory anywhere underneath (or outside of) +the source directory. + +Linux command line example: + +$ cd /path/to/fdmdv2 +$ mkdir build_linux +$ cd build_linux +$ cmake ../ (defaults to /usr/local, use CMAKE_INSTALL_PREFIX to override) +(if no errors) +$ make +(as root) +$ make install + +==================================== + Building and installing on Windows +==================================== + +The windows build is similar to linux and follows the same basic workflow. + +Only MinGW is supported. While it is likely possible to perform a pure MinGW +build, installing MSYS will make your life easier. + +CMake may not automatically detect that you're in the MSYS environment. If this +occurs you need to pass cmake the proper generator: + +cmake -G"MSYS Makefiles" [other options] + +=============================== + Bootstrapping wxWidgets build +=============================== + +If wxWidgets (>= 3.0) is not available then one option is to have CMake boot- +strap the build for FreeDV. + +This is required because the tool wx-config is used to get the correct compiler +and linker flags of the wxWidgets components needed by FreeDV. Since this is +normally done at configure time, not during "make", it is not possible for CMake +to have this information prior to building wxWidgets. + +In order to work around this issue you can "bootstrap" the wxWidgets build using +the CMake option, "BOOTSTRAP_WXWIDGETS". wxWidgets will be built using static +libraries. + +NOTE: This forces "USE_STATIC_WXWIDGETS" to be true internally regarless of the +value set manually. + +(from any prefered directory outside of the source) +$ cmake -DBOOTSTRAP_WXWIDGETS=TRUE +$ make +(wxWidgets is downloaded and built) +$ cmake . +$ make +(if all goes well, as root) +$ make install diff --git a/fdmdv2/branches/0.97/NEWS b/fdmdv2/branches/0.97/NEWS new file mode 100644 index 00000000..e69de29b diff --git a/fdmdv2/branches/0.97/README b/fdmdv2/branches/0.97/README new file mode 100644 index 00000000..e69de29b diff --git a/fdmdv2/branches/0.97/README.txt b/fdmdv2/branches/0.97/README.txt new file mode 100644 index 00000000..f54ff34c --- /dev/null +++ b/fdmdv2/branches/0.97/README.txt @@ -0,0 +1,114 @@ +================================== + Building and installing on Linux +================================== + +Quickstart 1 +----------- + +Builds static versions of wxWidgets, portaudio, codec2-dev, which are commonly +missing on many Linux systems, or of the wrong (older) version. + +Assuming the freedv-dev sources is checked out into ~/fdmdv2-dev: + +$ cd fdmdv2-dev +$ mkdir build_linux +$ cd build_linux +$ cmake -DBOOTSTRAP_WXWIDGETS=TRUE ~/fdmdv2-dev +$ make +[wxWidgets builds] + +Then you can use your local codec-dev, something like: + +$ cmake cmake -DBOOTSTRAP_WXWIDGETS=TRUE -DCODEC2_INCLUDE_DIR=/home/david/codec2-dev/src -DCODEC2_LIBRARY=/home/david/codec2-dev/build_linux/src/libcodec2.so -DUSE_STATIC_CODEC2=FALSE -DUSE_STATIC_PORTAUDIO=TRUE -DUSE_STATIC_SOX=TRUE ../ + +OR build a local copy of codec2-dev: + +$ cmake cmake -DBOOTSTRAP_WXWIDGETS=TRUE -DUSE_STATIC_CODEC2=TRUE -DUSE_STATIC_PORTAUDIO=TRUE -DUSE_STATIC_SOX=TRUE ../ + +$ make +[FreeDV builds] +$ ./src/freedv + +Note: add "-DCMAKE_BUILD_TYPE=Debug" the list above for debug (gcc -g) buildthat include source line numbers. + +Quickstart 2 +------------ + +Assuming you have all the dependant libraries: + +$ cd /path/to/fdmdv2 +$ mkdir build_linux +$ cd build_linux +$ cmake ../ (defaults to /usr/local, use CMAKE_INSTALL_PREFIX to override) +(if no errors) +$ make +(as root) +$ make install + +==================================== + Building and installing on Windows +==================================== + +The windows build is similar to linux and follows the same basic workflow. + +Only MinGW is supported. While it is likely possible to perform a pure MinGW +build, installing MSYS will make your life easier. + +CMake may not automatically detect that you're in the MSYS environment. If this +occurs you need to pass cmake the proper generator: + +cmake -G"MSYS Makefiles" [other options] + +=============================== + Bootstrapping wxWidgets build +=============================== + +If wxWidgets (>= 3.0) is not available then one option is to have CMake boot- +strap the build for FreeDV. + +This is required because the tool wx-config is used to get the correct compiler +and linker flags of the wxWidgets components needed by FreeDV. Since this is +normally done at configure time, not during "make", it is not possible for CMake +or have this information prior to building wxWidgets. + +In order to work around this issue you can "bootstrap" the wxWidgets build using +the CMake option, "BOOTSTRAP_WXWIDGETS". wxWidgets will be built using static +libraries. + +NOTE: This forces "USE_STATIC_WXWIDGETS" to be true internally regarless of the +value set manually. + +(from any prefered, but empty directory outside of the source) +$ cmake -DBOOTSTRAP_WXWIDGETS=TRUE /path/to/fdmdv2 +$ make +(wxWidgets is downloaded and built) +$ cmake . +$ make +(if all goes well, as root) +$ make install + +==================================== + Building and installing on OSX +==================================== + +==================================== + Building and installing on FreeBSD +==================================== + +As per "Quickstart 2" above but change build_linux to build_freebsd + +======= +Editing +======= + +Please make sure your text editor does not insert tabs, and +used indents of 4 spaces. The following .emacs code was used to +configure emacs: + +(setq-default indent-tabs-mode nil) + +(add-hook 'c-mode-common-hook + (function (lambda () + (setq c-basic-offset 4) + ))) + diff --git a/fdmdv2/branches/0.97/build/codelite/.clang/.gitignore b/fdmdv2/branches/0.97/build/codelite/.clang/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/fdmdv2/branches/0.97/build/codelite/dbfiles/fdmdv2config.sqlite.sql b/fdmdv2/branches/0.97/build/codelite/dbfiles/fdmdv2config.sqlite.sql new file mode 100644 index 00000000..fd66b5cb --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/dbfiles/fdmdv2config.sqlite.sql @@ -0,0 +1 @@ +CREATE TABLE "configuration" ("prikey" DATETIME PRIMARY KEY NOT NULL UNIQUE DEFAULT CURRENT_TIMESTAMP, "datecreate" DATETIME DEFAULT CURRENT_DATE, "timecreate" DATETIME DEFAULT CURRENT_TIME, "rx_driver_in_idx" INTEGER check(typeof("rx_driver_in_idx") = 'integer') , "rx_driver_in_string" TEXT check(typeof("rx_driver_in_string") = 'text') , "rx_driver_out_idx" INTEGER check(typeof("rx_driver_out_idx") = 'integer') , "rx_driver_out_str" TEXT check(typeof("rx_driver_out_str") = 'text') , "tx_driver_in_idx" INTEGER check(typeof("tx_driver_in_idx") = 'integer') , "tx_driver_in_str" TEXT check(typeof("tx_driver_in_str") = 'text') , "tx_driver_out_idx" INTEGER check(typeof("tx_driver_out_idx") = 'integer') , "tx_driver_out_str" TEXT check(typeof("tx_driver_out_str") = 'text') ); diff --git a/fdmdv2/branches/0.97/build/codelite/dbfiles/fdmdv2config.sqlite.sqlite b/fdmdv2/branches/0.97/build/codelite/dbfiles/fdmdv2config.sqlite.sqlite new file mode 100644 index 00000000..eace5f3f Binary files /dev/null and b/fdmdv2/branches/0.97/build/codelite/dbfiles/fdmdv2config.sqlite.sqlite differ diff --git a/fdmdv2/branches/0.97/build/codelite/dialogtest/MainDialog.cpp b/fdmdv2/branches/0.97/build/codelite/dialogtest/MainDialog.cpp new file mode 100644 index 00000000..ce5168ec --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/dialogtest/MainDialog.cpp @@ -0,0 +1,62 @@ +#include "MainDialog.h" + +PTTDialog::PTTDialog(wxWindow* parent): PTTDialogBaseClass(parent) +{ +} + +PTTDialog::~PTTDialog() +{ +} + +void PTTDialog::DTRVPlusClicked(wxCommandEvent& event) +{ + wxMessageBox(wxT("DTRVPlusClicked")); +} + +void PTTDialog::PTTAudioClick(wxCommandEvent& event) +{ + wxMessageBox(wxT("PTTAudioClick")); +} + +void PTTDialog::PTTPortSlelcted(wxCommandEvent& event) +{ + wxMessageBox(wxT("PTTPortSlelcted")); +} + +void PTTDialog::PTTUseSerialClicked(wxCommandEvent& event) +{ + wxMessageBox(wxT("PTTUseSerialClicked")); +} + +void PTTDialog::RTSVPlusClicked(wxCommandEvent& event) +{ + wxMessageBox(wxT("RTSVPlusClicked")); +} + +void PTTDialog::UseDTRCliched(wxCommandEvent& event) +{ + wxMessageBox(wxT("UseDTRCliched")); +} + +void PTTDialog::UseRTSClicked(wxCommandEvent& event) +{ + wxMessageBox(wxT("UseRTSClicked")); +} + +void PTTDialog::OnApply(wxCommandEvent& event) +{ + wxMessageBox(wxT("OnApply")); +} + +void PTTDialog::OnCancel(wxCommandEvent& event) +{ + wxMessageBox(wxT("OnCancel")); +} + +void PTTDialog::OnOK(wxCommandEvent& event) +{ + wxMessageBox(wxT("OnOK")); +} +void PTTDialog::OnInitDialog(wxInitDialogEvent& event) +{ +} diff --git a/fdmdv2/branches/0.97/build/codelite/dialogtest/MainDialog.h b/fdmdv2/branches/0.97/build/codelite/dialogtest/MainDialog.h new file mode 100644 index 00000000..2553079b --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/dialogtest/MainDialog.h @@ -0,0 +1,39 @@ +#ifndef PTTDialog_H +#define PTTDialog_H +#include +#include "wxcrafter.h" + +class PTTDialog : public PTTDialogBaseClass +{ +public: + PTTDialog(wxWindow* parent); + virtual ~PTTDialog(); +protected: + virtual void OnInitDialog(wxInitDialogEvent& event); + wxCheckBox* m_ckPTTRtChan; + wxListBox* m_listCtrlPorts; + wxCheckBox* m_ckUseSerialPTT; + wxRadioButton* m_rbUseDTR; + wxCheckBox* m_ckRTSPos; + wxRadioButton* m_rbUseRTS; + wxCheckBox* m_ckDTRPos; + wxButton* m_buttonOK; + wxButton* m_buttonCancel; + wxButton* m_buttonApply; + + void PTTAudioClick(wxCommandEvent& event); + void PTTPortSlelcted(wxCommandEvent& event); + void PTTUseSerialClicked(wxCommandEvent& event); + void UseDTRCliched(wxCommandEvent& event); + void DTRVPlusClicked(wxCommandEvent& event); + void UseRTSClicked(wxCommandEvent& event); + void RTSVPlusClicked(wxCommandEvent& event); + + virtual void OnApply(wxCommandEvent& event); + virtual void OnCancel(wxCommandEvent& event); + virtual void OnOK(wxCommandEvent& event); + + void ExchangeData(int inout); + void populatePortList(void); +}; +#endif // PTTDialog_H diff --git a/fdmdv2/branches/0.97/build/codelite/dialogtest/dialogTest.mk b/fdmdv2/branches/0.97/build/codelite/dialogtest/dialogTest.mk new file mode 100644 index 00000000..6d76a826 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/dialogtest/dialogTest.mk @@ -0,0 +1,147 @@ +## +## Auto Generated makefile by CodeLite IDE +## any manual changes will be erased +## +## Release +ProjectName :=dialogTest +ConfigurationName :=Release +WorkspacePath := "D:\Projects\Radio\fdmdv2\build" +ProjectPath := "D:\Projects\Radio\fdmdv2\build" +IntermediateDirectory :=./Release +OutDir := $(IntermediateDirectory) +CurrentFileName := +CurrentFilePath := +CurrentFileFullPath := +User :=wittend +Date :=12/10/2012 +CodeLitePath :="D:\bin\CodeLite" +LinkerName :=g++ +SharedObjectLinkerName :=g++ -shared -fPIC +ObjectSuffix :=.o +DependSuffix :=.o.d +PreprocessSuffix :=.o.i +DebugSwitch :=-gstab +IncludeSwitch :=-I +LibrarySwitch :=-l +OutputSwitch :=-o +LibraryPathSwitch :=-L +PreprocessorSwitch :=-D +SourceSwitch :=-c +OutputFile :=$(IntermediateDirectory)/$(ProjectName) +Preprocessors := +ObjectSwitch :=-o +ArchiveOutputSwitch := +PreprocessOnlySwitch :=-E +ObjectsFileList :="D:\Projects\Radio\fdmdv2\build\dialogTest.txt" +PCHCompileFlags := +MakeDirCommand :=makedir +RcCmpOptions := $(shell wx-config --rcflags) +RcCompilerName :=windres +LinkOptions := $(shell wx-config --libs) -mwindows +IncludePath := $(IncludeSwitch). $(IncludeSwitch). +IncludePCH := +RcIncludePath := +Libs := +ArLibs := +LibPath := $(LibraryPathSwitch). + +## +## Common variables +## AR, CXX, CC, CXXFLAGS and CFLAGS can be overriden using an environment variables +## +AR := ar rcus +CXX := g++ +CC := gcc +CXXFLAGS := -O2 -Wall $(shell wx-config --cflags) -DSVN_REVISION=\"1128\" $(Preprocessors) +CFLAGS := -O2 -Wall -DSVN_REVISION=\"1128\" $(Preprocessors) + + +## +## User defined environment variables +## +CodeLiteDir:=D:\bin\CodeLite +WXWIN:=D:\bin\wxWidgets-2.9.4 +PATH:=$(WXWIN)\lib\gcc_dll;$(PATH) +WXCFG:=gcc_dll\mswu +UNIT_TEST_PP_SRC_DIR:=D:\bin\UnitTest++-1.3 +Objects=$(IntermediateDirectory)/main$(ObjectSuffix) $(IntermediateDirectory)/wxcrafter$(ObjectSuffix) $(IntermediateDirectory)/wxcrafter_bitmaps$(ObjectSuffix) $(IntermediateDirectory)/MainDialog$(ObjectSuffix) $(IntermediateDirectory)/win_resources.rc$(ObjectSuffix) + +## +## Main Build Targets +## +.PHONY: all clean PreBuild PrePreBuild PostBuild +all: $(OutputFile) + +$(OutputFile): $(IntermediateDirectory)/.d $(Objects) + @$(MakeDirCommand) $(@D) + @echo "" > $(IntermediateDirectory)/.d + @echo $(Objects) > $(ObjectsFileList) + $(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions) + +$(IntermediateDirectory)/.d: + @$(MakeDirCommand) "./Release" + +PreBuild: + + +## +## Objects +## +$(IntermediateDirectory)/main$(ObjectSuffix): main.cpp $(IntermediateDirectory)/main$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/build/main.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/main$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/main$(DependSuffix): main.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/main$(ObjectSuffix) -MF$(IntermediateDirectory)/main$(DependSuffix) -MM "D:/Projects/Radio/fdmdv2/build/main.cpp" + +$(IntermediateDirectory)/main$(PreprocessSuffix): main.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/main$(PreprocessSuffix) "D:/Projects/Radio/fdmdv2/build/main.cpp" + +$(IntermediateDirectory)/wxcrafter$(ObjectSuffix): wxcrafter.cpp $(IntermediateDirectory)/wxcrafter$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/build/wxcrafter.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/wxcrafter$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/wxcrafter$(DependSuffix): wxcrafter.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/wxcrafter$(ObjectSuffix) -MF$(IntermediateDirectory)/wxcrafter$(DependSuffix) -MM "D:/Projects/Radio/fdmdv2/build/wxcrafter.cpp" + +$(IntermediateDirectory)/wxcrafter$(PreprocessSuffix): wxcrafter.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/wxcrafter$(PreprocessSuffix) "D:/Projects/Radio/fdmdv2/build/wxcrafter.cpp" + +$(IntermediateDirectory)/wxcrafter_bitmaps$(ObjectSuffix): wxcrafter_bitmaps.cpp $(IntermediateDirectory)/wxcrafter_bitmaps$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/build/wxcrafter_bitmaps.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/wxcrafter_bitmaps$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/wxcrafter_bitmaps$(DependSuffix): wxcrafter_bitmaps.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/wxcrafter_bitmaps$(ObjectSuffix) -MF$(IntermediateDirectory)/wxcrafter_bitmaps$(DependSuffix) -MM "D:/Projects/Radio/fdmdv2/build/wxcrafter_bitmaps.cpp" + +$(IntermediateDirectory)/wxcrafter_bitmaps$(PreprocessSuffix): wxcrafter_bitmaps.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/wxcrafter_bitmaps$(PreprocessSuffix) "D:/Projects/Radio/fdmdv2/build/wxcrafter_bitmaps.cpp" + +$(IntermediateDirectory)/MainDialog$(ObjectSuffix): MainDialog.cpp $(IntermediateDirectory)/MainDialog$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/build/MainDialog.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/MainDialog$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/MainDialog$(DependSuffix): MainDialog.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/MainDialog$(ObjectSuffix) -MF$(IntermediateDirectory)/MainDialog$(DependSuffix) -MM "D:/Projects/Radio/fdmdv2/build/MainDialog.cpp" + +$(IntermediateDirectory)/MainDialog$(PreprocessSuffix): MainDialog.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/MainDialog$(PreprocessSuffix) "D:/Projects/Radio/fdmdv2/build/MainDialog.cpp" + +$(IntermediateDirectory)/win_resources.rc$(ObjectSuffix): win_resources.rc + $(RcCompilerName) -i "D:/Projects/Radio/fdmdv2/build/win_resources.rc" $(RcCmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/win_resources.rc$(ObjectSuffix) $(RcIncludePath) + +-include $(IntermediateDirectory)/*$(DependSuffix) +## +## Clean +## +clean: + $(RM) $(IntermediateDirectory)/main$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/main$(DependSuffix) + $(RM) $(IntermediateDirectory)/main$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/wxcrafter$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/wxcrafter$(DependSuffix) + $(RM) $(IntermediateDirectory)/wxcrafter$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/wxcrafter_bitmaps$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/wxcrafter_bitmaps$(DependSuffix) + $(RM) $(IntermediateDirectory)/wxcrafter_bitmaps$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/MainDialog$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/MainDialog$(DependSuffix) + $(RM) $(IntermediateDirectory)/MainDialog$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/win_resources.rc$(ObjectSuffix) + $(RM) $(OutputFile) + $(RM) $(OutputFile).exe + $(RM) "D:\Projects\Radio\fdmdv2\build\.build-release\dialogTest" + + diff --git a/fdmdv2/branches/0.97/build/codelite/dialogtest/dialogTest.project b/fdmdv2/branches/0.97/build/codelite/dialogtest/dialogTest.project new file mode 100644 index 00000000..b9719ad0 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/dialogtest/dialogTest.project @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fdmdv2/branches/0.97/build/codelite/dialogtest/dialogTest.txt b/fdmdv2/branches/0.97/build/codelite/dialogtest/dialogTest.txt new file mode 100644 index 00000000..869f4615 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/dialogtest/dialogTest.txt @@ -0,0 +1 @@ +./Debug/main.o ./Debug/wxcrafter.o ./Debug/wxcrafter_bitmaps.o ./Debug/MainDialog.o ./Debug/win_resources.rc.o diff --git a/fdmdv2/branches/0.97/build/codelite/dialogtest/main.cpp b/fdmdv2/branches/0.97/build/codelite/dialogtest/main.cpp new file mode 100644 index 00000000..d1b49ab4 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/dialogtest/main.cpp @@ -0,0 +1,26 @@ +#include +#include +#include "MainDialog.h" +#include + +// Define the MainApp +class MainApp : public wxApp +{ +public: + MainApp() {} + virtual ~MainApp() {} + + virtual bool OnInit() + { + // Add the common image handlers + wxImage::AddHandler( new wxPNGHandler ); + wxImage::AddHandler( new wxJPEGHandler ); + + PTTDialog mainDialog(NULL); + mainDialog.ShowModal(); + return false; + } +}; + +DECLARE_APP(MainApp) +IMPLEMENT_APP(MainApp) diff --git a/fdmdv2/branches/0.97/build/codelite/dialogtest/win_resources.rc b/fdmdv2/branches/0.97/build/codelite/dialogtest/win_resources.rc new file mode 100644 index 00000000..fa70c15a --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/dialogtest/win_resources.rc @@ -0,0 +1,2 @@ +#include "wx/msw/wx.rc" +1 24 "wx/msw/wx.manifest" diff --git a/fdmdv2/branches/0.97/build/codelite/dialogtest/wxcrafter.cpp b/fdmdv2/branches/0.97/build/codelite/dialogtest/wxcrafter.cpp new file mode 100644 index 00000000..4bf7dc53 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/dialogtest/wxcrafter.cpp @@ -0,0 +1,143 @@ +////////////////////////////////////////////////////////////////////// +// This file was auto-generated by codelite's wxCrafter Plugin +// Do not modify this file by hand! +////////////////////////////////////////////////////////////////////// + +#include "wxcrafter.h" + + +// Declare the bitmap loading function +extern void wxC9ED9InitBitmapResources(); + +static bool bBitmapLoaded = false; + + +PTTDialogBaseClass::PTTDialogBaseClass(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) + : wxDialog(parent, id, title, pos, size, style) +{ + if ( !bBitmapLoaded ) { + // We need to initialise the default bitmap handler + wxXmlResource::Get()->AddHandler(new wxBitmapXmlHandler); + wxC9ED9InitBitmapResources(); + bBitmapLoaded = true; + } + + wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); + this->SetSizer(mainSizer); + + wxStaticBoxSizer* staticBoxSizer28 = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY, _("Audio Tone")), wxVERTICAL); + + mainSizer->Add(staticBoxSizer28, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5); + + m_ckPTTRtChan = new wxCheckBox(this, wxID_ANY, _("PTT tone on right audio channel"), wxDefaultPosition, wxSize(-1,-1), 0); + m_ckPTTRtChan->SetValue(false); + + staticBoxSizer28->Add(m_ckPTTRtChan, 0, wxALIGN_CENTER|wxALIGN_CENTER_VERTICAL, 5); + + wxStaticBoxSizer* staticBoxSizer17 = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY, _("Hardware PTT Settings")), wxVERTICAL); + + mainSizer->Add(staticBoxSizer17, 1, wxEXPAND, 5); + + wxStaticBoxSizer* staticBoxSizer31 = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY, _("PTT Port")), wxVERTICAL); + + staticBoxSizer17->Add(staticBoxSizer31, 0, wxEXPAND, 5); + + wxArrayString m_listCtrlPortsArr; + m_listCtrlPorts = new wxListBox(this, wxID_ANY, wxDefaultPosition, wxSize(-1,-1), m_listCtrlPortsArr, wxLB_SINGLE); + + staticBoxSizer31->Add(m_listCtrlPorts, 1, wxALIGN_CENTER, 0); + + wxBoxSizer* boxSizer19 = new wxBoxSizer(wxVERTICAL); + + staticBoxSizer17->Add(boxSizer19, 1, wxEXPAND, 5); + + wxStaticBoxSizer* staticBoxSizer16 = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY, _("Signal polarity")), wxHORIZONTAL); + + boxSizer19->Add(staticBoxSizer16, 1, wxEXPAND|wxALIGN_CENTER|wxALIGN_RIGHT, 5); + + wxGridSizer* gridSizer17 = new wxGridSizer( 3, 2, 0, 0); + + staticBoxSizer16->Add(gridSizer17, 1, wxEXPAND|wxALIGN_RIGHT, 5); + + m_ckUseSerialPTT = new wxCheckBox(this, wxID_ANY, _("Use Serial Port PTT"), wxDefaultPosition, wxSize(-1,-1), 0); + m_ckUseSerialPTT->SetValue(false); + + gridSizer17->Add(m_ckUseSerialPTT, 0, wxALIGN_CENTER, 10); + + gridSizer17->Add(0, 0, 0, 0, 5); + + m_rbUseDTR = new wxRadioButton(this, wxID_ANY, _("Use DTR"), wxDefaultPosition, wxSize(-1,-1), 0); + m_rbUseDTR->SetValue(1); + + gridSizer17->Add(m_rbUseDTR, 0, wxALIGN_CENTER|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5); + + m_ckRTSPos = new wxCheckBox(this, wxID_ANY, _("DTR = +V"), wxDefaultPosition, wxSize(-1,-1), 0); + m_ckRTSPos->SetValue(false); + + gridSizer17->Add(m_ckRTSPos, 0, wxALIGN_CENTER|wxALIGN_RIGHT, 5); + + m_rbUseRTS = new wxRadioButton(this, wxID_ANY, _("Use RTS"), wxDefaultPosition, wxSize(-1,-1), 0); + m_rbUseRTS->SetToolTip(_("Toggle the RTS pin for PTT")); + m_rbUseRTS->SetValue(1); + + gridSizer17->Add(m_rbUseRTS, 0, wxALIGN_CENTER|wxALIGN_RIGHT, 5); + + m_ckDTRPos = new wxCheckBox(this, wxID_ANY, _("RTS = +V"), wxDefaultPosition, wxSize(-1,-1), 0); + m_ckDTRPos->SetValue(false); + m_ckDTRPos->SetToolTip(_("Set Polarity of the RTS line")); + + gridSizer17->Add(m_ckDTRPos, 0, wxALIGN_CENTER|wxALIGN_RIGHT, 5); + + wxBoxSizer* boxSizer12 = new wxBoxSizer(wxHORIZONTAL); + + mainSizer->Add(boxSizer12, 0, wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL, 5); + + m_buttonOK = new wxButton(this, wxID_OK, _("OK"), wxDefaultPosition, wxSize(-1,-1), 0); + m_buttonOK->SetDefault(); + + boxSizer12->Add(m_buttonOK, 0, wxLEFT|wxRIGHT|wxTOP|wxBOTTOM, 5); + + m_buttonCancel = new wxButton(this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer12->Add(m_buttonCancel, 0, wxLEFT|wxRIGHT|wxTOP|wxBOTTOM, 5); + + m_buttonApply = new wxButton(this, wxID_APPLY, _("Apply"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer12->Add(m_buttonApply, 0, wxLEFT|wxRIGHT|wxTOP|wxBOTTOM, 5); + + + SetSizeHints(450,300); + if ( GetSizer() ) { + GetSizer()->Fit(this); + } + Centre(wxBOTH); + // Connect events + this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(PTTDialogBaseClass::OnInitDialog), NULL, this); + m_ckPTTRtChan->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(PTTDialogBaseClass::PTTAudioClick), NULL, this); + m_listCtrlPorts->Connect(wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(PTTDialogBaseClass::PTTPortSlelcted), NULL, this); + m_ckUseSerialPTT->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(PTTDialogBaseClass::PTTUseSerialClicked), NULL, this); + m_rbUseDTR->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(PTTDialogBaseClass::UseDTRCliched), NULL, this); + m_ckRTSPos->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(PTTDialogBaseClass::DTRVPlusClicked), NULL, this); + m_rbUseRTS->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(PTTDialogBaseClass::UseRTSClicked), NULL, this); + m_ckDTRPos->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(PTTDialogBaseClass::RTSVPlusClicked), NULL, this); + m_buttonOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PTTDialogBaseClass::OnOK), NULL, this); + m_buttonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PTTDialogBaseClass::OnCancel), NULL, this); + m_buttonApply->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PTTDialogBaseClass::OnApply), NULL, this); + +} + +PTTDialogBaseClass::~PTTDialogBaseClass() +{ + this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(PTTDialogBaseClass::OnInitDialog), NULL, this); + m_ckPTTRtChan->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(PTTDialogBaseClass::PTTAudioClick), NULL, this); + m_listCtrlPorts->Disconnect(wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler(PTTDialogBaseClass::PTTPortSlelcted), NULL, this); + m_ckUseSerialPTT->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(PTTDialogBaseClass::PTTUseSerialClicked), NULL, this); + m_rbUseDTR->Disconnect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(PTTDialogBaseClass::UseDTRCliched), NULL, this); + m_ckRTSPos->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(PTTDialogBaseClass::DTRVPlusClicked), NULL, this); + m_rbUseRTS->Disconnect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(PTTDialogBaseClass::UseRTSClicked), NULL, this); + m_ckDTRPos->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(PTTDialogBaseClass::RTSVPlusClicked), NULL, this); + m_buttonOK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PTTDialogBaseClass::OnOK), NULL, this); + m_buttonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PTTDialogBaseClass::OnCancel), NULL, this); + m_buttonApply->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PTTDialogBaseClass::OnApply), NULL, this); + +} diff --git a/fdmdv2/branches/0.97/build/codelite/dialogtest/wxcrafter.h b/fdmdv2/branches/0.97/build/codelite/dialogtest/wxcrafter.h new file mode 100644 index 00000000..fb0f63ac --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/dialogtest/wxcrafter.h @@ -0,0 +1,52 @@ +////////////////////////////////////////////////////////////////////// +// This file was auto-generated by codelite's wxCrafter Plugin +// Do not modify this file by hand! +////////////////////////////////////////////////////////////////////// + +#ifndef WXCRAFTER_BASE_CLASSES_H +#define WXCRAFTER_BASE_CLASSES_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class PTTDialogBaseClass : public wxDialog +{ +protected: + wxCheckBox* m_ckPTTRtChan; + wxListBox* m_listCtrlPorts; + wxCheckBox* m_ckUseSerialPTT; + wxRadioButton* m_rbUseDTR; + wxCheckBox* m_ckRTSPos; + wxRadioButton* m_rbUseRTS; + wxCheckBox* m_ckDTRPos; + wxButton* m_buttonOK; + wxButton* m_buttonCancel; + wxButton* m_buttonApply; + +protected: + virtual void OnInitDialog(wxInitDialogEvent& event) { event.Skip(); } + virtual void PTTAudioClick(wxCommandEvent& event) { event.Skip(); } + virtual void PTTPortSlelcted(wxCommandEvent& event) { event.Skip(); } + virtual void PTTUseSerialClicked(wxCommandEvent& event) { event.Skip(); } + virtual void UseDTRCliched(wxCommandEvent& event) { event.Skip(); } + virtual void DTRVPlusClicked(wxCommandEvent& event) { event.Skip(); } + virtual void UseRTSClicked(wxCommandEvent& event) { event.Skip(); } + virtual void RTSVPlusClicked(wxCommandEvent& event) { event.Skip(); } + virtual void OnOK(wxCommandEvent& event) { event.Skip(); } + virtual void OnCancel(wxCommandEvent& event) { event.Skip(); } + virtual void OnApply(wxCommandEvent& event) { event.Skip(); } + +public: + PTTDialogBaseClass(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Hardware PTT"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(450,300), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER); + virtual ~PTTDialogBaseClass(); +}; + +#endif diff --git a/fdmdv2/branches/0.97/build/codelite/dialogtest/wxcrafter.wxcp b/fdmdv2/branches/0.97/build/codelite/dialogtest/wxcrafter.wxcp new file mode 100644 index 00000000..b79705a9 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/dialogtest/wxcrafter.wxcp @@ -0,0 +1,965 @@ +{ + "metadata": { + "m_generatedFilesDir": "", + "m_objCounter": 32, + "m_includeFiles": [], + "m_bitmapFunction": "wxC9ED9InitBitmapResources", + "m_bitmapsFile": "wxcrafter_bitmaps.cpp", + "m_GenerateCodeTypes": 3 + }, + "windows": [{ + "m_type": 4421, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxDEFAULT_DIALOG_STYLE", "wxRESIZE_BORDER"], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "450,300" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "PTTDialog" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Title:", + "m_value": "Hardware PTT" + }, { + "type": "string", + "m_label": "File:", + "m_value": "MainDialog" + }, { + "type": "virtualFolderPicker", + "m_label": "Virtual Folder:", + "m_path": "" + }, { + "type": "choice", + "m_label": "Centre:", + "m_selection": 1, + "m_options": ["", "wxBOTH", "wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [{ + "m_eventName": "wxEVT_INIT_DIALOG", + "m_eventClass": "wxInitDialogEvent", + "m_eventHandler": "wxInitDialogEventHandler", + "m_functionNameAndSignature": "OnInitDialog(wxInitDialogEvent& event)", + "m_description": "A wxInitDialogEvent is sent as a dialog or panel is being initialised. Handlers for this event can transfer data to the window.\nThe default handler calls wxWindow::TransferDataToWindow" + }], + "m_children": [{ + "m_type": 4401, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "mainSizer" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4449, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxEXPAND", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "staticBoxSizer28" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["Vertical", "Horizontal"] + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Audio Tone" + }], + "m_events": [], + "m_children": [{ + "m_type": 4415, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALIGN_CENTER", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_ckPTTRtChan" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "PTT tone on right audio channel" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_CHECKBOX_CLICKED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "PTTAudioClick(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_CHECKBOX_CLICKED event, when the checkbox is clicked." + }], + "m_children": [] + }] + }, { + "m_type": 4449, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "staticBoxSizer17" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["Vertical", "Horizontal"] + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Hardware PTT Settings" + }], + "m_events": [], + "m_children": [{ + "m_type": 4449, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "staticBoxSizer31" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["Vertical", "Horizontal"] + }, { + "type": "string", + "m_label": "Label:", + "m_value": "PTT Port" + }], + "m_events": [], + "m_children": [{ + "m_type": 4412, + "proportion": 1, + "border": 0, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxLB_SINGLE"], + "m_sizerFlags": ["wxALIGN_CENTER"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_listCtrlPorts" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Choices:", + "m_value": "" + }, { + "type": "string", + "m_label": "Selection:", + "m_value": "-1" + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_LISTBOX_SELECTED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "PTTPortSlelcted(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_LISTBOX_SELECTED event, when an item on the list is selected or the selection changes." + }], + "m_children": [] + }] + }, { + "m_type": 4401, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer19" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4449, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxEXPAND", "wxALIGN_CENTER", "wxALIGN_RIGHT"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "staticBoxSizer16" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["Vertical", "Horizontal"] + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Signal polarity" + }], + "m_events": [], + "m_children": [{ + "m_type": 4452, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxEXPAND", "wxALIGN_RIGHT"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "gridSizer17" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "2" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "3" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4415, + "proportion": 0, + "border": 10, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALIGN_CENTER"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_ckUseSerialPTT" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Use Serial Port PTT" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_CHECKBOX_CLICKED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "PTTUseSerialClicked(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_CHECKBOX_CLICKED event, when the checkbox is clicked." + }], + "m_children": [] + }, { + "m_type": 4454, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": [], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "Spacer" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "0,0" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4417, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALIGN_CENTER", "wxALIGN_RIGHT", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_rbUseDTR" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Use DTR" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": true + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_RADIOBUTTON_SELECTED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "UseDTRCliched(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_RADIOBUTTON_SELECTED event, when the radiobutton is clicked." + }], + "m_children": [] + }, { + "m_type": 4415, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALIGN_CENTER", "wxALIGN_RIGHT"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_ckRTSPos" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "DTR = +V" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_CHECKBOX_CLICKED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "DTRVPlusClicked(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_CHECKBOX_CLICKED event, when the checkbox is clicked." + }], + "m_children": [] + }, { + "m_type": 4417, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALIGN_CENTER", "wxALIGN_RIGHT"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_rbUseRTS" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Toggle the RTS pin for PTT" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Use RTS" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": true + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_RADIOBUTTON_SELECTED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "UseRTSClicked(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_RADIOBUTTON_SELECTED event, when the radiobutton is clicked." + }], + "m_children": [] + }, { + "m_type": 4415, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALIGN_CENTER", "wxALIGN_RIGHT"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_ckDTRPos" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Set Polarity of the RTS line" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "RTS = +V" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_CHECKBOX_CLICKED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "RTSVPlusClicked(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_CHECKBOX_CLICKED event, when the checkbox is clicked." + }], + "m_children": [] + }] + }] + }] + }] + }, { + "m_type": 4401, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer12" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4400, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_OK" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_buttonOK" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "OK" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": true + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "string", + "m_label": "Margins:", + "m_value": "2,2" + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_BUTTON_CLICKED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "OnOK(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked." + }], + "m_children": [] + }, { + "m_type": 4400, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_CANCEL" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_buttonCancel" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Cancel" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": false + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "string", + "m_label": "Margins:", + "m_value": "2,2" + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_BUTTON_CLICKED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "OnCancel(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked." + }], + "m_children": [] + }, { + "m_type": 4400, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_APPLY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_buttonApply" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Apply" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": false + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "string", + "m_label": "Margins:", + "m_value": "2,2" + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_BUTTON_CLICKED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "OnApply(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked." + }], + "m_children": [] + }] + }] + }] + }] +} \ No newline at end of file diff --git a/fdmdv2/branches/0.97/build/codelite/dialogtest/wxcrafter_bitmaps.cpp b/fdmdv2/branches/0.97/build/codelite/dialogtest/wxcrafter_bitmaps.cpp new file mode 100644 index 00000000..b78c0b93 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/dialogtest/wxcrafter_bitmaps.cpp @@ -0,0 +1,48 @@ +// +// This file was automatically generated by wxrc, do not edit by hand. +// + +#include + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include +#include +#include +#include + +#if wxCHECK_VERSION(2,8,5) && wxABI_VERSION >= 20805 + #define XRC_ADD_FILE(name, data, size, mime) \ + wxMemoryFSHandler::AddFileWithMimeType(name, data, size, mime) +#else + #define XRC_ADD_FILE(name, data, size, mime) \ + wxMemoryFSHandler::AddFile(name, data, size) +#endif + +static size_t xml_res_size_0 = 108; +static unsigned char xml_res_file_0[] = { +60,63,120,109,108,32,118,101,114,115,105,111,110,61,34,49,46,48,34,32,101, +110,99,111,100,105,110,103,61,34,85,84,70,45,56,34,63,62,10,60,114,101, +115,111,117,114,99,101,32,120,109,108,110,115,61,34,104,116,116,112,58, +47,47,119,119,119,46,119,120,119,105,110,100,111,119,115,46,111,114,103, +47,119,120,120,114,99,34,32,118,101,114,115,105,111,110,61,34,50,46,51, +46,48,46,49,34,47,62,10}; + +void wxC9ED9InitBitmapResources() +{ + + // Check for memory FS. If not present, load the handler: + { + wxMemoryFSHandler::AddFile(wxT("XRC_resource/dummy_file"), wxT("dummy one")); + wxFileSystem fsys; + wxFSFile *f = fsys.OpenFile(wxT("memory:XRC_resource/dummy_file")); + wxMemoryFSHandler::RemoveFile(wxT("XRC_resource/dummy_file")); + if (f) delete f; + else wxFileSystem::AddHandler(new wxMemoryFSHandlerBase); + } + + XRC_ADD_FILE(wxT("XRC_resource/wxcrafter_bitmaps.cpp$._wxcrafter_bitmaps.xrc"), xml_res_file_0, xml_res_size_0, wxT("text/xml")); + wxXmlResource::Get()->Load(wxT("memory:XRC_resource/wxcrafter_bitmaps.cpp$._wxcrafter_bitmaps.xrc")); +} diff --git a/fdmdv2/branches/0.97/build/codelite/dialogtest/wxcrafter_bitmaps.xrc b/fdmdv2/branches/0.97/build/codelite/dialogtest/wxcrafter_bitmaps.xrc new file mode 100644 index 00000000..8a0ee509 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/dialogtest/wxcrafter_bitmaps.xrc @@ -0,0 +1,2 @@ + + diff --git a/fdmdv2/branches/0.97/build/codelite/fdmdv2.mk b/fdmdv2/branches/0.97/build/codelite/fdmdv2.mk new file mode 100644 index 00000000..1864ae1d --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/fdmdv2.mk @@ -0,0 +1,270 @@ +## +## Auto Generated makefile by CodeLite IDE +## any manual changes will be erased +## +## Debug +ProjectName :=fdmdv2 +ConfigurationName :=Debug +WorkspacePath := "D:\Projects\Radio\fdmdv2\build\codelite" +ProjectPath := "D:\Projects\Radio\fdmdv2\build\codelite" +IntermediateDirectory :=./Debug +OutDir := $(IntermediateDirectory) +CurrentFileName := +CurrentFilePath := +CurrentFileFullPath := +User :=wittend +Date :=5/6/2013 +CodeLitePath :="D:\bin\CodeLite" +LinkerName :=g++ +SharedObjectLinkerName :=g++ -shared -fPIC +ObjectSuffix :=.o +DependSuffix :=.o.d +PreprocessSuffix :=.o.i +DebugSwitch :=-gstab +IncludeSwitch :=-I +LibrarySwitch :=-l +OutputSwitch :=-o +LibraryPathSwitch :=-L +PreprocessorSwitch :=-D +SourceSwitch :=-c +OutputFile :=$(IntermediateDirectory)/freeDV +Preprocessors :=$(PreprocessorSwitch)__WX__ $(PreprocessorSwitch)_NO_AUTOTOOLS_=1 $(PreprocessorSwitch)DMW=1 +ObjectSwitch :=-o +ArchiveOutputSwitch := +PreprocessOnlySwitch :=-E +ObjectsFileList :="fdmdv2.txt" +PCHCompileFlags := +MakeDirCommand :=makedir +RcCmpOptions := $(shell wx-config --rcflags) +RcCompilerName :=windres +LinkOptions := -mwindows $(shell wx-config --debug=yes --libs --unicode=yes) +IncludePath := $(IncludeSwitch). $(IncludeSwitch)/bin/MinGW-4.7.1/msys/1.0/local/include $(IncludeSwitch)../../../codec2/src $(IncludeSwitch)/bin/Projects/Audio/libsndfile/include +IncludePCH := +RcIncludePath := +Libs := $(LibrarySwitch)sndfile-1 $(LibrarySwitch)codec2 $(LibrarySwitch)portaudio $(LibrarySwitch)portaudiocpp $(LibrarySwitch)samplerate.dll $(LibrarySwitch)ctb-0.16 $(LibrarySwitch)sox +ArLibs := "libsndfile-1.dll" "codec2" "libportaudio.a" "libportaudiocpp.a" "libsamplerate.dll.a" "libctb-0.16.a" "libsox" +LibPath := $(LibraryPathSwitch). $(LibraryPathSwitch)d:/Projects/Radio/codec2/src/.libs $(LibraryPathSwitch)d:/bin/MinGW-4.7.1/msys/1.0/local/lib + +## +## Common variables +## AR, CXX, CC, CXXFLAGS and CFLAGS can be overriden using an environment variables +## +AR := ar rcus +CXX := g++ +CC := gcc +CXXFLAGS := -g -O0 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=yes) -DSVN_REVISION=\"1237\" $(Preprocessors) +CFLAGS := -g -O0 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=yes) -DSVN_REVISION=\"1237\" $(Preprocessors) + + +## +## User defined environment variables +## +CodeLiteDir:=D:\bin\CodeLite +WXWIN:=D:\bin\wxWidgets-2.9.4 +PATH:=$(WXWIN)\lib\gcc_dll;$(PATH) +WXCFG:=gcc_dll\mswu +UNIT_TEST_PP_SRC_DIR:=D:\bin\UnitTest++1.3 +Objects0=$(IntermediateDirectory)/src_dlg_comports$(ObjectSuffix) $(IntermediateDirectory)/src_fdmdv2_main$(ObjectSuffix) $(IntermediateDirectory)/src_fdmdv2_plot$(ObjectSuffix) $(IntermediateDirectory)/src_topFrame$(ObjectSuffix) $(IntermediateDirectory)/src_fdmdv2_plot_scatter$(ObjectSuffix) $(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(ObjectSuffix) $(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(ObjectSuffix) $(IntermediateDirectory)/src_fdmdv2_plot_scalar$(ObjectSuffix) $(IntermediateDirectory)/src_fdmdv2_plot_waterfall_linux$(ObjectSuffix) $(IntermediateDirectory)/src_dlg_audiooptions$(ObjectSuffix) \ + $(IntermediateDirectory)/src_dlg_filter$(ObjectSuffix) $(IntermediateDirectory)/src_varicode$(ObjectSuffix) $(IntermediateDirectory)/src_sox_biquad$(ObjectSuffix) $(IntermediateDirectory)/src_dlg_about$(ObjectSuffix) $(IntermediateDirectory)/src_golay23$(ObjectSuffix) + + + +Objects=$(Objects0) + +## +## Main Build Targets +## +.PHONY: all clean PreBuild PrePreBuild PostBuild +all: $(OutputFile) + +$(OutputFile): $(IntermediateDirectory)/.d $(Objects) + @$(MakeDirCommand) $(@D) + @echo "" > $(IntermediateDirectory)/.d + @echo $(Objects0) > $(ObjectsFileList) + $(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions) + +$(IntermediateDirectory)/.d: + @$(MakeDirCommand) "./Debug" + +PreBuild: + + +## +## Objects +## +$(IntermediateDirectory)/src_dlg_comports$(ObjectSuffix): ../../src/dlg_comports.cpp $(IntermediateDirectory)/src_dlg_comports$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/src/dlg_comports.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_dlg_comports$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_dlg_comports$(DependSuffix): ../../src/dlg_comports.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_dlg_comports$(ObjectSuffix) -MF$(IntermediateDirectory)/src_dlg_comports$(DependSuffix) -MM "../../src/dlg_comports.cpp" + +$(IntermediateDirectory)/src_dlg_comports$(PreprocessSuffix): ../../src/dlg_comports.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_dlg_comports$(PreprocessSuffix) "../../src/dlg_comports.cpp" + +$(IntermediateDirectory)/src_fdmdv2_main$(ObjectSuffix): ../../src/fdmdv2_main.cpp $(IntermediateDirectory)/src_fdmdv2_main$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/src/fdmdv2_main.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_fdmdv2_main$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_fdmdv2_main$(DependSuffix): ../../src/fdmdv2_main.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_fdmdv2_main$(ObjectSuffix) -MF$(IntermediateDirectory)/src_fdmdv2_main$(DependSuffix) -MM "../../src/fdmdv2_main.cpp" + +$(IntermediateDirectory)/src_fdmdv2_main$(PreprocessSuffix): ../../src/fdmdv2_main.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_fdmdv2_main$(PreprocessSuffix) "../../src/fdmdv2_main.cpp" + +$(IntermediateDirectory)/src_fdmdv2_plot$(ObjectSuffix): ../../src/fdmdv2_plot.cpp $(IntermediateDirectory)/src_fdmdv2_plot$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/src/fdmdv2_plot.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_fdmdv2_plot$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_fdmdv2_plot$(DependSuffix): ../../src/fdmdv2_plot.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_fdmdv2_plot$(ObjectSuffix) -MF$(IntermediateDirectory)/src_fdmdv2_plot$(DependSuffix) -MM "../../src/fdmdv2_plot.cpp" + +$(IntermediateDirectory)/src_fdmdv2_plot$(PreprocessSuffix): ../../src/fdmdv2_plot.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_fdmdv2_plot$(PreprocessSuffix) "../../src/fdmdv2_plot.cpp" + +$(IntermediateDirectory)/src_topFrame$(ObjectSuffix): ../../src/topFrame.cpp $(IntermediateDirectory)/src_topFrame$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/src/topFrame.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_topFrame$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_topFrame$(DependSuffix): ../../src/topFrame.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_topFrame$(ObjectSuffix) -MF$(IntermediateDirectory)/src_topFrame$(DependSuffix) -MM "../../src/topFrame.cpp" + +$(IntermediateDirectory)/src_topFrame$(PreprocessSuffix): ../../src/topFrame.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_topFrame$(PreprocessSuffix) "../../src/topFrame.cpp" + +$(IntermediateDirectory)/src_fdmdv2_plot_scatter$(ObjectSuffix): ../../src/fdmdv2_plot_scatter.cpp $(IntermediateDirectory)/src_fdmdv2_plot_scatter$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/src/fdmdv2_plot_scatter.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_fdmdv2_plot_scatter$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_fdmdv2_plot_scatter$(DependSuffix): ../../src/fdmdv2_plot_scatter.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_fdmdv2_plot_scatter$(ObjectSuffix) -MF$(IntermediateDirectory)/src_fdmdv2_plot_scatter$(DependSuffix) -MM "../../src/fdmdv2_plot_scatter.cpp" + +$(IntermediateDirectory)/src_fdmdv2_plot_scatter$(PreprocessSuffix): ../../src/fdmdv2_plot_scatter.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_fdmdv2_plot_scatter$(PreprocessSuffix) "../../src/fdmdv2_plot_scatter.cpp" + +$(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(ObjectSuffix): ../../src/fdmdv2_plot_spectrum.cpp $(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/src/fdmdv2_plot_spectrum.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(DependSuffix): ../../src/fdmdv2_plot_spectrum.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(ObjectSuffix) -MF$(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(DependSuffix) -MM "../../src/fdmdv2_plot_spectrum.cpp" + +$(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(PreprocessSuffix): ../../src/fdmdv2_plot_spectrum.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(PreprocessSuffix) "../../src/fdmdv2_plot_spectrum.cpp" + +$(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(ObjectSuffix): ../../src/fdmdv2_pa_wrapper.cpp $(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/src/fdmdv2_pa_wrapper.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(DependSuffix): ../../src/fdmdv2_pa_wrapper.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(ObjectSuffix) -MF$(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(DependSuffix) -MM "../../src/fdmdv2_pa_wrapper.cpp" + +$(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(PreprocessSuffix): ../../src/fdmdv2_pa_wrapper.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(PreprocessSuffix) "../../src/fdmdv2_pa_wrapper.cpp" + +$(IntermediateDirectory)/src_fdmdv2_plot_scalar$(ObjectSuffix): ../../src/fdmdv2_plot_scalar.cpp $(IntermediateDirectory)/src_fdmdv2_plot_scalar$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/src/fdmdv2_plot_scalar.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_fdmdv2_plot_scalar$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_fdmdv2_plot_scalar$(DependSuffix): ../../src/fdmdv2_plot_scalar.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_fdmdv2_plot_scalar$(ObjectSuffix) -MF$(IntermediateDirectory)/src_fdmdv2_plot_scalar$(DependSuffix) -MM "../../src/fdmdv2_plot_scalar.cpp" + +$(IntermediateDirectory)/src_fdmdv2_plot_scalar$(PreprocessSuffix): ../../src/fdmdv2_plot_scalar.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_fdmdv2_plot_scalar$(PreprocessSuffix) "../../src/fdmdv2_plot_scalar.cpp" + +$(IntermediateDirectory)/src_fdmdv2_plot_waterfall_linux$(ObjectSuffix): ../../src/fdmdv2_plot_waterfall_linux.cpp $(IntermediateDirectory)/src_fdmdv2_plot_waterfall_linux$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/src/fdmdv2_plot_waterfall_linux.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_fdmdv2_plot_waterfall_linux$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_fdmdv2_plot_waterfall_linux$(DependSuffix): ../../src/fdmdv2_plot_waterfall_linux.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_fdmdv2_plot_waterfall_linux$(ObjectSuffix) -MF$(IntermediateDirectory)/src_fdmdv2_plot_waterfall_linux$(DependSuffix) -MM "../../src/fdmdv2_plot_waterfall_linux.cpp" + +$(IntermediateDirectory)/src_fdmdv2_plot_waterfall_linux$(PreprocessSuffix): ../../src/fdmdv2_plot_waterfall_linux.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_fdmdv2_plot_waterfall_linux$(PreprocessSuffix) "../../src/fdmdv2_plot_waterfall_linux.cpp" + +$(IntermediateDirectory)/src_dlg_audiooptions$(ObjectSuffix): ../../src/dlg_audiooptions.cpp $(IntermediateDirectory)/src_dlg_audiooptions$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/src/dlg_audiooptions.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_dlg_audiooptions$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_dlg_audiooptions$(DependSuffix): ../../src/dlg_audiooptions.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_dlg_audiooptions$(ObjectSuffix) -MF$(IntermediateDirectory)/src_dlg_audiooptions$(DependSuffix) -MM "../../src/dlg_audiooptions.cpp" + +$(IntermediateDirectory)/src_dlg_audiooptions$(PreprocessSuffix): ../../src/dlg_audiooptions.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_dlg_audiooptions$(PreprocessSuffix) "../../src/dlg_audiooptions.cpp" + +$(IntermediateDirectory)/src_dlg_filter$(ObjectSuffix): ../../src/dlg_filter.cpp $(IntermediateDirectory)/src_dlg_filter$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/src/dlg_filter.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_dlg_filter$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_dlg_filter$(DependSuffix): ../../src/dlg_filter.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_dlg_filter$(ObjectSuffix) -MF$(IntermediateDirectory)/src_dlg_filter$(DependSuffix) -MM "../../src/dlg_filter.cpp" + +$(IntermediateDirectory)/src_dlg_filter$(PreprocessSuffix): ../../src/dlg_filter.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_dlg_filter$(PreprocessSuffix) "../../src/dlg_filter.cpp" + +$(IntermediateDirectory)/src_varicode$(ObjectSuffix): ../../src/varicode.c $(IntermediateDirectory)/src_varicode$(DependSuffix) + $(CC) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/src/varicode.c" $(CFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_varicode$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_varicode$(DependSuffix): ../../src/varicode.c + @$(CC) $(CFLAGS) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_varicode$(ObjectSuffix) -MF$(IntermediateDirectory)/src_varicode$(DependSuffix) -MM "../../src/varicode.c" + +$(IntermediateDirectory)/src_varicode$(PreprocessSuffix): ../../src/varicode.c + @$(CC) $(CFLAGS) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_varicode$(PreprocessSuffix) "../../src/varicode.c" + +$(IntermediateDirectory)/src_sox_biquad$(ObjectSuffix): ../../src/sox_biquad.c $(IntermediateDirectory)/src_sox_biquad$(DependSuffix) + $(CC) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/src/sox_biquad.c" $(CFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_sox_biquad$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_sox_biquad$(DependSuffix): ../../src/sox_biquad.c + @$(CC) $(CFLAGS) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_sox_biquad$(ObjectSuffix) -MF$(IntermediateDirectory)/src_sox_biquad$(DependSuffix) -MM "../../src/sox_biquad.c" + +$(IntermediateDirectory)/src_sox_biquad$(PreprocessSuffix): ../../src/sox_biquad.c + @$(CC) $(CFLAGS) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_sox_biquad$(PreprocessSuffix) "../../src/sox_biquad.c" + +$(IntermediateDirectory)/src_dlg_about$(ObjectSuffix): ../../src/dlg_about.cpp $(IntermediateDirectory)/src_dlg_about$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/src/dlg_about.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_dlg_about$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_dlg_about$(DependSuffix): ../../src/dlg_about.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_dlg_about$(ObjectSuffix) -MF$(IntermediateDirectory)/src_dlg_about$(DependSuffix) -MM "../../src/dlg_about.cpp" + +$(IntermediateDirectory)/src_dlg_about$(PreprocessSuffix): ../../src/dlg_about.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_dlg_about$(PreprocessSuffix) "../../src/dlg_about.cpp" + +$(IntermediateDirectory)/src_golay23$(ObjectSuffix): ../../../codec2/src/golay23.c $(IntermediateDirectory)/src_golay23$(DependSuffix) + $(CC) $(SourceSwitch) "D:/Projects/Radio/codec2/src/golay23.c" $(CFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_golay23$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/src_golay23$(DependSuffix): ../../../codec2/src/golay23.c + @$(CC) $(CFLAGS) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/src_golay23$(ObjectSuffix) -MF$(IntermediateDirectory)/src_golay23$(DependSuffix) -MM "../../../codec2/src/golay23.c" + +$(IntermediateDirectory)/src_golay23$(PreprocessSuffix): ../../../codec2/src/golay23.c + @$(CC) $(CFLAGS) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_golay23$(PreprocessSuffix) "../../../codec2/src/golay23.c" + + +-include $(IntermediateDirectory)/*$(DependSuffix) +## +## Clean +## +clean: + $(RM) $(IntermediateDirectory)/src_dlg_comports$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/src_dlg_comports$(DependSuffix) + $(RM) $(IntermediateDirectory)/src_dlg_comports$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_main$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_main$(DependSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_main$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_plot$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_plot$(DependSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_plot$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/src_topFrame$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/src_topFrame$(DependSuffix) + $(RM) $(IntermediateDirectory)/src_topFrame$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_scatter$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_scatter$(DependSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_scatter$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(DependSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_spectrum$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(DependSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_pa_wrapper$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_scalar$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_scalar$(DependSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_scalar$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_waterfall_linux$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_waterfall_linux$(DependSuffix) + $(RM) $(IntermediateDirectory)/src_fdmdv2_plot_waterfall_linux$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/src_dlg_audiooptions$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/src_dlg_audiooptions$(DependSuffix) + $(RM) $(IntermediateDirectory)/src_dlg_audiooptions$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/src_dlg_filter$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/src_dlg_filter$(DependSuffix) + $(RM) $(IntermediateDirectory)/src_dlg_filter$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/src_varicode$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/src_varicode$(DependSuffix) + $(RM) $(IntermediateDirectory)/src_varicode$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/src_sox_biquad$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/src_sox_biquad$(DependSuffix) + $(RM) $(IntermediateDirectory)/src_sox_biquad$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/src_dlg_about$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/src_dlg_about$(DependSuffix) + $(RM) $(IntermediateDirectory)/src_dlg_about$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/src_golay23$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/src_golay23$(DependSuffix) + $(RM) $(IntermediateDirectory)/src_golay23$(PreprocessSuffix) + $(RM) $(OutputFile) + $(RM) $(OutputFile).exe + $(RM) ".build-debug/fdmdv2" + + diff --git a/fdmdv2/branches/0.97/build/codelite/fdmdv2.project b/fdmdv2/branches/0.97/build/codelite/fdmdv2.project new file mode 100644 index 00000000..acef6eff --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/fdmdv2.project @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + None + + + + + + + + + + + + + + + diff --git a/fdmdv2/branches/0.97/build/codelite/fdmdv2.txt b/fdmdv2/branches/0.97/build/codelite/fdmdv2.txt new file mode 100644 index 00000000..7b081257 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/fdmdv2.txt @@ -0,0 +1 @@ +./Debug/src_dlg_comports.o ./Debug/src_fdmdv2_main.o ./Debug/src_fdmdv2_plot.o ./Debug/src_topFrame.o ./Debug/src_fdmdv2_plot_scatter.o ./Debug/src_fdmdv2_plot_spectrum.o ./Debug/src_fdmdv2_pa_wrapper.o ./Debug/src_fdmdv2_plot_scalar.o ./Debug/src_fdmdv2_plot_waterfall_linux.o ./Debug/src_dlg_audiooptions.o ./Debug/src_dlg_filter.o ./Debug/src_varicode.o ./Debug/src_sox_biquad.o ./Debug/src_dlg_about.o ./Debug/src_golay23.o diff --git a/fdmdv2/branches/0.97/build/codelite/fdmdv2.workspace b/fdmdv2/branches/0.97/build/codelite/fdmdv2.workspace new file mode 100644 index 00000000..9a56dfc9 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/fdmdv2.workspace @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fdmdv2/branches/0.97/build/codelite/fdmdv2_copyright_block.txt b/fdmdv2/branches/0.97/build/codelite/fdmdv2_copyright_block.txt new file mode 100644 index 00000000..785ec41a --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/fdmdv2_copyright_block.txt @@ -0,0 +1,24 @@ +//========================================================================== +// Name: +// Purpose: +// Created: June 22, 2012 +// Initial author: David Witten +// Derived from: +// License: +// +// Copyright (C) 2012 David Witten +// +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License version 2.1, +// as published by the Free Software Foundation. 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 Lesser General Public License +// along with this program; if not, see . +// +//========================================================================== diff --git a/fdmdv2/branches/0.97/build/codelite/fdmdv2_wsp.mk b/fdmdv2/branches/0.97/build/codelite/fdmdv2_wsp.mk new file mode 100644 index 00000000..42262456 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/fdmdv2_wsp.mk @@ -0,0 +1,8 @@ +.PHONY: clean All + +All: + @echo "----------Building project:[ fdmdv2 - Debug ]----------" + @$(MAKE) -f "fdmdv2.mk" +clean: + @echo "----------Cleaning project:[ fdmdv2 - Debug ]----------" + @$(MAKE) -f "fdmdv2.mk" clean diff --git a/fdmdv2/branches/0.97/build/codelite/hamlib_trial/MainFrame.cpp b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/MainFrame.cpp new file mode 100644 index 00000000..c0fae92d --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/MainFrame.cpp @@ -0,0 +1,80 @@ +#include "main.h" +#include "MainFrame.h" +#include +#include "dlg_rig_ctrl.h" + +MainFrame::MainFrame(wxWindow* parent): MainFrameBaseClass(parent) +{ + wxConfigBase *pConfig = wxConfigBase::Get(); + if(pConfig) + { + pConfig->SetRecordDefaults(); + + // restore frame position and size + int x = pConfig->Read(wxT("/MainFrame/top"), 50); + int y = pConfig->Read(wxT("/MainFrame/left"), 50); + int w = pConfig->Read(wxT("/MainFrame/width"), 650); + int h = pConfig->Read(wxT("/MainFrame/height"), 400); + + Move(x, y); + SetClientSize(w, h); + } +} + +MainFrame::~MainFrame() +{ + int x; + int y; + int w; + int h; + + wxConfigBase *pConfig = wxConfigBase::Get(); + if(pConfig) + { + GetClientSize(&w, &h); + GetPosition(&x, &y); + //wxLogDebug("x = %d y = %d w = %d h = %d\n", x,y,w,h); + pConfig->Write(wxT("/MainFrame/top"), (long) x); + pConfig->Write(wxT("/MainFrame/left"), (long) y); + pConfig->Write(wxT("/MainFrame/width"), (long) w); + pConfig->Write(wxT("/MainFrame/height"), (long) h); + } + delete wxConfigBase::Set((wxConfigBase *) NULL); +} + +void MainFrame::OnExit(wxCommandEvent& event) +{ + wxUnusedVar(event); + Close(); +} + +void MainFrame::OnAbout(wxCommandEvent& event) +{ + wxUnusedVar(event); + wxAboutDialogInfo info; + info.SetCopyright(_("HAMLib Test")); + info.SetLicence(_("GPL v2 or later")); + info.SetDescription(_("Short description goes here")); + ::wxAboutBox(info); +} + +void MainFrame::OnNew(wxCommandEvent& event) +{ +} + +void MainFrame::OnOpen(wxCommandEvent& event) +{ +} + +void MainFrame::OnSize(wxSizeEvent& event) +{ +} + +void MainFrame::OnToolsPrefs(wxCommandEvent& event) +{ + wxUnusedVar(event); + DlgRigCtrlBase *dlg = new DlgRigCtrlBase(NULL); + //int rVal = dlg + dlg->ShowModal(); + delete dlg; +} diff --git a/fdmdv2/branches/0.97/build/codelite/hamlib_trial/MainFrame.h b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/MainFrame.h new file mode 100644 index 00000000..2797db0d --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/MainFrame.h @@ -0,0 +1,19 @@ +#ifndef MAINFRAME_H +#define MAINFRAME_H +#include "wxcrafter.h" + +class MainFrame : public MainFrameBaseClass +{ +public: + MainFrame(wxWindow* parent); + virtual ~MainFrame(); + + void OnExit(wxCommandEvent& event); + void OnAbout(wxCommandEvent& event); +protected: + virtual void OnToolsPrefs(wxCommandEvent& event); + virtual void OnNew(wxCommandEvent& event); + virtual void OnOpen(wxCommandEvent& event); + virtual void OnSize(wxSizeEvent& event); +}; +#endif // MAINFRAME_H diff --git a/fdmdv2/branches/0.97/build/codelite/hamlib_trial/dlg_rig_ctrl.cpp b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/dlg_rig_ctrl.cpp new file mode 100644 index 00000000..82ba6657 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/dlg_rig_ctrl.cpp @@ -0,0 +1,10 @@ +#include "dlg_rig_ctrl.h" + +DialogRigCtrl::DialogRigCtrl(wxWindow* parent) : DlgRigCtrlBase(parent) +{ +} + +DialogRigCtrl::~DialogRigCtrl() +{ +} + diff --git a/fdmdv2/branches/0.97/build/codelite/hamlib_trial/dlg_rig_ctrl.h b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/dlg_rig_ctrl.h new file mode 100644 index 00000000..88f2f887 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/dlg_rig_ctrl.h @@ -0,0 +1,11 @@ +#ifndef DIALOGRIGCTRL_H +#define DIALOGRIGCTRL_H +#include "wxcrafter.h" + +class DialogRigCtrl : public DlgRigCtrlBase +{ +public: + DialogRigCtrl(wxWindow* parent); + virtual ~DialogRigCtrl(); +}; +#endif // DIALOGRIGCTRL_H diff --git a/fdmdv2/branches/0.97/build/codelite/hamlib_trial/hamlib_trial.mk b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/hamlib_trial.mk new file mode 100644 index 00000000..c5ffaba6 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/hamlib_trial.mk @@ -0,0 +1,162 @@ +## +## Auto Generated makefile by CodeLite IDE +## any manual changes will be erased +## +## Debug +ProjectName :=hamlib_trial +ConfigurationName :=Debug +WorkspacePath := "D:\Projects\Radio\fdmdv2\build\codelite" +ProjectPath := "D:\Projects\Radio\fdmdv2\build\codelite\hamlib_trial" +IntermediateDirectory :=./Debug +OutDir := $(IntermediateDirectory) +CurrentFileName := +CurrentFilePath := +CurrentFileFullPath := +User :=wittend +Date :=5/6/2013 +CodeLitePath :="D:\bin\CodeLite" +LinkerName :=g++ +SharedObjectLinkerName :=g++ -shared -fPIC +ObjectSuffix :=.o +DependSuffix :=.o.d +PreprocessSuffix :=.o.i +DebugSwitch :=-gstab +IncludeSwitch :=-I +LibrarySwitch :=-l +OutputSwitch :=-o +LibraryPathSwitch :=-L +PreprocessorSwitch :=-D +SourceSwitch :=-c +OutputFile :=$(IntermediateDirectory)/$(ProjectName) +Preprocessors := +ObjectSwitch :=-o +ArchiveOutputSwitch := +PreprocessOnlySwitch :=-E +ObjectsFileList :="hamlib_trial.txt" +PCHCompileFlags := +MakeDirCommand :=makedir +RcCmpOptions := $(shell wx-config --rcflags) +RcCompilerName :=windres +LinkOptions := $(shell wx-config --libs --debug) -mwindows +IncludePath := $(IncludeSwitch). $(IncludeSwitch). +IncludePCH := +RcIncludePath := +Libs := +ArLibs := +LibPath := $(LibraryPathSwitch). + +## +## Common variables +## AR, CXX, CC, CXXFLAGS and CFLAGS can be overriden using an environment variables +## +AR := ar rcus +CXX := g++ +CC := gcc +CXXFLAGS := -g -O0 -Wall $(shell wx-config --cflags --debug) -DSVN_REVISION=\"1237\" $(Preprocessors) +CFLAGS := -g -O0 -Wall -DSVN_REVISION=\"1237\" $(Preprocessors) + + +## +## User defined environment variables +## +CodeLiteDir:=D:\bin\CodeLite +WXWIN:=D:\bin\wxWidgets-2.9.4 +PATH:=$(WXWIN)\lib\gcc_dll;$(PATH) +WXCFG:=gcc_dll\mswu +UNIT_TEST_PP_SRC_DIR:=D:\bin\UnitTest++1.3 +Objects0=$(IntermediateDirectory)/main$(ObjectSuffix) $(IntermediateDirectory)/MainFrame$(ObjectSuffix) $(IntermediateDirectory)/wxcrafter$(ObjectSuffix) $(IntermediateDirectory)/wxcrafter_bitmaps$(ObjectSuffix) $(IntermediateDirectory)/win_resources.rc$(ObjectSuffix) $(IntermediateDirectory)/dlg_rig_ctrl$(ObjectSuffix) + + + +Objects=$(Objects0) + +## +## Main Build Targets +## +.PHONY: all clean PreBuild PrePreBuild PostBuild +all: $(OutputFile) + +$(OutputFile): $(IntermediateDirectory)/.d $(Objects) + @$(MakeDirCommand) $(@D) + @echo "" > $(IntermediateDirectory)/.d + @echo $(Objects0) > $(ObjectsFileList) + $(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions) + +$(IntermediateDirectory)/.d: + @$(MakeDirCommand) "./Debug" + +PreBuild: + + +## +## Objects +## +$(IntermediateDirectory)/main$(ObjectSuffix): main.cpp $(IntermediateDirectory)/main$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/build/codelite/hamlib_trial/main.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/main$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/main$(DependSuffix): main.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/main$(ObjectSuffix) -MF$(IntermediateDirectory)/main$(DependSuffix) -MM "main.cpp" + +$(IntermediateDirectory)/main$(PreprocessSuffix): main.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/main$(PreprocessSuffix) "main.cpp" + +$(IntermediateDirectory)/MainFrame$(ObjectSuffix): MainFrame.cpp $(IntermediateDirectory)/MainFrame$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/build/codelite/hamlib_trial/MainFrame.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/MainFrame$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/MainFrame$(DependSuffix): MainFrame.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/MainFrame$(ObjectSuffix) -MF$(IntermediateDirectory)/MainFrame$(DependSuffix) -MM "MainFrame.cpp" + +$(IntermediateDirectory)/MainFrame$(PreprocessSuffix): MainFrame.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/MainFrame$(PreprocessSuffix) "MainFrame.cpp" + +$(IntermediateDirectory)/wxcrafter$(ObjectSuffix): wxcrafter.cpp $(IntermediateDirectory)/wxcrafter$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/build/codelite/hamlib_trial/wxcrafter.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/wxcrafter$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/wxcrafter$(DependSuffix): wxcrafter.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/wxcrafter$(ObjectSuffix) -MF$(IntermediateDirectory)/wxcrafter$(DependSuffix) -MM "wxcrafter.cpp" + +$(IntermediateDirectory)/wxcrafter$(PreprocessSuffix): wxcrafter.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/wxcrafter$(PreprocessSuffix) "wxcrafter.cpp" + +$(IntermediateDirectory)/wxcrafter_bitmaps$(ObjectSuffix): wxcrafter_bitmaps.cpp $(IntermediateDirectory)/wxcrafter_bitmaps$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/build/codelite/hamlib_trial/wxcrafter_bitmaps.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/wxcrafter_bitmaps$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/wxcrafter_bitmaps$(DependSuffix): wxcrafter_bitmaps.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/wxcrafter_bitmaps$(ObjectSuffix) -MF$(IntermediateDirectory)/wxcrafter_bitmaps$(DependSuffix) -MM "wxcrafter_bitmaps.cpp" + +$(IntermediateDirectory)/wxcrafter_bitmaps$(PreprocessSuffix): wxcrafter_bitmaps.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/wxcrafter_bitmaps$(PreprocessSuffix) "wxcrafter_bitmaps.cpp" + +$(IntermediateDirectory)/win_resources.rc$(ObjectSuffix): win_resources.rc + $(RcCompilerName) -i "D:/Projects/Radio/fdmdv2/build/codelite/hamlib_trial/win_resources.rc" $(RcCmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/win_resources.rc$(ObjectSuffix) $(RcIncludePath) +$(IntermediateDirectory)/dlg_rig_ctrl$(ObjectSuffix): dlg_rig_ctrl.cpp $(IntermediateDirectory)/dlg_rig_ctrl$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "D:/Projects/Radio/fdmdv2/build/codelite/hamlib_trial/dlg_rig_ctrl.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/dlg_rig_ctrl$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/dlg_rig_ctrl$(DependSuffix): dlg_rig_ctrl.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/dlg_rig_ctrl$(ObjectSuffix) -MF$(IntermediateDirectory)/dlg_rig_ctrl$(DependSuffix) -MM "dlg_rig_ctrl.cpp" + +$(IntermediateDirectory)/dlg_rig_ctrl$(PreprocessSuffix): dlg_rig_ctrl.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/dlg_rig_ctrl$(PreprocessSuffix) "dlg_rig_ctrl.cpp" + + +-include $(IntermediateDirectory)/*$(DependSuffix) +## +## Clean +## +clean: + $(RM) $(IntermediateDirectory)/main$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/main$(DependSuffix) + $(RM) $(IntermediateDirectory)/main$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/MainFrame$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/MainFrame$(DependSuffix) + $(RM) $(IntermediateDirectory)/MainFrame$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/wxcrafter$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/wxcrafter$(DependSuffix) + $(RM) $(IntermediateDirectory)/wxcrafter$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/wxcrafter_bitmaps$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/wxcrafter_bitmaps$(DependSuffix) + $(RM) $(IntermediateDirectory)/wxcrafter_bitmaps$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/win_resources.rc$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/dlg_rig_ctrl$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/dlg_rig_ctrl$(DependSuffix) + $(RM) $(IntermediateDirectory)/dlg_rig_ctrl$(PreprocessSuffix) + $(RM) $(OutputFile) + $(RM) $(OutputFile).exe + $(RM) "../.build-debug/hamlib_trial" + + diff --git a/fdmdv2/branches/0.97/build/codelite/hamlib_trial/hamlib_trial.project b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/hamlib_trial.project new file mode 100644 index 00000000..1217de44 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/hamlib_trial.project @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + None + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fdmdv2/branches/0.97/build/codelite/hamlib_trial/hamlib_trial.txt b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/hamlib_trial.txt new file mode 100644 index 00000000..2ade1a73 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/hamlib_trial.txt @@ -0,0 +1 @@ +./Release/main.o ./Release/MainFrame.o ./Release/wxcrafter.o ./Release/wxcrafter_bitmaps.o ./Release/win_resources.rc.o ./Release/dlg_rig_ctrl.o diff --git a/fdmdv2/branches/0.97/build/codelite/hamlib_trial/main.cpp b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/main.cpp new file mode 100644 index 00000000..56eb165a --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/main.cpp @@ -0,0 +1,24 @@ +#include "main.h" +#include "MainFrame.h" + +IMPLEMENT_APP(MainApp) + +bool MainApp::OnInit() +{ + // Add the common image handlers + wxImage::AddHandler( new wxPNGHandler ); + wxImage::AddHandler( new wxJPEGHandler ); + + SetVendorName(wxT("CODEC2-Project")); + SetAppName(wxT("Hamlib test")); + + wxConfig *pConfig = new wxConfig(); + wxFileConfig *pFConfig = new wxFileConfig(wxT("visiWidgits"), wxT("WWR Development"), wxT("visiWidgits.conf"), wxT("visiWidgits.conf"), wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH); + pConfig->Set(pFConfig); + pConfig->SetRecordDefaults(); + + + MainFrame *mainFrame = new MainFrame(NULL); + SetTopWindow(mainFrame); + return GetTopWindow()->Show(); +} diff --git a/fdmdv2/branches/0.97/build/codelite/hamlib_trial/main.h b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/main.h new file mode 100644 index 00000000..424bde98 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/main.h @@ -0,0 +1,62 @@ +//========================================================================== +// Name: main.h +// +// Purpose: Inclusions and constants for the entire visiWidgets program. +// Created: Mar. 01, 2013 +// Authors: David Witten +// +// License: +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, see . +// +//========================================================================== +#ifndef __HAMLIBTRIAL_MAIN__ +#define __HAMLIBTRIAL_MAIN__ + +#include +#include +#include +#include +#include "wx/file.h" +#include "wx/filename.h" +#include "wx/config.h" +#include +#include + +#include "MainFrame.h" + +#include "rig.h" +#include "rig_dll.h" +#include "riglist.h" +#include "rotator.h" +#include "rotlist.h" + +#if defined(__WINDOWS__) +#undef wxUSE_CONFIG_NATIVE +#endif + +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-= +// Class MainApp +// +// @class $(Name) +// @author $(User) +// @date $(Date) +// @file $(CurrentFileName).$(CurrentFileExt) +// @brief +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-= +// Define the MainApp +class MainApp : public wxApp +{ +public: + MainApp() {} + virtual ~MainApp() {} + + virtual bool OnInit(); +}; + +DECLARE_APP(MainApp) +//IMPLEMENT_APP(MainApp) + +#endif //__HAMLIBTRIAL_MAIN__ diff --git a/fdmdv2/branches/0.97/build/codelite/hamlib_trial/win_resources.rc b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/win_resources.rc new file mode 100644 index 00000000..fa70c15a --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/win_resources.rc @@ -0,0 +1,2 @@ +#include "wx/msw/wx.rc" +1 24 "wx/msw/wx.manifest" diff --git a/fdmdv2/branches/0.97/build/codelite/hamlib_trial/wxcrafter.cpp b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/wxcrafter.cpp new file mode 100644 index 00000000..4195f375 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/wxcrafter.cpp @@ -0,0 +1,754 @@ +////////////////////////////////////////////////////////////////////// +// This file was auto-generated by codelite's wxCrafter Plugin +// Do not modify this file by hand! +////////////////////////////////////////////////////////////////////// + +#include "wxcrafter.h" + + +// Declare the bitmap loading function +extern void wxC9ED9InitBitmapResources(); + +static bool bBitmapLoaded = false; + + +MainFrameBaseClass::MainFrameBaseClass(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) + : wxFrame(parent, id, title, pos, size, style) +{ + if ( !bBitmapLoaded ) { + // We need to initialise the default bitmap handler + wxXmlResource::Get()->AddHandler(new wxBitmapXmlHandler); + wxC9ED9InitBitmapResources(); + bBitmapLoaded = true; + } + + wxBoxSizer* boxSizer1 = new wxBoxSizer(wxVERTICAL); + this->SetSizer(boxSizer1); + + m_mainPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1,-1), wxTAB_TRAVERSAL); + + boxSizer1->Add(m_mainPanel, 1, wxEXPAND, 5); + + wxBoxSizer* boxSizer33 = new wxBoxSizer(wxVERTICAL); + m_mainPanel->SetSizer(boxSizer33); + + m_menuBar = new wxMenuBar(0); + this->SetMenuBar(m_menuBar); + + m_mbFile = new wxMenu(); + m_menuBar->Append(m_mbFile, _("File")); + + m_mbiNew = new wxMenuItem(m_mbFile, wxID_NEW, _("New"), wxT(""), wxITEM_NORMAL); + m_mbFile->Append(m_mbiNew); + + m_mbiOpen = new wxMenuItem(m_mbFile, wxID_OPEN, _("Open"), wxT(""), wxITEM_NORMAL); + m_mbFile->Append(m_mbiOpen); + + m_mbiSave = new wxMenuItem(m_mbFile, wxID_SAVE, _("Save"), wxT(""), wxITEM_NORMAL); + m_mbFile->Append(m_mbiSave); + + m_mbiSaveAs = new wxMenuItem(m_mbFile, wxID_SAVEAS, _("Save As"), wxT(""), wxITEM_NORMAL); + m_mbFile->Append(m_mbiSaveAs); + + m_mbFile->AppendSeparator(); + + m_mbiExit = new wxMenuItem(m_mbFile, wxID_EXIT, _("Exit Alt-X"), _("Quit"), wxITEM_NORMAL); + m_mbFile->Append(m_mbiExit); + + m_mbTools = new wxMenu(); + m_menuBar->Append(m_mbTools, _("Tools")); + + m_mbiPrefs = new wxMenuItem(m_mbTools, wxID_PREFERENCES, _("Preferences"), wxT(""), wxITEM_NORMAL); + m_mbTools->Append(m_mbiPrefs); + + m_mbHelp = new wxMenu(); + m_menuBar->Append(m_mbHelp, _("Help")); + + m_menuItem9 = new wxMenuItem(m_mbHelp, wxID_ABOUT, _("About..."), wxT(""), wxITEM_NORMAL); + m_mbHelp->Append(m_menuItem9); + + m_mainToolbar = this->CreateToolBar(wxTB_FLAT, wxID_ANY); + m_mainToolbar->SetToolBitmapSize(wxSize(16,16)); + + m_mainToolbar->AddTool(wxID_NEW, _("New"), wxXmlResource::Get()->LoadBitmap(wxT("placeholder16")), wxNullBitmap, wxITEM_NORMAL, _("New"), _("New"), NULL); + + m_mainToolbar->AddTool(wxID_OPEN, _("Tool Label"), wxXmlResource::Get()->LoadBitmap(wxT("placeholder16")), wxNullBitmap, wxITEM_NORMAL, _("Open"), _("Open"), NULL); + m_mainToolbar->Realize(); + + + SetSizeHints(500,300); + if ( GetSizer() ) { + GetSizer()->Fit(this); + } + Centre(wxBOTH); + // Connect events + m_mainPanel->Connect(wxEVT_SIZE, wxSizeEventHandler(MainFrameBaseClass::OnSize), NULL, this); + this->Connect(m_mbiExit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrameBaseClass::OnExit), NULL, this); + this->Connect(m_mbiPrefs->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrameBaseClass::OnToolsPrefs), NULL, this); + this->Connect(m_menuItem9->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrameBaseClass::OnAbout), NULL, this); + this->Connect(wxID_NEW, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(MainFrameBaseClass::OnNew), NULL, this); + this->Connect(wxID_OPEN, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(MainFrameBaseClass::OnOpen), NULL, this); + +} + +MainFrameBaseClass::~MainFrameBaseClass() +{ + m_mainPanel->Disconnect(wxEVT_SIZE, wxSizeEventHandler(MainFrameBaseClass::OnSize), NULL, this); + this->Disconnect(m_mbiExit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrameBaseClass::OnExit), NULL, this); + this->Disconnect(m_mbiPrefs->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrameBaseClass::OnToolsPrefs), NULL, this); + this->Disconnect(m_menuItem9->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrameBaseClass::OnAbout), NULL, this); + this->Disconnect(wxID_NEW, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(MainFrameBaseClass::OnNew), NULL, this); + this->Disconnect(wxID_OPEN, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(MainFrameBaseClass::OnOpen), NULL, this); + +} + +DlgRigCtrlBase::DlgRigCtrlBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) + : wxDialog(parent, id, title, pos, size, style) +{ + if ( !bBitmapLoaded ) { + // We need to initialise the default bitmap handler + wxXmlResource::Get()->AddHandler(new wxBitmapXmlHandler); + wxC9ED9InitBitmapResources(); + bBitmapLoaded = true; + } + + wxBoxSizer* boxSizer51 = new wxBoxSizer(wxVERTICAL); + this->SetSizer(boxSizer51); + + m_notebook53 = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxSize(-1, -1), wxBK_DEFAULT); + + boxSizer51->Add(m_notebook53, 1, wxALL|wxEXPAND, 2); + + m_panelHDWPTT = new wxPanel(m_notebook53, wxID_ANY, wxDefaultPosition, wxSize(-1,-1), wxTAB_TRAVERSAL); + m_panelHDWPTT->SetToolTip(_("Hardware Push-to-Talk")); + m_notebook53->AddPage(m_panelHDWPTT, _("Hardware PTT"), true); + + wxFlexGridSizer* flexGridSizer135 = new wxFlexGridSizer( 3, 1, 0, 0); + flexGridSizer135->SetFlexibleDirection( wxBOTH ); + flexGridSizer135->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + flexGridSizer135->AddGrowableCol(1); + flexGridSizer135->AddGrowableRow(3); + m_panelHDWPTT->SetSizer(flexGridSizer135); + + wxStaticBoxSizer* staticBoxSizer169 = new wxStaticBoxSizer( new wxStaticBox(m_panelHDWPTT, wxID_ANY, wxT("")), wxVERTICAL); + + flexGridSizer135->Add(staticBoxSizer169, 0, wxALL|wxEXPAND, 2); + + m_checkBox7537 = new wxCheckBox(m_panelHDWPTT, wxID_ANY, _("PTT tone on right audio channel"), wxDefaultPosition, wxSize(-1,-1), 0); + m_checkBox7537->SetValue(false); + + staticBoxSizer169->Add(m_checkBox7537, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); + + wxGridSizer* gridSizer159 = new wxGridSizer( 1, 1, 0, 0); + + flexGridSizer135->Add(gridSizer159, 0, wxALL|wxALIGN_LEFT|wxALIGN_TOP, 2); + + wxStaticBoxSizer* staticBoxSizer157 = new wxStaticBoxSizer( new wxStaticBox(m_panelHDWPTT, wxID_ANY, _("h/w ptt device pin")), wxHORIZONTAL); + + gridSizer159->Add(staticBoxSizer157, 0, wxALL|wxEXPAND|wxALIGN_TOP, 2); + + wxBoxSizer* boxSizer175 = new wxBoxSizer(wxVERTICAL); + + staticBoxSizer157->Add(boxSizer175, 1, wxALL, 2); + + m_checkBox9112 = new wxCheckBox(m_panelHDWPTT, wxID_ANY, _("Use separate PTT device pin"), wxDefaultPosition, wxSize(-1,-1), 0); + m_checkBox9112->SetValue(false); + + boxSizer175->Add(m_checkBox9112, 0, wxALL|wxALIGN_TOP, 2); + + m_staticText173 = new wxStaticText(m_panelHDWPTT, wxID_ANY, _("Device:"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer175->Add(m_staticText173, 0, wxALL, 5); + + wxArrayString m_comboBox9313Arr; + m_comboBox9313 = new wxComboBox(m_panelHDWPTT, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), m_comboBox9313Arr, 0); + + boxSizer175->Add(m_comboBox9313, 0, wxALL, 2); + + wxBoxSizer* boxSizer171 = new wxBoxSizer(wxHORIZONTAL); + + staticBoxSizer157->Add(boxSizer171, 1, wxALL, 2); + + wxBoxSizer* boxSizer12714 = new wxBoxSizer(wxVERTICAL); + + boxSizer171->Add(boxSizer12714, 1, wxALL|wxALIGN_CENTER_HORIZONTAL, 2); + + wxArrayString m_radioBox10115Arr; + m_radioBox10115Arr.Add(wxT("Normal (V-)")); + m_radioBox10115Arr.Add(wxT("Inverted (V+)")); + m_radioBox10115 = new wxRadioBox(m_panelHDWPTT, wxID_ANY, _("Use RTS"), wxDefaultPosition, wxSize(-1,-1), m_radioBox10115Arr, 2, wxRA_SPECIFY_COLS); + m_radioBox10115->SetSelection(0); + + boxSizer12714->Add(m_radioBox10115, 1, wxALL|wxALIGN_CENTER_HORIZONTAL, 2); + + wxArrayString m_radioBox10316Arr; + m_radioBox10316Arr.Add(wxT("Normal (V-)")); + m_radioBox10316Arr.Add(wxT("Inverted (V+)")); + m_radioBox10316 = new wxRadioBox(m_panelHDWPTT, wxID_ANY, _("Use DTR"), wxDefaultPosition, wxSize(-1,-1), m_radioBox10316Arr, 2, wxRA_SPECIFY_COLS); + m_radioBox10316->SetSelection(0); + + boxSizer12714->Add(m_radioBox10316, 1, wxALL|wxALIGN_CENTER_HORIZONTAL, 2); + + wxBoxSizer* boxSizer13118 = new wxBoxSizer(wxHORIZONTAL); + + boxSizer12714->Add(boxSizer13118, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + + m_button11319 = new wxButton(m_panelHDWPTT, wxID_ANY, _("Initialize"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer13118->Add(m_button11319, 1, wxALL, 2); + + wxStaticBoxSizer* staticBoxSizer79420 = new wxStaticBoxSizer( new wxStaticBox(m_panelHDWPTT, wxID_ANY, _("PTT delay for all CAT/PTT types")), wxHORIZONTAL); + + flexGridSizer135->Add(staticBoxSizer79420, 0, wxALL|wxEXPAND|wxALIGN_LEFT, 2); + + m_staticText177 = new wxStaticText(m_panelHDWPTT, wxID_ANY, _("Start of xmit delay"), wxDefaultPosition, wxSize(-1,-1), 0); + + staticBoxSizer79420->Add(m_staticText177, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2); + + m_slider10721 = new wxSlider(m_panelHDWPTT, wxID_ANY, 50, 0, 100, wxDefaultPosition, wxSize(-1,-1), wxSL_HORIZONTAL); + + staticBoxSizer79420->Add(m_slider10721, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + + m_staticText179 = new wxStaticText(m_panelHDWPTT, wxID_ANY, _("End of xmit delay:"), wxDefaultPosition, wxSize(-1,-1), 0); + + staticBoxSizer79420->Add(m_staticText179, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2); + + m_slider10922 = new wxSlider(m_panelHDWPTT, wxID_ANY, 50, 0, 100, wxDefaultPosition, wxSize(-1,-1), wxSL_HORIZONTAL); + + staticBoxSizer79420->Add(m_slider10922, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + + m_panelRIGCat = new wxPanel(m_notebook53, wxID_ANY, wxDefaultPosition, wxSize(-1,-1), wxTAB_TRAVERSAL); + m_panelRIGCat->SetToolTip(_("RigCat")); + m_notebook53->AddPage(m_panelRIGCat, _("RigCAT"), false); + + wxBoxSizer* boxSizer67 = new wxBoxSizer(wxVERTICAL); + m_panelRIGCat->SetSizer(boxSizer67); + + m_radioButton185 = new wxRadioButton(m_panelRIGCat, wxID_ANY, _("Use RigCAT"), wxDefaultPosition, wxSize(-1,-1), 0); + m_radioButton185->SetValue(1); + + boxSizer67->Add(m_radioButton185, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 2); + + wxStaticBoxSizer* staticBoxSizer183 = new wxStaticBoxSizer( new wxStaticBox(m_panelRIGCat, wxID_ANY, wxT("")), wxVERTICAL); + + boxSizer67->Add(staticBoxSizer183, 1, wxALL|wxEXPAND|wxALIGN_TOP, 2); + + wxFlexGridSizer* flexGridSizer187 = new wxFlexGridSizer( 1, 1, 0, 0); + flexGridSizer187->SetFlexibleDirection( wxBOTH ); + flexGridSizer187->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + flexGridSizer187->AddGrowableCol(1); + flexGridSizer187->AddGrowableRow(1); + + staticBoxSizer183->Add(flexGridSizer187, 0, wxALL, 2); + + wxFlexGridSizer* flexGridSizer204 = new wxFlexGridSizer( 3, 4, 0, 0); + flexGridSizer204->SetFlexibleDirection( wxBOTH ); + flexGridSizer204->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + flexGridSizer187->Add(flexGridSizer204, 1, wxALL|wxEXPAND, 2); + + wxBoxSizer* boxSizer193 = new wxBoxSizer(wxHORIZONTAL); + + flexGridSizer204->Add(boxSizer193, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 2); + + m_staticText189 = new wxStaticText(m_panelRIGCat, wxID_ANY, _("File:"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer193->Add(m_staticText189, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2); + + m_textCtrl191 = new wxTextCtrl(m_panelRIGCat, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer193->Add(m_textCtrl191, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2); + + wxBoxSizer* boxSizer206 = new wxBoxSizer(wxVERTICAL); + + flexGridSizer204->Add(boxSizer206, 1, wxALL|wxEXPAND, 5); + + m_button208 = new wxButton(m_panelRIGCat, wxID_ANY, _("Open"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer206->Add(m_button208, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2); + + wxBoxSizer* boxSizer19329 = new wxBoxSizer(wxHORIZONTAL); + + flexGridSizer204->Add(boxSizer19329, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 2); + + m_staticText18930 = new wxStaticText(m_panelRIGCat, wxID_ANY, _("Device:"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer19329->Add(m_staticText18930, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2); + + wxArrayString m_comboBox218Arr; + m_comboBox218 = new wxComboBox(m_panelRIGCat, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), m_comboBox218Arr, 0); + + boxSizer19329->Add(m_comboBox218, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); + + wxFlexGridSizer* flexGridSizer222 = new wxFlexGridSizer( 1, 3, 0, 0); + flexGridSizer222->SetFlexibleDirection( wxBOTH ); + flexGridSizer222->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + flexGridSizer222->AddGrowableCol(2); + + staticBoxSizer183->Add(flexGridSizer222, 0, wxALL, 2); + + wxBoxSizer* boxSizer19326 = new wxBoxSizer(wxHORIZONTAL); + + flexGridSizer222->Add(boxSizer19326, 1, wxALL|wxEXPAND, 2); + + m_staticText18927 = new wxStaticText(m_panelRIGCat, wxID_ANY, _("Retries:"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer19326->Add(m_staticText18927, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2); + + m_textCtrl19128 = new wxTextCtrl(m_panelRIGCat, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer19326->Add(m_textCtrl19128, 1, wxALL|wxALIGN_CENTER_VERTICAL, 2); + + wxBoxSizer* boxSizer19323 = new wxBoxSizer(wxHORIZONTAL); + + flexGridSizer222->Add(boxSizer19323, 1, wxALL|wxEXPAND, 2); + + m_staticText18924 = new wxStaticText(m_panelRIGCat, wxID_ANY, _("Retry Interval:"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer19323->Add(m_staticText18924, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2); + + m_textCtrl19125 = new wxTextCtrl(m_panelRIGCat, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer19323->Add(m_textCtrl19125, 1, wxALL|wxALIGN_CENTER_VERTICAL, 2); + + wxBoxSizer* boxSizer1932954 = new wxBoxSizer(wxHORIZONTAL); + + flexGridSizer222->Add(boxSizer1932954, 1, wxALL|wxEXPAND, 2); + + m_staticText1893055 = new wxStaticText(m_panelRIGCat, wxID_ANY, _("Baud Rate:"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer1932954->Add(m_staticText1893055, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2); + + wxArrayString m_comboBaudArr; + m_comboBaudArr.Add(wxT("300")); + m_comboBaudArr.Add(wxT("600")); + m_comboBaudArr.Add(wxT("1200")); + m_comboBaudArr.Add(wxT("2400")); + m_comboBaudArr.Add(wxT("9600")); + m_comboBaudArr.Add(wxT("19200")); + m_comboBaudArr.Add(wxT("38400")); + m_comboBaudArr.Add(wxT("56800")); + m_comboBaud = new wxComboBox(m_panelRIGCat, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), m_comboBaudArr, 0); + + boxSizer1932954->Add(m_comboBaud, 1, wxALL|wxALIGN_CENTER_VERTICAL, 2); + + wxFlexGridSizer* flexGridSizer18747 = new wxFlexGridSizer( 1, 1, 0, 0); + flexGridSizer18747->SetFlexibleDirection( wxBOTH ); + flexGridSizer18747->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + flexGridSizer18747->AddGrowableCol(1); + + staticBoxSizer183->Add(flexGridSizer18747, 0, wxALL|wxEXPAND, 2); + + wxFlexGridSizer* flexGridSizer20448 = new wxFlexGridSizer( 1, 3, 0, 0); + flexGridSizer20448->SetFlexibleDirection( wxBOTH ); + flexGridSizer20448->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + flexGridSizer20448->AddGrowableCol(3); + flexGridSizer20448->AddGrowableRow(1); + + flexGridSizer18747->Add(flexGridSizer20448, 1, wxALL, 2); + + wxBoxSizer* boxSizer19349 = new wxBoxSizer(wxHORIZONTAL); + + flexGridSizer20448->Add(boxSizer19349, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 2); + + m_staticText18950 = new wxStaticText(m_panelRIGCat, wxID_ANY, _("Write Delay (ms):"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer19349->Add(m_staticText18950, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2); + + m_textCtrl19151 = new wxTextCtrl(m_panelRIGCat, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer19349->Add(m_textCtrl19151, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2); + + wxBoxSizer* boxSizer298 = new wxBoxSizer(wxHORIZONTAL); + + flexGridSizer20448->Add(boxSizer298, 1, wxALL|wxEXPAND, 2); + + m_staticText298 = new wxStaticText(m_panelRIGCat, wxID_ANY, _("Stop Bits:"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer298->Add(m_staticText298, 0, wxALL, 2); + + m_sliderStopBits = new wxSlider(m_panelRIGCat, wxID_ANY, 0, 0, 2, wxDefaultPosition, wxSize(-1,-1), wxSL_HORIZONTAL); + + boxSizer298->Add(m_sliderStopBits, 0, wxALL, 5); + + wxFlexGridSizer* flexGridSizer224 = new wxFlexGridSizer( 1, 4, 0, 0); + flexGridSizer224->SetFlexibleDirection( wxBOTH ); + flexGridSizer224->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + flexGridSizer224->AddGrowableCol(4); + flexGridSizer224->AddGrowableRow(1); + + staticBoxSizer183->Add(flexGridSizer224, 0, wxALL|wxEXPAND, 2); + + flexGridSizer224->Add(2, 2, 1, wxALL|wxEXPAND, 2); + + m_cbEcho = new wxCheckBox(m_panelRIGCat, wxID_ANY, _("Commands echoed"), wxDefaultPosition, wxSize(-1,-1), 0); + m_cbEcho->SetValue(false); + m_cbEcho->SetToolTip(_("Commands are echoed")); + + flexGridSizer224->Add(m_cbEcho, 0, wxALL|wxEXPAND, 1); + + flexGridSizer224->Add(2, 2, 1, wxALL|wxEXPAND, 2); + + m_cbCATPTT = new wxCheckBox(m_panelRIGCat, wxID_ANY, _("CAT command for PTT"), wxDefaultPosition, wxSize(-1,-1), 0); + m_cbCATPTT->SetValue(false); + m_cbCATPTT->SetToolTip(_("Use CAT commands for PTT")); + + flexGridSizer224->Add(m_cbCATPTT, 1, wxALL|wxEXPAND, 2); + + wxFlexGridSizer* flexGridSizer22432 = new wxFlexGridSizer( 1, 4, 0, 0); + flexGridSizer22432->SetFlexibleDirection( wxBOTH ); + flexGridSizer22432->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + flexGridSizer22432->AddGrowableCol(4); + flexGridSizer22432->AddGrowableRow(1); + + staticBoxSizer183->Add(flexGridSizer22432, 0, wxALL|wxEXPAND, 2); + + flexGridSizer22432->Add(2, 2, 1, wxALL|wxEXPAND, 2); + + m_cbToggleRTSPTT = new wxCheckBox(m_panelRIGCat, wxID_ANY, _("Toggle RTS for PTT"), wxDefaultPosition, wxSize(-1,-1), 0); + m_cbToggleRTSPTT->SetValue(false); + m_cbToggleRTSPTT->SetToolTip(_("Toggle RTS for PTT")); + + flexGridSizer22432->Add(m_cbToggleRTSPTT, 1, wxALL, 2); + + flexGridSizer22432->Add(2, 2, 1, wxALL|wxEXPAND, 2); + + m_cbToggleDTRPTT = new wxCheckBox(m_panelRIGCat, wxID_ANY, _("Toggle DTR for PTT"), wxDefaultPosition, wxSize(-1,-1), 0); + m_cbToggleDTRPTT->SetValue(false); + m_cbToggleDTRPTT->SetToolTip(_("Toggle DTR for PTT")); + + flexGridSizer22432->Add(m_cbToggleDTRPTT, 1, wxALL, 2); + + wxFlexGridSizer* flexGridSizer22437 = new wxFlexGridSizer( 1, 4, 0, 0); + flexGridSizer22437->SetFlexibleDirection( wxBOTH ); + flexGridSizer22437->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + flexGridSizer22437->AddGrowableCol(4); + flexGridSizer22437->AddGrowableRow(1); + + staticBoxSizer183->Add(flexGridSizer22437, 0, wxALL|wxEXPAND, 2); + + flexGridSizer22437->Add(2, 2, 1, wxALL|wxEXPAND, 2); + + m_cbRTS12VInit = new wxCheckBox(m_panelRIGCat, wxID_ANY, _("Initial RTS +12v"), wxDefaultPosition, wxSize(-1,-1), 0); + m_cbRTS12VInit->SetValue(false); + m_cbRTS12VInit->SetToolTip(_("Initialize state of RTS")); + + flexGridSizer22437->Add(m_cbRTS12VInit, 1, wxALL|wxEXPAND, 2); + + flexGridSizer22437->Add(2, 2, 1, wxALL|wxEXPAND, 2); + + m_cbDTR12VInit = new wxCheckBox(m_panelRIGCat, wxID_ANY, _("Initial DTR +12v"), wxDefaultPosition, wxSize(-1,-1), 0); + m_cbDTR12VInit->SetValue(false); + m_cbDTR12VInit->SetToolTip(_("Initialize state of DTR")); + + flexGridSizer22437->Add(m_cbDTR12VInit, 1, wxALL|wxEXPAND, 2); + + wxFlexGridSizer* flexGridSizer22442 = new wxFlexGridSizer( 1, 4, 0, 0); + flexGridSizer22442->SetFlexibleDirection( wxBOTH ); + flexGridSizer22442->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + flexGridSizer22442->AddGrowableCol(4); + flexGridSizer22442->AddGrowableRow(1); + + staticBoxSizer183->Add(flexGridSizer22442, 0, wxALL|wxEXPAND, 2); + + flexGridSizer22442->Add(2, 2, 0, wxALL, 2); + + m_cbRTSCTSFlowCtl = new wxCheckBox(m_panelRIGCat, wxID_ANY, _("RTS/CTS Flow Control"), wxDefaultPosition, wxSize(-1,-1), 0); + m_cbRTSCTSFlowCtl->SetValue(false); + + flexGridSizer22442->Add(m_cbRTSCTSFlowCtl, 0, wxALL, 2); + + flexGridSizer22442->Add(2, 2, 0, wxALL, 2); + + m_cbVSPEnable = new wxCheckBox(m_panelRIGCat, wxID_ANY, _("RTS/CTS Flow Control"), wxDefaultPosition, wxSize(-1,-1), 0); + m_cbVSPEnable->SetValue(false); + m_cbVSPEnable->SetToolTip(_("Virtual serial port enable. Suppress WARNINGS")); + + flexGridSizer22442->Add(m_cbVSPEnable, 0, wxALL, 2); + + m_panelHAMLib = new wxPanel(m_notebook53, wxID_ANY, wxDefaultPosition, wxSize(-1,-1), wxTAB_TRAVERSAL); + m_panelHAMLib->SetToolTip(_("Hamlib Configuration")); + m_notebook53->AddPage(m_panelHAMLib, _("HAMlib"), false); + + wxStaticBoxSizer* staticBoxSizer296 = new wxStaticBoxSizer( new wxStaticBox(m_panelHAMLib, wxID_ANY, wxT("")), wxVERTICAL); + m_panelHAMLib->SetSizer(staticBoxSizer296); + + wxGridSizer* gridSizer368 = new wxGridSizer( 8, 3, 0, 0); + + staticBoxSizer296->Add(gridSizer368, 0, wxALL|wxEXPAND, 5); + + wxBoxSizer* boxSizer312 = new wxBoxSizer(wxHORIZONTAL); + + gridSizer368->Add(boxSizer312, 1, wxALL|wxEXPAND, 2); + + m_staticText308 = new wxStaticText(m_panelHAMLib, wxID_ANY, _("Device:"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer312->Add(m_staticText308, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 2); + + wxArrayString m_comboBox314Arr; + m_comboBox314 = new wxComboBox(m_panelHAMLib, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), m_comboBox314Arr, 0); + + boxSizer312->Add(m_comboBox314, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); + + m_staticText304 = new wxStaticText(m_panelHAMLib, wxID_ANY, _("Rig:"), wxDefaultPosition, wxSize(-1,-1), 0); + + gridSizer368->Add(m_staticText304, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 2); + + wxBoxSizer* boxSizer302 = new wxBoxSizer(wxHORIZONTAL); + + gridSizer368->Add(boxSizer302, 1, wxALL, 2); + + m_textCtrl306 = new wxTextCtrl(m_panelHAMLib, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer302->Add(m_textCtrl306, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); + + wxBoxSizer* boxSizer320 = new wxBoxSizer(wxHORIZONTAL); + + gridSizer368->Add(boxSizer320, 1, wxALL, 2); + + m_staticText326 = new wxStaticText(m_panelHAMLib, wxID_ANY, _("Retries:"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer320->Add(m_staticText326, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 2); + + m_textCtrl328 = new wxTextCtrl(m_panelHAMLib, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer320->Add(m_textCtrl328, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); + + wxBoxSizer* boxSizer32057 = new wxBoxSizer(wxHORIZONTAL); + + gridSizer368->Add(boxSizer32057, 1, wxALL, 2); + + m_staticText32658 = new wxStaticText(m_panelHAMLib, wxID_ANY, _("Retry Interval:"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer32057->Add(m_staticText32658, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 2); + + m_textCtrl32859 = new wxTextCtrl(m_panelHAMLib, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer32057->Add(m_textCtrl32859, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + + wxBoxSizer* boxSizer32060 = new wxBoxSizer(wxHORIZONTAL); + + gridSizer368->Add(boxSizer32060, 1, wxALL, 2); + + m_staticText32661 = new wxStaticText(m_panelHAMLib, wxID_ANY, _("Baud Rate:"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer32060->Add(m_staticText32661, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 2); + + wxArrayString m_comboBox339Arr; + m_comboBox339Arr.Add(wxT("300")); + m_comboBox339Arr.Add(wxT("600")); + m_comboBox339Arr.Add(wxT("1200")); + m_comboBox339Arr.Add(wxT("2400")); + m_comboBox339Arr.Add(wxT("9600")); + m_comboBox339Arr.Add(wxT("19200")); + m_comboBox339Arr.Add(wxT("38400")); + m_comboBox339Arr.Add(wxT("56800")); + m_comboBox339 = new wxComboBox(m_panelHAMLib, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), m_comboBox339Arr, 0); + + boxSizer32060->Add(m_comboBox339, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + + wxBoxSizer* boxSizer32064 = new wxBoxSizer(wxHORIZONTAL); + + gridSizer368->Add(boxSizer32064, 0, wxALL, 2); + + m_staticText32665 = new wxStaticText(m_panelHAMLib, wxID_ANY, _("Write Delay:"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer32064->Add(m_staticText32665, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 2); + + m_textCtrl32866 = new wxTextCtrl(m_panelHAMLib, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer32064->Add(m_textCtrl32866, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); + + wxBoxSizer* boxSizer3205767 = new wxBoxSizer(wxHORIZONTAL); + + gridSizer368->Add(boxSizer3205767, 1, wxALL, 2); + + m_staticText3265868 = new wxStaticText(m_panelHAMLib, wxID_ANY, _("Post Write Delay:"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer3205767->Add(m_staticText3265868, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 2); + + m_textCtrl3285969 = new wxTextCtrl(m_panelHAMLib, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer3205767->Add(m_textCtrl3285969, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + + wxBoxSizer* boxSizer3206070 = new wxBoxSizer(wxHORIZONTAL); + + gridSizer368->Add(boxSizer3206070, 0, wxALL, 2); + + m_staticText3266171 = new wxStaticText(m_panelHAMLib, wxID_ANY, _("Stop bits:"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer3206070->Add(m_staticText3266171, 1, wxALL, 2); + + m_slider361 = new wxSlider(m_panelHAMLib, wxID_ANY, 1, 0, 2, wxDefaultPosition, wxSize(-1,-1), wxSL_LABELS|wxSL_HORIZONTAL); + + boxSizer3206070->Add(m_slider361, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + + m_cbHAMLIBPTT = new wxCheckBox(m_panelHAMLib, wxID_ANY, _("PTT via HAMLib"), wxDefaultPosition, wxSize(-1,-1), 0); + m_cbHAMLIBPTT->SetValue(false); + m_cbHAMLIBPTT->SetToolTip(_("Use Hamlib to control PTT")); + + gridSizer368->Add(m_cbHAMLIBPTT, 1, wxALL, 2); + + m_staticText408 = new wxStaticText(m_panelHAMLib, wxID_ANY, _("Sideband:"), wxDefaultPosition, wxSize(-1,-1), 0); + + gridSizer368->Add(m_staticText408, 1, wxALL|wxALIGN_RIGHT, 2); + + wxBoxSizer* boxSizer410 = new wxBoxSizer(wxVERTICAL); + + gridSizer368->Add(boxSizer410, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + + wxArrayString m_comboBox376Arr; + m_comboBox376Arr.Add(wxT("Upper")); + m_comboBox376Arr.Add(wxT("Lower")); + m_comboBox376 = new wxComboBox(m_panelHAMLib, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), m_comboBox376Arr, 0); + + boxSizer410->Add(m_comboBox376, 0, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); + + m_checkBox378 = new wxCheckBox(m_panelHAMLib, wxID_ANY, _("Initial RTS +12v"), wxDefaultPosition, wxSize(-1,-1), 0); + m_checkBox378->SetValue(false); + m_checkBox378->SetToolTip(_("Initialize state of RTS")); + + gridSizer368->Add(m_checkBox378, 0, wxALL, 2); + + gridSizer368->Add(0, 0, 0, wxALL, 2); + + m_checkBox382 = new wxCheckBox(m_panelHAMLib, wxID_ANY, _("Initial DTR +12v"), wxDefaultPosition, wxSize(-1,-1), 0); + m_checkBox382->SetValue(false); + + gridSizer368->Add(m_checkBox382, 0, wxALL, 2); + + m_cbRTSCTS = new wxCheckBox(m_panelHAMLib, wxID_ANY, _("RTS/CTS Flow Control"), wxDefaultPosition, wxSize(-1,-1), 0); + m_cbRTSCTS->SetValue(false); + m_cbRTSCTS->SetToolTip(_("Use RTS/CTS Flow Control")); + + gridSizer368->Add(m_cbRTSCTS, 0, wxALL, 2); + + gridSizer368->Add(0, 0, 0, wxALL, 2); + + m_cbXONXOFF = new wxCheckBox(m_panelHAMLib, wxID_ANY, _("XON/XOFF Flow Control"), wxDefaultPosition, wxSize(-1,-1), 0); + m_cbXONXOFF->SetValue(false); + m_cbXONXOFF->SetToolTip(_("Use XON/XOFF flow control")); + + gridSizer368->Add(m_cbXONXOFF, 0, wxALL, 2); + + m_staticText404 = new wxStaticText(m_panelHAMLib, wxID_ANY, _("Advanced Configuration:"), wxDefaultPosition, wxSize(-1,-1), 0); + + gridSizer368->Add(m_staticText404, 0, wxALL, 2); + + gridSizer368->Add(0, 0, 0, wxALL, 2); + + m_btnRevert = new wxButton(m_panelHAMLib, wxID_ANY, _("Revert"), wxDefaultPosition, wxSize(-1,-1), 0); + m_btnRevert->SetToolTip(_("Revert to previous settings")); + + gridSizer368->Add(m_btnRevert, 0, wxALL, 2); + + m_textAdvancedCFG = new wxTextCtrl(m_panelHAMLib, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), 0); + m_textAdvancedCFG->SetToolTip(_("Enter Advanced Configuration string")); + + gridSizer368->Add(m_textAdvancedCFG, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 2); + + gridSizer368->Add(0, 0, 0, wxALL, 2); + + m_btnInitHamlib = new wxButton(m_panelHAMLib, wxID_ANY, _("Initialize"), wxDefaultPosition, wxSize(-1,-1), 0); + m_btnInitHamlib->SetToolTip(_("Initialize HAMLib")); + + gridSizer368->Add(m_btnInitHamlib, 0, wxALL, 2); + + m_panelMemMap = new wxPanel(m_notebook53, wxID_ANY, wxDefaultPosition, wxSize(-1,-1), wxTAB_TRAVERSAL); + m_panelMemMap->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT)); + m_panelMemMap->SetToolTip(_("Memory Mapped control")); + m_notebook53->AddPage(m_panelMemMap, _("MemMap"), false); + + wxStaticBoxSizer* staticBoxSizer294 = new wxStaticBoxSizer( new wxStaticBox(m_panelMemMap, wxID_ANY, wxT("")), wxVERTICAL); + m_panelMemMap->SetSizer(staticBoxSizer294); + + wxGridSizer* gridSizer420 = new wxGridSizer( 2, 1, 0, 0); + + staticBoxSizer294->Add(gridSizer420, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + + wxStaticBoxSizer* staticBoxSizer424 = new wxStaticBoxSizer( new wxStaticBox(m_panelMemMap, wxID_ANY, wxT("")), wxVERTICAL); + + gridSizer420->Add(staticBoxSizer424, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + + m_staticText422 = new wxStaticText(m_panelMemMap, wxID_ANY, _("\nControl via Memory Mapped Shared Variables, i. e. Kachina \n"), wxDefaultPosition, wxSize(-1,-1), wxALIGN_CENTRE); + m_staticText422->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); + + staticBoxSizer424->Add(m_staticText422, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + + wxBoxSizer* boxSizer4456 = new wxBoxSizer(wxVERTICAL); + + gridSizer420->Add(boxSizer4456, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5); + + m_checkBox4377 = new wxCheckBox(m_panelMemMap, wxID_ANY, _("Use Memorymap"), wxDefaultPosition, wxSize(-1,-1), 0); + m_checkBox4377->SetValue(false); + + boxSizer4456->Add(m_checkBox4377, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + + m_checkBox4398 = new wxCheckBox(m_panelMemMap, wxID_ANY, _("Use Memmap PTT"), wxDefaultPosition, wxSize(-1,-1), 0); + m_checkBox4398->SetValue(false); + + boxSizer4456->Add(m_checkBox4398, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_BOTTOM, 5); + + m_button4419 = new wxButton(m_panelMemMap, wxID_ANY, _("Initialize"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer4456->Add(m_button4419, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + + m_panelXMLRPC = new wxPanel(m_notebook53, wxID_ANY, wxDefaultPosition, wxSize(-1,-1), wxTAB_TRAVERSAL); + m_panelXMLRPC->SetToolTip(_("XML-RPC control")); + m_notebook53->AddPage(m_panelXMLRPC, _("XML-RPC"), false); + + wxStaticBoxSizer* staticBoxSizer85 = new wxStaticBoxSizer( new wxStaticBox(m_panelXMLRPC, wxID_ANY, wxT("")), wxVERTICAL); + m_panelXMLRPC->SetSizer(staticBoxSizer85); + + wxGridSizer* gridSizer4203 = new wxGridSizer( 2, 1, 0, 0); + + staticBoxSizer85->Add(gridSizer4203, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + + wxStaticBoxSizer* staticBoxSizer4244 = new wxStaticBoxSizer( new wxStaticBox(m_panelXMLRPC, wxID_ANY, wxT("")), wxVERTICAL); + + gridSizer4203->Add(staticBoxSizer4244, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + + m_staticText42210 = new wxStaticText(m_panelXMLRPC, wxID_ANY, _("\nRig control via external program using XML RPC Remote Calls\n"), wxDefaultPosition, wxSize(-1,-1), wxALIGN_CENTRE); + m_staticText42210->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); + + staticBoxSizer4244->Add(m_staticText42210, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + + wxBoxSizer* boxSizer445 = new wxBoxSizer(wxVERTICAL); + + gridSizer4203->Add(boxSizer445, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5); + + m_checkBox437 = new wxCheckBox(m_panelXMLRPC, wxID_ANY, _("Use XML-RPC"), wxDefaultPosition, wxSize(-1,-1), 0); + m_checkBox437->SetValue(false); + + boxSizer445->Add(m_checkBox437, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + + m_button441 = new wxButton(m_panelXMLRPC, wxID_ANY, _("Initialize"), wxDefaultPosition, wxSize(-1,-1), 0); + + boxSizer445->Add(m_button441, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + + m_stdBtnSizer155 = new wxStdDialogButtonSizer(); + + boxSizer51->Add(m_stdBtnSizer155, 0, wxALL|wxALIGN_RIGHT|wxALIGN_BOTTOM, 2); + + m_button165 = new wxButton(this, wxID_APPLY, wxT(""), wxDefaultPosition, wxSize(-1, -1), 0); + m_stdBtnSizer155->AddButton(m_button165); + + m_button167 = new wxButton(this, wxID_OK, wxT(""), wxDefaultPosition, wxSize(-1, -1), 0); + m_button167->SetDefault(); + m_stdBtnSizer155->AddButton(m_button167); + + m_button366 = new wxButton(this, wxID_CANCEL, wxT(""), wxDefaultPosition, wxSize(-1, -1), 0); + m_stdBtnSizer155->AddButton(m_button366); + m_stdBtnSizer155->Realize(); + + + SetSizeHints(460,315); + if ( GetSizer() ) { + GetSizer()->Fit(this); + } + Centre(wxBOTH); +} + +DlgRigCtrlBase::~DlgRigCtrlBase() +{ +} diff --git a/fdmdv2/branches/0.97/build/codelite/hamlib_trial/wxcrafter.h b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/wxcrafter.h new file mode 100644 index 00000000..752b774b --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/wxcrafter.h @@ -0,0 +1,153 @@ +////////////////////////////////////////////////////////////////////// +// This file was auto-generated by codelite's wxCrafter Plugin +// Do not modify this file by hand! +////////////////////////////////////////////////////////////////////// + +#ifndef WXCRAFTER_BASE_CLASSES_H +#define WXCRAFTER_BASE_CLASSES_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class MainFrameBaseClass : public wxFrame +{ +protected: + wxPanel* m_mainPanel; + wxMenuBar* m_menuBar; + wxMenu* m_mbFile; + wxMenuItem* m_mbiNew; + wxMenuItem* m_mbiOpen; + wxMenuItem* m_mbiSave; + wxMenuItem* m_mbiSaveAs; + wxMenuItem* m_menuItem21; + wxMenuItem* m_mbiExit; + wxMenu* m_mbTools; + wxMenuItem* m_mbiPrefs; + wxMenu* m_mbHelp; + wxMenuItem* m_menuItem9; + wxToolBar* m_mainToolbar; + +protected: + virtual void OnSize(wxSizeEvent& event) { event.Skip(); } + virtual void OnExit(wxCommandEvent& event) { event.Skip(); } + virtual void OnToolsPrefs(wxCommandEvent& event) { event.Skip(); } + virtual void OnAbout(wxCommandEvent& event) { event.Skip(); } + virtual void OnNew(wxCommandEvent& event) { event.Skip(); } + virtual void OnOpen(wxCommandEvent& event) { event.Skip(); } + +public: + MainFrameBaseClass(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("topFrame"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(500,300), long style = wxCAPTION|wxRESIZE_BORDER|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxSYSTEM_MENU|wxCLOSE_BOX); + virtual ~MainFrameBaseClass(); +}; + + +class DlgRigCtrlBase : public wxDialog +{ +protected: + wxNotebook* m_notebook53; + wxPanel* m_panelHDWPTT; + wxCheckBox* m_checkBox7537; + wxCheckBox* m_checkBox9112; + wxStaticText* m_staticText173; + wxComboBox* m_comboBox9313; + wxRadioBox* m_radioBox10115; + wxRadioBox* m_radioBox10316; + wxButton* m_button11319; + wxStaticText* m_staticText177; + wxSlider* m_slider10721; + wxStaticText* m_staticText179; + wxSlider* m_slider10922; + wxPanel* m_panelRIGCat; + wxRadioButton* m_radioButton185; + wxStaticText* m_staticText189; + wxTextCtrl* m_textCtrl191; + wxButton* m_button208; + wxStaticText* m_staticText18930; + wxComboBox* m_comboBox218; + wxStaticText* m_staticText18927; + wxTextCtrl* m_textCtrl19128; + wxStaticText* m_staticText18924; + wxTextCtrl* m_textCtrl19125; + wxStaticText* m_staticText1893055; + wxComboBox* m_comboBaud; + wxStaticText* m_staticText18950; + wxTextCtrl* m_textCtrl19151; + wxStaticText* m_staticText298; + wxSlider* m_sliderStopBits; + wxCheckBox* m_cbEcho; + wxCheckBox* m_cbCATPTT; + wxCheckBox* m_cbToggleRTSPTT; + wxCheckBox* m_cbToggleDTRPTT; + wxCheckBox* m_cbRTS12VInit; + wxCheckBox* m_cbDTR12VInit; + wxCheckBox* m_cbRTSCTSFlowCtl; + wxCheckBox* m_cbVSPEnable; + wxPanel* m_panelHAMLib; + wxStaticText* m_staticText308; + wxComboBox* m_comboBox314; + wxStaticText* m_staticText304; + wxTextCtrl* m_textCtrl306; + wxStaticText* m_staticText326; + wxTextCtrl* m_textCtrl328; + wxStaticText* m_staticText32658; + wxTextCtrl* m_textCtrl32859; + wxStaticText* m_staticText32661; + wxComboBox* m_comboBox339; + wxStaticText* m_staticText32665; + wxTextCtrl* m_textCtrl32866; + wxStaticText* m_staticText3265868; + wxTextCtrl* m_textCtrl3285969; + wxStaticText* m_staticText3266171; + wxSlider* m_slider361; + wxCheckBox* m_cbHAMLIBPTT; + wxStaticText* m_staticText408; + wxComboBox* m_comboBox376; + wxCheckBox* m_checkBox378; + wxCheckBox* m_checkBox382; + wxCheckBox* m_cbRTSCTS; + wxCheckBox* m_cbXONXOFF; + wxStaticText* m_staticText404; + wxButton* m_btnRevert; + wxTextCtrl* m_textAdvancedCFG; + wxButton* m_btnInitHamlib; + wxPanel* m_panelMemMap; + wxStaticText* m_staticText422; + wxCheckBox* m_checkBox4377; + wxCheckBox* m_checkBox4398; + wxButton* m_button4419; + wxPanel* m_panelXMLRPC; + wxStaticText* m_staticText42210; + wxCheckBox* m_checkBox437; + wxButton* m_button441; + wxStdDialogButtonSizer* m_stdBtnSizer155; + wxButton* m_button165; + wxButton* m_button167; + wxButton* m_button366; + +protected: + +public: + DlgRigCtrlBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Rig Control"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(460,315), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX); + virtual ~DlgRigCtrlBase(); +}; + +#endif diff --git a/fdmdv2/branches/0.97/build/codelite/hamlib_trial/wxcrafter.wxcp b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/wxcrafter.wxcp new file mode 100644 index 00000000..7a31bf3b --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/wxcrafter.wxcp @@ -0,0 +1,7969 @@ +{ + "metadata": { + "m_generatedFilesDir": "", + "m_objCounter": 455, + "m_includeFiles": [], + "m_bitmapFunction": "wxC9ED9InitBitmapResources", + "m_bitmapsFile": "wxcrafter_bitmaps.cpp", + "m_GenerateCodeTypes": 3, + "m_outputFileName": "", + "m_templateClasses": [] + }, + "windows": [{ + "m_type": 4402, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxCAPTION", "wxRESIZE_BORDER", "wxMAXIMIZE_BOX", "wxMINIMIZE_BOX", "wxSYSTEM_MENU", "wxCLOSE_BOX"], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Size:", + "m_value": "500,300" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "MainFrameBaseClass" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Title:", + "m_value": "topFrame" + }, { + "type": "virtualFolderPicker", + "m_label": "Virtual Folder:", + "m_path": "" + }, { + "type": "choice", + "m_label": "Centre:", + "m_selection": 1, + "m_options": ["", "wxBOTH", "wxVERTICAL", "wxHORIZONTAL"] + }, { + "type": "string", + "m_label": "File:", + "m_value": "MainFrame" + }, { + "type": "string", + "m_label": "Inherited Class", + "m_value": "MainFrame" + }, { + "type": "string", + "m_label": "Class Decorator", + "m_value": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4401, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer1" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4408, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxTAB_TRAVERSAL"], + "m_sizerFlags": ["wxEXPAND"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_mainPanel" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }], + "m_events": [{ + "m_eventName": "wxEVT_SIZE", + "m_eventClass": "wxSizeEvent", + "m_eventHandler": "wxSizeEventHandler", + "m_functionNameAndSignature": "OnSize(wxSizeEvent& event)", + "m_description": "Process a wxEVT_SIZE event" + }], + "m_children": [{ + "m_type": 4401, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer33" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [] + }] + }] + }, { + "m_type": 4457, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_menuBar" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4458, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "m_mbFile" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "File" + }], + "m_events": [], + "m_children": [{ + "m_type": 4459, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": [], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_NEW" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_mbiNew" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "New" + }, { + "type": "string", + "m_label": "Shortcut:", + "m_value": "" + }, { + "type": "string", + "m_label": "Help String:", + "m_value": "" + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "choice", + "m_label": "Kind:", + "m_selection": 0, + "m_options": ["normal", "checkable", "radio", "separator"] + }, { + "type": "bool", + "m_label": "Checked", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4459, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": [], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_OPEN" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_mbiOpen" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Open" + }, { + "type": "string", + "m_label": "Shortcut:", + "m_value": "" + }, { + "type": "string", + "m_label": "Help String:", + "m_value": "" + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "choice", + "m_label": "Kind:", + "m_selection": 0, + "m_options": ["normal", "checkable", "radio", "separator"] + }, { + "type": "bool", + "m_label": "Checked", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4459, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": [], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_SAVE" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_mbiSave" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Save" + }, { + "type": "string", + "m_label": "Shortcut:", + "m_value": "" + }, { + "type": "string", + "m_label": "Help String:", + "m_value": "" + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "choice", + "m_label": "Kind:", + "m_selection": 0, + "m_options": ["normal", "checkable", "radio", "separator"] + }, { + "type": "bool", + "m_label": "Checked", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4459, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": [], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_SAVEAS" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_mbiSaveAs" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Save As" + }, { + "type": "string", + "m_label": "Shortcut:", + "m_value": "" + }, { + "type": "string", + "m_label": "Help String:", + "m_value": "" + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "choice", + "m_label": "Kind:", + "m_selection": 0, + "m_options": ["normal", "checkable", "radio", "separator"] + }, { + "type": "bool", + "m_label": "Checked", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4459, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": [], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_menuItem21" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Item7" + }, { + "type": "string", + "m_label": "Shortcut:", + "m_value": "" + }, { + "type": "string", + "m_label": "Help String:", + "m_value": "" + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "choice", + "m_label": "Kind:", + "m_selection": 3, + "m_options": ["normal", "checkable", "radio", "separator"] + }, { + "type": "bool", + "m_label": "Checked", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4459, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": [], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_EXIT" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_mbiExit" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Exit" + }, { + "type": "string", + "m_label": "Shortcut:", + "m_value": "Alt-X" + }, { + "type": "string", + "m_label": "Help String:", + "m_value": "Quit" + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "choice", + "m_label": "Kind:", + "m_selection": 0, + "m_options": ["normal", "checkable", "radio", "separator"] + }, { + "type": "bool", + "m_label": "Checked", + "m_value": false + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_MENU_SELECTED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "OnExit(wxCommandEvent& event)", + "m_description": "Menu item has been clicked" + }], + "m_children": [] + }] + }, { + "m_type": 4458, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "m_mbTools" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Tools" + }], + "m_events": [], + "m_children": [{ + "m_type": 4459, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": [], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_PREFERENCES" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_mbiPrefs" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Preferences" + }, { + "type": "string", + "m_label": "Shortcut:", + "m_value": "" + }, { + "type": "string", + "m_label": "Help String:", + "m_value": "" + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "choice", + "m_label": "Kind:", + "m_selection": 0, + "m_options": ["normal", "checkable", "radio", "separator"] + }, { + "type": "bool", + "m_label": "Checked", + "m_value": false + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_MENU_SELECTED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "OnToolsPrefs(wxCommandEvent& event)", + "m_description": "Menu item has been clicked" + }], + "m_children": [] + }] + }, { + "m_type": 4458, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "m_mbHelp" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Help" + }], + "m_events": [], + "m_children": [{ + "m_type": 4459, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": [], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ABOUT" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_menuItem9" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "About..." + }, { + "type": "string", + "m_label": "Shortcut:", + "m_value": "" + }, { + "type": "string", + "m_label": "Help String:", + "m_value": "" + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "choice", + "m_label": "Kind:", + "m_selection": 0, + "m_options": ["normal", "checkable", "radio", "separator"] + }, { + "type": "bool", + "m_label": "Checked", + "m_value": false + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_MENU_SELECTED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "OnAbout(wxCommandEvent& event)", + "m_description": "Menu item has been clicked" + }], + "m_children": [] + }] + }] + }, { + "m_type": 4461, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxTB_FLAT"], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_mainToolbar" + }, { + "type": "string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "string", + "m_label": "Bitmap Size:", + "m_value": "16,16" + }, { + "type": "string", + "m_label": "Margins:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Padding:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Separator Size:", + "m_value": "5" + }], + "m_events": [], + "m_children": [{ + "m_type": 4462, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": [], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_NEW" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_tbiNew" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "New" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "New" + }, { + "type": "string", + "m_label": "Help String:", + "m_value": "New" + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "C:\\Users\\wittend\\AppData\\Local\\Temp\\placeholder16.png" + }, { + "type": "filePicker", + "m_label": "Disabled-Bitmap File", + "m_path": "" + }, { + "type": "choice", + "m_label": "Kind:", + "m_selection": 0, + "m_options": ["normal", "checkable", "radio", "separator"] + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_TOOL_CLICKED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "OnNew(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_TOOL_CLICKED event (a synonym for wxEVT_COMMAND_MENU_SELECTED). Pass the id of the tool" + }], + "m_children": [] + }, { + "m_type": 4462, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": [], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_OPEN" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_rbiOpen" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Tool Label" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Open" + }, { + "type": "string", + "m_label": "Help String:", + "m_value": "Open" + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "C:\\Users\\wittend\\AppData\\Local\\Temp\\placeholder16.png" + }, { + "type": "filePicker", + "m_label": "Disabled-Bitmap File", + "m_path": "" + }, { + "type": "choice", + "m_label": "Kind:", + "m_selection": 0, + "m_options": ["normal", "checkable", "radio", "separator"] + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_TOOL_CLICKED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "OnOpen(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_TOOL_CLICKED event (a synonym for wxEVT_COMMAND_MENU_SELECTED). Pass the id of the tool" + }], + "m_children": [] + }] + }] + }, { + "m_type": 4421, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxDEFAULT_DIALOG_STYLE", "wxRESIZE_BORDER", "wxCLOSE_BOX"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Size:", + "m_value": "460,315" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "DlgRigCtrlBase" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Title:", + "m_value": "Rig Control" + }, { + "type": "virtualFolderPicker", + "m_label": "Virtual Folder:", + "m_path": "hamlib_trial:rig_ctrl" + }, { + "type": "choice", + "m_label": "Centre:", + "m_selection": 1, + "m_options": ["", "wxBOTH", "wxVERTICAL", "wxHORIZONTAL"] + }, { + "type": "string", + "m_label": "File:", + "m_value": "dlg_rig_ctrl" + }, { + "type": "string", + "m_label": "Inherited Class", + "m_value": "DialogRigCtrl" + }, { + "type": "string", + "m_label": "Class Decorator", + "m_value": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4401, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer51" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4442, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxBK_DEFAULT"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1, -1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_notebook53" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4441, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxTAB_TRAVERSAL"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_panelHDWPTT" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Hardware Push-to-Talk" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Hardware PTT" + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "bool", + "m_label": "Selected", + "m_value": true + }], + "m_events": [], + "m_children": [{ + "m_type": 4403, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "flexGridSizer135" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "1" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "3" + }, { + "type": "string", + "m_label": "Growable columns:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Growable rows:", + "m_value": "3" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4449, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "staticBoxSizer169" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["Vertical", "Horizontal"] + }, { + "type": "string", + "m_label": "Label:", + "m_value": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4415, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_LEFT", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_checkBox7537" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "PTT tone on right audio channel" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4452, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_LEFT", "wxALIGN_TOP"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "gridSizer159" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "1" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4449, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND", "wxALIGN_TOP"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "staticBoxSizer157" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["Vertical", "Horizontal"] + }, { + "type": "string", + "m_label": "Label:", + "m_value": "h/w ptt device pin" + }], + "m_events": [], + "m_children": [{ + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer175" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4415, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_TOP"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_checkBox9112" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Use separate PTT device pin" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4405, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText173" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Device:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4410, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_comboBox9313" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "ComboBox Choices:", + "m_value": "" + }, { + "type": "string", + "m_label": "Selection:", + "m_value": "-1" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer171" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer12714" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4416, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxRA_SPECIFY_COLS"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_radioBox10115" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Use RTS" + }, { + "type": "multi-string", + "m_label": "Choices:", + "m_value": "Normal (V-);Inverted (V+)" + }, { + "type": "string", + "m_label": "Selection:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Major Dimension:", + "m_value": "2" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4416, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxRA_SPECIFY_COLS"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_radioBox10316" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Use DTR" + }, { + "type": "multi-string", + "m_label": "Choices:", + "m_value": "Normal (V-);Inverted (V+)" + }, { + "type": "string", + "m_label": "Selection:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Major Dimension:", + "m_value": "2" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4401, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer13118" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4400, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_button11319" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Initialize" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": false + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "string", + "m_label": "Margins:", + "m_value": "2,2" + }], + "m_events": [], + "m_children": [] + }] + }] + }] + }] + }] + }, { + "m_type": 4449, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND", "wxALIGN_LEFT"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "staticBoxSizer79420" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["Vertical", "Horizontal"] + }, { + "type": "string", + "m_label": "Label:", + "m_value": "PTT delay for all CAT/PTT types" + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText177" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Start of xmit delay" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4419, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxSL_HORIZONTAL"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_slider10721" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "50" + }, { + "type": "string", + "m_label": "Min value:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Max value:", + "m_value": "100" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText179" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "End of xmit delay:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4419, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxSL_HORIZONTAL"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_slider10922" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "50" + }, { + "type": "string", + "m_label": "Min value:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Max value:", + "m_value": "100" + }], + "m_events": [], + "m_children": [] + }] + }] + }] + }, { + "m_type": 4441, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxTAB_TRAVERSAL"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_panelRIGCat" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "RigCat" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "RigCAT" + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "bool", + "m_label": "Selected", + "m_value": false + }], + "m_events": [], + "m_children": [{ + "m_type": 4401, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer67" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4417, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_radioButton185" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Use RigCAT" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": true + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4449, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND", "wxALIGN_TOP"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "staticBoxSizer183" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["Vertical", "Horizontal"] + }, { + "type": "string", + "m_label": "Label:", + "m_value": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4403, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "flexGridSizer187" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "1" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Growable columns:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Growable rows:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4403, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "flexGridSizer204" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "4" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "3" + }, { + "type": "string", + "m_label": "Growable columns:", + "m_value": "" + }, { + "type": "string", + "m_label": "Growable rows:", + "m_value": "" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer193" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText189" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "File:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4406, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_textCtrl191" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }, { + "type": "string", + "m_label": "Max Length:", + "m_value": "0" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4401, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer206" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4400, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_button208" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Open" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": false + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "string", + "m_label": "Margins:", + "m_value": "2,2" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer19329" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText18930" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Device:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4410, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_comboBox218" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "ComboBox Choices:", + "m_value": "" + }, { + "type": "string", + "m_label": "Selection:", + "m_value": "-1" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }], + "m_events": [], + "m_children": [] + }] + }] + }] + }, { + "m_type": 4403, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "flexGridSizer222" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "3" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Growable columns:", + "m_value": "2" + }, { + "type": "string", + "m_label": "Growable rows:", + "m_value": "" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer19326" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText18927" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Retries:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4406, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_textCtrl19128" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }, { + "type": "string", + "m_label": "Max Length:", + "m_value": "0" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer19323" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText18924" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Retry Interval:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4406, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_textCtrl19125" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }, { + "type": "string", + "m_label": "Max Length:", + "m_value": "0" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer1932954" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText1893055" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Baud Rate:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4410, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_comboBaud" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "ComboBox Choices:", + "m_value": "300\\n600\\n1200\\n2400\\n9600\\n19200\\n38400\\n56800" + }, { + "type": "string", + "m_label": "Selection:", + "m_value": "-1" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }], + "m_events": [], + "m_children": [] + }] + }] + }, { + "m_type": 4403, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "flexGridSizer18747" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "1" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Growable columns:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Growable rows:", + "m_value": "" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4403, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "flexGridSizer20448" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "3" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Growable columns:", + "m_value": "3" + }, { + "type": "string", + "m_label": "Growable rows:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer19349" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText18950" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Write Delay (ms):" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4406, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_textCtrl19151" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }, { + "type": "string", + "m_label": "Max Length:", + "m_value": "0" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer298" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText298" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Stop Bits:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4419, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxSL_HORIZONTAL"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_sliderStopBits" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Min value:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Max value:", + "m_value": "2" + }], + "m_events": [], + "m_children": [] + }] + }] + }] + }, { + "m_type": 4403, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "flexGridSizer224" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "4" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Growable columns:", + "m_value": "4" + }, { + "type": "string", + "m_label": "Growable rows:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4454, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "Spacer234" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "2,2" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4415, + "proportion": 0, + "border": 1, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_cbEcho" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Commands are echoed" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Commands echoed" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4454, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "Spacer240" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "2,2" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4415, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_cbCATPTT" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Use CAT commands for PTT" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "CAT command for PTT" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4403, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "flexGridSizer22432" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "4" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Growable columns:", + "m_value": "4" + }, { + "type": "string", + "m_label": "Growable rows:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4454, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "Spacer2402" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "2,2" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4415, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_cbToggleRTSPTT" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Toggle RTS for PTT" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Toggle RTS for PTT" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4454, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "Spacer2401" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "2,2" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4415, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_cbToggleDTRPTT" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Toggle DTR for PTT" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Toggle DTR for PTT" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4403, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "flexGridSizer22437" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "4" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Growable columns:", + "m_value": "4" + }, { + "type": "string", + "m_label": "Growable rows:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4454, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "Spacer23438" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "2,2" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4415, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_cbRTS12VInit" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Initialize state of RTS" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Initial RTS +12v" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4454, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "Spacer24040" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "2,2" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4415, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_cbDTR12VInit" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Initialize state of DTR" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Initial DTR +12v" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4403, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "flexGridSizer22442" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "4" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Growable columns:", + "m_value": "4" + }, { + "type": "string", + "m_label": "Growable rows:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4454, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "Spacer23443" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "2,2" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4415, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_cbRTSCTSFlowCtl" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "RTS/CTS Flow Control" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4454, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "Spacer24045" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "2,2" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4415, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_cbVSPEnable" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Virtual serial port enable. Suppress WARNINGS" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "RTS/CTS Flow Control" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }] + }] + }] + }] + }, { + "m_type": 4441, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxTAB_TRAVERSAL"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_panelHAMLib" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Hamlib Configuration" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "HAMlib" + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "bool", + "m_label": "Selected", + "m_value": false + }], + "m_events": [], + "m_children": [{ + "m_type": 4449, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "staticBoxSizer296" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["Vertical", "Horizontal"] + }, { + "type": "string", + "m_label": "Label:", + "m_value": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4452, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "gridSizer368" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "3" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "8" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer312" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_RIGHT", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText308" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Device:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4410, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_LEFT", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_comboBox314" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "ComboBox Choices:", + "m_value": "" + }, { + "type": "string", + "m_label": "Selection:", + "m_value": "-1" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4405, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_RIGHT", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText304" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Rig:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer302" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4406, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_LEFT", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_textCtrl306" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }, { + "type": "string", + "m_label": "Max Length:", + "m_value": "0" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer320" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_RIGHT", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText326" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Retries:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4406, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_LEFT", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_textCtrl328" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }, { + "type": "string", + "m_label": "Max Length:", + "m_value": "0" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer32057" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_RIGHT", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText32658" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Retry Interval:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4406, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_textCtrl32859" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }, { + "type": "string", + "m_label": "Max Length:", + "m_value": "0" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer32060" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_RIGHT", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText32661" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Baud Rate:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4410, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_comboBox339" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "ComboBox Choices:", + "m_value": "300\\n600\\n1200\\n2400\\n9600\\n19200\\n38400\\n56800\\n" + }, { + "type": "string", + "m_label": "Selection:", + "m_value": "-1" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4401, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer32064" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_RIGHT", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText32665" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Write Delay:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4406, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_LEFT", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_textCtrl32866" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }, { + "type": "string", + "m_label": "Max Length:", + "m_value": "0" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer3205767" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_RIGHT", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText3265868" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Post Write Delay:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4406, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_textCtrl3285969" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }, { + "type": "string", + "m_label": "Max Length:", + "m_value": "0" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4401, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer3206070" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText3266171" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Stop bits:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4419, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxSL_LABELS", "wxSL_HORIZONTAL"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_slider361" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "1" + }, { + "type": "string", + "m_label": "Min value:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Max value:", + "m_value": "2" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4415, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_cbHAMLIBPTT" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Use Hamlib to control PTT" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "PTT via HAMLib" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4405, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_RIGHT"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText408" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Sideband:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4401, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer410" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4410, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_LEFT", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_comboBox376" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "ComboBox Choices:", + "m_value": "Upper\\nLower" + }, { + "type": "string", + "m_label": "Selection:", + "m_value": "-1" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4415, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_checkBox378" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Initialize state of RTS" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Initial RTS +12v" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4454, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "Spacer380" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "0,0" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4415, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_checkBox382" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Initial DTR +12v" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4415, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_cbRTSCTS" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Use RTS/CTS Flow Control" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "RTS/CTS Flow Control" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4454, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "Spacer386" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "0,0" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4415, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_cbXONXOFF" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Use XON/XOFF flow control" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "XON/XOFF Flow Control" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4405, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText404" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Advanced Configuration:" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4454, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "Spacer396" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "0,0" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4400, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_btnRevert" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Revert to previous settings" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Revert" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": false + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "string", + "m_label": "Margins:", + "m_value": "2,2" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4406, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_textAdvancedCFG" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Enter Advanced Configuration string" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }, { + "type": "string", + "m_label": "Max Length:", + "m_value": "0" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4454, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "Spacer406" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "0,0" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4400, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_btnInitHamlib" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Initialize HAMLib" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Initialize" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": false + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "string", + "m_label": "Margins:", + "m_value": "2,2" + }], + "m_events": [], + "m_children": [] + }] + }] + }] + }, { + "m_type": 4441, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxTAB_TRAVERSAL"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_panelMemMap" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "Memory Mapped control" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "ButtonHighlight" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "MemMap" + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "bool", + "m_label": "Selected", + "m_value": false + }], + "m_events": [], + "m_children": [{ + "m_type": 4449, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "staticBoxSizer294" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["Vertical", "Horizontal"] + }, { + "type": "string", + "m_label": "Label:", + "m_value": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4452, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "gridSizer420" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "1" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "2" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4449, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "staticBoxSizer424" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["Vertical", "Horizontal"] + }, { + "type": "string", + "m_label": "Label:", + "m_value": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxALIGN_CENTRE"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText422" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "ButtonFace" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "\\nControl via Memory Mapped Shared Variables, i. e. Kachina \\n" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4401, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer4456" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4415, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_checkBox4377" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Use Memorymap" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4415, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_BOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_checkBox4398" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Use Memmap PTT" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4400, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_button4419" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Initialize" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": false + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "string", + "m_label": "Margins:", + "m_value": "2,2" + }], + "m_events": [], + "m_children": [] + }] + }] + }] + }] + }, { + "m_type": 4441, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxTAB_TRAVERSAL"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_panelXMLRPC" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "XML-RPC control" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "XML-RPC" + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "bool", + "m_label": "Selected", + "m_value": false + }], + "m_events": [], + "m_children": [{ + "m_type": 4449, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "staticBoxSizer85" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["Vertical", "Horizontal"] + }, { + "type": "string", + "m_label": "Label:", + "m_value": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4452, + "proportion": 1, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "gridSizer4203" + }, { + "type": "string", + "m_label": "# Columns:", + "m_value": "1" + }, { + "type": "string", + "m_label": "# Rows:", + "m_value": "2" + }, { + "type": "string", + "m_label": "Horizontal gap:", + "m_value": "0" + }, { + "type": "string", + "m_label": "Vertical gap:", + "m_value": "0" + }], + "m_events": [], + "m_children": [{ + "m_type": 4449, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "staticBoxSizer4244" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["Vertical", "Horizontal"] + }, { + "type": "string", + "m_label": "Label:", + "m_value": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxALIGN_CENTRE"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticText42210" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "ButtonFace" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "\\nRig control via external program using XML RPC Remote Calls\\n" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }] + }, { + "m_type": 4401, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "boxSizer445" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4415, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_checkBox437" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Use XML-RPC" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4400, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_CENTER_HORIZONTAL", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_button441" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Initialize" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": false + }, { + "type": "filePicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "string", + "m_label": "Margins:", + "m_value": "2,2" + }], + "m_events": [], + "m_children": [] + }] + }] + }] + }] + }] + }, { + "m_type": 4467, + "proportion": 0, + "border": 2, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_RIGHT", "wxALIGN_BOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_stdBtnSizer155" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4468, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "choice", + "m_label": "ID:", + "m_selection": 3, + "m_options": ["wxID_OK", "wxID_YES", "wxID_SAVE", "wxID_APPLY", "wxID_CLOSE", "wxID_NO", "wxID_CANCEL", "wxID_HELP", "wxID_CONTEXT_HELP"] + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_button165" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4468, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "choice", + "m_label": "ID:", + "m_selection": 0, + "m_options": ["wxID_OK", "wxID_YES", "wxID_SAVE", "wxID_APPLY", "wxID_CLOSE", "wxID_NO", "wxID_CANCEL", "wxID_HELP", "wxID_CONTEXT_HELP"] + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_button167" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": true + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4468, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "choice", + "m_label": "ID:", + "m_selection": 6, + "m_options": ["wxID_OK", "wxID_YES", "wxID_SAVE", "wxID_APPLY", "wxID_CLOSE", "wxID_NO", "wxID_CANCEL", "wxID_HELP", "wxID_CONTEXT_HELP"] + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_button366" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": false + }], + "m_events": [], + "m_children": [] + }] + }] + }] + }] +} \ No newline at end of file diff --git a/fdmdv2/branches/0.97/build/codelite/hamlib_trial/wxcrafter.xrc b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/wxcrafter.xrc new file mode 100644 index 00000000..4c562ab0 --- /dev/null +++ b/fdmdv2/branches/0.97/build/codelite/hamlib_trial/wxcrafter.xrc @@ -0,0 +1,1326 @@ + + + + topFrame + 1 + + 500,300 + + wxVERTICAL + + wxEXPAND + 5 + + + + + wxVERTICAL + + + + + + + 16,16 + + + New + New + C:/Users/wittend/AppData/Local/Temp/placeholder16.png + + + + Open + Open + C:/Users/wittend/AppData/Local/Temp/placeholder16.png + + + + + Rig Control + 1 + + 460,315 + + wxVERTICAL + + wxALL|wxEXPAND + 2 + + + + + + 1 + + + Hardware Push-to-Talk + + 1 + 3 + 0 + 0 + 1 + 3 + + wxALL|wxEXPAND + 2 + + + + + wxVERTICAL + + + + + + 0 + + + RigCat + + wxVERTICAL + + wxALL|wxALIGN_CENTER_HORIZONTAL + 2 + + + 0 + 2 + 0 + + + + + + + + + + wxALL|wxEXPAND + 2 + + 4 + 1 + 0 + 0 + 4 + 1 + + 2,2 + wxALL|wxEXPAND + 2 + + + + wxALL|wxEXPAND + 1 + + Commands are echoed + + Hamlib Configuration + + + + + wxVERTICAL +