Compare commits

...

170 commits

Author SHA1 Message Date
Batman b831777f8f Merge pull request #10 from n5ac/thumbDV_unplug_fixes
Thumb DV unplug fixes
2016-10-26 15:53:27 -05:00
Ed Gonzalez df8dc86f5f ThumbDV now v1.1.0.0 - Fix unplug/reconnect logic 2016-10-26 13:02:55 -05:00
Ed Gonzalez 7ff5441146 Merge pull request #9 from n5ac/thubDV_change_to_ftd2xx_library_for_serial
Switch to FTD2XX library for serial communication to ThumbDV
2016-10-25 17:09:52 -05:00
Ed Gonzalez 7339840e8a Merge branch 'thubDV_change_to_ftd2xx_library_for_serial' of github.com:n5ac/smartsdr-dsp into thubDV_change_to_ftd2xx_library_for_serial 2016-10-25 17:08:25 -05:00
Ed Gonzalez f93ba24113 Repackage ThumbDV.ssdr_waveform for minor changes. Still v1.0.8 2016-10-25 17:08:18 -05:00
Ed Gonzalez ad994bf4a5 Change float ms_sleep to uint32 us_sleep in processSerial() 2016-10-25 17:07:40 -05:00
Ed Gonzalez 5297aa5fa6 ThumbDV GUI now v1.0.8 to match .ssdr_waveform 2016-10-25 14:49:01 -05:00
Ed Gonzalez 10993f9c7c ThumbDV now v1.0.8 2016-10-25 14:47:02 -05:00
Ed Gonzalez 559235f423 Slightly more aggressive RX gains for DSTAR 2016-10-25 14:32:39 -05:00
Ed Gonzalez e784f93878 Fix ThumbDV pacing 2016-10-25 14:24:04 -05:00
Ed Gonzalez c1745eea15 Fix some pacing errors by setting data/flow control characteristics 2016-10-25 07:51:37 -05:00
Ed Gonzalez 06cf3e975c Blocking read instead of polling for _thumbDV_readThread() 2016-10-24 14:12:02 -05:00
Ed Gonzalez c5bd30c090 Switch to FTD2XX library for serial communication to ThumbDV 2016-10-24 13:59:21 -05:00
Ed Gonzalez f5891bc89d ThumbDV GUI now v1.0.7 to match .ssdr_waveform. Compatible with SmartSDR v1.6 2015-12-22 10:35:46 -06:00
Ed Gonzalez 0c4354784b ThumbDV now v1.0.7 - RX Filter +-3500 2015-10-28 10:10:38 -05:00
Abed Haque c12ec3a1da D-STAR: Added back reference to dstar.ico. 2015-09-10 11:31:50 -05:00
Abed Haque 2c8a623ec1 Copying License files in D-STAR inno setup. 2015-09-09 19:41:34 -05:00
Abed Haque ac519e3f25 Copying License files in D-STAR inno setup. 2015-09-09 19:31:49 -05:00
Abed Haque 54c38fd598 Changed AssmeblyVersion for D-STAR application. 2015-09-09 16:06:57 -05:00
Abed Haque b079bd7c20 Merge pull request #8 from n5ac/thumbDV_installer
Thumb dv installer
2015-09-09 16:04:25 -05:00
Abed Haque 0b7581aa7c Modified D-STAR installer MyAppVersion defines so that they can be passed in as parameters by a build script. 2015-09-09 16:04:05 -05:00
Abed Haque 121576fc19 Added version to desktop shortcut. Added Libs directory. 2015-09-09 10:52:01 -05:00
Abed Haque 247bf25ff5 Updated AppId for D-STAR Waveform installer. 2015-09-08 17:22:01 -05:00
Ed Gonzalez bc73d826a9 Update ThumbDV configuration and package to v1.0.6 2015-09-08 15:09:56 -05:00
Abed Haque 4b21897ce5 Renamed application to 'SmartSDR D-STAR Waveform'. 2015-09-08 14:59:27 -05:00
Abed Haque 325088ae56 DSTAR Waveform installer now checks the 'Create Desktop Icon' by default. 2015-09-08 14:33:03 -05:00
Ed Gonzalez c75fde445c Merge pull request #7 from n5ac/thumbDV_installer
Installer naming changes.  Chnaged Installer icon. Added firewall exc…
2015-09-04 18:09:08 -05:00
Abed Haque 42ba4f02b9 Added an updated ThumDV.ssdr_waveform (v0.0.4). 2015-09-04 18:08:51 -05:00
Abed Haque 3fa7dc9c0c Installer naming changes. Chnaged Installer icon. Added firewall exception adding. 2015-09-04 17:59:28 -05:00
Ed Gonzalez b21e1927ed Merge branch 'thumbDV_support' of github.com:n5ac/smartsdr-dsp into thumbDV_support 2015-09-04 10:23:23 -05:00
Ed Gonzalez 8009e6e372 Merge branch 'thumbDV_support' of github.com:n5ac/smartsdr-dsp into thumbDV_support 2015-09-04 10:22:33 -05:00
Ed Gonzalez e7d7d506ea Update ThumbDV.cfg with new filter limits 2015-09-04 10:19:19 -05:00
Ed Gonzalez 8382c7455a Fix weird collision in iss file 2015-09-03 17:00:02 -05:00
Ed Gonzalez a40983ada4 Merge pull request #6 from mlhnet/thumbDV_support
ThumbDB GUI Log Event fix
2015-09-03 16:56:19 -05:00
mlhnet 7c0ec87169 Log event bugfix, bump version 2015-09-03 17:49:25 -04:00
Mark Hanson d5b39e2b7d Merge pull request #4 from n5ac/thumbDV_support
Thumb dv support
2015-09-03 16:15:06 -04:00
Ed Gonzalez 7e7162312e Update ISS script to say FlexRadio instead of just Flex and fix ssdr_waveform copy command 2015-09-03 13:48:31 -05:00
Ed Gonzalez ba4f6afe90 Merge branch 'thumbDV_support' of github.com:n5ac/smartsdr-dsp into thumbDV_support 2015-09-03 13:38:02 -05:00
Ed Gonzalez 42ff3dd0d8 Add ssdr_waveform package to git and update iss script to point to new location 2015-09-03 13:37:49 -05:00
Ed Gonzalez 5c8bf9b182 Fix type in AssemblyTitle 2015-09-03 13:28:50 -05:00
Ed Gonzalez 693a362e35 Don't replace spaces with underscores to save APPDATA - This uses the existing FlexRadio Systems folder 2015-09-03 13:28:24 -05:00
Ed Gonzalez 2733a893f3 Trigger log on first header instead of waiting for 3 to get repeater reponses 2015-09-03 13:19:37 -05:00
Ed Gonzalez e327a8c150 Merge branch 'thumbDV_support' of github.com:n5ac/smartsdr-dsp into thumbDV_support 2015-09-03 12:49:22 -05:00
Ed Gonzalez 09fc0194f7 Add slight peaking IIR at 4800Hz after GMSK demod. 2015-09-03 12:49:20 -05:00
Ed Gonzalez 74a9ed5a6b Handle radio disconnect 2015-09-03 12:42:44 -05:00
Ed Gonzalez 0c8391700c Add strlen() to TX Message debug output 2015-09-03 10:47:14 -05:00
Ed Gonzalez 6c82100170 Reset message index if we decode gets off 2015-09-03 10:46:32 -05:00
Ed Gonzalez 62abf0058c Default TX messge to empty 2015-09-03 10:45:03 -05:00
Ed Gonzalez e38e976fbc Add DUMP_GMSK_MOD flag for debuging GMSK_ENCODE 2015-09-03 10:44:02 -05:00
Ed Gonzalez 8b703f8bbc Change deviation to 1200 2015-09-03 10:34:33 -05:00
Ed Gonzalez a8ef82646c Reset encoder on END_PATTERN and shorted the initial SYNC and END tones 2015-09-03 10:32:53 -05:00
Ed Gonzalez ce962e6d87 Add thumbDV_flushLists() to flush thumbDV lists in TX/RX transistions 2015-09-03 10:29:12 -05:00
Ed Gonzalez 40920e7c37 Merge branch 'thumbDV_support' of github.com:n5ac/smartsdr-dsp into thumbDV_support 2015-09-01 19:13:35 -05:00
Ed Gonzalez 675e300742 Update ThumbDV.cfg to support new versioning scheme 2015-09-01 17:36:57 -05:00
Ed Gonzalez 131c271403 Merge branch 'thumbDV_support' of github.com:n5ac/smartsdr-dsp into thumbDV_support 2015-09-01 17:36:32 -05:00
Ed Gonzalez aee120a8aa Merge pull request #5 from mlhnet/thumbDV_support
Thumb dv support - Update GUI
2015-09-01 08:03:59 -05:00
mlhnet 5102978111 Bump INNO setup version 2015-08-31 20:23:10 -04:00
mlhnet def0ad067e Remove GUI flag, bump version 2015-08-31 20:19:41 -04:00
mlhnet 4c70735140 List Sorting, DR Mode Set RPT2 2015-08-31 18:46:32 -04:00
mlhnet f8b5c17214 RPT1 / RPT2 bug fix 2015-08-31 13:48:38 -04:00
Ed Gonzalez fdc522e747 Move RX=END status message to DSTAR State machine and add new STATUS_END_RX case in status message function 2015-08-31 11:52:41 -05:00
Ed Gonzalez 12df08f2d0 Merge branch 'thumbDV_support' of github.com:n5ac/smartsdr-dsp into thumbDV_support
Conflicts:
	pc/CODEC2 GUI/CODEC2 GUI/Form1.Designer.cs
	pc/CODEC2 GUI/CODEC2 GUI/Form1.cs
	pc/CODEC2 GUI/CODEC2 GUI/Properties/AssemblyInfo.cs
	pc/CODEC2 GUI/CODEC2 GUI/Properties/Resources.Designer.cs
	pc/CODEC2 GUI/CODEC2 GUI/Properties/Settings.Designer.cs
2015-08-31 10:54:53 -05:00
Ed Gonzalez 3008950e50 Merge pull request #2 from mlhnet/thumbDV_support
Mark AA3RK ThumbDV Support Work
2015-08-31 10:31:43 -05:00
mlhnet 134cb2cfee INNO Setup File 2015-08-30 20:05:23 -04:00
mlhnet f737a6b618 Add message field, improve logging 2015-08-30 19:25:56 -04:00
mlhnet b618fcb1fd Add RX=END waveform message, bug fixes 2015-08-30 19:16:48 -04:00
Mark Hanson 700615f4fd Merge pull request #3 from n5ac/thumbDV_support
Add slow_data.c|.h
2015-08-29 16:07:44 -04:00
Ed Gonzalez 5c2e0b6ae8 Add slow_data.c|.h 2015-08-29 14:48:56 -05:00
Mark Hanson 6a3d05293c Merge pull request #2 from n5ac/thumbDV_support
Thumb dv support
2015-08-28 12:20:20 -04:00
mlhnet 5aacd492f9 Add Repeater selection and tuning 2015-08-27 10:20:32 -04:00
Ed Gonzalez 10fe766b62 Change build - will probably go away 2015-08-26 14:52:41 -05:00
Ed Gonzalez 253ab84a34 Add functions to set DSTAR message field. 2015-08-26 14:41:06 -05:00
Ed Gonzalez 8a210b587b Add slow data encode of message and header data 2015-08-26 14:18:32 -05:00
Ed Gonzalez 3a9f59def9 Add DSTAR TX State machine to handle transmit. Move current TX Logic from sched_waveform to the TX State Machine 2015-08-26 11:27:01 -05:00
Ed Gonzalez 52f27e54fd Add slow data message parsing and status updates 2015-08-26 10:41:01 -05:00
Ed Gonzalez 7be0c446d1 Add slice to DSTAR state machine which allows proper status updates with correct index 2015-08-26 10:40:45 -05:00
Ed Gonzalez 1a19337f43 First pass at slow data decode 2015-08-25 18:01:45 -05:00
Ed Gonzalez 1b3d5202f0 Try to unify code style 2015-08-25 10:15:43 -05:00
Ed Gonzalez e25403d6c1 Set the repeater relay bit when using a destination repeater 2015-08-25 09:53:03 -05:00
Ed Gonzalez de442eb75b Fix RX Audio not being emitted 2015-08-25 09:52:41 -05:00
Ed Gonzalez 0d68f11117 Fix declaration of _end_of_transmission 2015-08-25 09:52:24 -05:00
Ed Gonzalez e48c43913c Add sending of end bits at end of transmission. Needs heave cleanup. 2015-08-24 15:07:01 -05:00
Ed Gonzalez b82637e5d2 Add reset function for MODFilter and correct the bytes for END_PATTERN 2015-08-24 15:06:27 -05:00
Ed Gonzalez c742d3b3ff Add mechanism that allows the waveform to know when the radio is unkeying.
This is needed so that DSTAR can encode it's end bits.
2015-08-24 15:05:03 -05:00
mlhnet 2f75571d03 Merge pull request #1 from n5ac/thumbDV_support
Thumb dv support
2015-08-24 15:08:55 -04:00
mlhnet c5a7ba3adb New layout, log, MRU lists, Reflector selection, VS2015 Solution 2015-08-24 14:43:53 -04:00
Ed Gonzalez edd809c269 Look for end bits in voice frames too. 2015-08-21 08:16:06 -05:00
Ed Gonzalez 181e69a97c Remove reset_softcfg from ThumbDV Init since it messes up new ThumbDVs 2015-08-20 14:23:37 -05:00
Ed Gonzalez 2f828cf2ac Handle ThumbDV being unplugged gracefully.
When the ThumbDV is unplugged the serial read thread stops and tries to re-connect. All writes to the serial port also stop.
2015-08-20 14:21:38 -05:00
Ed Gonzalez 09cca8a92d Trigger slice commands on a slice entering DSTR mode instead of D*FM 2015-08-11 11:08:18 -05:00
Ed Gonzalez d935086b89 Update ThumbDV.cfg to change waveform mode to DSTR 2015-08-11 11:03:50 -05:00
Ed Gonzalez 08b9375fd5 Make companion_call default to CQCQCQ to follow convention 2015-08-10 13:50:27 -05:00
Ed Gonzalez 5c93764a36 Add support for higher speed ThumbDV (460800 Baud) 2015-08-04 15:18:23 -05:00
Ed Gonzalez 76cd75b585 Merge branch 'thumbDV_support' of github.com:n5ac/smartsdr-dsp into thumbDV_support 2015-08-04 14:44:31 -05:00
Ed Gonzalez 88dd1d94e7 When sending commands replace spaces with \u007f 2015-08-04 14:44:18 -05:00
Ed Gonzalez b34f02c311 Merge branch 'thumbDV_support' of github.com:n5ac/smartsdr-dsp into thumbDV_support 2015-08-04 14:42:12 -05:00
Ed Gonzalez d82c84e994 Default header with instructional fields added 2015-08-04 14:42:10 -05:00
Ed Gonzalez 7eacc2472e Change status parsing to take into account both rx and tx incoming data 2015-08-04 14:40:02 -05:00
Ed Gonzalez 33e1c96b1f Merge branch 'thumbDV_support' of github.com:n5ac/smartsdr-dsp into thumbDV_support 2015-08-04 14:39:10 -05:00
Ed Gonzalez 12b06958ed Change status update to be specific to tx and rx headers. Add status command to send current state 2015-08-04 14:39:07 -05:00
Ed Gonzalez ad5ab7d721 Add parsing of waveform status to receive RX information 2015-08-04 14:26:57 -05:00
Ed Gonzalez 95f844e59f Add parsing of input fields for DSTARGui 2015-08-04 13:55:42 -05:00
Ed Gonzalez b2310cfaee Create controls for DSTAR waveform 2015-08-04 11:55:37 -05:00
Ed Gonzalez 87c3132618 Make header dump more friendly by adding single quotes around string fields to be able to see spaces 2015-08-03 17:11:59 -05:00
Ed Gonzalez a1c2094429 Sanitize DSTAR header fields more. Automatically insert spaces required when callsigns/rptr do not extend the full 8 characters in header 2015-08-03 17:11:22 -05:00
Ed Gonzalez 3dd58394ce Update GMSK Encode filter for new 24kHz sample rate. Header decode working on ICOM 2015-08-03 14:50:24 -05:00
Ed Gonzalez f17aaa53d8 Add test function that creates a default outgoing header for TX testing 2015-08-03 14:50:01 -05:00
Ed Gonzalez bea9eea4a8 Increase drive of gmsk_encode and remove slow data dump 2015-08-03 08:57:02 -05:00
Ed Gonzalez 280051c0ec Fix magic number that should be DSTAR_RADIO_BIT_LENGTH 2015-08-03 08:50:10 -05:00
Ed Gonzalez dc62823035 Waveform now subscribes to slice status messages and sets parameters when a slice enters the waveform mode 2015-07-30 15:16:02 -05:00
Ed Gonzalez 09440809a6 Spacing and set initial_rx to FALSE regardless of whether we got good decode audio or not 2015-06-22 17:26:44 -05:00
Ed Gonzalez b171c4b372 Add commands to set various outgoing header fields and add status message that reports incoming header fields 2015-06-22 17:25:59 -05:00
Ed Gonzalez 2ca2373c81 Fix stack smashing when command into console where > 80. maximum allowed is now 511 2015-06-22 17:23:58 -05:00
Ed Gonzalez 9221d5b0b8 Add spaces to slow data output to try to get Icom to decode header. 2015-06-22 11:26:51 -05:00
Ed Gonzalez f5d4a997f4 Add 4 synchronization bits to header detect to reduce false positives 2015-06-22 11:26:03 -05:00
Ed Gonzalez 8303e3e135 Remove unused variables 2015-06-19 14:30:20 -05:00
Ed Gonzalez 8f6d86be48 Fix RX buffering and begin adding slow data encoding 2015-06-19 14:22:06 -05:00
Ed Gonzalez b27cdc451a Add more descriptive output to a circular buffer overwrite 2015-06-19 14:21:15 -05:00
Ed Gonzalez 524891c602 Transmit working with NFM TX 2015-06-18 16:07:09 -05:00
Ed Gonzalez c76d81e448 Header TX working. Requires pre-emphasis on TX 2015-06-17 18:34:15 -05:00
Ed Gonzalez ea1ce6307e Increase TX4_cb buffer size to be able to hold a full header worth of audio data 2015-06-17 18:21:02 -05:00
Ed Gonzalez fe678569b4 Transmit of SYNC bits working. Very dirty state 2015-06-17 18:04:43 -05:00
Ed Gonzalez 13d4d64014 Add P_FCS checksum check for incoming header 2015-06-17 11:21:26 -05:00
Ed Gonzalez 5eb520fcce Move header, voice_bits and data_bits into the dstar_machine data structure for future support of multiple instances 2015-06-16 18:14:34 -05:00
Ed Gonzalez 8ab5a053aa Replace some magic numbers with their appropriate macros. 2015-06-16 18:14:06 -05:00
Ed Gonzalez 8cac900b72 Don't use the 64 training bits for detecting the header. Just the synchronization bits and also allow transitioning directly from waiting on sync bits to voice frames if we detect a data_sync frame 2015-06-16 15:32:59 -05:00
Ed Gonzalez 843d734b60 DSTAR Audio decode working. Add ICOM order bits to bytes 2015-06-16 14:49:55 -05:00
Ed Gonzalez 319feb6f0e Add incoming header packet parsing and output 2015-06-12 14:18:10 -05:00
Ed Gonzalez a2e5110085 CID12151 - Fix passing byte as array 2015-06-12 11:24:58 -05:00
Ed Gonzalez eda34ee255 CID12153 - Make sure we get a correct serial descriptor on startup if not loop until we do 2015-06-12 11:22:34 -05:00
Ed Gonzalez a3e918ee32 CID12154 - Close tty on failure to set attribute 2015-06-12 11:17:14 -05:00
Ed Gonzalez 907e3514fa CID12156 - Uninitialized array 2015-06-12 11:14:15 -05:00
Ed Gonzalez d9568a9e1f Fix build problems caused by missing CODEC2 folder 2015-06-12 11:13:46 -05:00
Ed Gonzalez f3f2c50e51 Remove unneeded variables 2015-06-12 10:57:38 -05:00
Ed Gonzalez 5b5947dd06 Remove CODEC2_FREEDV folder and files 2015-06-12 10:56:49 -05:00
Ed Gonzalez 880581d4ea Buffering working but decode de-stabilizes to FFs and 00s 2015-06-11 18:35:05 -05:00
Ed Gonzalez aabd5424cb Remove debug from bit_pattern_matcher 2015-06-11 16:52:59 -05:00
Ed Gonzalez c429f359d1 Update ThumbDV encode function to no work circularly 2015-06-11 16:52:36 -05:00
Ed Gonzalez 2a0b2366c5 Add ThumbDV_Debug and ThumbDV_Release build configurations 2015-06-11 16:48:49 -05:00
Ed Gonzalez f9164e29b5 Encapsulate DSTAR into state machine that is fed incoming bits. 2015-06-11 14:13:33 -05:00
Ed Gonzalez 014b457794 Successfully decoding DSTAR Header information. Cleanup and full state machine work starting 2015-06-11 11:31:29 -05:00
Ed Gonzalez 8b3fc14b2f Add dstar.c|.h that add FEC, interleaving and scrambling 2015-06-11 09:20:37 -05:00
Ed Gonzalez 8bfb382d25 Use output in dump function and change const to static const 2015-06-11 09:14:50 -05:00
Ed Gonzalez b3c43dafe5 Add syn and frame syn pattern matcher to find header of DSTAR frame 2015-06-10 11:07:16 -05:00
Ed Gonzalez a5609ca279 Add bit pattern match files and functions 2015-06-03 14:14:10 -05:00
Ed Gonzalez 81bb26dc15 Encapsulate encode/decode test into function. 2015-06-03 12:59:32 -05:00
Ed Gonzalez d60f28031d GMSK Encode/decode functional. DEMOD filter unecessary from OpenDV code 2015-06-03 12:53:50 -05:00
Ed Gonzalez 6ca3c9cd3a Change executable for stack trace to thumbdv instead of freedv 2015-06-03 10:29:02 -05:00
Ed Gonzalez ef467c41aa Begin porting FIR Filter for GMSK Modem 2015-06-02 14:51:33 -05:00
Ed Gonzalez fc8de37bd6 Begin porting GMSK modulator 2015-06-02 14:28:42 -05:00
Ed Gonzalez 4095503a38 Add gmsk_modem.c|.h files and begin porting GMSK Demod functions and structures 2015-06-02 14:22:50 -05:00
Ed Gonzalez 7939a2907b Use #define instead of const values to avoid non-constant initializer errors 2015-06-02 14:21:08 -05:00
Ed Gonzalez f9a65e23a8 Add DStarDefines.h and modify bool type to Waveform BOOL type 2015-06-02 13:48:02 -05:00
Ed Gonzalez f57926f1da Update TRUE/FALSE definitiions to use uint8 instead of uint32 2015-06-02 13:47:20 -05:00
Ed Gonzalez 3c092ad57d Fix scaling issues and decode_out indexing. Audio encode/decode now completely functional 2015-06-01 18:10:34 -05:00
Ed Gonzalez 011100778c Add Init,PKT_GAIN and PKT_COMPAND commands to initialization and fix by-one error in writing speech data. Encode/decode example working with input gain problems 2015-06-01 17:31:08 -05:00
Ed Gonzalez 637558a4a4 Cleanup hard coded values for DV_PACKET_SAMPLES and increase ring buffers to fit new size 2015-06-01 17:30:00 -05:00
Ed Gonzalez d1218b7346 Loopback of encode TX and decode in RX test working 2015-05-29 14:22:37 -05:00
Ed Gonzalez d618652579 Add lists for encoded/decoded frames. Link into correct chain from process serial 2015-05-29 13:16:25 -05:00
Ed Gonzalez 3158f09387 Change buffering scheme to 160 samples at coder from 128 of FDV. 2015-05-29 13:15:42 -05:00
Ed Gonzalez cbc248ca15 Add read_cfg command and fix set DSTAR mode command 2015-05-29 11:19:38 -05:00
Ed Gonzalez b1c1b162ca ThumbDV encode/decode list handling milestone. 2015-05-28 17:02:48 -05:00
Ed Gonzalez 375cbfc717 Add separate read thread for ThumbDV and fix encoding function 2015-05-28 13:00:48 -05:00
Ed Gonzalez 2b16a3242f Initial work on encoding functions 2015-05-27 18:21:27 -05:00
Ed Gonzalez 8e033a0610 Change APP_NAME to ThumbDV, update ThumbDV.cfg to reflect new name and change UDP Port to 5000 to avoid conflicts with FreeDV 2015-05-27 17:35:41 -05:00
Ed Gonzalez de0de8335e Add errno output to hal_Listener_Init 2015-05-27 17:25:07 -05:00
Ed Gonzalez ac61d281d0 Begin porting AMBServer code for use in waveforms. Add thumbDV.c|h files and successfully open serial port 2015-05-27 17:19:27 -05:00
Ed Gonzalez 4ed6e30c1f Add ThumbDV.cfg file 2015-05-27 17:18:12 -05:00
Ed Gonzalez ff21298f9f Change appname to ThumbDV 2015-05-27 17:12:08 -05:00
Ed Gonzalez 8f21ad3b5b Remove FreeDV references in preparation for ThumbDV DSTAR waveform 2015-05-27 16:47:10 -05:00
136 changed files with 11141 additions and 33242 deletions

9
.gitignore vendored
View file

@ -3,6 +3,7 @@
*.ko
*.obj
*.elf
obj
# Libraries
*.lib
@ -21,3 +22,11 @@
*.i*86
*.x86_64
*.hex
# Others
.metadata
.vs
bin
Debug
Release
.settings

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.1657845058">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1657845058" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<cconfiguration id="cdt.managedbuild.config.gnu.exe.release.455329745.1404386624.1765509816">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.455329745.1404386624.1765509816" moduleId="org.eclipse.cdt.core.settings" name="ThumbDV_Release">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
@ -14,30 +14,68 @@
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1657845058" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug">
<folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1657845058." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.129177593" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.1657808751" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
<builder buildPath="${workspace_loc:/DSP_API/Debug}" id="cdt.managedbuild.target.gnu.builder.exe.debug.500443345" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.378388625" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.452072644" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
<option id="gnu.cpp.compiler.exe.debug.option.optimization.level.255266438" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.exe.debug.option.debugging.level.1622629806" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<configuration artifactName="thumbdv" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.455329745.1404386624.1765509816" name="ThumbDV_Release" parent="cdt.managedbuild.config.gnu.exe.release" postbuildStep="cp thumbdv /nfsroots/microburst/home/root">
<folderInfo id="cdt.managedbuild.config.gnu.exe.release.455329745.1404386624.1765509816." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.2071852954" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.1507208472" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/>
<builder arguments="-k" buildPath="${workspace_loc:/Firmware/Release}" command="make" enableAutoBuild="true" id="cdt.managedbuild.target.gnu.builder.exe.release.932263035" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="unlimited" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.1164203563" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool command="g++" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.874400876" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release">
<option id="gnu.cpp.compiler.exe.release.option.optimization.level.364093054" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.exe.release.option.debugging.level.659391275" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1471059699" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1129794659" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.1333928878" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.exe.debug.option.debugging.level.524794473" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.169997605" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
<tool command="arm-angstrom-linux-gnueabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.1305639214" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.647544514" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" value="gnu.c.optimization.level.most" valueType="enumerated"/>
<option id="gnu.c.compiler.exe.release.option.debugging.level.1653886956" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.1892851487" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/ThumbDV}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/SmartSDR_Interface}&quot;"/>
</option>
<option id="gnu.c.compiler.option.misc.other.2117180814" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -lpthread" valueType="string"/>
<option id="gnu.c.compiler.option.optimization.flags.1009255072" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" value="-mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize" valueType="string"/>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.2118993357" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols"/>
<option id="gnu.c.compiler.option.dialect.std.1831515322" name="Language standard" superClass="gnu.c.compiler.option.dialect.std" value="gnu.c.compiler.dialect.default" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1381777350" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.1232021528" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug">
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.855569710" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<tool command="arm-angstrom-linux-gnueabi-gcc" id="cdt.managedbuild.tool.gnu.c.linker.exe.release.539834230" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release">
<option id="gnu.c.link.option.paths.593721395" name="Library search path (-L)" superClass="gnu.c.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;../../Firmware/lib&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
</option>
<option id="gnu.c.link.option.libs.1868504239" name="Libraries (-l)" superClass="gnu.c.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="ftd2xx"/>
<listOptionValue builtIn="false" value="rt"/>
<listOptionValue builtIn="false" value="pthread"/>
<listOptionValue builtIn="false" value="dl"/>
<listOptionValue builtIn="false" value="m"/>
</option>
<option id="gnu.c.link.option.other.890688482" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" valueType="stringList">
<listOptionValue builtIn="false" value="-Map=Firmware.map"/>
</option>
<option id="gnu.c.link.option.ldflags.827896357" name="Linker flags" superClass="gnu.c.link.option.ldflags" value="" valueType="string"/>
<option id="gnu.c.link.option.noshared.504312789" name="No shared libraries (-static)" superClass="gnu.c.link.option.noshared" value="false" valueType="boolean"/>
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1207451390" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.636258136" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.245282209" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1245243501" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
<tool command="arm-angstrom-linux-gnueabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.848513527" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release">
<option id="gnu.cpp.link.option.libs.1567202613" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="pthread"/>
<listOptionValue builtIn="false" value="rt"/>
<listOptionValue builtIn="false" value="m"/>
</option>
<option id="gnu.cpp.link.option.flags.274457628" name="Linker flags" superClass="gnu.cpp.link.option.flags" value="-rdynamic" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.461120935" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool command="arm-angstrom-linux-gnueabi-as" id="cdt.managedbuild.tool.gnu.assembler.exe.release.825234294" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1550773879" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
@ -45,8 +83,8 @@
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.exe.release.2130310972">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.2130310972" moduleId="org.eclipse.cdt.core.settings" name="Release">
<cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.954644819">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.954644819" moduleId="org.eclipse.cdt.core.settings" name="ThumbDV_Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
@ -58,40 +96,158 @@
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="freedv" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.2130310972" name="Release" parent="cdt.managedbuild.config.gnu.exe.release" postannouncebuildStep="Install in BeagleBone at /home/debian/bin" postbuildStep="scp freedv root@192.168.20.33:/home/debian/bin/">
<folderInfo id="cdt.managedbuild.config.gnu.exe.release.2130310972." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.1484889450" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.545007599" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/>
<builder buildPath="${workspace_loc:/DSP_API/Release}" id="cdt.managedbuild.target.gnu.builder.exe.release.723246358" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.2118169362" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.994145082" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release">
<option id="gnu.cpp.compiler.exe.release.option.optimization.level.1517306120" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.exe.release.option.debugging.level.1723325095" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
</tool>
<tool command="arm-linux-gnueabihf-gcc -static" id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.266717095" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.653650005" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.exe.release.option.debugging.level.1324464501" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.1269310734" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/SmartSDR_Interface}&quot;"/>
<configuration artifactName="thumbdv" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.954644819" name="ThumbDV_Debug" parent="cdt.managedbuild.config.gnu.exe.debug" postbuildStep="cp thumbdv /nfsroots/microburst/home/root/" prebuildStep="">
<folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.954644819." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.537899118" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.192715654" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
<builder arguments="" autoBuildTarget="all" buildPath="${workspace_loc:../../bin}" cleanBuildTarget="clean" command="make" enableAutoBuild="true" enableCleanBuild="true" enabledIncrementalBuild="true" id="cdt.managedbuild.target.gnu.builder.exe.debug.1941511159" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="unlimited" stopOnErr="false" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.967484618" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool command="g++" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.353448207" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
<option id="gnu.cpp.compiler.exe.debug.option.optimization.level.1720864543" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.exe.debug.option.debugging.level.1795907651" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.1014859077" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/CODEC2_FREEDV}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/SmartSDR_Interface}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.297736145" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1562312530" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool command="arm-linux-gnueabihf-gcc -static" id="cdt.managedbuild.tool.gnu.c.linker.exe.release.405388815" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release">
<option id="gnu.c.link.option.libs.365322339" name="Libraries (-l)" superClass="gnu.c.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="m"/>
<listOptionValue builtIn="false" value="pthread"/>
<listOptionValue builtIn="false" value="rt"/>
<tool command="arm-angstrom-linux-gnueabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.2095437572" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.686601172" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" value="gnu.c.optimization.level.none" valueType="enumerated"/>
<option id="gnu.c.compiler.exe.debug.option.debugging.level.50794825" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.1981926866" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/ThumbDV}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/SmartSDR_Interface}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1966360149" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<option id="gnu.c.compiler.option.misc.other.1057497227" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -lpthread" valueType="string"/>
<option id="gnu.c.compiler.option.debugging.other.677970457" name="Other debugging flags" superClass="gnu.c.compiler.option.debugging.other" value="-ggdb -g3 -fstack-protector-all -funwind-tables" valueType="string"/>
<option id="gnu.c.compiler.option.optimization.flags.424680423" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" value="-mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize" valueType="string"/>
<option id="gnu.c.compiler.option.debugging.prof.1659574071" name="Generate prof information (-p)" superClass="gnu.c.compiler.option.debugging.prof" value="false" valueType="boolean"/>
<option id="gnu.c.compiler.option.debugging.gprof.1544981865" name="Generate gprof information (-pg)" superClass="gnu.c.compiler.option.debugging.gprof" value="false" valueType="boolean"/>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.1846081830" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
</option>
<option id="gnu.c.compiler.option.include.files.949443204" name="Include files (-include)" superClass="gnu.c.compiler.option.include.files"/>
<option id="gnu.c.compiler.option.dialect.std.224213537" name="Language standard" superClass="gnu.c.compiler.option.dialect.std" value="gnu.c.compiler.dialect.default" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.252305069" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool command="arm-angstrom-linux-gnueabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} " id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.2144927630" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug">
<option id="gnu.c.link.option.ldflags.1025040973" name="Linker flags" superClass="gnu.c.link.option.ldflags" value="-rdynamic" valueType="string"/>
<option id="gnu.c.link.option.libs.2079493028" name="Libraries (-l)" superClass="gnu.c.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="rt"/>
<listOptionValue builtIn="false" value="dl"/>
<listOptionValue builtIn="false" value="pthread"/>
<listOptionValue builtIn="false" value="m"/>
<listOptionValue builtIn="false" value="ftd2xx"/>
</option>
<option id="gnu.c.link.option.paths.971526928" name="Library search path (-L)" superClass="gnu.c.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;../../Firmware/lib&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/lib}&quot;"/>
</option>
<option id="gnu.c.link.option.shared.2014214536" name="Shared (-shared)" superClass="gnu.c.link.option.shared" value="false" valueType="boolean"/>
<option id="gnu.c.link.option.other.1419802631" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" valueType="stringList">
<listOptionValue builtIn="false" value="-Map=Firmware.map"/>
</option>
<option id="gnu.c.link.option.debugging.prof.1268785376" name="Generate prof information (-p)" superClass="gnu.c.link.option.debugging.prof" value="false" valueType="boolean"/>
<option id="gnu.c.link.option.debugging.gprof.1336488789" name="Generate gprof information (-pg)" superClass="gnu.c.link.option.debugging.gprof" value="false" valueType="boolean"/>
<option id="gnu.c.link.option.userobjs.723775110" name="Other objects" superClass="gnu.c.link.option.userobjs"/>
<option id="gnu.c.link.option.soname.1263316050" name="Shared object name (-Wl,-soname=)" superClass="gnu.c.link.option.soname" value="" valueType="string"/>
<option id="gnu.c.link.option.noshared.164821868" name="No shared libraries (-static)" superClass="gnu.c.link.option.noshared" value="false" valueType="boolean"/>
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.966428107" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.891470429" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release"/>
<tool command="arm-linux-gnueabihf-as" id="cdt.managedbuild.tool.gnu.assembler.exe.release.164963024" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.538472274" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
<tool command="arm-angstrom-linux-gnueabi-gcc" id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.381256252" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
<option id="gnu.cpp.link.option.libs.1514982658" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="pthread"/>
<listOptionValue builtIn="false" value="rt"/>
<listOptionValue builtIn="false" value="m"/>
</option>
<option id="gnu.cpp.link.option.flags.733960100" name="Linker flags" superClass="gnu.cpp.link.option.flags" value="-rdynamic" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.2110307887" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool command="arm-angstrom-linux-gnueabi-as" id="cdt.managedbuild.tool.gnu.assembler.exe.debug.1079285663" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.906031255" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
<fileInfo id="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.954644819.lib/libcrypto.a" name="libcrypto.a" rcbsApplicability="disable" resourcePath="lib/libcrypto.a" toolsToInvoke=""/>
<fileInfo id="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.954644819.lib/libssl.a" name="libssl.a" rcbsApplicability="disable" resourcePath="lib/libssl.a" toolsToInvoke=""/>
<fileInfo id="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.954644819.hwl/hwl_spi.c" name="hwl_spi.c" rcbsApplicability="disable" resourcePath="hwl/hwl_spi.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1446636885">
<tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1446636885" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.2095437572">
<option id="gnu.c.compiler.option.optimization.flags.1330483267" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" value="-mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp " valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.254866290" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
</fileInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.1123319373">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1123319373" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="thumbdv" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1123319373" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug">
<folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1123319373." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.135558959" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.1664200855" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
<builder buildPath="${workspace_loc:/DSP_API}/Debug" id="cdt.managedbuild.target.gnu.builder.exe.debug.1630925757" keepEnvironmentInBuildfile="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.1646365699" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.178865484" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
<option id="gnu.cpp.compiler.exe.debug.option.optimization.level.1676264233" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.exe.debug.option.debugging.level.492380600" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.6020742" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.1115077957" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.exe.debug.option.debugging.level.808232689" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.849100602" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/ThumbDV}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/SmartSDR_Interface}&quot;"/>
</option>
<option id="gnu.c.compiler.option.dialect.std.789654788" name="Language standard" superClass="gnu.c.compiler.option.dialect.std" value="gnu.c.compiler.dialect.default" valueType="enumerated"/>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.921022350" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
</option>
<option id="gnu.c.compiler.option.optimization.flags.652093285" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" value="-ftree-vectorize" valueType="string"/>
<option id="gnu.c.compiler.option.debugging.other.1789455642" name="Other debugging flags" superClass="gnu.c.compiler.option.debugging.other" value="-ggdb -g3 -fstack-protector-all -funwind-tables" valueType="string"/>
<option id="gnu.c.compiler.option.misc.other.2048476274" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -lpthread" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.882862181" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.1632667335" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug">
<option id="gnu.c.link.option.libs.1384921770" name="Libraries (-l)" superClass="gnu.c.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="rt"/>
<listOptionValue builtIn="false" value="pthread"/>
<listOptionValue builtIn="false" value="m"/>
</option>
<option id="gnu.c.link.option.paths.1500008865" name="Library search path (-L)" superClass="gnu.c.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;../../Firmware/lib&quot;"/>
</option>
<option id="gnu.c.link.option.other.2078769507" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" valueType="stringList">
<listOptionValue builtIn="false" value="-Map=Firmware.map"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1757655897" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.2106176645" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.340381532" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.857123865" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
@ -101,17 +257,67 @@
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="DSP_API.cdt.managedbuild.target.gnu.exe.1129142882" name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/>
<project id="DSP_API.null.1167863079" name="DSP_API"/>
</storageModule>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Release">
<resource resourceType="PROJECT" workspacePath="/DSP_API"/>
</configuration>
<configuration configurationName="ThumbDV_Release"/>
<configuration configurationName="Debug">
<resource resourceType="PROJECT" workspacePath="/DSP_API"/>
</configuration>
<configuration configurationName="ThumbDV_Debug"/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1657845058;cdt.managedbuild.config.gnu.exe.debug.1657845058.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1129794659;cdt.managedbuild.tool.gnu.c.compiler.input.169997605">
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.455329745.1404386624;cdt.managedbuild.config.gnu.exe.release.455329745.1404386624.dsp;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.77704066;cdt.managedbuild.tool.gnu.cpp.compiler.input.981666482">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1423223971;cdt.managedbuild.config.gnu.cross.exe.debug.1423223971.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.558177475;cdt.managedbuild.tool.gnu.cpp.compiler.input.2076444223">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.455329745.1404386624;cdt.managedbuild.config.gnu.exe.release.455329745.1404386624.dsp;cdt.managedbuild.tool.gnu.c.compiler.exe.release.1873213506;cdt.managedbuild.tool.gnu.c.compiler.input.36724063">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.2130310972;cdt.managedbuild.config.gnu.exe.release.2130310972.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.266717095;cdt.managedbuild.tool.gnu.c.compiler.input.297736145">
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.455329745.1404386624;cdt.managedbuild.config.gnu.exe.release.455329745.1404386624.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.1484401702;cdt.managedbuild.tool.gnu.cpp.compiler.input.417250856">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495;cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.hwl/hwl_spi.c;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1489556063;cdt.managedbuild.tool.gnu.c.compiler.input.1363831854">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495;cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.2124708629;cdt.managedbuild.tool.gnu.cpp.compiler.input.1803519384">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495;cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1918981003;cdt.managedbuild.tool.gnu.c.compiler.input.1061662189">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495;cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.dsp/src/host;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1823095473;cdt.managedbuild.tool.gnu.c.compiler.input.1314211591">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495;cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.dsp;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1984162325;cdt.managedbuild.tool.gnu.c.compiler.input.395302614">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1423223971;cdt.managedbuild.config.gnu.cross.exe.debug.1423223971.;cdt.managedbuild.tool.gnu.cross.c.compiler.735801497;cdt.managedbuild.tool.gnu.c.compiler.input.1014719840">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1057191106;cdt.managedbuild.config.gnu.cross.exe.debug.1057191106.;cdt.managedbuild.tool.gnu.cross.c.compiler.1844935333;cdt.managedbuild.tool.gnu.c.compiler.input.215614298">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.980857108;cdt.managedbuild.config.gnu.cross.exe.release.980857108.;cdt.managedbuild.tool.gnu.cross.c.compiler.466835252;cdt.managedbuild.tool.gnu.c.compiler.input.1877777492">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495;cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.dsp;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.743641091;cdt.managedbuild.tool.gnu.cpp.compiler.input.1684539436">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.455329745.1404386624;cdt.managedbuild.config.gnu.exe.release.455329745.1404386624.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.1604589678;cdt.managedbuild.tool.gnu.c.compiler.input.1521355092">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495;cdt.managedbuild.config.gnu.exe.debug.1561919164.675793495.dsp/src/host;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.200033409;cdt.managedbuild.tool.gnu.cpp.compiler.input.1989995846">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="refreshScope"/>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>

View file

@ -7,7 +7,6 @@
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?name?</key>

View file

@ -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 <limits.h>
#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 <alloca.h>
#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

View file

@ -1,245 +0,0 @@
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
/*
* This intermediary file and the files that used to create it are under
* The LGPL. See the file COPYING.
*/
#include "defines.h"
/* codebook/lsp1.txt */
static const float codes0[] = {
225,
250,
275,
300,
325,
350,
375,
400,
425,
450,
475,
500,
525,
550,
575,
600
};
/* codebook/lsp2.txt */
static const float codes1[] = {
325,
350,
375,
400,
425,
450,
475,
500,
525,
550,
575,
600,
625,
650,
675,
700
};
/* codebook/lsp3.txt */
static const float codes2[] = {
500,
550,
600,
650,
700,
750,
800,
850,
900,
950,
1000,
1050,
1100,
1150,
1200,
1250
};
/* codebook/lsp4.txt */
static const float codes3[] = {
700,
800,
900,
1000,
1100,
1200,
1300,
1400,
1500,
1600,
1700,
1800,
1900,
2000,
2100,
2200
};
/* codebook/lsp5.txt */
static const float codes4[] = {
950,
1050,
1150,
1250,
1350,
1450,
1550,
1650,
1750,
1850,
1950,
2050,
2150,
2250,
2350,
2450
};
/* codebook/lsp6.txt */
static const float codes5[] = {
1100,
1200,
1300,
1400,
1500,
1600,
1700,
1800,
1900,
2000,
2100,
2200,
2300,
2400,
2500,
2600
};
/* codebook/lsp7.txt */
static const float codes6[] = {
1500,
1600,
1700,
1800,
1900,
2000,
2100,
2200,
2300,
2400,
2500,
2600,
2700,
2800,
2900,
3000
};
/* codebook/lsp8.txt */
static const float codes7[] = {
2300,
2400,
2500,
2600,
2700,
2800,
2900,
3000
};
/* codebook/lsp9.txt */
static const float codes8[] = {
2500,
2600,
2700,
2800,
2900,
3000,
3100,
3200
};
/* codebook/lsp10.txt */
static const float codes9[] = {
2900,
3100,
3300,
3500
};
const struct lsp_codebook lsp_cb[] = {
/* codebook/lsp1.txt */
{
1,
4,
16,
codes0
},
/* codebook/lsp2.txt */
{
1,
4,
16,
codes1
},
/* codebook/lsp3.txt */
{
1,
4,
16,
codes2
},
/* codebook/lsp4.txt */
{
1,
4,
16,
codes3
},
/* codebook/lsp5.txt */
{
1,
4,
16,
codes4
},
/* codebook/lsp6.txt */
{
1,
4,
16,
codes5
},
/* codebook/lsp7.txt */
{
1,
4,
16,
codes6
},
/* codebook/lsp8.txt */
{
1,
3,
8,
codes7
},
/* codebook/lsp9.txt */
{
1,
3,
8,
codes8
},
/* codebook/lsp10.txt */
{
1,
2,
4,
codes9
},
{ 0, 0, 0, 0 }
};

View file

@ -1,433 +0,0 @@
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
/*
* This intermediary file and the files that used to create it are under
* The LGPL. See the file COPYING.
*/
#include "defines.h"
/* codebook/dlsp1.txt */
static const float codes0[] = {
25,
50,
75,
100,
125,
150,
175,
200,
225,
250,
275,
300,
325,
350,
375,
400,
425,
450,
475,
500,
525,
550,
575,
600,
625,
650,
675,
700,
725,
750,
775,
800
};
/* codebook/dlsp2.txt */
static const float codes1[] = {
25,
50,
75,
100,
125,
150,
175,
200,
225,
250,
275,
300,
325,
350,
375,
400,
425,
450,
475,
500,
525,
550,
575,
600,
625,
650,
675,
700,
725,
750,
775,
800
};
/* codebook/dlsp3.txt */
static const float codes2[] = {
25,
50,
75,
100,
125,
150,
175,
200,
225,
250,
275,
300,
325,
350,
375,
400,
425,
450,
475,
500,
525,
550,
575,
600,
625,
650,
675,
700,
725,
750,
775,
800
};
/* codebook/dlsp4.txt */
static const float codes3[] = {
25,
50,
75,
100,
125,
150,
175,
200,
250,
300,
350,
400,
450,
500,
550,
600,
650,
700,
750,
800,
850,
900,
950,
1000,
1050,
1100,
1150,
1200,
1250,
1300,
1350,
1400
};
/* codebook/dlsp5.txt */
static const float codes4[] = {
25,
50,
75,
100,
125,
150,
175,
200,
250,
300,
350,
400,
450,
500,
550,
600,
650,
700,
750,
800,
850,
900,
950,
1000,
1050,
1100,
1150,
1200,
1250,
1300,
1350,
1400
};
/* codebook/dlsp6.txt */
static const float codes5[] = {
25,
50,
75,
100,
125,
150,
175,
200,
250,
300,
350,
400,
450,
500,
550,
600,
650,
700,
750,
800,
850,
900,
950,
1000,
1050,
1100,
1150,
1200,
1250,
1300,
1350,
1400
};
/* codebook/dlsp7.txt */
static const float codes6[] = {
25,
50,
75,
100,
125,
150,
175,
200,
225,
250,
275,
300,
325,
350,
375,
400,
425,
450,
475,
500,
525,
550,
575,
600,
625,
650,
675,
700,
725,
750,
775,
800
};
/* codebook/dlsp8.txt */
static const float codes7[] = {
25,
50,
75,
100,
125,
150,
175,
200,
225,
250,
275,
300,
325,
350,
375,
400,
425,
450,
475,
500,
525,
550,
575,
600,
625,
650,
675,
700,
725,
750,
775,
800
};
/* codebook/dlsp9.txt */
static const float codes8[] = {
25,
50,
75,
100,
125,
150,
175,
200,
225,
250,
275,
300,
325,
350,
375,
400,
425,
450,
475,
500,
525,
550,
575,
600,
625,
650,
675,
700,
725,
750,
775,
800
};
/* codebook/dlsp10.txt */
static const float codes9[] = {
25,
50,
75,
100,
125,
150,
175,
200,
225,
250,
275,
300,
325,
350,
375,
400,
425,
450,
475,
500,
525,
550,
575,
600,
625,
650,
675,
700,
725,
750,
775,
800
};
const struct lsp_codebook lsp_cbd[] = {
/* codebook/dlsp1.txt */
{
1,
5,
32,
codes0
},
/* codebook/dlsp2.txt */
{
1,
5,
32,
codes1
},
/* codebook/dlsp3.txt */
{
1,
5,
32,
codes2
},
/* codebook/dlsp4.txt */
{
1,
5,
32,
codes3
},
/* codebook/dlsp5.txt */
{
1,
5,
32,
codes4
},
/* codebook/dlsp6.txt */
{
1,
5,
32,
codes5
},
/* codebook/dlsp7.txt */
{
1,
5,
32,
codes6
},
/* codebook/dlsp8.txt */
{
1,
5,
32,
codes7
},
/* codebook/dlsp9.txt */
{
1,
5,
32,
codes8
},
/* codebook/dlsp10.txt */
{
1,
5,
32,
codes9
},
{ 0, 0, 0, 0 }
};

View file

@ -1,153 +0,0 @@
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
/*
* This intermediary file and the files that used to create it are under
* The LGPL. See the file COPYING.
*/
#include "defines.h"
/* codebook/lspdt1.txt */
static const float codes0[] = {
-75,
-50,
-25,
0,
25,
50,
75,
100
};
/* codebook/lspdt2.txt */
static const float codes1[] = {
-75,
-50,
-25,
0,
25,
50,
75,
100
};
/* codebook/lspdt3.txt */
static const float codes2[] = {
-50,
0,
50,
100
};
/* codebook/lspdt4.txt */
static const float codes3[] = {
-50,
0,
50,
100
};
/* codebook/lspdt5.txt */
static const float codes4[] = {
-50,
0,
50,
100
};
/* codebook/lspdt6.txt */
static const float codes5[] = {
-50,
0,
50,
100
};
/* codebook/lspdt7.txt */
static const float codes6[] = {
-50,
50
};
/* codebook/lspdt8.txt */
static const float codes7[] = {
-50,
50
};
/* codebook/lspdt9.txt */
static const float codes8[] = {
-50,
50
};
/* codebook/lspdt10.txt */
static const float codes9[] = {
-50,
50
};
const struct lsp_codebook lsp_cbdt[] = {
/* codebook/lspdt1.txt */
{
1,
3,
8,
codes0
},
/* codebook/lspdt2.txt */
{
1,
3,
8,
codes1
},
/* codebook/lspdt3.txt */
{
1,
2,
4,
codes2
},
/* codebook/lspdt4.txt */
{
1,
2,
4,
codes3
},
/* codebook/lspdt5.txt */
{
1,
2,
4,
codes4
},
/* codebook/lspdt6.txt */
{
1,
2,
4,
codes5
},
/* codebook/lspdt7.txt */
{
1,
1,
2,
codes6
},
/* codebook/lspdt8.txt */
{
1,
1,
2,
codes7
},
/* codebook/lspdt9.txt */
{
1,
1,
2,
codes8
},
/* codebook/lspdt10.txt */
{
1,
1,
2,
codes9
},
{ 0, 0, 0, 0 }
};

View file

@ -1,279 +0,0 @@
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
/*
* This intermediary file and the files that used to create it are under
* The LGPL. See the file COPYING.
*/
#include "defines.h"
/* codebook/gecb.txt */
static const float codes0[] = {
2.71, 12.0184,
0.04675, -2.73881,
0.120993, 8.38895,
-1.58028, -0.892307,
1.19307, -1.91561,
0.187101, -3.27679,
0.332251, -7.66455,
-1.47944, 31.2461,
1.52761, 27.7095,
-0.524379, 5.25012,
0.55333, 7.4388,
-0.843451, -1.95299,
2.26389, 8.61029,
0.143143, 2.36549,
0.616506, 1.28427,
-1.71133, 22.0967,
1.00813, 17.3965,
-0.106718, 1.41891,
-0.136246, 14.2736,
-1.70909, -20.5319,
1.65787, -3.39107,
0.138049, -4.95785,
0.536729, -1.94375,
0.196307, 36.8519,
1.27248, 22.5565,
-0.670219, -1.90604,
0.382092, 6.40113,
-0.756911, -4.90102,
1.82931, 4.6138,
0.318794, 0.73683,
0.612815, -2.07505,
-0.410151, 24.7871,
1.77602, 13.1909,
0.106457, -0.104492,
0.192206, 10.1838,
-1.82442, -7.71565,
0.931346, 4.34835,
0.308813, -4.086,
0.397143, -11.8089,
-0.048715, 41.2273,
0.877342, 35.8503,
-0.759794, 0.476634,
0.978593, 7.67467,
-1.19506, 3.03883,
2.63989, -3.41106,
0.191127, 3.60351,
0.402932, 1.0843,
-2.15202, 18.1076,
1.5468, 8.32271,
-0.143089, -4.07592,
-0.150142, 5.86674,
-1.40844, -3.2507,
1.56615, -10.4132,
0.178171, -10.2267,
0.362164, -0.028556,
-0.070125, 24.3907,
0.594752, 17.4828,
-0.28698, -6.90407,
0.464818, 10.2055,
-1.00684, -14.3572,
2.32957, -3.69161,
0.335745, 2.40714,
1.01966, -3.15565,
-1.25945, 7.9919,
2.38369, 19.6806,
-0.094947, -2.41374,
0.20933, 6.66477,
-2.22103, 1.37986,
1.29239, 2.04633,
0.243626, -0.890741,
0.428773, -7.19366,
-1.11374, 41.3414,
2.6098, 31.1405,
-0.446468, 2.53419,
0.490104, 4.62757,
-1.11723, -3.24174,
1.79156, 8.41493,
0.156012, 0.183336,
0.532447, 3.15455,
-0.764484, 18.514,
0.952395, 11.7713,
-0.332567, 0.346987,
0.202165, 14.7168,
-2.12924, -15.559,
1.35358, -1.92679,
-0.010963, -16.3364,
0.399053, -2.79057,
0.750657, 31.1483,
0.655743, 24.4819,
-0.45321, -0.735879,
0.2869, 6.5467,
-0.715673, -12.3578,
1.54849, 3.87217,
0.271874, 0.802339,
0.502073, -4.85485,
-0.497037, 17.7619,
1.19116, 13.9544,
0.01563, 1.33157,
0.341867, 8.93537,
-2.31601, -5.39506,
0.75861, 1.9645,
0.24132, -3.23769,
0.267151, -11.2344,
-0.273126, 32.6248,
1.75352, 40.432,
-0.784011, 3.04576,
0.705987, 5.66118,
-1.3864, 1.35356,
2.37646, 1.67485,
0.242973, 4.73218,
0.491227, 0.354061,
-1.60676, 8.65895,
1.16711, 5.9871,
-0.137601, -12.0417,
-0.251375, 10.3972,
-1.43151, -8.90411,
0.98828, -13.209,
0.261484, -6.35497,
0.395932, -0.702529,
0.283704, 26.8996,
0.420959, 15.4418,
-0.355804, -13.7278,
0.527372, 12.3985,
-1.16956, -15.9985,
1.90669, -5.81605,
0.354492, 3.85157,
0.82576, -4.16264,
-0.49019, 13.0572,
2.25577, 13.5264,
-0.004956, -3.23713,
0.026709, 7.86645,
-1.81037, -0.451183,
1.08383, -0.18362,
0.135836, -2.26658,
0.375812, -5.51225,
-1.96644, 38.6829,
1.97799, 24.5655,
-0.704656, 6.35881,
0.480786, 7.05175,
-0.976417, -2.42273,
2.50215, 6.75935,
0.083588, 3.2588,
0.543629, 0.910013,
-1.23196, 23.0915,
0.785492, 14.807,
-0.213554, 1.688,
0.004748, 18.1718,
-1.54719, -16.1168,
1.50104, -3.28114,
0.080133, -4.63472,
0.476592, -2.18093,
0.44247, 40.304,
1.07277, 27.592,
-0.594738, -4.16681,
0.42248, 7.61609,
-0.927521, -7.27441,
1.99162, 1.29636,
0.291307, 2.39878,
0.721081, -1.95062,
-0.804256, 24.9295,
1.64839, 19.1197,
0.060852, -0.590639,
0.266085, 9.10325,
-1.9574, -2.88461,
1.11693, 2.6724,
0.35458, -2.74854,
0.330733, -14.1561,
-0.527851, 39.5756,
0.991152, 43.195,
-0.589619, 1.26919,
0.787401, 8.73071,
-1.0138, 1.02507,
2.8254, 1.89538,
0.24089, 2.74557,
0.427195, 2.54446,
-1.95311, 12.244,
1.44862, 12.0607,
-0.210492, -3.37906,
-0.056713, 10.204,
-1.65237, -5.10274,
1.29475, -12.2708,
0.111608, -8.67592,
0.326634, -1.16763,
0.021781, 31.1258,
0.455335, 21.4684,
-0.37544, -3.37121,
0.39362, 11.302,
-0.851456, -19.4149,
2.10703, -2.22886,
0.373233, 1.92406,
0.884438, -1.72058,
-0.975127, 9.84013,
2.0033, 17.3954,
-0.036915, -1.11137,
0.148456, 5.39997,
-1.91441, 4.77382,
1.44791, 0.537122,
0.194979, -1.03818,
0.495771, -9.95502,
-1.05899, 32.9471,
2.01122, 32.4544,
-0.30965, 4.71911,
0.436082, 4.63552,
-1.23711, -1.25428,
2.02274, 9.42834,
0.190342, 1.46077,
0.479017, 2.48479,
-1.07848, 16.2217,
1.20764, 9.65421,
-0.258087, -1.67236,
0.071852, 13.416,
-1.87723, -16.072,
1.28957, -4.87118,
0.067713, -13.4427,
0.435551, -4.1655,
0.46614, 30.5895,
0.904895, 21.598,
-0.518369, -2.53205,
0.337363, 5.63726,
-0.554975, -17.4005,
1.69188, 1.14574,
0.227934, 0.889297,
0.587303, -5.72973,
-0.262133, 18.6666,
1.39505, 17.0029,
-0.01909, 4.30838,
0.304235, 12.6699,
-2.07406, -6.46084,
0.920546, 1.21296,
0.284927, -1.78547,
0.209724, -16.024,
-0.636067, 31.5768,
1.34989, 34.6775,
-0.971625, 5.30086,
0.590249, 4.44971,
-1.56787, 3.60239,
2.1455, 4.51666,
0.296022, 4.12017,
0.445299, 0.868772,
-1.44193, 14.1284,
1.35575, 6.0074,
-0.012814, -7.49657,
-0.43, 8.50012,
-1.20469, -7.11326,
1.10102, -6.83682,
0.196463, -6.234,
0.436747, -1.12979,
0.141052, 22.8549,
0.290821, 18.8114,
-0.529536, -7.73251,
0.63428, 10.7898,
-1.33472, -20.3258,
1.81564, -1.90332,
0.394778, 3.79758,
0.732682, -8.18382,
-0.741244, 11.7683
};
const struct lsp_codebook ge_cb[] = {
/* codebook/gecb.txt */
{
2,
8,
256,
codes0
},
{ 0, 0, 0, 0 }
};

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,565 +0,0 @@
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
/*
* This intermediary file and the files that used to create it are under
* The LGPL. See the file COPYING.
*/
#include "defines.h"
/* codebook/lspvqanssi1.txt */
static const float codes0[] = {
0.5862, 0.7213, 0.9146, 1.0909, 1.291, 1.4954, 1.837, 2.084, 2.3771, 2.5518,
0.0871, 0.2049, 0.5849, 0.8552, 1.2096, 1.4686, 1.821, 2.0926, 2.4508, 2.7389,
0.2274, 0.3126, 0.6088, 0.8338, 1.1824, 1.5948, 1.8228, 1.9856, 2.1832, 2.4793,
0.1827, 0.2706, 0.5842, 0.7761, 1.0301, 1.2462, 1.6313, 1.9786, 2.3479, 2.679,
0.3055, 0.3863, 0.7194, 1.1609, 1.3303, 1.5017, 1.7265, 1.9412, 2.4659, 2.6315,
0.1794, 0.2522, 0.5477, 0.7892, 1.3887, 1.7101, 1.9471, 2.1667, 2.4361, 2.631,
0.1825, 0.2729, 0.4185, 0.6024, 1.2531, 1.7291, 1.9937, 2.1849, 2.5865, 2.7748,
0.3219, 0.4045, 0.7357, 1.2708, 1.4626, 1.6439, 1.9388, 2.1212, 2.5005, 2.6749,
0.2234, 0.3496, 0.5054, 0.6981, 0.8672, 1.0431, 1.7091, 2.069, 2.329, 2.6195,
0.3009, 0.3957, 0.7576, 0.9751, 1.1955, 1.7727, 2.0383, 2.2474, 2.5612, 2.7188,
0.3841, 0.5544, 0.9209, 1.1811, 1.5441, 1.8126, 2.1175, 2.3192, 2.5486, 2.6935,
0.2153, 0.3105, 0.5597, 0.8313, 1.2168, 1.4512, 1.7012, 1.8962, 2.3893, 2.5852,
0.3196, 0.4814, 0.7629, 1.0869, 1.5517, 1.778, 2.0462, 2.2547, 2.5023, 2.6706,
0.1964, 0.3055, 0.4307, 0.7178, 1.426, 1.624, 1.8392, 2.0576, 2.2976, 2.5492,
0.426, 0.6888, 1.2019, 1.4194, 1.6437, 1.8221, 2.0469, 2.2508, 2.5142, 2.6795,
0.3004, 0.3944, 0.5847, 1.005, 1.1812, 1.3559, 1.5479, 1.7847, 2.4924, 2.6703,
0.1595, 0.2398, 0.4336, 0.9228, 1.2602, 1.5064, 1.7915, 1.984, 2.232, 2.5692,
0.1832, 0.2985, 0.4205, 0.598, 0.762, 0.9894, 1.7499, 2.1151, 2.4814, 2.7214,
0.2234, 0.3207, 0.5457, 0.9799, 1.2074, 1.7079, 1.9734, 2.1742, 2.4575, 2.6366,
0.3598, 0.4819, 0.6385, 0.8878, 1.3226, 1.491, 1.7257, 1.9456, 2.2061, 2.4579,
0.4671, 0.5911, 0.8513, 1.0923, 1.5104, 1.7043, 1.9727, 2.1839, 2.4484, 2.6111,
0.2418, 0.3937, 0.542, 0.8971, 1.1152, 1.3054, 1.7928, 1.9796, 2.5441, 2.7572,
0.3541, 0.473, 0.6546, 0.9063, 1.0792, 1.2743, 1.8545, 2.0555, 2.3083, 2.5404,
0.3121, 0.4016, 0.7137, 0.8835, 1.0736, 1.5907, 1.8624, 2.0857, 2.5075, 2.6668,
0.2232, 0.3631, 0.5273, 0.7438, 1.0492, 1.2235, 1.5449, 2.2198, 2.516, 2.6852,
0.2557, 0.3528, 0.5051, 0.6528, 0.8351, 1.5688, 1.8838, 2.1056, 2.4401, 2.6111,
0.4342, 0.5318, 0.9234, 1.1146, 1.3015, 1.5198, 1.8211, 2.034, 2.3694, 2.5506,
0.431, 0.5269, 0.7431, 0.9018, 1.0734, 1.5196, 1.8267, 2.0244, 2.4508, 2.6177,
0.215, 0.3249, 0.4966, 0.9434, 1.1627, 1.3497, 1.8003, 2.0045, 2.3567, 2.5909,
0.2798, 0.4111, 0.5786, 0.7971, 1.0414, 1.2142, 1.6947, 2.0866, 2.3351, 2.5545,
0.1688, 0.2693, 0.4004, 0.6337, 1.3058, 1.5064, 1.7535, 1.9689, 2.5542, 2.7424,
0.4419, 0.6209, 1.0127, 1.2135, 1.4104, 1.6111, 1.882, 2.1005, 2.4238, 2.5966,
0.3645, 0.512, 0.8977, 1.2209, 1.5286, 1.7204, 1.9787, 2.1779, 2.439, 2.6114,
0.2897, 0.4136, 0.5504, 0.8515, 1.2641, 1.4334, 1.8079, 2.0656, 2.3509, 2.7593,
0.1611, 0.4723, 0.742, 1.0071, 1.2571, 1.5891, 1.9224, 2.2345, 2.5647, 2.7991,
0.2528, 0.4178, 0.8909, 1.3117, 1.6622, 1.8641, 2.1017, 2.2974, 2.5299, 2.6982,
0.1749, 0.27, 0.4116, 0.6036, 1.143, 1.7776, 2.0394, 2.222, 2.4667, 2.6598,
0.3451, 0.4325, 0.6194, 0.7406, 0.9176, 1.554, 1.8426, 2.0479, 2.4401, 2.5965,
0.3672, 0.5164, 0.6558, 0.8441, 1.2332, 1.4114, 1.6955, 2.0875, 2.3674, 2.5471,
0.2194, 0.3467, 0.7384, 1.1079, 1.5398, 1.8437, 2.1212, 2.3296, 2.58, 2.7403,
0.1525, 0.2343, 0.3915, 0.6843, 1.0517, 1.502, 1.7905, 1.9667, 2.2027, 2.6725,
0.3531, 0.5908, 0.7462, 0.9441, 1.2774, 1.4743, 1.8268, 2.1059, 2.4478, 2.6484,
0.3611, 0.4981, 0.7598, 0.9676, 1.4024, 1.633, 1.9094, 2.1433, 2.4408, 2.613,
0.2153, 0.3366, 0.4974, 0.6693, 1.1944, 1.6791, 1.9002, 2.1105, 2.41, 2.5922,
0.2421, 0.3392, 0.5123, 0.9818, 1.5411, 1.7092, 1.9989, 2.1981, 2.5659, 2.7656,
0.2116, 0.325, 0.4845, 0.8021, 1.0088, 1.2158, 1.8038, 2.0223, 2.2975, 2.581,
0.1902, 0.2942, 0.8003, 1.1086, 1.3606, 1.6008, 1.8956, 2.1328, 2.4481, 2.6405,
0.2772, 0.3914, 0.5826, 0.7654, 0.9495, 1.124, 1.3949, 2.0411, 2.3891, 2.5959,
0.2678, 0.522, 0.763, 1.1, 1.3747, 1.6432, 1.9391, 2.2237, 2.5511, 2.7893,
0.32, 0.4245, 0.6174, 0.9904, 1.1662, 1.3882, 1.7601, 1.9524, 2.3998, 2.5819,
0.1702, 0.4871, 0.837, 1.0989, 1.3593, 1.583, 1.875, 2.1277, 2.4666, 2.6885,
0.228, 0.3748, 0.6554, 0.9113, 1.2081, 1.4619, 1.8181, 2.0541, 2.3791, 2.5701,
0.1752, 0.4363, 0.6454, 0.8798, 1.1079, 1.5367, 1.8667, 2.1716, 2.4804, 2.7249,
0.3804, 0.47, 0.8224, 1.0099, 1.1892, 1.5906, 1.8879, 2.0907, 2.4544, 2.6238,
0.1808, 0.291, 0.4683, 0.7059, 0.898, 1.4031, 1.7063, 1.9444, 2.4658, 2.6776,
0.2418, 0.3803, 0.5443, 0.7589, 1.1496, 1.3185, 1.5451, 1.7433, 2.131, 2.6523,
0.2698, 0.369, 0.5362, 1.0732, 1.2921, 1.4696, 1.744, 1.947, 2.5051, 2.6841,
0.4099, 0.5102, 0.6983, 1.0468, 1.2459, 1.4185, 1.8851, 2.0815, 2.3464, 2.5605,
0.0669, 0.1354, 0.3764, 0.8433, 1.1719, 1.4834, 1.8181, 2.1312, 2.4626, 2.8044,
0.1614, 0.2372, 0.3878, 0.5708, 1.2759, 1.495, 1.8052, 2.0807, 2.3485, 2.6293,
0.1688, 0.2875, 0.4301, 0.9059, 1.2361, 1.4054, 1.8057, 1.9924, 2.5589, 2.7495,
0.2864, 0.3783, 0.7032, 1.0817, 1.2382, 1.5741, 1.8619, 2.0656, 2.5139, 2.6848,
0.3829, 0.4781, 0.6766, 0.834, 1.0056, 1.4147, 1.665, 1.884, 2.3922, 2.5619,
0.3259, 0.4187, 0.6139, 0.7338, 1.1831, 1.6497, 1.9, 2.1278, 2.4322, 2.593,
0.2569, 0.379, 0.5426, 0.839, 0.9871, 1.485, 1.8652, 2.0732, 2.4314, 2.6005,
0.1408, 0.2283, 0.4024, 0.8784, 1.1485, 1.4003, 1.7004, 1.9205, 2.3723, 2.6522,
0.2971, 0.5039, 0.8005, 1.1212, 1.4232, 1.7801, 2.1255, 2.3907, 2.6795, 2.8487,
0.1515, 0.2344, 0.4684, 0.804, 1.0401, 1.3774, 1.8329, 2.1235, 2.5555, 2.777,
0.5778, 0.7157, 0.891, 1.0966, 1.4235, 1.6482, 1.9551, 2.1831, 2.4572, 2.6234,
0.3017, 0.4161, 0.8088, 0.9971, 1.2, 1.4419, 1.7867, 2.0224, 2.3473, 2.54,
0.1208, 0.2814, 0.6564, 0.9448, 1.2377, 1.5663, 1.9084, 2.2112, 2.5583, 2.8155,
0.2127, 0.3127, 0.4635, 0.6416, 0.8449, 1.6652, 2.0577, 2.2656, 2.5811, 2.7434,
0.1942, 0.3011, 0.4212, 0.6901, 1.5369, 1.7639, 1.9608, 2.1766, 2.4435, 2.6663,
0.351, 0.4345, 0.7146, 0.9086, 1.0678, 1.2579, 1.4425, 2.0265, 2.4574, 2.6252,
0.3225, 0.4323, 0.6168, 0.858, 1.5388, 1.791, 1.9927, 2.2013, 2.4494, 2.616,
0.2271, 0.4488, 0.6287, 0.7857, 1.2086, 1.383, 1.6194, 2.1955, 2.5236, 2.6945,
0.2568, 0.351, 0.5613, 1.05, 1.2521, 1.4359, 1.6995, 1.9187, 2.2148, 2.4275,
0.2933, 0.3941, 0.6128, 0.8899, 1.072, 1.2862, 1.5331, 1.8301, 2.1553, 2.3865,
0.348, 0.4626, 0.6009, 0.763, 0.9044, 1.1225, 1.8539, 2.1845, 2.5035, 2.7091,
0.1337, 0.4722, 0.8099, 1.1273, 1.4252, 1.699, 2.0188, 2.2922, 2.6018, 2.8168,
0.1138, 0.3263, 0.8059, 1.0473, 1.3262, 1.6202, 1.9439, 2.2007, 2.5347, 2.7702,
0.1979, 0.313, 0.4635, 0.8504, 1.1143, 1.3221, 2.0371, 2.2421, 2.5406, 2.7491,
0.3321, 0.4194, 0.8239, 1.0458, 1.1981, 1.3733, 1.5661, 1.9985, 2.3747, 2.5416,
0.3729, 0.5958, 0.9551, 1.265, 1.5484, 1.9255, 2.2256, 2.4809, 2.7276, 2.8935,
0.1664, 0.2516, 0.5347, 0.7545, 1.1971, 1.4089, 1.74, 2.0871, 2.4098, 2.6795,
0.237, 0.3178, 0.6123, 1.3315, 1.547, 1.7257, 2.0063, 2.1977, 2.5449, 2.7252,
0.203, 0.3328, 0.4766, 0.7357, 1.278, 1.4439, 1.7229, 1.9405, 2.2278, 2.6816,
0.1702, 0.2919, 0.4598, 0.7123, 0.9077, 1.145, 1.8632, 2.0806, 2.499, 2.71,
0.2421, 0.3578, 0.54, 0.7217, 0.8971, 1.4898, 1.8518, 2.1205, 2.6077, 2.7894,
0.303, 0.3935, 0.5812, 0.7404, 0.9425, 1.8342, 2.0887, 2.2811, 2.5596, 2.7118,
0.1322, 0.1997, 0.3466, 0.6981, 1.1811, 1.4849, 1.8594, 2.1114, 2.4708, 2.7804,
0.2317, 0.3069, 0.686, 1.4306, 1.7121, 1.8671, 2.1249, 2.2995, 2.5705, 2.7456,
0.3778, 0.4863, 0.6639, 0.9163, 1.156, 1.3186, 1.5389, 1.7169, 2.1603, 2.5797,
0.2118, 0.3499, 0.5259, 0.72, 1.1348, 1.314, 1.5657, 2.0241, 2.2873, 2.5184,
0.2902, 0.4368, 0.6331, 0.8971, 1.3102, 1.5219, 1.8674, 2.1512, 2.4708, 2.6809,
0.1418, 0.3988, 0.6251, 0.8544, 1.1268, 1.3964, 1.7585, 2.0322, 2.3964, 2.6928,
0.2314, 0.3462, 0.7282, 0.9211, 1.1766, 1.4941, 1.7368, 1.9546, 2.517, 2.7066,
0.2076, 0.3251, 0.7423, 0.959, 1.1936, 1.5329, 1.8887, 2.1588, 2.4667, 2.6709,
0.2058, 0.4139, 0.5745, 0.7832, 0.9595, 1.1688, 1.7561, 1.9562, 2.484, 2.7001,
0.1834, 0.2971, 0.4643, 0.6625, 0.8802, 1.1137, 1.5183, 1.8417, 2.3842, 2.7042,
0.1688, 0.4218, 0.707, 1.0465, 1.4496, 1.6953, 1.956, 2.2174, 2.5172, 2.7404,
0.2323, 0.3981, 0.5489, 0.7227, 1.2886, 1.5221, 1.7158, 2.1184, 2.4066, 2.5898,
0.347, 0.5265, 0.814, 1.0152, 1.3206, 1.5411, 1.849, 2.0588, 2.3556, 2.5393,
0.1707, 0.2595, 0.6762, 0.9037, 1.2781, 1.4903, 1.7946, 2.061, 2.3741, 2.5771,
0.1457, 0.2318, 0.6039, 1.0078, 1.3461, 1.5908, 1.8818, 2.1248, 2.4432, 2.6714,
0.6574, 0.8086, 1.0243, 1.2183, 1.4837, 1.7129, 2.0197, 2.2464, 2.5059, 2.6716,
0.2546, 0.4983, 0.8674, 1.2536, 1.6704, 1.9529, 2.2134, 2.4319, 2.6532, 2.8109,
0.2455, 0.3379, 0.4632, 0.8635, 1.5286, 1.8047, 1.9909, 2.1806, 2.4031, 2.5729,
0.4772, 0.6742, 1, 1.2474, 1.5288, 1.7415, 2.0102, 2.2168, 2.477, 2.6449,
0.3357, 0.4382, 0.6033, 1.1317, 1.3681, 1.5576, 1.9251, 2.1119, 2.5548, 2.7395,
0.2588, 0.7015, 0.8953, 1.083, 1.2828, 1.516, 1.8965, 2.1921, 2.515, 2.7258,
0.2466, 0.3512, 0.5047, 0.6646, 0.8161, 1.2577, 1.8046, 2.0214, 2.4447, 2.6491,
0.1631, 0.2283, 0.407, 0.5955, 1.1126, 1.3894, 1.8978, 2.1849, 2.5384, 2.7382,
0.3424, 0.4748, 0.6222, 0.802, 0.9706, 1.1568, 1.7044, 1.9297, 2.2127, 2.5627,
0.2088, 0.5143, 0.74, 0.9277, 1.1032, 1.3561, 1.8841, 2.2004, 2.5882, 2.7993,
0.2016, 0.3488, 0.5894, 0.7419, 1.1488, 1.3626, 1.5566, 1.9694, 2.5488, 2.7209,
0.2558, 0.3914, 0.536, 0.7521, 1.433, 1.6955, 1.8886, 2.1428, 2.419, 2.5966,
0.4021, 0.5034, 0.6653, 0.8123, 0.9586, 1.2825, 1.9184, 2.112, 2.409, 2.597,
0.2343, 0.48, 0.6934, 0.8523, 1.2786, 1.4763, 1.7235, 2.04, 2.3602, 2.5562,
0.246, 0.3687, 0.5325, 0.7044, 1.1488, 1.3608, 1.8112, 2.0757, 2.4183, 2.663,
0.1616, 0.3644, 0.5725, 0.9166, 1.2481, 1.4938, 1.8388, 2.1175, 2.4712, 2.7464,
0.376, 0.4841, 0.635, 1.0082, 1.211, 1.4003, 1.8127, 2.0018, 2.5199, 2.7238,
0.1988, 0.2824, 0.6553, 1.0337, 1.5413, 1.7369, 1.9751, 2.1751, 2.4372, 2.6265,
0.2728, 0.4094, 0.7498, 1.0645, 1.3516, 1.5946, 1.991, 2.2172, 2.483, 2.6614,
0.1657, 0.5327, 0.7281, 0.9966, 1.2385, 1.4629, 1.8119, 2.0973, 2.4469, 2.6979,
0.1413, 0.2098, 0.354, 0.5492, 0.8486, 1.1288, 1.632, 1.9056, 2.2805, 2.5438,
0.2856, 0.3666, 0.6259, 1.1424, 1.6605, 1.8197, 2.0147, 2.1986, 2.4121, 2.5919,
0.2725, 0.4829, 0.765, 1.0119, 1.2977, 1.5488, 1.8755, 2.1155, 2.4383, 2.6377,
0.2736, 0.3804, 0.5537, 1.0258, 1.2269, 1.4186, 1.9718, 2.1468, 2.5665, 2.7689,
0.2341, 0.5953, 1.103, 1.4549, 1.7361, 1.9758, 2.2126, 2.4213, 2.6405, 2.8181,
0.2273, 0.4638, 0.6228, 0.85, 1.1016, 1.2823, 1.7094, 1.9523, 2.2669, 2.7029,
0.2438, 0.3798, 0.7299, 0.96, 1.3765, 1.6104, 1.8644, 2.1161, 2.5073, 2.7137,
0.1551, 0.4869, 0.8676, 1.2274, 1.5069, 1.8857, 2.1868, 2.4411, 2.7106, 2.8767,
0.2746, 0.5454, 0.7589, 0.9458, 1.1597, 1.3349, 1.6653, 2.1142, 2.4356, 2.6239,
0.1793, 0.2646, 0.4344, 0.7482, 1.1502, 1.3733, 1.8558, 2.0817, 2.3248, 2.5171,
0.2698, 0.4202, 0.5765, 0.8301, 1.0073, 1.2101, 1.9714, 2.2051, 2.5138, 2.7395,
0.1929, 0.3091, 0.446, 0.6266, 1.1805, 1.3672, 1.599, 2.1514, 2.4729, 2.6468,
0.1901, 0.3047, 0.4607, 1.1019, 1.3168, 1.5343, 1.9234, 2.1365, 2.5924, 2.7807,
0.3139, 0.5009, 0.67, 0.8268, 1.0117, 1.181, 1.6539, 2.1984, 2.4828, 2.6576,
0.1403, 0.2173, 0.4117, 0.7302, 1.0038, 1.2732, 1.7392, 2.0337, 2.3809, 2.7386,
0.4166, 0.5101, 0.7449, 1.1663, 1.3492, 1.5543, 1.9, 2.0941, 2.4588, 2.6365,
0.3342, 0.4335, 0.616, 0.8559, 1.0112, 1.2097, 1.4029, 1.6361, 2.4129, 2.6324,
0.4543, 0.6159, 0.7932, 0.9843, 1.2562, 1.4308, 1.7116, 1.9919, 2.2671, 2.4631,
0.2153, 0.3609, 0.5302, 0.7089, 0.8756, 1.0376, 1.6496, 2.2826, 2.568, 2.7441,
0.438, 0.6439, 0.8282, 1.0651, 1.365, 1.5829, 1.8838, 2.1005, 2.4006, 2.5771,
0.2523, 0.3636, 0.5879, 1.1628, 1.3542, 1.6756, 2.0488, 2.2543, 2.6093, 2.7953,
0.4179, 0.5426, 0.7065, 0.8996, 1.0684, 1.3146, 1.9705, 2.2021, 2.5051, 2.7061,
0.1659, 0.286, 0.6693, 0.9229, 1.3959, 1.6544, 1.9709, 2.2257, 2.5236, 2.746,
0.254, 0.4356, 0.5946, 0.7627, 1.2274, 1.4222, 1.6573, 1.9601, 2.2514, 2.4711,
0.1633, 0.2337, 0.3698, 0.5421, 1.1757, 1.5916, 2.1561, 2.3371, 2.5534, 2.7737,
0.1953, 0.273, 0.4521, 1.2005, 1.7062, 1.8627, 2.1313, 2.3266, 2.5906, 2.7667,
0.3053, 0.4054, 0.5651, 0.747, 0.891, 1.172, 1.8864, 2.1074, 2.3705, 2.5744,
0.1761, 0.3033, 0.6501, 0.8268, 1.0369, 1.2687, 1.8534, 2.1889, 2.5074, 2.7339,
0.2265, 0.399, 1.1359, 1.4137, 1.6839, 1.8912, 2.0948, 2.3042, 2.5489, 2.7234,
0.3326, 0.54, 0.8711, 1.0948, 1.3752, 1.6155, 1.936, 2.1537, 2.4451, 2.6133,
0.2162, 0.3522, 0.5309, 0.747, 0.9677, 1.1747, 1.5056, 1.7942, 2.1615, 2.48,
0.1872, 0.2761, 0.4053, 0.7469, 1.5858, 1.8945, 2.1198, 2.3197, 2.5819, 2.7758,
0.5381, 0.8651, 1.2695, 1.4918, 1.7774, 1.9696, 2.1865, 2.3687, 2.5739, 2.7158,
0.2663, 0.3422, 0.6098, 1.212, 1.4516, 1.6092, 1.8506, 2.0376, 2.2929, 2.5088,
0.1904, 0.3051, 0.5663, 0.7391, 1.1589, 1.5705, 1.8756, 2.1653, 2.5518, 2.7693,
0.1543, 0.3519, 0.6976, 1.0664, 1.3696, 1.7817, 2.1308, 2.4259, 2.707, 2.8753,
0.3304, 0.4283, 0.5942, 0.7425, 0.8906, 1.4067, 2.0676, 2.246, 2.5394, 2.7006,
0.208, 0.3215, 0.6278, 0.7882, 1.3123, 1.5592, 1.8048, 2.0831, 2.4303, 2.6266,
0.1188, 0.2481, 0.827, 1.242, 1.5824, 1.8976, 2.1816, 2.4248, 2.6645, 2.8459,
0.0635, 0.1528, 0.5973, 0.9377, 1.2653, 1.5465, 1.8818, 2.1681, 2.5089, 2.7924,
0.3249, 0.5179, 0.9143, 1.2973, 1.4966, 1.755, 2.0715, 2.3166, 2.65, 2.8305,
0.1918, 0.3107, 0.4506, 0.6994, 1.3463, 1.5348, 1.8447, 2.1903, 2.448, 2.6877,
0.3405, 0.4644, 0.7232, 0.9199, 1.2611, 1.5175, 1.8446, 2.0652, 2.3915, 2.5781,
0.3289, 0.5152, 0.6602, 1.0213, 1.1886, 1.5496, 1.9553, 2.1883, 2.5394, 2.7362,
0.3, 0.4097, 0.8372, 1.0793, 1.3095, 1.5684, 1.8746, 2.0783, 2.3643, 2.549,
0.2421, 0.328, 0.5288, 0.9261, 1.6911, 1.8959, 2.1013, 2.2823, 2.5238, 2.696,
0.107, 0.3131, 0.6226, 0.8881, 1.1808, 1.4867, 1.8146, 2.1088, 2.4594, 2.7186,
0.44, 0.5533, 0.7025, 0.9206, 1.4089, 1.582, 1.808, 2.0832, 2.3577, 2.53,
0.225, 0.3434, 0.4808, 0.6721, 0.8198, 1.1446, 2.0201, 2.2625, 2.552, 2.7604,
0.1671, 0.2551, 0.4603, 0.6777, 0.9661, 1.5579, 1.8659, 2.1196, 2.4425, 2.6551,
0.391, 0.5877, 1.0287, 1.3547, 1.6899, 1.9166, 2.1451, 2.3337, 2.5519, 2.7071,
0.1435, 0.2165, 0.3968, 0.8376, 1.2572, 1.5298, 1.8791, 2.1352, 2.4636, 2.7011,
0.1756, 0.2799, 0.412, 0.5808, 0.7573, 1.334, 1.8235, 2.12, 2.4993, 2.7365,
0.1332, 0.2174, 0.4716, 0.9483, 1.2723, 1.6028, 1.9272, 2.219, 2.5588, 2.799,
0.2122, 0.3143, 0.7042, 0.8849, 1.1312, 1.3711, 1.6832, 1.9633, 2.2685, 2.5156,
0.2089, 0.3339, 0.4817, 0.8526, 1.0657, 1.2741, 1.5747, 1.8, 2.486, 2.6843,
0.1636, 0.2617, 0.44, 0.7357, 1.0355, 1.2638, 1.5672, 1.8504, 2.1904, 2.6588,
0.1945, 0.2934, 0.4869, 0.8567, 1.1262, 1.3604, 1.6898, 1.9143, 2.1475, 2.3503,
0.1606, 0.2442, 0.3931, 0.9237, 1.5811, 1.7529, 2.0133, 2.2272, 2.525, 2.7265,
0.4866, 0.7045, 1.0593, 1.2795, 1.5326, 1.8221, 2.1461, 2.3665, 2.6041, 2.7599,
0.4012, 0.4911, 0.7103, 0.8585, 1.0495, 1.7244, 2.0116, 2.2041, 2.5189, 2.6643,
0.4365, 0.6694, 0.8644, 1.133, 1.451, 1.7627, 2.1032, 2.369, 2.628, 2.8306,
0.2072, 0.4018, 0.6227, 0.8913, 1.3038, 1.6056, 1.9704, 2.2816, 2.6135, 2.8182,
0.3302, 0.4968, 0.8713, 1.0761, 1.2576, 1.4654, 1.8152, 2.14, 2.5404, 2.7493,
0.1385, 0.2292, 0.353, 0.6006, 1.4699, 1.6571, 1.9438, 2.1663, 2.5027, 2.7308,
0.1894, 0.2915, 0.4345, 0.6341, 1.0024, 1.1896, 1.6896, 2.0966, 2.4086, 2.6768,
0.3841, 0.5197, 0.8889, 1.148, 1.4383, 1.6285, 1.8642, 2.0669, 2.3466, 2.5325,
0.2008, 0.3097, 0.4664, 0.6638, 1.2798, 1.494, 1.727, 2.0264, 2.2915, 2.475,
0.1864, 0.2857, 0.4481, 1.1025, 1.3096, 1.5035, 1.7614, 1.9891, 2.4255, 2.6031,
0.4081, 0.6134, 0.9514, 1.1818, 1.3943, 1.6361, 1.9891, 2.2395, 2.5547, 2.7287,
0.2964, 0.3876, 0.945, 1.2247, 1.3906, 1.5882, 1.8241, 2.0589, 2.4188, 2.5871,
0.3127, 0.4038, 0.6168, 1.081, 1.3067, 1.4759, 1.8817, 2.0781, 2.3394, 2.5539,
0.2066, 0.3059, 0.4989, 0.7132, 0.9066, 1.446, 1.7584, 1.9755, 2.221, 2.4741,
0.2634, 0.3956, 0.5667, 0.8777, 1.0517, 1.6029, 2.059, 2.2607, 2.6064, 2.7647,
0.4331, 0.5315, 0.7764, 1.0444, 1.2269, 1.4311, 1.7093, 1.9187, 2.4337, 2.6149,
0.2161, 0.4429, 0.6851, 0.8336, 1.1037, 1.2966, 1.5283, 2.0299, 2.3407, 2.5384,
0.2814, 0.3637, 0.5416, 0.9475, 1.5137, 1.6945, 1.8892, 2.1017, 2.319, 2.5007,
0.4454, 0.6883, 1.1402, 1.4098, 1.7435, 2.0014, 2.2521, 2.4457, 2.6495, 2.7985,
0.1641, 0.4083, 0.6426, 1.0592, 1.3258, 1.5754, 1.8666, 2.1381, 2.4572, 2.7177,
0.3391, 0.4607, 0.6072, 0.8463, 1.4207, 1.6062, 1.8303, 2.0887, 2.3615, 2.5348,
0.2414, 0.3396, 0.51, 0.747, 1.3329, 1.8618, 2.0751, 2.2564, 2.5147, 2.6874,
0.1694, 0.2535, 0.4156, 0.8302, 1.2853, 1.5838, 2.0907, 2.3085, 2.5929, 2.7951,
0.2047, 0.3652, 0.65, 0.8068, 1.0178, 1.1865, 1.4889, 2.0671, 2.5966, 2.7634,
0.2425, 0.3247, 0.602, 1.2226, 1.4272, 1.5996, 1.8377, 2.0413, 2.5333, 2.7021,
0.3842, 0.503, 0.6541, 0.8771, 1.0576, 1.2612, 1.6744, 1.8735, 2.4781, 2.6803,
0.2042, 0.328, 0.7283, 0.8985, 1.1444, 1.3299, 1.6032, 2.1539, 2.4739, 2.6547,
0.1268, 0.1924, 0.3208, 0.5153, 1.1304, 1.4443, 1.8047, 2.0552, 2.4385, 2.7572,
0.2713, 0.3659, 0.5395, 1.0705, 1.4228, 1.5836, 1.9763, 2.1641, 2.4459, 2.6301,
0.3047, 0.4043, 0.5727, 0.7368, 0.8997, 1.3242, 1.6473, 1.8879, 2.433, 2.6295,
0.1224, 0.3948, 0.6903, 0.9199, 1.2852, 1.5516, 1.8645, 2.1231, 2.4657, 2.7044,
0.2157, 0.3281, 0.5036, 0.9272, 1.0975, 1.5285, 1.808, 2.0569, 2.5448, 2.7221,
0.167, 0.249, 0.3696, 0.5921, 1.3019, 1.8398, 2.2165, 2.3725, 2.6142, 2.8338,
0.3899, 0.5573, 0.81, 1.0732, 1.3966, 1.6598, 2.0001, 2.2517, 2.5548, 2.7403,
0.4905, 0.6064, 0.8222, 0.9966, 1.1912, 1.5714, 1.9628, 2.1727, 2.53, 2.7055,
0.1309, 0.2342, 0.6232, 0.8795, 1.1283, 1.3655, 1.7371, 2.0251, 2.3992, 2.6885,
0.1805, 0.2672, 0.4297, 1.244, 1.4967, 1.6796, 1.9592, 2.1784, 2.5439, 2.7289,
0.228, 0.5429, 0.6967, 0.8732, 1.4074, 1.6074, 1.9516, 2.2124, 2.5486, 2.7722,
0.2339, 0.3379, 0.4924, 0.9061, 1.3074, 1.4719, 1.8884, 2.111, 2.3618, 2.5545,
0.1384, 0.2291, 0.5127, 1.045, 1.4017, 1.7884, 2.1134, 2.3664, 2.6588, 2.8435,
0.2196, 0.6359, 0.91, 1.2007, 1.4589, 1.7053, 2.0128, 2.2722, 2.552, 2.7643,
0.1698, 0.2615, 0.381, 0.5706, 1.4297, 1.8686, 2.0728, 2.2559, 2.486, 2.6701,
0.1445, 0.2158, 0.3658, 0.5451, 0.9389, 1.3669, 1.79, 2.0846, 2.3924, 2.7161,
0.2789, 0.3816, 0.5277, 0.8487, 1.3751, 1.5461, 1.7832, 2.0264, 2.2695, 2.4665,
0.1733, 0.3023, 0.9216, 1.2368, 1.4776, 1.7229, 1.9952, 2.2471, 2.539, 2.7265,
0.3374, 0.5033, 1.0951, 1.3262, 1.5284, 1.7336, 1.9733, 2.2009, 2.4992, 2.6751,
0.1293, 0.2743, 0.7533, 1.0166, 1.2416, 1.4444, 1.7962, 2.0851, 2.477, 2.7204,
0.3106, 0.4176, 0.6358, 0.9434, 1.1419, 1.3458, 1.9638, 2.1678, 2.439, 2.6235,
0.4533, 0.576, 0.7392, 0.9136, 1.0829, 1.2759, 1.7903, 2.036, 2.3124, 2.5325,
0.3702, 0.5218, 0.6977, 0.8776, 1.1096, 1.2855, 1.5612, 1.948, 2.217, 2.4361,
0.1637, 0.2647, 0.4185, 0.6666, 1.1584, 1.327, 1.7829, 1.9821, 2.4361, 2.7094,
0.1769, 0.2767, 0.3942, 0.5746, 1.3595, 1.711, 1.9176, 2.1405, 2.3722, 2.5705,
0.2712, 0.382, 0.6524, 0.8317, 1.0341, 1.3972, 1.7312, 1.9918, 2.3854, 2.5886,
0.1003, 0.2046, 0.7261, 1.1004, 1.4057, 1.6697, 1.9903, 2.2603, 2.5813, 2.8009,
0.2534, 0.3752, 0.7192, 0.9323, 1.3698, 1.5955, 1.8653, 2.0656, 2.3368, 2.534,
0.3589, 0.4508, 0.6631, 1.0521, 1.5065, 1.6697, 1.8929, 2.1074, 2.3466, 2.5242,
0.1955, 0.2862, 0.6111, 0.8053, 1.0501, 1.5218, 1.7996, 2.0303, 2.3788, 2.5973,
0.2982, 0.4033, 0.566, 0.8924, 1.1933, 1.3465, 1.7895, 2.0173, 2.2606, 2.5069,
0.3356, 0.4711, 0.631, 0.8491, 1.0049, 1.4364, 1.8176, 2.0292, 2.571, 2.7525,
0.2016, 0.2912, 0.4363, 0.98, 1.4897, 1.6494, 1.8862, 2.0819, 2.3636, 2.6091,
0.4549, 0.6491, 0.845, 1.0209, 1.1747, 1.3745, 1.8824, 2.113, 2.376, 2.5768,
0.251, 0.3524, 0.5171, 0.8931, 1.4094, 1.571, 1.8536, 2.0478, 2.4766, 2.732,
0.1576, 0.2547, 0.3891, 0.8551, 1.4282, 1.588, 1.8583, 2.0521, 2.5359, 2.734,
0.3481, 0.4382, 0.772, 1.1289, 1.3203, 1.5019, 1.7665, 1.957, 2.2231, 2.4465,
0.3116, 0.4068, 0.6991, 0.8894, 1.0912, 1.5356, 1.8084, 2.0006, 2.2323, 2.4367,
0.2706, 0.4033, 0.8272, 1.0851, 1.482, 1.6927, 1.9292, 2.1267, 2.4049, 2.5857,
0.2745, 0.355, 0.8663, 1.3742, 1.5545, 1.7324, 1.9664, 2.1538, 2.4581, 2.6245,
0.1736, 0.2553, 0.5357, 0.9009, 1.1888, 1.5132, 1.8579, 2.1181, 2.4273, 2.6847,
0.3026, 0.4148, 0.9044, 1.1695, 1.3657, 1.7036, 1.9891, 2.2226, 2.5441, 2.7085,
0.3998, 0.5108, 0.7205, 0.9848, 1.1828, 1.3716, 1.7154, 1.9191, 2.1875, 2.4257,
0.2141, 0.3095, 0.7428, 1.0426, 1.2851, 1.5571, 1.7901, 1.9804, 2.2462, 2.5265,
0.1574, 0.229, 0.3869, 0.5735, 1.0925, 1.3383, 1.6598, 1.9364, 2.2095, 2.4195
};
/* codebook/lspvqanssi2.txt */
static const float codes1[] = {
0.012, 0.0022, 0.0068, -0.0112, -0.0508, -0.049, 0.2249, 0.1476, 0.0133, -0.0379,
0.0598, 0.0477, 0.038, 0.066, 0.0517, 0.015, 0.0617, 0.0081, -0.0768, -0.1007,
-0.0087, -0.044, 0.0873, 0.0882, 0.0391, -0.006, 0.11, 0.0569, -0.0241, -0.0468,
0.0146, -0.0005, 0.0322, -0.065, -0.0778, -0.078, -0.0255, -0.0527, -0.0301, -0.0401,
-0.024, -0.056, -0.0374, 0.0274, 0.0484, -0.0227, 0.0328, 0.1135, 0.0117, -0.03,
-0.0324, -0.0574, 0.0302, 0.0137, -0.0603, -0.1194, -0.0105, -0.0513, 0.0698, 0.0538,
0.0635, 0.0382, 0.0531, 0.0897, 0.0495, 0.0039, -0.0421, -0.0919, 0.0407, 0.0167,
0.0954, 0.0854, 0.036, -0.0025, -0.0252, -0.0528, -0.0435, -0.0561, -0.0405, -0.0432,
0.011, -0.001, -0.0433, -0.0167, 0.1402, 0.0738, 0.0423, -0.0024, -0.092, -0.1099,
0.0179, 0.0184, -0.0041, -0.064, 0.1004, 0.0608, -0.0023, -0.0357, 0.1509, 0.1262,
-0.0145, -0.024, -0.0595, -0.1063, 0.0597, -0.004, -0.0886, 0.1184, 0.038, 0.0126,
-0.0072, 0.0172, 0.0076, 0.0288, 0.081, 0.0278, 0.0709, 0.0051, 0.0214, -0.0301,
0.0127, -0.0126, -0.0434, 0.161, 0.1178, 0.0704, 0.0257, -0.0073, -0.0425, -0.061,
-0.0165, -0.0369, -0.0785, 0.1007, 0.0309, -0.0651, 0.0142, -0.0614, 0.0426, 0.0289,
-0.0374, -0.0712, 0.0049, -0.0382, 0.0472, 0.0095, -0.0268, -0.0747, -0.0457, -0.0758,
-0.0211, -0.0432, -0.0547, -0.0446, -0.1078, 0.009, -0.0565, -0.1298, 0.0721, 0.0351,
-0.0014, -0.0072, -0.0283, -0.0324, -0.0208, -0.0703, 0.0979, 0.0865, -0.0007, 0.1881,
-0.0077, -0.0302, 0.1231, 0.0905, 0.0786, 0.0432, -0.0286, -0.0661, -0.0055, -0.0275,
0.001, 0.0043, 0.0044, 0.038, -0.1201, -0.0098, -0.0166, 0.0105, 0.0153, 0.0134,
0.0843, 0.0636, 0.0416, -0.0004, -0.057, -0.0592, 0.1158, 0.059, 0.0126, 0.0034,
0.0346, 0.029, -0.0037, -0.0026, -0.0457, 0.1824, 0.1469, 0.087, 0.0291, -0.0074,
0.0066, 0.0682, -0.0148, 0.0287, 0.0095, -0.0563, 0.1296, 0.0426, 0.1215, 0.0886,
-0.0132, -0.0399, 0.096, 0.0474, 0.014, 0.0306, -0.0192, -0.0703, -0.1559, -0.1556,
-0.06, 0.0482, 0.1257, 0.0521, 0.0229, -0.0031, 0.0817, 0.0571, -0.0138, -0.0277,
0.0013, -0.0103, -0.047, -0.0687, -0.1444, 0.0181, 0.135, 0.0559, -0.0177, -0.0598,
-0.0215, -0.0318, -0.0689, -0.0268, 0.0917, 0.0307, 0.0135, -0.0184, -0.0857, 0.1231,
0.0137, -0.0152, 0.0199, -0.0291, -0.0685, 0.0438, -0.1137, 0.0231, -0.0632, -0.0802,
-0.0011, 0.0314, 0.0535, -0.0135, -0.0291, -0.0579, -0.1049, 0.0288, -0.0628, 0.1355,
-0.0901, 0.0041, -0.017, 0.0351, 0.0144, -0.0505, 0.0396, 0.0638, -0.0145, 0.0141,
-0.04, -0.0603, -0.0714, 0.0329, -0.0049, -0.0529, -0.1251, 0.0022, -0.0449, -0.0778,
0.0247, 0.0296, 0.0239, 0.0122, -0.0348, -0.1224, -0.0033, 0.1237, -0.0016, -0.0436,
0.0246, 0.005, 0.0322, 0.0818, 0.0203, 0.0846, 0.0022, 0.0876, 0.0149, -0.0184,
-0.0204, -0.0228, 0.0365, -0.0164, 0.1087, 0.0374, -0.055, 0.033, -0.0582, -0.0736,
-0.0305, -0.0485, -0.0572, 0.0275, -0.0271, -0.0436, 0.1217, 0.07, 0.1253, 0.099,
-0.0079, -0.0204, -0.0325, 0.0491, 0.0158, -0.0365, -0.1309, -0.1812, 0.1428, 0.1148,
0.068, 0.0547, 0.0309, 0.0079, -0.0332, 0.0391, -0.0287, 0.1258, 0.1123, 0.1016,
-0.0264, -0.0409, -0.0538, -0.0192, -0.0393, -0.0713, -0.0618, -0.1078, -0.185, 0.0532,
0.0081, -0.0115, -0.009, 0.1201, -0.0413, -0.0995, 0.0445, -0.0032, -0.0286, -0.0497,
-0.0023, -0.0184, -0.0358, 0.1279, 0.0847, 0.053, 0.023, -0.0212, 0.1245, 0.0965,
0.0111, 0.1038, 0.0597, 0.0413, 0.0533, 0.0011, 0.0031, 0.0705, 0.0242, 0.0198,
0.002, -0.0071, -0.0262, -0.0496, -0.075, -0.1273, -0.1785, 0.0606, -0.0223, -0.0583,
-0.0202, 0.0669, 0.0081, 0.0335, -0.0218, -0.1073, -0.0146, -0.0673, 0.049, 0.021,
-0.0108, -0.023, -0.0614, -0.0986, 0.0629, 0.0006, 0.1496, 0.1099, 0.0316, 0.0098,
-0.0368, -0.0685, 0.0138, -0.0213, -0.0009, 0.0344, -0.0249, 0.0311, 0.0803, 0.0759,
0.0038, -0.0158, 0.0142, 0.0254, 0.097, 0.0021, -0.1029, 0.0006, 0.0576, 0.0261,
-0.0083, 0.0698, 0.0406, -0.0348, 0.02, 0.0833, 0.0186, -0.0145, -0.0725, -0.0872,
-0.0506, -0.0673, 0.0776, -0.0172, -0.0444, -0.0531, -0.0799, 0.0005, -0.0359, -0.0446,
0.0368, 0.0376, -0.0407, -0.019, 0.0987, 0.0212, -0.0349, -0.0951, -0.0084, -0.0342,
-0.0309, -0.0561, 0.095, -0.0125, -0.1028, -0.0133, 0.092, 0.0965, 0.0668, 0.0409,
-0.0898, 0.0036, -0.0353, -0.0024, -0.0365, -0.0259, -0.0485, -0.0843, -0.0063, -0.0167,
-0.0255, -0.0407, -0.0456, -0.0931, -0.0892, -0.0293, -0.051, 0.0183, -0.0104, 0.0472,
-0.0172, -0.0399, -0.0731, 0.0546, 0.032, -0.0283, 0.0415, -0.0107, -0.1237, -0.1102,
0.021, 0.0294, -0.0038, -0.009, -0.0551, -0.0922, 0.0261, -0.0334, -0.1181, -0.1536,
0.0092, 0.0032, -0.0162, 0.0398, 0.0205, 0.1266, -0.0107, -0.0858, 0.0392, 0.0032,
-0.0038, -0.0269, -0.0737, 0.1138, 0.0263, -0.0031, -0.1188, 0.1621, 0.0831, 0.0526,
0.0023, -0.0149, -0.0497, 0.0898, 0.0456, -0.0145, -0.0928, -0.1507, -0.0611, -0.0938,
0.012, 0.0124, -0.0286, -0.1319, 0.0219, 0.0311, -0.0398, -0.0465, -0.0008, -0.0375,
0.0138, 0.0023, 0.0024, 0.1072, 0.0531, 0.0006, 0.0292, -0.0115, -0.062, 0.165,
0.007, -0.0251, 0.0715, 0.038, -0.0404, 0.123, 0.0629, 0.0096, 0.0973, 0.0641,
-0.0586, 0.0772, 0.0128, 0.106, 0.0715, 0.0374, -0.0074, -0.0365, -0.0543, -0.0489,
-0.0392, 0.0871, -0.0069, -0.1084, 0.0264, -0.0495, 0.0396, 0.0005, -0.0293, -0.024,
-0.0327, 0.0605, 0.0662, 0.01, -0.0007, -0.0525, -0.0812, -0.0686, -0.0873, -0.083,
0.0119, 0.0058, 0.003, -0.0307, 0.065, 0.0175, -0.0741, -0.15, -0.1947, 0.0881,
0.0572, 0.0411, 0.0152, -0.0127, -0.0589, -0.051, -0.0212, -0.0834, 0.1434, 0.1318,
0.0518, 0.0417, -0.043, 0.0963, -0.0014, 0.0173, 0.0234, -0.0273, 0.0359, -0.0118,
0.0652, 0.0587, 0.0013, -0.07, 0.1262, 0.0975, 0.068, 0.0598, 0.0048, -0.0305,
-0.0185, -0.044, 0.1178, 0.0656, 0.0052, -0.0534, -0.1151, 0.1116, 0.0659, 0.0344,
0.0788, 0.0577, 0.0452, 0.0283, -0.0278, 0.0911, 0.028, -0.0254, 0.0029, -0.0361,
-0.0165, -0.0322, -0.0526, -0.1057, 0.0927, 0.0293, -0.1026, -0.1671, 0.047, 0.0355,
0.01, 0.0001, -0.0221, -0.0775, -0.1109, -0.1416, 0.0884, 0.0441, 0.0632, 0.0409,
0.0204, 0.0432, 0.0141, -0.0296, 0.1073, 0.058, 0.0383, 0.027, -0.0857, 0.1246,
0.0488, 0.0231, 0.0648, -0.0179, 0.0747, 0.0156, -0.0384, -0.0733, -0.0732, -0.097,
0.0005, -0.0199, -0.026, -0.0511, -0.111, 0.067, -0.0413, 0.1571, 0.0498, 0.0191,
0.0037, -0.0085, -0.0796, 0.0086, -0.0852, 0.085, 0.0115, -0.0065, 0.1161, 0.0727,
0.0023, 0.0483, 0.0285, -0.0642, -0.0477, 0.0175, 0.0346, 0.0452, 0.0655, 0.0284,
-0.0986, 0.0463, 0.0326, -0.0055, 0.0702, 0.0194, -0.0423, -0.0107, 0.0338, 0.0619,
0.0126, -0.0138, -0.1115, 0.0159, -0.0331, 0.0217, -0.0376, -0.0407, -0.0222, -0.0503,
0.0222, 0.0071, -0.049, 0.1017, 0.0551, -0.0164, 0.1578, 0.1059, 0.0025, -0.0107,
0.0124, -0.009, 0.0322, 0.093, 0.0281, -0.0403, -0.0781, 0.0125, -0.067, -0.1058,
0.0363, 0.0077, 0.1052, 0.0039, 0.0676, 0.0891, 0.0433, 0.0252, 0.0224, -0.0043,
-0.0045, -0.0194, -0.0193, -0.048, -0.064, -0.0695, -0.1597, -0.003, 0.1728, 0.1231,
0.0297, 0.0025, 0.0619, -0.0347, -0.1171, 0.1043, 0.0868, 0.0191, -0.0739, -0.1075,
0.0073, 0.0914, 0.0367, -0.0236, 0.0232, 0.0304, -0.0787, -0.1099, 0.046, 0.0082,
0.0296, 0.0297, -0.0444, 0.0184, 0.0602, -0.0295, -0.0934, 0.0636, -0.0347, -0.0722,
-0.029, -0.0629, 0.0598, 0.0013, 0.0064, 0.1431, 0.092, 0.0468, -0.0311, -0.0614,
-0.0152, -0.0311, -0.05, -0.0672, -0.1257, -0.0134, -0.022, -0.0612, -0.1131, -0.1417,
0.0371, 0.0153, -0.0817, -0.0007, 0.0837, 0.0481, 0.046, 0.0678, 0.0524, 0.0432,
0.0126, -0.0069, -0.0092, -0.0693, -0.025, 0.151, 0.0098, -0.0683, -0.0566, -0.0769,
-0.0199, -0.0423, 0.0806, 0.0562, 0.0009, -0.0563, -0.1358, -0.1578, -0.0456, 0.0032,
0.0091, 0.0101, -0.009, -0.0279, -0.0489, -0.1038, -0.0815, 0.2184, 0.1172, 0.0902,
-0.0024, -0.0135, 0.0392, 0.0028, 0.0792, 0.0404, 0.0867, 0.161, 0.0954, 0.0846,
-0.0004, -0.022, -0.0282, -0.1022, -0.0799, 0.1278, 0.0765, 0.0402, 0.085, 0.0611,
0.0443, 0.032, -0.0384, -0.0964, 0.003, -0.0398, -0.073, -0.0052, -0.0267, 0.1209,
-0.0706, 0.1151, 0.0722, -0.0175, -0.0927, -0.0559, 0.0316, 0.0186, 0.0105, 0.0314,
-0.0145, -0.0263, -0.0564, 0.0248, -0.0181, -0.0817, -0.0938, 0.0366, -0.0315, 0.1253,
0.0307, 0.0039, 0.129, 0.0402, -0.0439, -0.0384, 0.0044, -0.0177, -0.0172, -0.031,
0.0447, 0.0298, 0.0287, 0.0273, -0.035, -0.0708, -0.1829, -0.0317, 0.0643, 0.0057,
-0.082, -0.0326, 0.0209, -0.0711, 0.0084, 0.0111, 0.0426, 0.0262, -0.0061, 0.0005,
0.0545, 0.0377, -0.0417, -0.0625, 0.0114, -0.0405, 0.0573, 0.0191, -0.0263, -0.0472,
-0.0053, -0.0049, -0.0255, -0.0578, -0.0237, -0.0721, -0.1487, -0.1636, 0.0046, -0.0355,
0.0309, 0.0107, 0.0163, 0.0132, -0.0536, -0.0009, -0.0706, -0.135, -0.0514, -0.096,
0.0306, 0.0003, 0.0494, 0.0701, 0.0027, -0.0458, 0.078, 0.0327, 0.0937, 0.0605,
-0.0017, -0.0275, 0.0797, -0.0268, -0.1014, 0.0593, -0.0528, -0.1103, 0.0682, 0.0322,
-0.0507, -0.0806, -0.0646, -0.0052, -0.0576, 0.0451, 0.0489, 0.015, 0.0029, -0.0189,
0.027, 0.0143, -0.0375, -0.0071, -0.0607, -0.1157, -0.0345, -0.1115, 0.0201, -0.0104,
-0.0807, -0.1088, 0.0845, 0.072, 0.0441, 0.0301, 0.0043, 0.0052, 0.0016, 0.0201,
-0.029, -0.0532, 0.0036, -0.0201, -0.0723, -0.1321, 0.0867, 0.0479, -0.0556, -0.085,
-0.0271, 0.0126, 0.1283, 0.0533, -0.003, -0.0352, -0.0326, -0.0553, 0.1402, 0.1121,
-0.0358, -0.0518, -0.108, 0.0134, 0.095, 0.0384, -0.004, -0.0254, 0.0026, -0.0217,
-0.0152, -0.0375, -0.0827, 0.0916, 0.0188, 0.1306, 0.0983, 0.0606, 0.0381, 0.008,
-0.0107, -0.0269, -0.0573, -0.1189, 0.0258, 0.1009, 0.0565, 0.027, -0.0557, -0.0778,
-0.0193, -0.0242, -0.0784, -0.0816, 0.0287, -0.0484, 0.0292, -0.0414, 0.1124, 0.0767,
0.0177, -0.0148, 0.0472, -0.0808, 0.0623, -0.0636, 0.075, -0.0107, 0.0673, 0.0425,
-0.022, 0.0577, -0.0769, -0.0247, -0.0321, 0.0341, -0.0108, 0.0109, -0.0142, 0.0122,
0.0194, 0.0248, -0.0096, -0.0205, -0.046, -0.116, 0.0492, -0.0188, -0.1535, 0.0816,
0.0301, -0.0286, -0.0077, -0.0117, -0.0036, -0.0026, 0.0133, -0.0032, 0.0007, -0.016,
0.0115, -0.0111, 0.0246, -0.0639, 0.0325, -0.0313, 0.0808, 0.0435, -0.0777, -0.1108,
-0.0079, -0.0334, -0.0144, -0.0539, 0.1564, 0.1175, 0.0549, 0.034, 0.0319, 0.0027,
-0.0155, -0.0275, -0.0739, -0.0932, 0.0108, -0.0698, 0.0036, -0.0213, -0.0486, -0.067,
-0.0234, -0.0567, 0.002, 0.0908, -0.0151, 0.046, -0.0175, -0.0523, 0.0098, -0.0237,
0.0057, -0.0066, -0.0418, 0.0418, -0.0449, 0.1069, 0.0629, -0.0016, -0.1068, -0.1492,
-0.0791, 0.0403, -0.0009, 0.0285, -0.0065, 0.0963, 0.055, 0.0634, 0.0693, 0.0694,
-0.0068, -0.0197, -0.0919, 0.0071, -0.0551, -0.1173, 0.0926, 0.0413, 0.0127, -0.0158,
0.054, 0.0389, -0.0195, -0.08, -0.1383, 0.044, -0.0139, -0.0405, 0.0147, -0.0183,
0.038, 0.0248, 0.052, -0.0609, 0.0339, -0.007, -0.0974, 0.1182, 0.0221, -0.031,
0.0043, 0.0046, -0.0274, -0.0502, 0.0326, -0.0143, -0.0586, -0.0866, -0.1673, -0.1624,
0.0428, 0.0385, -0.0228, 0.0704, 0.0069, -0.0145, -0.0623, -0.0639, -0.1479, 0.0212,
-0.0078, -0.0297, 0.0025, -0.0239, -0.0793, 0.0896, 0.0315, -0.0546, -0.1309, 0.108
};
/* codebook/lspvqanssi3.txt */
static const float codes2[] = {
-0.0291, 0.0272, -0.0364, -0.0313, -0.0487, -0.0205, 0.0501, 0.0225, 0.0178, 0.008,
-0.0406, -0.0383, 0.0013, -0.0155, -0.0261, -0.0598, 0.0003, -0.0242, 0.0151, -0.014,
-0.0445, 0.0356, 0.018, -0.0272, -0.0018, -0.0177, -0.0703, 0.0471, 0.0128, -0.0068,
-0.0033, -0.0285, -0.056, -0.0186, -0.0499, -0.007, 0.0068, -0.0126, 0.0388, -0.0097,
-0.0071, -0.0114, -0.0308, -0.0094, -0.0541, -0.0272, -0.0756, 0.0477, -0.0234, 0.0678,
0.0048, 0.0307, -0.0174, -0.0593, 0.0097, -0.0134, 0.0034, -0.0212, -0.0418, 0.0869,
-0.0189, 0.0165, -0.0269, 0.0744, 0.0344, -0.0177, -0.0603, 0.0212, -0.0104, 0.0345,
-0.013, -0.0352, -0.0086, -0.0257, -0.0286, 0.0409, 0.0656, 0.0106, -0.0598, 0.0252,
0.0041, 0.0097, -0.0032, -0.0154, -0.0405, 0.067, -0.0164, 0.0451, 0.0774, 0.0504,
0.001, -0.0091, -0.0345, 0.0511, 0.0016, 0.0011, 0.0684, 0.0167, 0.0601, 0.0512,
0.0204, -0.0038, -0.0426, 0.0185, -0.0191, -0.063, 0.0295, -0.0153, -0.0559, 0.056,
-0.0461, -0.0041, 0.0515, 0.0219, 0.0322, 0.0093, 0.0044, 0.0106, -0.0329, -0.0521,
0.0304, 0.0017, 0.0209, -0.0002, 0.0689, 0.0136, 0.0216, -0.0268, -0.0682, 0.0333,
-0.0175, -0.0425, 0.0153, -0.005, -0.0113, 0.0297, -0.0659, -0.0344, 0.0302, -0.0272,
-0.0217, -0.0362, 0.0426, 0.0233, -0.0393, 0.0052, 0.0138, 0.0657, 0.0427, 0.022,
-0.0039, -0.0011, -0.0002, -0.0453, -0.0835, 0.0144, -0.0268, -0.0589, -0.0185, 0.0133,
0.0081, -0.0032, 0.0638, 0.0032, 0.006, 0.0002, -0.0303, -0.0823, 0.0124, -0.0308,
0.0108, 0.0011, 0.0059, 0.0396, 0.0392, 0.0351, -0.0045, -0.0323, -0.0512, -0.0975,
-0.0144, -0.0306, -0.0302, -0.007, 0.0123, -0.0042, -0.0083, -0.0514, 0.012, 0.1116,
-0.0046, -0.0131, 0.0472, 0.0144, -0.0296, -0.0518, 0.0337, -0.0145, -0.0733, 0.0793,
-0.0064, -0.0162, -0.0327, -0.0711, 0.0108, -0.0131, 0.0025, -0.0254, -0.0277, -0.068,
-0.0306, 0.0055, 0.0272, -0.0189, -0.0173, 0.0221, 0.0773, 0.0043, 0.0458, -0.0169,
-0.0006, 0.0299, 0.0259, 0.0227, -0.053, -0.0596, -0.0271, -0.0091, 0.0181, -0.0233,
-0.0116, -0.0398, 0.0089, 0.0708, -0.0028, -0.0084, -0.0206, -0.0354, -0.0275, -0.0037,
0.0259, -0.0064, -0.038, 0.0572, 0.0083, 0.0286, -0.0565, 0.0158, 0.0396, -0.0123,
0.0552, 0.0331, -0.0052, -0.0346, -0.018, -0.0194, -0.0237, 0.0184, 0.0056, -0.0199,
0.0143, 0.0131, -0.0166, 0.0196, 0.0154, 0.031, -0.0048, 0.0901, -0.0333, 0.0761,
0.0118, -0.0107, 0.0099, 0.0078, 0.0002, -0.0716, -0.0233, 0.0793, 0.0516, 0.03,
0.0204, 0.0243, 0.0192, 0.0181, 0.0001, -0.0243, -0.0764, -0.0622, -0.0324, 0.064,
0.0132, 0.0016, -0.0187, -0.0425, 0.0627, 0.0094, -0.0786, 0.0304, 0.0294, -0.0146,
-0.0221, -0.0154, 0.0285, -0.0709, 0.0406, 0.0114, 0.0073, -0.0199, 0.0081, 0.0268,
0.0227, 0.0055, 0.0163, -0.0447, 0.0246, 0.0795, 0.0239, 0.0211, -0.0145, -0.0576,
-0.0119, 0.0637, 0.0278, 0.0202, -0.0086, 0.0389, 0.032, -0.0049, -0.0272, -0.0274,
0.004, -0.0211, 0.0426, 0.048, 0.0415, 0.0659, 0.0408, 0.0198, 0.0327, 0.0029,
0.043, 0.0311, 0.0083, 0.0353, 0.025, 0.0143, 0.0106, -0.0305, 0.0633, 0.0227,
-0.0277, 0.0302, 0.0337, 0.0176, 0.0191, -0.0156, 0.0231, 0.0118, 0.0465, 0.0875,
0.0221, 0.0146, 0.0147, -0.0211, -0.0317, -0.0179, -0.0049, -0.0297, -0.1078, -0.0413,
-0.0531, 0.018, -0.0066, 0.0365, -0.0033, 0.009, -0.0158, -0.0698, 0.0315, -0.0048,
0.0289, 0.0053, 0.0082, 0.0077, -0.0664, 0.0474, 0.0407, -0.0096, 0.0028, -0.0526,
-0.0106, -0.0129, -0.0315, 0.0335, -0.0217, -0.0427, 0.0582, 0.0193, -0.0288, -0.0777,
-0.0003, -0.0141, -0.0102, 0.0007, -0.0077, -0.0517, -0.0909, 0.0128, -0.0349, -0.0769,
-0.0227, -0.0159, -0.0327, 0.0011, 0.0312, 0.01, -0.018, -0.0537, -0.0997, 0.0122,
0.019, -0.0139, 0.0341, -0.0131, -0.0368, -0.0138, -0.0074, -0.0415, 0.0791, 0.0503,
0.0182, 0.0027, 0.0032, -0.0325, -0.0309, -0.0898, 0.0509, -0.017, 0.0301, -0.0137,
0.0233, 0.01, 0.0231, 0.073, 0.0212, -0.0299, 0.044, 0.0041, -0.0101, -0.0251,
0.0074, -0.0033, -0.0285, -0.035, 0.0101, 0.0735, 0.0036, -0.0659, 0.0429, -0.0052,
0.0148, -0.0035, -0.0233, 0.0079, -0.0142, -0.0402, -0.0358, -0.0985, -0.008, -0.0549,
0.0203, 0.0057, -0.0604, 0.0098, 0.0402, 0.0151, 0.05, 0.0058, -0.0086, -0.0401,
0.0056, -0.0381, 0.042, -0.0125, 0.0157, -0.0268, 0.0433, 0.0123, -0.0176, -0.0685,
0.003, 0.0502, 0.0067, -0.0222, 0.0405, -0.0226, 0.002, -0.0401, -0.0026, -0.0521,
0.0317, 0.0089, 0.062, 0.0251, 0.0066, 0.0089, -0.0565, 0.0414, 0.0005, -0.0365,
-0.0058, 0.0086, -0.0291, -0.0164, -0.0134, -0.049, -0.0427, -0.0451, 0.0869, 0.0334,
0.0024, 0.0328, -0.0415, 0.0003, -0.0287, 0.0193, -0.0547, -0.0222, -0.0196, -0.0571,
-0.0271, -0.0397, -0.0431, -0.0043, 0.0332, 0.0093, 0.0082, 0.0585, 0.0282, 0.0004,
-0.0251, -0.0167, -0.0289, 0.0196, -0.0363, 0.085, 0.0028, 0.0319, -0.0202, -0.0512,
0.0389, 0.0226, 0.0401, -0.0091, -0.0152, 0.0001, 0.0738, 0.0402, 0.0097, 0.031,
-0.0126, 0.013, -0.0046, -0.0216, 0.0298, -0.0344, 0.0713, 0.0547, -0.047, -0.0294,
0.0125, 0.0044, -0.0028, 0.0209, -0.02, 0.0854, 0.0018, -0.0386, -0.0703, 0.0778,
-0.0036, -0.0347, 0.0309, -0.0184, 0.029, -0.0025, -0.0644, 0.0347, -0.0523, 0.0644,
0.0064, 0.0295, -0.0017, 0.0282, 0.0176, 0.0027, 0.0246, 0.0967, 0.0401, -0.0231,
0.0054, -0.0109, 0.0055, -0.0479, -0.049, -0.0136, -0.0245, 0.0839, 0.0026, -0.0493,
0.0128, -0.005, -0.0219, -0.0621, 0.0313, 0.0019, 0.0696, 0.0459, 0.0574, 0.0299,
-0.0091, -0.029, -0.0068, 0.0276, 0.0645, -0.015, 0.0015, -0.0374, 0.0415, -0.0124,
-0.0171, 0.0177, -0.0138, 0.0034, 0.084, 0.0584, 0.0233, 0.01, 0.0122, 0.0047
};
/* codebook/lspvqanssi4.txt */
static const float codes3[] = {
0.0221, -0.0035, -0.0032, -0.0177, -0.0327, 0.0518, -0.011, -0.015, -0.0136, -0.0327,
0.0099, -0.0059, 0.0031, -0.0174, 0.0464, -0.024, 0.0251, -0.027, 0.0454, -0.0082,
-0.0029, 0.0025, -0.0267, -0.0318, -0.0157, 0.0173, 0.0253, 0.0063, -0.0481, 0.0419,
-0.0332, -0.0179, -0.0042, 0.0241, 0.0044, -0.0098, -0.0081, 0.0024, -0.0414, 0.0339,
-0.006, 0.0182, -0.0051, -0.0479, 0.0016, -0.0179, 0.0316, 0.0222, -0.0029, -0.0351,
0.0074, 0.0015, 0.0337, -0.0082, -0.0008, 0.0129, 0.0001, 0.065, 0.0175, 0.0309,
-0.0212, -0.0261, 0.0196, -0.0309, 0.0093, -0.0272, 0.026, 0.0169, 0.0132, 0.0116,
-0.001, 0.0202, 0.0228, -0.0227, -0.0141, 0.0192, -0.0423, -0.0097, -0.0342, 0.0338,
-0.0149, -0.011, -0.0156, 0.029, 0.0028, 0.0123, -0.035, -0.0501, 0.0272, -0.0245,
-0.0005, -0.0194, 0.046, -0.0001, -0.028, 0.0216, -0.0028, -0.0162, 0.0177, -0.0254,
-0.0109, -0.0026, 0.0038, -0.015, -0.0421, -0.0422, 0.0164, -0.0436, 0.0054, -0.0098,
0.0061, -0.0106, 0.0062, 0.0207, -0.0329, 0.0177, -0.0578, 0.0408, 0.0077, -0.026,
0.0001, -0.0098, 0.0106, -0.0003, -0.0292, 0.0032, 0.056, 0.0311, -0.0282, -0.0445,
0.0033, 0.0345, -0.0022, -0.0029, -0.0228, 0.0242, 0.0197, -0.0286, 0.0194, -0.0328,
0.0094, -0.001, 0.0121, 0.0229, 0.0161, 0.0363, -0.0124, 0.0179, -0.0626, 0.002,
-0.007, -0.0272, -0.0171, -0.0249, -0.0039, 0.0254, 0.0317, -0.0324, 0.0276, -0.009,
-0.0002, 0.0057, -0.0204, 0.0512, -0.017, 0.0113, 0.0157, 0.0427, -0.0024, 0.0162,
-0.0064, -0.0144, 0.0216, 0.0053, -0.0361, 0.0287, 0.023, -0.0161, -0.0189, 0.0589,
0.0091, -0.0059, -0.0308, 0.0171, -0.0137, -0.0033, -0.0505, -0.0155, -0.0527, 0.0133,
-0.0121, -0.0051, 0.0219, 0.0136, 0.0476, -0.009, -0.046, 0.0208, 0.0072, -0.0076,
0.0098, -0.0328, -0.0211, 0.0054, -0.0146, -0.0263, 0.0248, 0.0045, -0.0183, 0.0301,
0.0101, 0.0139, -0.0073, 0.0234, 0.0083, -0.0194, -0.0365, 0.0307, 0.058, 0.0153,
-0.0111, 0.0019, 0.0265, -0.015, 0.0311, 0.0362, 0.0244, -0.0213, -0.0224, -0.0299,
0.0061, 0.0082, -0.0181, 0.0081, -0.0344, 0.0133, -0.0095, -0.0411, 0.0462, 0.0371,
0.0089, -0.0157, 0.0179, -0.0256, -0.0118, -0.0302, -0.0329, 0.0212, -0.0463, -0.0162,
-0.0313, 0.0096, -0.004, 0.0186, 0.0248, -0.0126, 0.0472, -0.0079, 0.0115, -0.027,
0.0055, 0.0044, 0.0172, 0.0079, -0.0089, -0.0202, -0.0233, -0.0397, -0.0305, -0.062,
-0.0282, -0.0104, -0.0071, -0.0242, -0.0255, 0.0204, -0.0187, -0.0103, -0.0227, -0.0424,
-0.0056, 0.0065, 0.0151, -0.0376, 0.0039, 0.0009, -0.0507, -0.004, 0.0393, -0.0201,
0.0128, -0.0228, 0.0115, -0.0446, 0.0316, 0.0266, -0.0036, 0.0117, -0.0009, 0.0048,
-0.0088, 0.0226, 0.0125, 0.009, 0.0008, -0.0341, 0.0243, -0.0178, -0.0589, 0.0278,
0.0151, 0.0021, -0.0349, -0.0365, -0.0098, -0.0179, -0.0212, -0.0313, 0.0109, -0.0164,
-0.0211, -0.0112, -0.0446, 0.0014, -0.0034, -0.0179, 0.011, 0.0176, 0.0286, 0.0045,
0.0034, -0.0151, 0.038, 0.0331, -0.0034, -0.0439, 0.0145, 0.012, 0.0036, 0.0017,
-0.0348, 0.0192, 0.0167, 0.0069, -0.0266, -0.0085, -0.0076, 0.026, 0.0234, 0.0075,
-0.0237, 0.015, -0.0094, -0.0201, 0.0234, -0.0041, -0.016, -0.0549, -0.0021, 0.0239,
-0.0019, 0.0173, 0.0295, 0.0443, 0.0081, 0.0181, -0.0039, -0.027, 0.0155, 0.0107,
0.0065, -0.0055, -0.0368, 0.0232, 0.037, 0.0367, 0.0046, -0.0167, 0.0047, 0.0173,
0.0116, 0.0053, -0.0229, 0.0382, 0.016, -0.0453, 0.0057, -0.0267, 0.002, -0.0051,
-0.014, 0.0302, -0.0208, 0.0106, 0.0101, -0.0049, -0.0319, 0.0227, -0.0206, -0.0371,
-0.0007, -0.0109, -0.0053, 0.0078, 0.041, -0.0001, 0.0543, 0.0328, -0.0196, 0.0332,
-0.0043, -0.0028, -0.0246, 0.0285, -0.0248, 0.0153, 0.0303, -0.031, -0.0335, -0.0315,
-0.0417, 0.1029, 0.0377, 0.0069, 0.0012, 0.0065, 0.0007, -0.0144, -0.0083, 0.0004,
0.0295, 0.0099, -0.0144, -0.0145, 0.0141, -0.0013, 0.0362, -0.0142, -0.0428, -0.0161,
-0.0095, -0.0206, 0.0116, 0.0132, 0.0164, 0.0158, 0.0012, -0.0024, 0.064, 0.0364,
0.0005, -0.0022, -0.0165, -0.0057, 0.0263, 0.0339, 0.0014, 0.0541, 0.0164, -0.0411,
0.0039, -0.0143, -0.0107, 0.0032, -0.016, -0.0502, 0.001, 0.0272, 0.0161, -0.05,
0.0083, 0.0292, -0.0076, -0.0201, 0.0313, 0.0213, 0.012, 0.0087, 0.0285, 0.0332,
0.017, 0.0018, 0.0001, 0.0205, 0.0106, -0.0064, -0.0082, -0.0083, -0.0082, 0.0886,
0.0075, -0.0078, -0.0038, -0.0337, -0.0491, 0.0048, 0.0069, 0.03, 0.0369, 0.0088,
-0.0091, -0.0327, 0.0041, 0.0376, 0.017, 0.0154, 0.0126, 0.0153, -0.0024, -0.0353,
0.0289, -0.008, 0.0063, 0.0274, -0.0061, 0.0208, 0.039, -0.006, 0.0294, -0.0088,
-0.0037, -0.0195, 0.0058, 0.0023, -0.0149, -0.036, -0.0587, -0.0248, 0.0288, 0.0203,
-0.0031, 0.0081, -0.0112, -0.0221, 0.0067, -0.0505, -0.0233, 0.0353, -0.0131, 0.0417,
0.0243, 0.0231, -0.0013, 0.0049, -0.0423, -0.0245, -0.0029, 0.0184, -0.0162, -0.001,
0.0045, 0.0101, -0.0042, 0.0014, -0.0133, -0.0321, 0.0642, 0.0153, 0.0377, 0.0277,
0.0275, 0.0083, 0.0286, -0.0243, -0.0084, -0.0236, 0.0027, -0.0289, 0.0201, 0.0235,
0.0281, 0.0078, 0.0038, 0.0069, 0.0302, 0.017, -0.0423, -0.034, 0.0104, -0.0181,
0.0334, -0.0034, -0.0257, -0.0061, 0.014, -0.0099, -0.0195, 0.0529, 0.0019, 0.001,
-0.0114, 0.0012, -0.0038, -0.0016, -0.014, 0.0697, 0.0372, 0.0243, 0.0172, 0.0066,
0.0192, 0.0149, 0.0285, 0.0077, 0.0246, -0.0135, 0.0145, 0.0317, -0.0074, -0.0438,
-0.0034, -0.0175, -0.0245, -0.0153, 0.0357, -0.0102, -0.0062, -0.0053, -0.0308, -0.0499,
0.0025, -0.0253, 0.0148, 0.0031, 0.0189, -0.0023, -0.0085, -0.0596, -0.0337, 0.0175,
-0.0091, -0.0171, -0.0217, -0.0189, 0.0056, 0.0249, -0.0499, 0.0236, 0.0042, 0.0449
};
const struct lsp_codebook lsp_cbvqanssi[] = {
/* codebook/lspvqanssi1.txt */
{
10,
8,
256,
codes0
},
/* codebook/lspvqanssi2.txt */
{
10,
7,
128,
codes1
},
/* codebook/lspvqanssi3.txt */
{
10,
6,
64,
codes2
},
/* codebook/lspvqanssi4.txt */
{
10,
6,
64,
codes3
},
{ 0, 0, 0, 0 }
};

File diff suppressed because it is too large Load diff

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

View file

@ -1,128 +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 <http://www.gnu.org/licenses/>.
*/
#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 2 /* oversampling rate */
#define FDMDV_OS_TAPS_16K 48 /* number of OS filter taps at 16kHz */
#define FDMDV_OS_TAPS_8K (FDMDV_OS_TAPS_16K/FDMDV_OS) /* number of OS filter taps at 8kHz */
/* 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 * fdmdv_create(int Nc);
void fdmdv_destroy(struct FDMDV *fdmdv_state);
void fdmdv_use_old_qpsk_mapping(struct FDMDV *fdmdv_state);
int fdmdv_bits_per_frame(struct FDMDV *fdmdv_state);
float fdmdv_get_fsep(struct FDMDV *fdmdv_state);
void fdmdv_set_fsep(struct FDMDV *fdmdv_state, float fsep);
void fdmdv_mod(struct FDMDV *fdmdv_state, COMP tx_fdm[], int tx_bits[], int *sync_bit);
void fdmdv_demod(struct FDMDV *fdmdv_state, int rx_bits[], int *reliable_sync_bit, COMP rx_fdm[], int *nin);
void fdmdv_get_test_bits(struct FDMDV *fdmdv_state, int tx_bits[]);
int fdmdv_error_pattern_size(struct FDMDV *fdmdv_state);
void fdmdv_put_test_bits(struct FDMDV *f, int *sync, short error_pattern[], int *bit_errors, int *ntest_bits, int rx_bits[]);
void fdmdv_get_demod_stats(struct FDMDV *fdmdv_state, struct FDMDV_STATS *fdmdv_stats);
void fdmdv_get_rx_spectrum(struct FDMDV *fdmdv_state, float mag_dB[], COMP rx_fdm[], int nin);
void fdmdv_8_to_16(float out16k[], float in8k[], int n);
void fdmdv_8_to_16_short(short out16k[], short in8k[], int n);
void fdmdv_16_to_8(float out8k[], float in16k[], int n);
void fdmdv_16_to_8_short(short out8k[], short in16k[], int n);
void fdmdv_freq_shift(COMP rx_fdm_fcorr[], COMP rx_fdm[], float foff, COMP *foff_phase_rect, int nin);
/* debug/development function(s) */
void fdmdv_dump_osc_mags(struct FDMDV *f);
void fdmdv_simulate_channel(struct FDMDV *f, COMP samples[], int nin, float target_snr);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef __COMP__
#define __COMP__
/* Complex number */
typedef struct {
float real;
float imag;
} COMP;
#endif

View file

@ -1,93 +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 <http://www.gnu.org/licenses/>.
*/
#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_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

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#include "defines.h"
#include "comp.h"
#include "dump.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#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; i<M/2; i++)
fprintf(fsn,"%f\t",Sn[i]);
fprintf(fsn,"\n");
for(i=M/2; i<M; i++)
fprintf(fsn,"%f\t",Sn[i]);
fprintf(fsn,"\n");
}
void dump_Sw(COMP Sw[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fsw == NULL) {
sprintf(s,"%s_sw.txt", prefix);
fsw = fopen(s, "wt");
assert(fsw != NULL);
}
for(i=0; i<FFT_ENC/2; i++)
fprintf(fsw,"%f\t",
10.0*log10(Sw[i].real*Sw[i].real + Sw[i].imag*Sw[i].imag));
fprintf(fsw,"\n");
}
void dump_Sw_(COMP Sw_[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fsw_ == NULL) {
sprintf(s,"%s_sw_.txt", prefix);
fsw_ = fopen(s, "wt");
assert(fsw_ != NULL);
}
for(i=0; i<FFT_ENC/2; i++)
fprintf(fsw_,"%f\t",
10.0*log10(Sw_[i].real*Sw_[i].real + Sw_[i].imag*Sw_[i].imag));
fprintf(fsw_,"\n");
}
void dump_Ew(COMP Ew[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (few == NULL) {
sprintf(s,"%s_ew.txt", prefix);
few = fopen(s, "wt");
assert(few != NULL);
}
for(i=0; i<FFT_ENC/2; i++)
fprintf(few,"%f\t",
10.0*log10(Ew[i].real*Ew[i].real + Ew[i].imag*Ew[i].imag));
fprintf(few,"\n");
}
void dump_model(MODEL *model) {
int l;
char s[MAX_STR];
char line[2048];
if (!dumpon) return;
if (fmodel == NULL) {
sprintf(s,"%s_model.txt", prefix);
fmodel = fopen(s, "wt");
assert(fmodel != 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(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<MAX_AMP; l++)
fprintf(fphase_,"%f\t",0.0);
fprintf(fphase_,"\n");
}
void dump_hephase(int ind[], int dim) {
int m;
char s[MAX_STR];
if (!dumpon) return;
if (fhephase == NULL) {
sprintf(s,"%s_hephase.txt", prefix);
fhephase = fopen(s, "wt");
assert(fhephase != NULL);
}
for(m=0; m<dim; m++)
fprintf(fhephase,"%d\t",ind[m]);
fprintf(fhephase,"\n");
}
void dump_snr(float snr) {
char s[MAX_STR];
if (!dumpon) return;
if (fsnr == NULL) {
sprintf(s,"%s_snr.txt", prefix);
fsnr = fopen(s, "wt");
assert(fsnr != NULL);
}
fprintf(fsnr,"%f\n",snr);
}
void dump_lpc_snr(float snr) {
char s[MAX_STR];
if (!dumpon) return;
if (flpcsnr == NULL) {
sprintf(s,"%s_lpc_snr.txt", prefix);
flpcsnr = fopen(s, "wt");
assert(flpcsnr != NULL);
}
fprintf(flpcsnr,"%f\n",snr);
}
/* Pw "before" post filter so we can plot before and after */
void dump_Pwb(COMP Pwb[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fpwb == NULL) {
sprintf(s,"%s_pwb.txt", prefix);
fpwb = fopen(s, "wt");
assert(fpwb != NULL);
}
for(i=0; i<FFT_ENC/2; i++)
fprintf(fpwb,"%f\t",Pwb[i].real);
fprintf(fpwb,"\n");
}
void dump_Pw(COMP Pw[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fpw == NULL) {
sprintf(s,"%s_pw.txt", prefix);
fpw = fopen(s, "wt");
assert(fpw != NULL);
}
for(i=0; i<FFT_ENC/2; i++)
fprintf(fpw,"%f\t",Pw[i].real);
fprintf(fpw,"\n");
}
void dump_Rw(float Rw[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (frw == NULL) {
sprintf(s,"%s_rw.txt", prefix);
frw = fopen(s, "wt");
assert(frw != NULL);
}
for(i=0; i<FFT_ENC/2; i++)
fprintf(frw,"%f\t",Rw[i]);
fprintf(frw,"\n");
}
void dump_weights(float w[], int order) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fweights == NULL) {
sprintf(s,"%s_weights.txt", prefix);
fweights = fopen(s, "wt");
assert(fweights != NULL);
}
for(i=0; i<order; i++)
fprintf(fweights,"%f\t", w[i]);
fprintf(fweights,"\n");
}
void dump_lsp(float lsp[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (flsp == NULL) {
sprintf(s,"%s_lsp.txt", prefix);
flsp = fopen(s, "wt");
assert(flsp != NULL);
}
for(i=0; i<10; i++)
fprintf(flsp,"%f\t",lsp[i]);
fprintf(flsp,"\n");
}
void dump_lsp_(float lsp_[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (flsp_ == NULL) {
sprintf(s,"%s_lsp_.txt", prefix);
flsp_ = fopen(s, "wt");
assert(flsp_ != NULL);
}
for(i=0; i<10; i++)
fprintf(flsp_,"%f\t",lsp_[i]);
fprintf(flsp_,"\n");
}
void dump_mel(int mel[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fmel == NULL) {
sprintf(s,"%s_mel.txt", prefix);
fmel = fopen(s, "wt");
assert(fmel != NULL);
}
for(i=0; i<10; i++)
fprintf(fmel,"%d\t",mel[i]);
fprintf(fmel,"\n");
}
void dump_ak(float ak[], int order) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fak == NULL) {
sprintf(s,"%s_ak.txt", prefix);
fak = fopen(s, "wt");
assert(fak != NULL);
}
for(i=0; i<=order; i++)
fprintf(fak,"%f\t",ak[i]);
fprintf(fak,"\n");
}
void dump_ak_(float ak_[], int order) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fak_ == NULL) {
sprintf(s,"%s_ak_.txt", prefix);
fak_ = fopen(s, "wt");
assert(fak_ != NULL);
}
for(i=0; i<=order; i++)
fprintf(fak_,"%f\t",ak_[i]);
fprintf(fak_,"\n");
}
void dump_Fw(COMP Fw[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (ffw == NULL) {
sprintf(s,"%s_fw.txt", prefix);
ffw = fopen(s, "wt");
assert(ffw != NULL);
}
for(i=0; i<256; i++)
fprintf(ffw,"%f\t",Fw[i].real);
fprintf(ffw,"\n");
}
void dump_e(float e_hz[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fe == NULL) {
sprintf(s,"%s_e.txt", prefix);
fe = fopen(s, "wt");
assert(fe != NULL);
}
for(i=0; i<500/2; i++)
fprintf(fe,"%f\t",e_hz[i]);
fprintf(fe,"\n");
for(i=500/2; i<500; i++)
fprintf(fe,"%f\t",e_hz[i]);
fprintf(fe,"\n");
}
void dump_sq(float sq[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fsq == NULL) {
sprintf(s,"%s_sq.txt", prefix);
fsq = fopen(s, "wt");
assert(fsq != NULL);
}
for(i=0; i<M/2; i++)
fprintf(fsq,"%f\t",sq[i]);
fprintf(fsq,"\n");
for(i=M/2; i<M; i++)
fprintf(fsq,"%f\t",sq[i]);
fprintf(fsq,"\n");
}
void dump_dec(COMP Fw[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fdec == NULL) {
sprintf(s,"%s_dec.txt", prefix);
fdec = fopen(s, "wt");
assert(fdec != NULL);
}
for(i=0; i<320/5; i++)
fprintf(fdec,"%f\t",Fw[i].real);
fprintf(fdec,"\n");
}
void dump_bg(float e, float bg_est, float percent_uv) {
char s[MAX_STR];
if (!dumpon) return;
if (fbg == NULL) {
sprintf(s,"%s_bg.txt", prefix);
fbg = fopen(s, "wt");
assert(fbg != NULL);
}
fprintf(fbg,"%f\t%f\t%f\n", e, bg_est, percent_uv);
}
void dump_E(float E) {
char s[MAX_STR];
if (!dumpon) return;
if (fE == NULL) {
sprintf(s,"%s_E.txt", prefix);
fE = fopen(s, "wt");
assert(fE != NULL);
}
fprintf(fE,"%f\n", 10.0*log10(E));
}
void dump_Rk(float Rk[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (frk == NULL) {
sprintf(s,"%s_rk.txt", prefix);
frk = fopen(s, "wt");
assert(frk != NULL);
}
for(i=0; i<P_MAX; i++)
fprintf(frk,"%f\t",Rk[i]);
fprintf(frk,"\n");
}
#endif

View file

@ -1,78 +0,0 @@
/*---------------------------------------------------------------------------*\
FILE........: dump.h
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 <http://www.gnu.org/licenses/>.
*/
#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

File diff suppressed because it is too large Load diff

View file

@ -1,193 +0,0 @@
/*---------------------------------------------------------------------------*\
FILE........: fdmdv_internal.h
AUTHOR......: David Rowe
DATE CREATED: April 16 2012
Header file for FDMDV internal functions, exposed via this header
file for 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 <http://www.gnu.org/licenses/>.
*/
#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 output */
#define Q (M/4) /* oversample factor used for initial rx symbol filtering input */
#define NRXDEC 31 /* number of taps in the rx decimation filter */
#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];
float freq_pol[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];
/* baseband to low IF carrier states */
COMP fbb_rect;
float fbb_pol;
COMP fbb_phase_tx;
COMP fbb_phase_rx;
/* freq offset correction states */
float foff;
COMP foff_phase_rect;
/* Demodulator */
COMP rxdec_lpf_mem[NRXDEC-1+M];
COMP rx_fdm_mem[NFILTER+M];
COMP phase_rx[NC+1];
COMP rx_filter_mem_timing[NC+1][NT*P];
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;
/* channel simulation */
float sig_pwr_av;
};
/*---------------------------------------------------------------------------*\
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[],
COMP *fbb_phase, COMP fbb_rect);
void tx_filter_and_upconvert(COMP tx_fdm[], int Nc, COMP tx_symbols[],
COMP tx_filter_memory[NC+1][NSYM],
COMP phase_tx[], COMP freq[], COMP *fbb_phase, COMP fbb_rect);
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, int do_fft);
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 do_fft);
void fdm_downconvert(COMP rx_baseband[NC+1][M+M/P], int Nc, COMP rx_fdm[], COMP phase_rx[], COMP freq[], int nin);
void rxdec_filter(COMP rx_fdm_filter[], COMP rx_fdm[], COMP rxdec_lpf_mem[], 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);
void down_convert_and_rx_filter(COMP rx_filt[NC+1][P+1], int Nc, COMP rx_fdm[],
COMP rx_fdm_mem[], COMP phase_rx[], COMP freq[],
float freq_pol[], int nin, int dec_rate);
float rx_est_timing(COMP rx_symbols[], int Nc,
COMP rx_filt[NC+1][P+1],
COMP rx_filter_mem_timing[NC+1][NT*P],
float env[],
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

View file

@ -1,142 +0,0 @@
/*---------------------------------------------------------------------------*\
FILE........: fifo.c
AUTHOR......: David Rowe
DATE CREATED: Oct 15 2012
A FIFO design useful in gluing the FDMDV modem and codec together in
integrated applications. The unittest/tfifo indicates these
routines are thread safe without the need for syncronisation
object, e.g. a different thread can read and write to a fifo at the
same time.
\*---------------------------------------------------------------------------*/
/*
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 <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#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; i<n; i++) {
*pin++ = *pdata++;
if (pin == (fifo->buf + 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; i<n; i++) {
*pdata++ = *pout++;
if (pout == (fifo->buf + 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;
}

View file

@ -1,399 +0,0 @@
/*---------------------------------------------------------------------------*\
FILE........: freedv_api.c
AUTHOR......: David Rowe
DATE CREATED: August 2014
Library of API functions that implement FreeDV "modes", useful for
embedding FreeDV in other programs.
TODO:
[X] speex tx/rx works
[X] txt messages
[ ] optional test tx framemode
\*---------------------------------------------------------------------------*/
/*
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 <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "codec2.h"
#include "codec2_fdmdv.h"
#include "golay23.h"
#include "varicode.h"
#include "freedv_api.h"
/*---------------------------------------------------------------------------*\
FUNCTION....: freedv_open
AUTHOR......: David Rowe
DATE CREATED: 3 August 2014
Call this first to initialise. Returns NULL if initialisation fails
(e.g. out of memory or mode not supported).
\*---------------------------------------------------------------------------*/
struct freedv *freedv_open(int mode) {
struct freedv *f;
int Nc, codec2_mode, nbit, nbyte;
if (mode != FREEDV_MODE_1600)
return NULL;
f = (struct freedv*)malloc(sizeof(struct freedv));
if (f == NULL)
return NULL;
f->mode = mode;
f->tx_sync_bit = 0;
f->snr_thresh = 2.0;
if (mode == FREEDV_MODE_1600) {
Nc = 16;
codec2_mode = CODEC2_MODE_1300;
}
f->codec2 = codec2_create(codec2_mode);
if (f->codec2 == NULL)
return NULL;
f->fdmdv = fdmdv_create(Nc);
if (f->fdmdv == NULL)
return NULL;
nbit = codec2_bits_per_frame(f->codec2);
nbyte = (nbit + 7) / 8;
f->packed_codec_bits = (unsigned char*)malloc(nbyte*sizeof(char));
f->codec_bits = (int*)malloc(nbit*sizeof(int));
nbit = 2*fdmdv_bits_per_frame(f->fdmdv);
f->tx_bits = (int*)malloc(nbit*sizeof(int));
f->rx_bits = (int*)malloc(nbit*sizeof(int));
nbit = fdmdv_bits_per_frame(f->fdmdv);
f->fdmdv_bits = (int*)malloc(nbit*sizeof(int));
if ((f->packed_codec_bits == NULL) || (f->codec_bits == NULL)
|| (f->tx_bits == NULL) || (f->rx_bits == NULL) || (f->fdmdv_bits == NULL))
return NULL;
varicode_decode_init(&f->varicode_dec_states, 1);
f->nvaricode_bits = 0;
f->varicode_bit_index = 0;
f->freedv_get_next_tx_char = NULL;
f->freedv_put_next_rx_char = NULL;
golay23_init();
f->total_bit_errors = 0;
f->nin = FDMDV_NOM_SAMPLES_PER_FRAME;
return f;
}
/*---------------------------------------------------------------------------*\
FUNCTION....: freedv_close
AUTHOR......: David Rowe
DATE CREATED: 3 August 2014
Frees up memory.
\*---------------------------------------------------------------------------*/
void freedv_close(struct freedv *freedv) {
free(freedv->packed_codec_bits);
free(freedv->codec_bits);
free(freedv->tx_bits);
fdmdv_destroy(freedv->fdmdv);
codec2_destroy(freedv->codec2);
free(freedv);
}
/*---------------------------------------------------------------------------*\
FUNCTION....: freedv_tx
AUTHOR......: David Rowe
DATE CREATED: 3 August 2014
Takes a frame of input speech samples, encodes and modulates them to produce
a frame of modem samples that can be sent to the transmitter.
speech_in[] and mod_out[] are sampled at 8 kHz, 16 bit shorts, and
FREEDV_NSAMPLES long. The speech_in[] level should be such that the
peak speech level is between +/16384 and +/- 32767. mod_out[] will
be scaled such that the peak level is just less than +/-32767.
The FDM modem signal mod_out[] has a high crest factor (around
12dB), however the energy and duration of the peaks is small.
FreeDV is generally operated at a "backoff" of 6-8dB. Adjust the
power amplifier drive so that the average power is 6-8dB less than
the peak power of the PA. For example, on a radio rated at 100W PEP
for SSB, the average FreeDV power is typically 20-25W.
\*---------------------------------------------------------------------------*/
void freedv_tx(struct freedv *f, short mod_out[], short speech_in[]) {
int bit, byte, i, j;
int bits_per_codec_frame, bits_per_fdmdv_frame;
int data, codeword1, data_flag_index;
COMP tx_fdm[2*FDMDV_NOM_SAMPLES_PER_FRAME];
bits_per_codec_frame = codec2_bits_per_frame(f->codec2);
bits_per_fdmdv_frame = fdmdv_bits_per_frame(f->fdmdv);
codec2_encode(f->codec2, f->packed_codec_bits, speech_in);
/* unpack bits, MSB first */
bit = 7; byte = 0;
for(i=0; i<bits_per_codec_frame; i++) {
f->codec_bits[i] = (f->packed_codec_bits[byte] >> bit) & 0x1;
bit--;
if (bit < 0) {
bit = 7;
byte++;
}
}
// spare bit in frame that codec defines. Use this 1
// bit/frame to send txt messages
data_flag_index = codec2_get_spare_bit_index(f->codec2);
if (f->nvaricode_bits) {
f->codec_bits[data_flag_index] = f->tx_varicode_bits[f->varicode_bit_index++];
f->nvaricode_bits--;
}
if (f->nvaricode_bits == 0) {
/* get new char and encode */
char s[2];
if (f->freedv_get_next_tx_char != NULL) {
s[0] = (*f->freedv_get_next_tx_char)(f->callback_state);
f->nvaricode_bits = varicode_encode(f->tx_varicode_bits, s, VARICODE_MAX_BITS, 1, 1);
f->varicode_bit_index = 0;
}
}
if (f->mode == FREEDV_MODE_1600) {
/* 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 |= f->codec_bits[i];
}
for(i=11; i<15; i++) {
data <<= 1;
data |= f->codec_bits[i];
}
codeword1 = golay23_encode(data);
/* 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<bits_per_codec_frame; i++)
f->tx_bits[i] = f->codec_bits[i];
for(j=0; i<bits_per_codec_frame+11; i++,j++) {
f->tx_bits[i] = (codeword1 >> (10-j)) & 0x1;
}
f->tx_bits[i] = 0; /* spare bit */
//for(i=0; i<bits_per_codec_frame+12; i++)
// printf("%d\n", f->tx_bits[i]);
}
/* modulate even and odd frames */
fdmdv_mod(f->fdmdv, tx_fdm, f->tx_bits, &f->tx_sync_bit);
assert(f->tx_sync_bit == 1);
fdmdv_mod(f->fdmdv, &tx_fdm[FDMDV_NOM_SAMPLES_PER_FRAME], &f->tx_bits[bits_per_fdmdv_frame], &f->tx_sync_bit);
assert(f->tx_sync_bit == 0);
for(i=0; i<2*FDMDV_NOM_SAMPLES_PER_FRAME; i++)
mod_out[i] = FDMDV_SCALE * tx_fdm[i].real;
assert(2*FDMDV_NOM_SAMPLES_PER_FRAME == FREEDV_NSAMPLES);
}
int freedv_nin(struct freedv *f) {
return f->nin;
}
/*---------------------------------------------------------------------------*\
FUNCTION....: freedv_rx
AUTHOR......: David Rowe
DATE CREATED: 3 August 2014
Takes a frame of samples from the radio receiver, demodulates them,
then decodes them, producing a frame of decoded speech samples.
Both demod_in[] and speech_out[] are 16 bit shorts sampled at 8 kHz.
The peak level of demod_in[] is not critical, as the demod works
well over a wide range of amplitude scaling. However it is best to
avoid clipping (overload, or samples pinned to +/- 32767). Suggest
scaling so the peak (modem signal plus noise) is between +/-16384
and +/-32767. speech_out[] will peak at just less than +/-32767.
To account for difference in the transmit and receive sample clock
frequencies, the number of demod_in[] samples is time varying. It
is the responsibility of the caller to supply the correct number of
samples. Call freedv_nin() before each call to freedv_rx() to
determine how many samples to pass to this function (see example).
Returns the number of output speech samples available in
speech_out[]. When in sync this will typically alternate between 0
and FREEDV_NSAMPLES. When out of sync, this will be f->nin.
When out of sync, this function echoes the demod_in[] samples to
speech_out[]. This allows the user to listen to the channel, which
is useful for tuning FreeDV signals or reception of non-FreeDV
signals.
\*---------------------------------------------------------------------------*/
int freedv_rx(struct freedv *f, short speech_out[], short demod_in[]) {
COMP rx_fdm[FDMDV_MAX_SAMPLES_PER_FRAME];
int bits_per_codec_frame, bytes_per_codec_frame, bits_per_fdmdv_frame;
int reliable_sync_bit, i, j, bit, byte, nin_prev, nout;
int recd_codeword, codeword1, data_flag_index, n_ascii;
short abit[1];
char ascii_out;
bits_per_codec_frame = codec2_bits_per_frame(f->codec2);
bytes_per_codec_frame = (bits_per_codec_frame + 7) / 8;
bits_per_fdmdv_frame = fdmdv_bits_per_frame(f->fdmdv);
for(i=0; i<f->nin; i++) {
rx_fdm[i].real = (float)demod_in[i]/FDMDV_SCALE;
rx_fdm[i].imag = 0;
}
nin_prev = f->nin;
fdmdv_demod(f->fdmdv, f->fdmdv_bits, &reliable_sync_bit, rx_fdm, &f->nin);
fdmdv_get_demod_stats(f->fdmdv, &f->fdmdv_stats);
if (f->fdmdv_stats.sync) {
// printf("\033[97mIn sync. Pass demod_in to Codec, Codec to speech_out\n");
if (reliable_sync_bit == 0) {
memcpy(f->rx_bits, f->fdmdv_bits, bits_per_fdmdv_frame*sizeof(int));
nout = 0;
}
else {
memcpy(&f->rx_bits[bits_per_fdmdv_frame], f->fdmdv_bits, bits_per_fdmdv_frame*sizeof(int));
if (f->mode == FREEDV_MODE_1600) {
recd_codeword = 0;
for(i=0; i<8; i++) {
recd_codeword <<= 1;
recd_codeword |= f->rx_bits[i];
}
for(i=11; i<15; i++) {
recd_codeword <<= 1;
recd_codeword |= f->rx_bits[i];
}
for(i=bits_per_codec_frame; i<bits_per_codec_frame+11; i++) {
recd_codeword <<= 1;
recd_codeword |= f->rx_bits[i];
}
codeword1 = golay23_decode(recd_codeword);
f->total_bit_errors += golay23_count_errors(recd_codeword, codeword1);
//codeword1 = recd_codeword;
//fprintf(stderr, "received codeword1: 0x%x decoded codeword1: 0x%x\n", recd_codeword, codeword1);
for(i=0; i<bits_per_codec_frame; i++)
f->codec_bits[i] = f->rx_bits[i];
for(i=0; i<8; i++) {
f->codec_bits[i] = (codeword1 >> (22-i)) & 0x1;
}
for(i=8,j=11; i<12; i++,j++) {
f->codec_bits[j] = (codeword1 >> (22-i)) & 0x1;
}
}
// extract txt msg data bit ------------------------------------------------------------
data_flag_index = codec2_get_spare_bit_index(f->codec2);
abit[0] = f->codec_bits[data_flag_index];
n_ascii = varicode_decode(&f->varicode_dec_states, &ascii_out, abit, 1, 1);
if (n_ascii && (f->freedv_put_next_rx_char != NULL)) {
(*f->freedv_put_next_rx_char)(f->callback_state, ascii_out);
}
// reconstruct missing bit we steal for data bit and decode speech
codec2_rebuild_spare_bit(f->codec2, f->codec_bits);
// pack bits, MSB received first
bit = 7;
byte = 0;
memset(f->packed_codec_bits, 0, bytes_per_codec_frame);
for(i=0; i<bits_per_codec_frame; i++) {
f->packed_codec_bits[byte] |= (f->codec_bits[i] << bit);
bit--;
if(bit < 0) {
bit = 7;
byte++;
}
}
codec2_decode(f->codec2, speech_out, f->packed_codec_bits);
/* squelch if beneath SNR threshold */
if (f->fdmdv_stats.snr_est < f->snr_thresh) {
for(i=0; i<FREEDV_NSAMPLES; i++)
speech_out[i] = 0;
}
nout = FREEDV_NSAMPLES;
}
} /* if (sync) .... */
else {
// printf("\033[97mNot in sync. Pass demod_in to speech_out\n");
/* if not in sync pass through analog samples */
/* this lets us "hear" whats going on, e.g. during tuning */
for(i=0; i<nin_prev; i++)
speech_out[i] = demod_in[i];
nout = nin_prev;
}
return nout;
}

View file

@ -1,78 +0,0 @@
/*---------------------------------------------------------------------------*\
FILE........: freedv_api.h
AUTHOR......: David Rowe
DATE CREATED: August 2014
Library of API functions that implement FreeDV "modes", useful for
embedding FreeDV in other programs.
\*---------------------------------------------------------------------------*/
/*
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 <http://www.gnu.org/licenses/>.
*/
#ifndef __FREEDV__
#define FREEDV_MODE_1600 0
#define FREEDV_NSAMPLES 320
#include "varicode.h"
#include "codec2_fdmdv.h"
struct freedv {
int mode;
void *codec2;
struct FDMDV *fdmdv;
struct FDMDV_STATS fdmdv_stats;
unsigned char *packed_codec_bits;
int *codec_bits;
int *tx_bits;
int *fdmdv_bits;
int *rx_bits;
int tx_sync_bit;
int total_bit_errors;
float snr_thresh;
int nin;
struct VARICODE_DEC varicode_dec_states;
short tx_varicode_bits[VARICODE_MAX_BITS];
int nvaricode_bits;
int varicode_bit_index;
/* user defined function ptrs to produce and consume ASCII
characters using aux txt channel */
char (*freedv_get_next_tx_char)(void *callback_state);
void (*freedv_put_next_rx_char)(void *callback_state, char c);
void *callback_state;
};
struct freedv *freedv_open(int mode);
void freedv_close(struct freedv *freedv);
void freedv_tx(struct freedv *f, short mod_out[], short speech_in[]);
int freedv_nin(struct freedv *f);
int freedv_rx(struct freedv *f, short speech_out[], short demod_in[]);
//float Get_freedv_S2N(struct freedv *f);
#endif

View file

@ -1,418 +0,0 @@
/*---------------------------------------------------------------------------*\
FILE........: golay23.c
AUTHOR......: Robert Morelos-Zaragoza & David Rowe
DATE CREATED: 3 March 2013
To test:
src$ gcc golay23.c -o golay23 -Wall -DGOLAY23_UNITTEST
src$ ./golay23
To generate tables:
src$ gcc golay23.c -o golay23 -Wall -DGOLAY23_MAKETABLES -DRUN_TIME_TABLES
\*---------------------------------------------------------------------------*/
/* File: golay23.c
* Title: Encoder/decoder for a binary (23,12,7) Golay code
* Author: Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu)
* Date: August 1994
*
* The binary (23,12,7) Golay code is an example of a perfect code, that is,
* the number of syndromes equals the number of correctable error patterns.
* The minimum distance is 7, so all error patterns of Hamming weight up to
* 3 can be corrected. The total number of these error patterns is:
*
* Number of errors Number of patterns
* ---------------- ------------------
* 0 1
* 1 23
* 2 253
* 3 1771
* ----
* Total number of error patterns = 2048 = 2^{11} = number of syndromes
* --
* number of redundant bits -------^
*
* Because of its relatively low length (23), dimension (12) and number of
* redundant bits (11), the binary (23,12,7) Golay code can be encoded and
* decoded simply by using look-up tables. The program below uses a 16K
* encoding table and an 8K decoding table.
*
* For more information, suggestions, or other ideas on implementing error
* correcting codes, please contact me at (I'm temporarily in Japan, but
* below is my U.S. address):
*
* Robert Morelos-Zaragoza
* 770 S. Post Oak Ln. #200
* Houston, Texas 77056
*
* email: robert@spectra.eng.hawaii.edu
*
* Homework: Add an overall parity-check bit to get the (24,12,8)
* extended Golay code.
*
* COPYRIGHT NOTICE: This computer program is free for non-commercial purposes.
* You may implement this program for any non-commercial application. You may
* also implement this program for commercial purposes, provided that you
* obtain my written permission. Any modification of this program is covered
* by this copyright.
*
* == Copyright (c) 1994 Robert Morelos-Zaragoza. All rights reserved. ==
*/
#include "golay23.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#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;
#ifdef RUN_TIME_TABLES
static int encoding_table[4096], decoding_table[2048];
#else
#include "golayenctable.h"
#include "golaydectable.h"
#endif
#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
#ifdef RUN_TIME_TABLES
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);
}
#endif
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) {
#ifdef RUN_TIME_TABLES
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;
}
#endif
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;
int tests;
int a[4];
int error_pattern;
golay23_init();
/* ---------------------------------------------------------------------
* 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
#ifdef GOLAY23_MAKETABLES
int main(int argc, char *argv[]) {
FILE *f;
int i;
golay23_init();
f=fopen("golayenctable.h","wt");
assert(f != NULL);
fprintf(f,"/* Generated by golay23.c -DGOLAY23_MAKETABLE */\n\n");
fprintf(f,"const int static encoding_table[]={\n");
for (i=0; i<4095; i++)
fprintf(f," 0x%x,\n", encoding_table[i]);
fprintf(f, " 0x%x\n};\n", encoding_table[i]);
fclose(f);
f=fopen("golaydectable.h","wt");
assert(f != NULL);
fprintf(f,"/* Generated by golay23.c -DGOLAY23_MAKETABLE */\n\n");
fprintf(f,"const int static decoding_table[]={\n");
for (i=0; i<2047; i++)
fprintf(f," 0x%x,\n", decoding_table[i]);
fprintf(f, " 0x%x\n};\n", decoding_table[i]);
fclose(f);
return 0;
}
#endif

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -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
};

View file

@ -1,325 +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 <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <math.h>
#include <string.h>
#include <stdio.h>
#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;
}
#ifdef NOT_NEEDED
/*---------------------------------------------------------------------------*\
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; i<LPC_ORD; i++) {
lsps_interp[i] = (prev_lsps[i] + next_lsps[i])/2.0;
}
/* Interpolate LPC energy in log domain */
e = powf(10.0, (log10f(prev_e) + log10f(next_e))/2.0);
//printf(" interp: e: %f\n", e);
/* convert back to amplitudes */
lsp_to_lpc(lsps_interp, ak_interp, LPC_ORD);
aks_to_M2(fft_fwd_cfg, ak_interp, LPC_ORD, interp, e, &snr, 0, 0, 1, 1, LPCPF_BETA, LPCPF_GAMMA);
//printf(" interp: ak[1]: %f A[1] %f\n", ak_interp[1], interp->A[1]);
}
#endif
/*---------------------------------------------------------------------------*\
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<LPC_ORD; i++)
interp[i] = (1.0 - weight)*prev[i] + weight*next[i];
}

View file

@ -1,45 +0,0 @@
/*---------------------------------------------------------------------------*\
FILE........: interp.h
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 <http://www.gnu.org/licenses/>.
*/
#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

View file

@ -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; u<m; ++u ) {
C_FIXDIV( *Fout0,5); C_FIXDIV( *Fout1,5); C_FIXDIV( *Fout2,5); C_FIXDIV( *Fout3,5); C_FIXDIV( *Fout4,5);
scratch[0] = *Fout0;
C_MUL(scratch[1] ,*Fout1, tw[u*fstride]);
C_MUL(scratch[2] ,*Fout2, tw[2*u*fstride]);
C_MUL(scratch[3] ,*Fout3, tw[3*u*fstride]);
C_MUL(scratch[4] ,*Fout4, tw[4*u*fstride]);
C_ADD( scratch[7],scratch[1],scratch[4]);
C_SUB( scratch[10],scratch[1],scratch[4]);
C_ADD( scratch[8],scratch[2],scratch[3]);
C_SUB( scratch[9],scratch[2],scratch[3]);
Fout0->r += 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<m; ++u ) {
k=u;
for ( q1=0 ; q1<p ; ++q1 ) {
scratch[q1] = Fout[ k ];
C_FIXDIV(scratch[q1],p);
k += m;
}
k=u;
for ( q1=0 ; q1<p ; ++q1 ) {
int twidx=0;
Fout[ k ] = scratch[0];
for (q=1;q<p;++q ) {
twidx += fstride * k;
if (twidx>=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<p;++k)
kf_work( Fout +k*m, f+ fstride*in_stride*k,fstride*p,in_stride,factors,st);
// all threads have joined by this point
switch (p) {
case 2: kf_bfly2(Fout,fstride,st,m); break;
case 3: kf_bfly3(Fout,fstride,st,m); break;
case 4: kf_bfly4(Fout,fstride,st,m); break;
case 5: kf_bfly5(Fout,fstride,st,m); break;
default: kf_bfly_generic(Fout,fstride,st,m,p); break;
}
return;
}
#endif
if (m==1) {
do{
*Fout = *f;
f += fstride*in_stride;
}while(++Fout != Fout_end );
}else{
do{
// recursive call:
// DFT of size m*p performed by doing
// p instances of smaller DFTs of size m,
// each one takes a decimated version of the input
kf_work( Fout , f, fstride*p, in_stride, factors,st);
f += fstride*in_stride;
}while( (Fout += m) != Fout_end );
}
Fout=Fout_beg;
// recombine the p smaller DFTs
switch (p) {
case 2: kf_bfly2(Fout,fstride,st,m); break;
case 3: kf_bfly3(Fout,fstride,st,m); break;
case 4: kf_bfly4(Fout,fstride,st,m); break;
case 5: kf_bfly5(Fout,fstride,st,m); break;
default: kf_bfly_generic(Fout,fstride,st,m,p); break;
}
}
/* facbuf is populated by p1,m1,p2,m2, ...
where
p[i] * m[i] = m[i-1]
m0 = n */
static
void kf_factor(int n,int * facbuf)
{
int p=4;
double floor_sqrt;
floor_sqrt = floor( sqrt((double)n) );
/*factor out powers of 4, powers of 2, then any remaining primes */
do {
while (n % p) {
switch (p) {
case 4: p = 2; break;
case 2: p = 3; break;
default: p += 2; break;
}
if (p > 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;i<nfft;++i) {
const double pi=3.141592653589793238462643383279502884197169399375105820974944;
double phase = -2*pi*i / nfft;
if (st->inverse)
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;
}

View file

@ -1,124 +0,0 @@
#ifndef KISS_FFT_H
#define KISS_FFT_H
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#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 <xmmintrin.h>
# 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 <sys/types.h>
# 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

View file

@ -1,306 +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 <http://www.gnu.org/licenses/>.
*/
#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 <assert.h>
#include <math.h>
#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<Nsam; i++) {
Sn_pre[i] = Sn[i] - ALPHA * mem[0];
mem[0] = Sn[i];
}
}
/*---------------------------------------------------------------------------*\
de_emp()
De-emphasis filter (low pass filter with polse close to 0 Hz).
\*---------------------------------------------------------------------------*/
void de_emp(
float Sn_de[], /* 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<Nsam; i++) {
Sn_de[i] = Sn[i] + BETA * mem[0];
mem[0] = Sn_de[i];
}
}
/*---------------------------------------------------------------------------*\
hanning_window()
Hanning windows a frame of speech samples.
\*---------------------------------------------------------------------------*/
void hanning_window(
float Sn[], /* input frame of speech samples */
float Wn[], /* output frame of windowed samples */
int Nsam /* number of samples */
)
{
int i; /* loop variable */
for(i=0; i<Nsam; i++)
Wn[i] = Sn[i]*(0.5 - 0.5*cosf(2*PI*(float)i/(Nsam-1)));
}
/*---------------------------------------------------------------------------*\
autocorrelate()
Finds the first P autocorrelation values of an array of windowed speech
samples Sn[].
\*---------------------------------------------------------------------------*/
void autocorrelate(
float Sn[], /* frame of Nsam windowed speech samples */
float Rn[], /* array of P+1 autocorrelation coefficients */
int Nsam, /* number of windowed samples to use */
int order /* order of LPC analysis */
)
{
int i,j; /* loop variables */
for(j=0; j<order+1; j++) {
Rn[j] = 0.0;
for(i=0; i<Nsam-j; i++)
Rn[j] += Sn[i]*Sn[i+j];
}
}
/*---------------------------------------------------------------------------*\
levinson_durbin()
Given P+1 autocorrelation coefficients, finds P Linear Prediction Coeff.
(LPCs) where P is the order of the LPC all-pole model. The Levinson-Durbin
algorithm is used, and is described in:
J. Makhoul
"Linear prediction, a tutorial review"
Proceedings of the IEEE
Vol-63, No. 4, April 1975
\*---------------------------------------------------------------------------*/
void levinson_durbin(
float R[], /* order+1 autocorrelation coeff */
float lpcs[], /* order+1 LPC's */
int order /* order of the LPC analysis */
)
{
float a[order+1][order+1];
float sum, e, k;
int i,j; /* loop variables */
e = R[0]; /* Equation 38a, Makhoul */
for(i=1; i<=order; i++) {
sum = 0.0;
for(j=1; j<=i-1; j++)
sum += a[i-1][j]*R[i-j];
k = -1.0*(R[i] + sum)/e; /* Equation 38b, Makhoul */
if (fabsf(k) > 1.0)
k = 0.0;
a[i][i] = k;
for(j=1; j<=i-1; j++)
a[i][j] = a[i-1][j] + k*a[i-1][i-j]; /* Equation 38c, Makhoul */
e *= (1-k*k); /* 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<Nsam; i++) {
res[i] = 0.0;
for(j=0; j<=order; j++)
res[i] += Sn[i-j]*a[j];
}
}
/*---------------------------------------------------------------------------*\
synthesis_filter()
C version of the Speech Synthesis Filter, 1/A(z). Given an array of
residual or excitation samples, and the the LP filter coefficients, this
function will produce an array of speech samples. This filter structure is
IIR.
The synthesis filter has memory as well, this is treated in the same way
as the memory for the inverse filter (see inverse_filter() notes above).
The difference is that the memory for the synthesis filter is stored in
the output array, wheras the memory of the inverse filter is stored in the
input array.
Note: the calling function must update the filter memory.
\*---------------------------------------------------------------------------*/
void synthesis_filter(
float res[], /* Nsam input residual (excitation) samples */
float a[], /* LPCs for this frame of speech samples */
int Nsam, /* number of speech samples */
int order, /* LPC order */
float Sn_[] /* Nsam output synthesised speech samples */
)
{
int i,j; /* loop variables */
/* Filter Nsam samples */
for(i=0; i<Nsam; i++) {
Sn_[i] = res[i]*a[0];
for(j=1; j<=order; j++)
Sn_[i] -= Sn_[i-j]*a[j];
}
}
/*---------------------------------------------------------------------------*\
find_aks()
This function takes a frame of samples, and determines the linear
prediction coefficients for that frame of samples.
\*---------------------------------------------------------------------------*/
void find_aks(
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[LPC_MAX_N]; /* windowed frame of Nsam speech samples */
float R[order+1]; /* order+1 autocorrelation values of Sn[] */
int i;
assert(Nsam < LPC_MAX_N);
hanning_window(Sn,Wn,Nsam);
autocorrelate(Wn,R,Nsam,order);
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;
}
/*---------------------------------------------------------------------------*\
weight()
Weights a vector of LPCs.
\*---------------------------------------------------------------------------*/
void weight(
float ak[], /* vector of order+1 LPCs */
float gamma, /* weighting factor */
int order, /* num LPCs (excluding leading 1.0) */
float akw[] /* weighted vector of order+1 LPCs */
)
{
int i;
for(i=1; i<=order; i++)
akw[i] = ak[i]*powf(gamma,(float)i);
}

View file

@ -1,43 +0,0 @@
/*---------------------------------------------------------------------------*\
FILE........: lpc.h
AUTHOR......: David Rowe
DATE CREATED: 24/8/09
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 <http://www.gnu.org/licenses/>.
*/
#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

View file

@ -1,321 +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 <http://www.gnu.org/licenses/>.
*/
#include "defines.h"
#include "lsp.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
/*---------------------------------------------------------------------------*\
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 order)
/* float coef[] coefficients of the polynomial to be evaluated */
/* float x the point where polynomial is to be evaluated */
/* int order order of the polynomial */
{
int i;
float *t,*u,*v,sum;
float T[(order / 2) + 1];
/* Initialize 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<=order/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<=order/2;i++)
sum+=coef[(order/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 order, float *freq, int nb, float delta)
/* float *a lpc coefficients */
/* int order 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[order + 1];
float P[order + 1];
flag = 1;
m = order/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[order+1-i]-*p++;
*qx++ = a[i]-a[order+1-i]+*q++;
}
px = P;
qx = Q;
for(i=0;i<m;i++){
*px = 2**px;
*qx = 2**qx;
px++;
qx++;
}
px = P; /* re-initialise ptrs */
qx = Q;
/* Search for a zero in P'(z) polynomial first and then alternate to Q'(z).
Keep alternating between the two polynomials as each zero is found */
xr = 0; /* initialise xr to zero */
xl = 1.0; /* start at point xl = 1 */
for(j=0;j<order;j++){
if(j%2) /* determines whether P' or Q' is eval. */
pt = qx;
else
pt = px;
psuml = cheb_poly_eva(pt,xl,order); /* evals poly. at xl */
flag = 1;
while(flag && (xr >= -1.0)){
xr = xl - delta ; /* interval spacing */
psumr = cheb_poly_eva(pt,xr,order);/* 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,order);
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<order; i++) {
freq[i] = acos(freq[i]);
}
return(roots);
}
/*---------------------------------------------------------------------------*\
FUNCTION....: lsp_to_lpc()
AUTHOR......: David Rowe
DATE CREATED: 24/2/93
This function converts LSP coefficients to LPC coefficients. In the
Speex code we worked out a way to simplify this significantly.
\*---------------------------------------------------------------------------*/
void lsp_to_lpc(float *lsp, float *ak, int order)
/* float *freq array of LSP frequencies in radians */
/* float *ak array of LPC coefficients */
/* int order order of LPC coefficients */
{
int i,j;
float xout1,xout2,xin1,xin2;
float *pw,*n1,*n2,*n3,*n4 = 0;
float freq[order];
float Wp[(order * 4) + 2];
/* convert from radians to the x=cos(w) domain */
for(i=0; i<order; i++)
freq[i] = cos(lsp[i]);
pw = Wp;
/* initialise contents of array */
for(i=0;i<=4*(order/2)+1;i++){ /* set contents of buffer to 0 */
*pw++ = 0.0;
}
/* Set pointers up */
pw = Wp;
xin1 = 1.0;
xin2 = 1.0;
/* reconstruct P(z) and Q(z) by cascading second order polynomials
in form 1 - 2xz(-1) +z(-2), where x is the LSP coefficient */
for(j=0;j<=order;j++){
for(i=0;i<(order/2);i++){
n1 = pw+(i*4);
n2 = n1 + 1;
n3 = n2 + 1;
n4 = n3 + 1;
xout1 = xin1 - 2*(freq[2*i]) * *n1 + *n2;
xout2 = xin2 - 2*(freq[2*i+1]) * *n3 + *n4;
*n2 = *n1;
*n4 = *n3;
*n1 = xin1;
*n3 = xin2;
xin1 = xout1;
xin2 = xout2;
}
xout1 = xin1 + *(n4+1);
xout2 = xin2 - *(n4+2);
ak[j] = (xout1 + xout2)*0.5;
*(n4+1) = xin1;
*(n4+2) = xin2;
xin1 = 0.0;
xin2 = 0.0;
}
}

View file

@ -1,37 +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 <http://www.gnu.org/licenses/>.
*/
#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

View file

@ -1,52 +0,0 @@
/*---------------------------------------------------------------------------*\
FILE........: machdep.h
AUTHOR......: David Rowe
DATE CREATED: May 2 2013
Machine dependant functions, e.g. profiling that requires access to a clock
counter register.
\*---------------------------------------------------------------------------*/
/*
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 <http://www.gnu.org/licenses/>.
*/
#ifndef __MACHDEP__
#define __MACHDEP__
#ifdef PROFILE
#define PROFILE_VAR(...) unsigned int __VA_ARGS__
#define PROFILE_SAMPLE(timestamp) timestamp = machdep_profile_sample()
#define PROFILE_SAMPLE_AND_LOG(timestamp, prev_timestamp, label) \
timestamp = machdep_profile_sample_and_log(prev_timestamp, label)
#define PROFILE_SAMPLE_AND_LOG2(prev_timestamp, label) \
machdep_profile_sample_and_log(prev_timestamp, label)
#else
#define PROFILE_VAR(...)
#define PROFILE_SAMPLE(timestamp)
#define PROFILE_SAMPLE_AND_LOG(timestamp, prev_timestamp, label)
#define PROFILE_SAMPLE_AND_LOG2(prev_timestamp, label)
#endif
void machdep_profile_init(void);
void machdep_profile_reset(void);
unsigned int machdep_profile_sample(void);
unsigned int machdep_profile_sample_and_log(unsigned int start, char s[]);
void machdep_profile_print_logged_samples(void);
#endif

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#include "defines.h"
#include "nlp.h"
#include "dump.h"
#include "kiss_fft.h"
#undef PROFILE
#include "machdep.h"
#include <assert.h>
#include <math.h>
#include <stdlib.h>
/*---------------------------------------------------------------------------*\
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; i<m/DEC; i++) {
nlp->w[i] = 0.5 - 0.5*cosf(2*PI*i/(m/DEC-1));
}
for(i=0; i<PMAX_M; i++)
nlp->sq[i] = 0.0;
nlp->mem_x = 0.0;
nlp->mem_y = 0.0;
for(i=0; i<NLP_NTAP; i++)
nlp->mem_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;
PROFILE_VAR(start, tnotch, filter, peakpick, window, fft, magsq, shiftmem);
assert(nlp_state != NULL);
nlp = (NLP*)nlp_state;
m = nlp->m;
PROFILE_SAMPLE(start);
/* Square, notch filter at DC, and LP filter vector */
for(i=m-n; i<m; i++) /* square latest speech samples */
nlp->sq[i] = Sn[i]*Sn[i];
for(i=m-n; i<m; i++) { /* notch filter at DC */
notch = nlp->sq[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. */
}
PROFILE_SAMPLE_AND_LOG(tnotch, start, " square and notch");
for(i=m-n; i<m; i++) { /* FIR filter vector */
for(j=0; j<NLP_NTAP-1; j++)
nlp->mem_fir[j] = nlp->mem_fir[j+1];
nlp->mem_fir[NLP_NTAP-1] = nlp->sq[i];
nlp->sq[i] = 0.0;
for(j=0; j<NLP_NTAP; j++)
nlp->sq[i] += nlp->mem_fir[j]*nlp_fir[j];
}
PROFILE_SAMPLE_AND_LOG(filter, tnotch, " filter");
/* Decimate and DFT */
for(i=0; i<PE_FFT_SIZE; i++) {
fw[i].real = 0.0;
fw[i].imag = 0.0;
}
for(i=0; i<m/DEC; i++) {
fw[i].real = nlp->sq[i*DEC]*nlp->w[i];
}
PROFILE_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);
PROFILE_SAMPLE_AND_LOG(fft, window, " fft");
for(i=0; i<PE_FFT_SIZE; i++)
Fw[i].real = Fw[i].real*Fw[i].real + Fw[i].imag*Fw[i].imag;
PROFILE_SAMPLE_AND_LOG(magsq, fft, " mag sq");
#ifdef DUMP
dump_sq(nlp->sq);
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;
}
}
PROFILE_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
PROFILE_SAMPLE_AND_LOG(shiftmem, peakpick, " post process");
/* Shift samples in buffer to make room for new samples */
for(i=0; i<m-n; i++)
nlp->sq[i] = nlp->sq[i+n];
/* return pitch and F0 estimate */
*pitch = (float)SAMPLE_RATE/best_f0;
PROFILE_SAMPLE_AND_LOG2(shiftmem, " shift mem");
PROFILE_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<F0_MAX; i++)
e_hz[i] = -1;
#endif
e_min = 1E32;
best_f0 = 50;
for(i=PE_FFT_SIZE*DEC/pmax; i<=PE_FFT_SIZE*DEC/pmin; i++) {
if ((Fw[i].real > 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<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 */
for(m=al; m<bl; m++) {
offset = FFT_ENC/2 + m - l*Wo*FFT_ENC/TWO_PI + 0.5;
Am.real += Sw[m].real*W[offset].real + Sw[m].imag*W[offset].imag;
Am.imag += Sw[m].imag*W[offset].real - Sw[m].real*W[offset].imag;
den += W[offset].real*W[offset].real + W[offset].imag*W[offset].imag;
}
Am.real = Am.real/den;
Am.imag = Am.imag/den;
/* Determine error between estimated harmonic and original */
for(m=al; m<bl; m++) {
offset = FFT_ENC/2 + m - l*Wo*FFT_ENC/TWO_PI + 0.5;
Sw_[m].real = Am.real*W[offset].real - Am.imag*W[offset].imag;
Sw_[m].imag = Am.real*W[offset].imag + Am.imag*W[offset].real;
error += (Sw[m].real - Sw_[m].real)*(Sw[m].real - Sw_[m].real);
error += (Sw[m].imag - Sw_[m].imag)*(Sw[m].imag - Sw_[m].imag);
}
}
return error;
}

View file

@ -1,38 +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 <http://www.gnu.org/licenses/>.
*/
#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

View file

@ -1,53 +0,0 @@
/* Generate using fir1(47,1/2) in Octave */
const float fdmdv_os_filter[]= {
-0.0008215855034550382,
-0.0007833023901802921,
0.001075563790768233,
0.001199092367787555,
-0.001765309502928316,
-0.002055372115328064,
0.002986877604154257,
0.003462567920638414,
-0.004856570111126334,
-0.005563143845031497,
0.007533613299748122,
0.008563932468880897,
-0.01126857129039911,
-0.01280782411693687,
0.01651443896361847,
0.01894875110322284,
-0.02421604439474981,
-0.02845107338464062,
0.03672973563400258,
0.04542046150312214,
-0.06189165826716491,
-0.08721876380763803,
0.1496157094199961,
0.4497962274137046,
0.4497962274137046,
0.1496157094199961,
-0.08721876380763803,
-0.0618916582671649,
0.04542046150312216,
0.03672973563400257,
-0.02845107338464062,
-0.02421604439474984,
0.01894875110322284,
0.01651443896361848,
-0.01280782411693687,
-0.0112685712903991,
0.008563932468880899,
0.007533613299748123,
-0.005563143845031501,
-0.004856570111126346,
0.003462567920638419,
0.002986877604154259,
-0.002055372115328063,
-0.001765309502928318,
0.001199092367787557,
0.001075563790768233,
-0.0007833023901802925,
-0.0008215855034550383
};

View file

@ -1,140 +0,0 @@
/*
Copyright (C) 2010 Perens LLC <bruce@perens.com>
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 <http://www.gnu.org/licenses/>.
*/
#include "defines.h"
#include "quantise.h"
#include <stdio.h>
/* 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;
}

View file

@ -1,199 +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 <http://www.gnu.org/licenses/>.
*/
#include "defines.h"
#include "phase.h"
#include "kiss_fft.h"
#include "comp.h"
#include "sine.h"
#include <assert.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
/*---------------------------------------------------------------------------*\
phase_synth_zero_order()
Synthesises phases based on SNR and a rule based approach. No phase
parameters are required apart from the SNR (which can be reduced to a
1 bit V/UV decision per frame).
The phase of each harmonic is modelled as the phase of a LPC
synthesis filter excited by an impulse. Unlike the first order
model the position of the impulse is not transmitted, so we create
an excitation pulse train using a rule based approach.
Consider a pulse train with a pulse starting time n=0, with pulses
repeated at a rate of Wo, the fundamental frequency. A pulse train
in the time domain is equivalent to harmonics in the frequency
domain. We can make an excitation pulse train using a sum of
sinsusoids:
for(m=1; m<=L; m++)
ex[n] = cos(m*Wo*n)
Note: the Octave script ../octave/phase.m is an example of this if
you would like to try making a pulse train.
The phase of each excitation harmonic is:
arg(E[m]) = mWo
where E[m] are the complex excitation (freq domain) samples,
arg(x), just returns the phase of a complex sample x.
As we don't transmit the pulse position for this model, we need to
synthesise it. Now the excitation pulses occur at a rate of Wo.
This means the phase of the first harmonic advances by N samples
over a synthesis frame of N samples. For example if Wo is pi/20
(200 Hz), then over a 10ms frame (N=80 samples), the phase of the
first harmonic would advance (pi/20)*80 = 4*pi or two complete
cycles.
We generate the excitation phase of the fundamental (first
harmonic):
arg[E[1]] = Wo*N;
We then relate the phase of the m-th excitation harmonic to the
phase of the fundamental as:
arg(E[m]) = m*arg(E[1])
This E[m] then gets passed through the LPC synthesis filter to
determine the final harmonic phase.
Comparing to speech synthesised using original phases:
- Through headphones speech synthesised with this model is not as
good. Through a loudspeaker it is very close to original phases.
- If there are voicing errors, the speech can sound clicky or
staticy. If V speech is mistakenly declared UV, this model tends to
synthesise impulses or clicks, as there is usually very little shift or
dispersion through the LPC filter.
- When combined with LPC amplitude modelling there is an additional
drop in quality. I am not sure why, theory is interformant energy
is raised making any phase errors more obvious.
NOTES:
1/ This synthesis model is effectively the same as a simple LPC-10
vocoders, and yet sounds much better. Why? Conventional wisdom
(AMBE, MELP) says mixed voicing is required for high quality
speech.
2/ I am pretty sure the Lincoln Lab sinusoidal coding guys (like xMBE
also from MIT) first described this zero phase model, I need to look
up the paper.
3/ Note that this approach could cause some discontinuities in
the phase at the edge of synthesis frames, as no attempt is made
to make sure that the phase tracks are continuous (the excitation
phases are continuous, but not the final phases after filtering
by the LPC spectra). Technically this is a bad thing. However
this may actually be a good thing, disturbing the phase tracks a
bit. More research needed, e.g. test a synthesis model that adds
a small delta-W to make phase tracks line up for voiced
harmonics.
\*---------------------------------------------------------------------------*/
void phase_synth_zero_order(
kiss_fft_cfg fft_fwd_cfg,
MODEL *model,
float *ex_phase, /* excitation phase of fundamental */
COMP A[]
)
{
int m, b;
float phi_, new_phi, r;
COMP Ex[MAX_AMP+1]; /* excitation samples */
COMP A_[MAX_AMP+1]; /* synthesised harmonic samples */
COMP H[MAX_AMP+1]; /* LPC freq domain samples */
r = TWO_PI/(FFT_ENC);
/* Sample phase at harmonics */
for(m=1; m<=model->L; m++) {
b = (int)(m*model->Wo/r + 0.5);
phi_ = -atan2f(A[b].imag, A[b].real);
H[m].real = cosf(phi_);
H[m].imag = sinf(phi_);
}
/*
Update excitation fundamental phase track, this sets the position
of each pitch pulse during voiced speech. After much experiment
I found that using just this frame's Wo improved quality for UV
sounds compared to interpolating two frames Wo like this:
ex_phase[0] += (*prev_Wo+model->Wo)*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;
}
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef __PHASE__
#define __PHASE__
#include "kiss_fft.h"
#include "comp.h"
void phase_synth_zero_order(kiss_fft_cfg fft_dec_cfg,
MODEL *model,
float *ex_phase,
COMP A[]);
#endif

View file

@ -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
};

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#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
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef __POSTFILTER__
#define __POSTFILTER__
void postfilter(MODEL *model, float *bg_est);
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,127 +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 <http://www.gnu.org/licenses/>.
*/
#ifndef __QUANTISE__
#define __QUANTISE__
#include "kiss_fft.h"
#include "comp.h"
#define WO_BITS 7
#define WO_LEVELS (1<<WO_BITS)
#define WO_DT_BITS 3
#define E_BITS 5
#define E_LEVELS (1<<E_BITS)
#define E_MIN_DB -10.0
#define E_MAX_DB 40.0
#define LSP_SCALAR_INDEXES 10
#define LSPD_SCALAR_INDEXES 10
#define LSP_PRED_VQ_INDEXES 3
#define LSP_DIFF_FREQ_INDEXES 5
#define LSP_DIFF_TIME_BITS 7
#define LSPDT_ALL 0
#define LSPDT_LOW 1
#define LSPDT_HIGH 2
#define WO_E_BITS 8
#define LPCPF_GAMMA 0.5
#define LPCPF_BETA 0.2
void quantise_init();
float lpc_model_amplitudes(float Sn[], float w[], MODEL *model, int order,
int lsp,float ak[]);
void aks_to_M2(kiss_fft_cfg fft_fwd_cfg, float ak[], int order, MODEL *model,
float E, float *snr, int dump, int sim_pf,
int pf, int bass_boost, float beta, float gamma, COMP Aw[]);
int encode_Wo(float Wo);
float decode_Wo(int index);
int encode_Wo_dt(float Wo, float prev_Wo);
float decode_Wo_dt(int index, float prev_Wo);
void encode_lsps_scalar(int indexes[], float lsp[], int order);
void decode_lsps_scalar(float lsp[], int indexes[], int order);
void encode_lspds_scalar(int indexes[], float lsp[], int order);
void decode_lspds_scalar(float lsp[], int indexes[], int order);
void encode_lsps_diff_freq_vq(int indexes[], float lsp[], int order);
void decode_lsps_diff_freq_vq(float lsp_[], int indexes[], int order);
void encode_lsps_diff_time(int indexes[],
float lsp[],
float lsp__prev[],
int order);
void decode_lsps_diff_time(float lsp_[],
int indexes[],
float lsp__prev[],
int order);
void encode_lsps_vq(int *indexes, float *x, float *xq, int order);
void decode_lsps_vq(int *indexes, float *xq, int order);
long quantise(const float * cb, float vec[], float w[], int k, int m, float *se);
void lspvq_quantise(float lsp[], float lsp_[], int order);
void lspjnd_quantise(float lsp[], float lsp_[], int order);
void lspdt_quantise(float lsps[], float lsps_[], float lsps__prev[], int mode);
void lspjvm_quantise(float lsps[], float lsps_[], int order);
void lspanssi_quantise(float lsps[], float lsps_[], int order, int mbest_entries);
void quantise_WoE(MODEL *model, float *e, float xq[]);
int encode_WoE(MODEL *model, float e, float xq[]);
void decode_WoE(MODEL *model, float *e, float xq[], int n1);
int encode_energy(float e);
float decode_energy(int index);
void pack(unsigned char * bits, unsigned int *nbit, int index, unsigned int index_bits);
void pack_natural_or_gray(unsigned char * bits, unsigned int *nbit, int index, unsigned int index_bits, unsigned int gray);
int unpack(const unsigned char * bits, unsigned int *nbit, unsigned int index_bits);
int unpack_natural_or_gray(const unsigned char * bits, unsigned int *nbit, unsigned int index_bits, unsigned int gray);
int lsp_bits(int i);
int lspd_bits(int i);
int lspdt_bits(int i);
int lsp_pred_vq_bits(int i);
void apply_lpc_correction(MODEL *model);
float speech_to_uq_lsps(float lsp[],
float ak[],
float Sn[],
float w[],
int order
);
int check_lsp_order(float lsp[], int lpc_order);
void bw_expand_lsps(float lsp[], int order, float min_sep_low, float min_sep_high);
void bw_expand_lsps2(float lsp[], int order);
void locate_lsps_jnd_steps(float lsp[], int order);
float decode_amplitudes(MODEL *model,
float ak[],
int lsp_indexes[],
int energy_index,
float lsps[],
float *e);
#endif

View file

@ -1,964 +0,0 @@
/* Generated by rn_file() Octave function */
const float gt_alpha5_root[]={
2.86997e-05,
2.2286e-05,
1.82863e-05,
1.42303e-05,
1.04905e-05,
6.70859e-06,
3.05918e-06,
-6.22187e-07,
-4.22748e-06,
-7.85603e-06,
-1.14317e-05,
-1.50227e-05,
-1.85712e-05,
-2.21275e-05,
-2.56455e-05,
-2.91642e-05,
-3.26453e-05,
-3.61199e-05,
-3.95556e-05,
-4.29778e-05,
-4.63581e-05,
-4.97179e-05,
-5.3032e-05,
-5.63184e-05,
-5.95548e-05,
-6.27565e-05,
-6.59032e-05,
-6.90085e-05,
-7.20538e-05,
-7.50509e-05,
-7.7983e-05,
-8.08605e-05,
-8.36678e-05,
-8.64141e-05,
-8.9085e-05,
-9.16888e-05,
-9.42119e-05,
-9.66619e-05,
-9.9026e-05,
-0.000101311,
-0.000103505,
-0.000105614,
-0.000107627,
-0.00010955,
-0.000111372,
-0.000113099,
-0.00011472,
-0.000116241,
-0.000117652,
-0.000118959,
-0.000120152,
-0.000121235,
-0.000122201,
-0.000123053,
-0.000123784,
-0.000124397,
-0.000124884,
-0.00012525,
-0.000125487,
-0.000125598,
-0.000125578,
-0.000125428,
-0.000125145,
-0.000124729,
-0.000124185,
-0.000123518,
-0.000122709,
-0.000121766,
-0.000120685,
-0.000119471,
-0.000118119,
-0.000116633,
-0.000115009,
-0.000113251,
-0.000111356,
-0.000109326,
-0.00010716,
-0.00010486,
-0.000102424,
-9.98553e-05,
-9.71528e-05,
-9.43199e-05,
-9.13551e-05,
-8.82623e-05,
-8.50404e-05,
-8.16936e-05,
-7.82211e-05,
-7.46271e-05,
-7.09109e-05,
-6.70773e-05,
-6.31256e-05,
-5.90607e-05,
-5.48823e-05,
-5.05954e-05,
-4.62001e-05,
-4.17016e-05,
-3.71002e-05,
-3.24015e-05,
-2.7606e-05,
-2.27195e-05,
-1.77428e-05,
-1.2682e-05,
-7.53795e-06,
-2.31702e-06,
2.97965e-06,
8.34567e-06,
1.37796e-05,
1.9275e-05,
2.483e-05,
3.04382e-05,
3.60975e-05,
4.18011e-05,
4.75467e-05,
5.33273e-05,
5.91403e-05,
6.49787e-05,
7.08393e-05,
7.67152e-05,
8.26029e-05,
8.84957e-05,
9.43895e-05,
0.000100278,
0.000106157,
0.00011202,
0.000117864,
0.000123681,
0.000129468,
0.000135218,
0.000140929,
0.000146583,
0.000152183,
0.000157725,
0.000163202,
0.000168608,
0.000173938,
0.000179183,
0.00018434,
0.0001894,
0.00019436,
0.000199211,
0.000203949,
0.000208568,
0.000213063,
0.000217426,
0.000221654,
0.00022574,
0.000229678,
0.000233463,
0.000237089,
0.000240551,
0.000243843,
0.000246959,
0.000249895,
0.000252644,
0.000255202,
0.000257562,
0.000259721,
0.000261672,
0.000263411,
0.000264933,
0.000266234,
0.000267308,
0.000268152,
0.00026876,
0.000269128,
0.000269253,
0.000269129,
0.000268754,
0.000268123,
0.000267232,
0.000266079,
0.000264658,
0.000262968,
0.000261006,
0.000258767,
0.000256251,
0.000253453,
0.000250373,
0.000247007,
0.000243354,
0.000239412,
0.00023518,
0.000230655,
0.000225837,
0.000220723,
0.000215314,
0.000209608,
0.000203605,
0.000197304,
0.000190706,
0.000183812,
0.000176621,
0.000169145,
0.000161363,
0.000153275,
0.000144895,
0.000136224,
0.000127266,
0.00011802,
0.000108491,
9.8679e-05,
8.85877e-05,
7.82196e-05,
6.7577e-05,
5.66636e-05,
4.54822e-05,
3.40369e-05,
2.23311e-05,
1.03695e-05,
-1.844e-06,
-1.43041e-05,
-2.70061e-05,
-3.99444e-05,
-5.31139e-05,
-6.65082e-05,
-8.01218e-05,
-9.39481e-05,
-0.000107981,
-0.000122213,
-0.000136638,
-0.000151248,
-0.000166036,
-0.000180995,
-0.000196115,
-0.00021139,
-0.000226811,
-0.000242369,
-0.000258056,
-0.000273861,
-0.000289776,
-0.000305792,
-0.000321898,
-0.000338084,
-0.000354342,
-0.00037066,
-0.000387027,
-0.000403434,
-0.00041987,
-0.000436324,
-0.000452784,
-0.00046924,
-0.00048568,
-0.000502091,
-0.000518464,
-0.000534785,
-0.000551043,
-0.000567225,
-0.000583319,
-0.000599314,
-0.000615196,
-0.000630955,
-0.000646575,
-0.000662049,
-0.000677361,
-0.000692506,
-0.000707464,
-0.00072229,
-0.000736922,
-0.000751266,
-0.000765372,
-0.000779217,
-0.000792798,
-0.000806094,
-0.000819098,
-0.000831793,
-0.000844168,
-0.000856207,
-0.000867898,
-0.000879227,
-0.00089018,
-0.000900744,
-0.000910906,
-0.000920652,
-0.00092997,
-0.000938844,
-0.000947263,
-0.000955214,
-0.000962682,
-0.000969654,
-0.000976119,
-0.000982062,
-0.00098747,
-0.000992332,
-0.000996634,
-0.00100036,
-0.00100351,
-0.00100606,
-0.001008,
-0.00100932,
-0.00101,
-0.00101005,
-0.00100943,
-0.00100816,
-0.0010062,
-0.00100356,
-0.00100021,
-0.000996162,
-0.000991392,
-0.000985892,
-0.000979654,
-0.000972668,
-0.000964925,
-0.000956415,
-0.000947131,
-0.000937065,
-0.000926208,
-0.000914552,
-0.00090209,
-0.000888816,
-0.000874721,
-0.0008598,
-0.000844046,
-0.000827453,
-0.000810015,
-0.000791726,
-0.000772581,
-0.000752576,
-0.000731704,
-0.000709965,
-0.00068735,
-0.000663865,
-0.000639509,
-0.000614269,
-0.000588146,
-0.000561139,
-0.000533246,
-0.000504468,
-0.000474802,
-0.000444251,
-0.000412813,
-0.00038049,
-0.000347281,
-0.000313189,
-0.000278215,
-0.000242361,
-0.000205629,
-0.000168024,
-0.000129546,
-9.02024e-05,
-4.99954e-05,
-8.93026e-06,
3.2988e-05,
7.57537e-05,
0.000119361,
0.000163804,
0.000209075,
0.000255167,
0.000302074,
0.000349786,
0.000398297,
0.000447596,
0.000497676,
0.000548526,
0.000600136,
0.000652497,
0.000705598,
0.000759427,
0.000813972,
0.000869223,
0.000925166,
0.000981789,
0.00103908,
0.00109702,
0.00115561,
0.00121482,
0.00127464,
0.00133505,
0.00139605,
0.00145762,
0.00151973,
0.00158238,
0.00164555,
0.00170922,
0.00177337,
0.00183799,
0.00190305,
0.00196854,
0.00203445,
0.00210075,
0.00216742,
0.00223445,
0.00230181,
0.00236949,
0.00243747,
0.00250572,
0.00257423,
0.00264296,
0.00271192,
0.00278107,
0.00285039,
0.00291986,
0.00298947,
0.00305918,
0.00312898,
0.00319884,
0.00326874,
0.00333866,
0.00340857,
0.00347846,
0.00354831,
0.00361808,
0.00368775,
0.00375731,
0.00382673,
0.00389599,
0.00396506,
0.00403393,
0.00410256,
0.00417094,
0.00423904,
0.00430684,
0.00437431,
0.00444144,
0.0045082,
0.00457457,
0.00464052,
0.00470603,
0.00477108,
0.00483565,
0.00489972,
0.00496325,
0.00502623,
0.00508865,
0.00515046,
0.00521166,
0.00527223,
0.00533213,
0.00539135,
0.00544987,
0.00550766,
0.00556472,
0.005621,
0.00567651,
0.00573121,
0.00578508,
0.00583811,
0.00589028,
0.00594157,
0.00599196,
0.00604143,
0.00608996,
0.00613754,
0.00618415,
0.00622977,
0.00627439,
0.00631798,
0.00636054,
0.00640204,
0.0064425,
0.00648186,
0.00652009,
0.00655722,
0.00659322,
0.00662808,
0.00666179,
0.00669433,
0.00672571,
0.00675589,
0.00678488,
0.00681266,
0.00683921,
0.00686454,
0.00688863,
0.00691147,
0.00693305,
0.00695336,
0.0069724,
0.00699016,
0.00700663,
0.00702181,
0.00703569,
0.00704826,
0.00705952,
0.00706947,
0.00707809,
0.0070854,
0.00709138,
0.00709604,
0.00709937,
0.00710136,
0.00710203,
0.00710136,
0.00709937,
0.00709604,
0.00709138,
0.0070854,
0.00707809,
0.00706947,
0.00705952,
0.00704826,
0.00703569,
0.00702181,
0.00700663,
0.00699016,
0.0069724,
0.00695336,
0.00693305,
0.00691147,
0.00688863,
0.00686454,
0.00683921,
0.00681266,
0.00678488,
0.00675589,
0.00672571,
0.00669433,
0.00666179,
0.00662808,
0.00659322,
0.00655722,
0.00652009,
0.00648186,
0.0064425,
0.00640204,
0.00636054,
0.00631798,
0.00627439,
0.00622977,
0.00618415,
0.00613754,
0.00608996,
0.00604143,
0.00599196,
0.00594157,
0.00589028,
0.00583811,
0.00578508,
0.00573121,
0.00567651,
0.005621,
0.00556472,
0.00550766,
0.00544987,
0.00539135,
0.00533213,
0.00527223,
0.00521166,
0.00515046,
0.00508865,
0.00502623,
0.00496325,
0.00489972,
0.00483565,
0.00477108,
0.00470603,
0.00464052,
0.00457457,
0.0045082,
0.00444144,
0.00437431,
0.00430684,
0.00423904,
0.00417094,
0.00410256,
0.00403393,
0.00396506,
0.00389599,
0.00382673,
0.00375731,
0.00368775,
0.00361808,
0.00354831,
0.00347846,
0.00340857,
0.00333866,
0.00326874,
0.00319884,
0.00312898,
0.00305918,
0.00298947,
0.00291986,
0.00285039,
0.00278107,
0.00271192,
0.00264296,
0.00257423,
0.00250572,
0.00243747,
0.00236949,
0.00230181,
0.00223445,
0.00216742,
0.00210075,
0.00203445,
0.00196854,
0.00190305,
0.00183799,
0.00177337,
0.00170922,
0.00164555,
0.00158238,
0.00151973,
0.00145762,
0.00139605,
0.00133505,
0.00127464,
0.00121482,
0.00115561,
0.00109702,
0.00103908,
0.000981789,
0.000925166,
0.000869223,
0.000813972,
0.000759427,
0.000705598,
0.000652497,
0.000600136,
0.000548526,
0.000497676,
0.000447596,
0.000398297,
0.000349786,
0.000302074,
0.000255167,
0.000209075,
0.000163804,
0.000119361,
7.57537e-05,
3.2988e-05,
-8.93026e-06,
-4.99954e-05,
-9.02024e-05,
-0.000129546,
-0.000168024,
-0.000205629,
-0.000242361,
-0.000278215,
-0.000313189,
-0.000347281,
-0.00038049,
-0.000412813,
-0.000444251,
-0.000474802,
-0.000504468,
-0.000533246,
-0.000561139,
-0.000588146,
-0.000614269,
-0.000639509,
-0.000663865,
-0.00068735,
-0.000709965,
-0.000731704,
-0.000752576,
-0.000772581,
-0.000791726,
-0.000810015,
-0.000827453,
-0.000844046,
-0.0008598,
-0.000874721,
-0.000888816,
-0.00090209,
-0.000914552,
-0.000926208,
-0.000937065,
-0.000947131,
-0.000956415,
-0.000964925,
-0.000972668,
-0.000979654,
-0.000985892,
-0.000991392,
-0.000996162,
-0.00100021,
-0.00100356,
-0.0010062,
-0.00100816,
-0.00100943,
-0.00101005,
-0.00101,
-0.00100932,
-0.001008,
-0.00100606,
-0.00100351,
-0.00100036,
-0.000996634,
-0.000992332,
-0.00098747,
-0.000982062,
-0.000976119,
-0.000969654,
-0.000962682,
-0.000955214,
-0.000947263,
-0.000938844,
-0.00092997,
-0.000920652,
-0.000910906,
-0.000900744,
-0.00089018,
-0.000879227,
-0.000867898,
-0.000856207,
-0.000844168,
-0.000831793,
-0.000819098,
-0.000806094,
-0.000792798,
-0.000779217,
-0.000765372,
-0.000751266,
-0.000736922,
-0.00072229,
-0.000707464,
-0.000692506,
-0.000677361,
-0.000662049,
-0.000646575,
-0.000630955,
-0.000615196,
-0.000599314,
-0.000583319,
-0.000567225,
-0.000551043,
-0.000534785,
-0.000518464,
-0.000502091,
-0.00048568,
-0.00046924,
-0.000452784,
-0.000436324,
-0.00041987,
-0.000403434,
-0.000387027,
-0.00037066,
-0.000354342,
-0.000338084,
-0.000321898,
-0.000305792,
-0.000289776,
-0.000273861,
-0.000258056,
-0.000242369,
-0.000226811,
-0.00021139,
-0.000196115,
-0.000180995,
-0.000166036,
-0.000151248,
-0.000136638,
-0.000122213,
-0.000107981,
-9.39481e-05,
-8.01218e-05,
-6.65082e-05,
-5.31139e-05,
-3.99444e-05,
-2.70061e-05,
-1.43041e-05,
-1.844e-06,
1.03695e-05,
2.23311e-05,
3.40369e-05,
4.54822e-05,
5.66636e-05,
6.7577e-05,
7.82196e-05,
8.85877e-05,
9.8679e-05,
0.000108491,
0.00011802,
0.000127266,
0.000136224,
0.000144895,
0.000153275,
0.000161363,
0.000169145,
0.000176621,
0.000183812,
0.000190706,
0.000197304,
0.000203605,
0.000209608,
0.000215314,
0.000220723,
0.000225837,
0.000230655,
0.00023518,
0.000239412,
0.000243354,
0.000247007,
0.000250373,
0.000253453,
0.000256251,
0.000258767,
0.000261006,
0.000262968,
0.000264658,
0.000266079,
0.000267232,
0.000268123,
0.000268754,
0.000269129,
0.000269253,
0.000269128,
0.00026876,
0.000268152,
0.000267308,
0.000266234,
0.000264933,
0.000263411,
0.000261672,
0.000259721,
0.000257562,
0.000255202,
0.000252644,
0.000249895,
0.000246959,
0.000243843,
0.000240551,
0.000237089,
0.000233463,
0.000229678,
0.00022574,
0.000221654,
0.000217426,
0.000213063,
0.000208568,
0.000203949,
0.000199211,
0.00019436,
0.0001894,
0.00018434,
0.000179183,
0.000173938,
0.000168608,
0.000163202,
0.000157725,
0.000152183,
0.000146583,
0.000140929,
0.000135218,
0.000129468,
0.000123681,
0.000117864,
0.00011202,
0.000106157,
0.000100278,
9.43895e-05,
8.84957e-05,
8.26029e-05,
7.67152e-05,
7.08393e-05,
6.49787e-05,
5.91403e-05,
5.33273e-05,
4.75467e-05,
4.18011e-05,
3.60975e-05,
3.04382e-05,
2.483e-05,
1.9275e-05,
1.37796e-05,
8.34567e-06,
2.97965e-06,
-2.31702e-06,
-7.53795e-06,
-1.2682e-05,
-1.77428e-05,
-2.27195e-05,
-2.7606e-05,
-3.24015e-05,
-3.71002e-05,
-4.17016e-05,
-4.62001e-05,
-5.05954e-05,
-5.48823e-05,
-5.90607e-05,
-6.31256e-05,
-6.70773e-05,
-7.09109e-05,
-7.46271e-05,
-7.82211e-05,
-8.16936e-05,
-8.50404e-05,
-8.82623e-05,
-9.13551e-05,
-9.43199e-05,
-9.71528e-05,
-9.98553e-05,
-0.000102424,
-0.00010486,
-0.00010716,
-0.000109326,
-0.000111356,
-0.000113251,
-0.000115009,
-0.000116633,
-0.000118119,
-0.000119471,
-0.000120685,
-0.000121766,
-0.000122709,
-0.000123518,
-0.000124185,
-0.000124729,
-0.000125145,
-0.000125428,
-0.000125578,
-0.000125598,
-0.000125487,
-0.00012525,
-0.000124884,
-0.000124397,
-0.000123784,
-0.000123053,
-0.000122201,
-0.000121235,
-0.000120152,
-0.000118959,
-0.000117652,
-0.000116241,
-0.00011472,
-0.000113099,
-0.000111372,
-0.00010955,
-0.000107627,
-0.000105614,
-0.000103505,
-0.000101311,
-9.9026e-05,
-9.66619e-05,
-9.42119e-05,
-9.16888e-05,
-8.9085e-05,
-8.64141e-05,
-8.36678e-05,
-8.08605e-05,
-7.7983e-05,
-7.50509e-05,
-7.20538e-05,
-6.90085e-05,
-6.59032e-05,
-6.27565e-05,
-5.95548e-05,
-5.63184e-05,
-5.3032e-05,
-4.97179e-05,
-4.63581e-05,
-4.29778e-05,
-3.95556e-05,
-3.61199e-05,
-3.26453e-05,
-2.91642e-05,
-2.56455e-05,
-2.21275e-05,
-1.85712e-05,
-1.50227e-05,
-1.14317e-05,
-7.85603e-06,
-4.22748e-06,
-6.22187e-07,
3.05918e-06,
6.70859e-06,
1.04905e-05,
1.42303e-05,
1.82863e-05,
2.2286e-05
};

View file

@ -1,35 +0,0 @@
/* Generated by rxdec_file() Octave function */
const float rxdec_coeff[]={
-0.00125472,
-0.00204605,
-0.0019897,
0.000163906,
0.00490937,
0.00986375,
0.0096718,
-0.000480351,
-0.019311,
-0.0361822,
-0.0341251,
0.000827866,
0.0690577,
0.152812,
0.222115,
0.249004,
0.222115,
0.152812,
0.0690577,
0.000827866,
-0.0341251,
-0.0361822,
-0.019311,
-0.000480351,
0.0096718,
0.00986375,
0.00490937,
0.000163906,
-0.0019897,
-0.00204605,
-0.00125472
};

View file

@ -1,647 +0,0 @@
/*---------------------------------------------------------------------------*\
FILE........: sine.c
AUTHOR......: David Rowe
DATE CREATED: 19/8/2010
Sinusoidal analysis and synthesis functions.
\*---------------------------------------------------------------------------*/
/*
Copyright (C) 1990-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 <http://www.gnu.org/licenses/>.
*/
/*---------------------------------------------------------------------------*\
INCLUDES
\*---------------------------------------------------------------------------*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#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; i<M/2-NW/2; i++)
w[i] = 0.0;
for(i=M/2-NW/2,j=0; i<M/2+NW/2; i++,j++) {
w[i] = 0.5 - 0.5*cosf(TWO_PI*j/(NW-1));
m += w[i]*w[i];
}
for(i=M/2+NW/2; i<M; i++)
w[i] = 0.0;
/* Normalise - makes freq domain amplitude estimation straight
forward */
m = 1.0/sqrtf(m*FFT_ENC);
for(i=0; i<M; i++) {
w[i] *= m;
}
/*
Generate DFT of analysis window, used for later processing. Note
we modulo FFT_ENC shift the time domain window w[], this makes the
imaginary part of the DFT W[] equal to zero as the shifted w[] is
even about the n=0 time axis if NW is odd. Having the imag part
of the DFT W[] makes computation easier.
0 FFT_ENC-1
|-------------------------|
----\ /----
\ /
\ / <- shifted version of window w[n]
\ /
\ /
-------
|---------| |---------|
NW/2 NW/2
*/
for(i=0; i<FFT_ENC; i++) {
wshift[i].real = 0.0;
wshift[i].imag = 0.0;
}
for(i=0; i<NW/2; i++)
wshift[i].real = w[i+M/2];
for(i=FFT_ENC-NW/2,j=M/2-NW/2; i<FFT_ENC; i++,j++)
wshift[i].real = w[j];
kiss_fft(fft_fwd_cfg, (kiss_fft_cpx *)wshift, (kiss_fft_cpx *)W);
/*
Re-arrange W[] to be symmetrical about FFT_ENC/2. Makes later
analysis convenient.
Before:
0 FFT_ENC-1
|----------|---------|
__ _
\ /
\_______________/
After:
0 FFT_ENC-1
|----------|---------|
___
/ \
________/ \_______
*/
for(i=0; i<FFT_ENC/2; i++) {
temp.real = W[i].real;
temp.imag = W[i].imag;
W[i].real = W[i+FFT_ENC/2].real;
W[i].imag = W[i+FFT_ENC/2].imag;
W[i+FFT_ENC/2].real = temp.real;
W[i+FFT_ENC/2].imag = temp.imag;
}
}
/*---------------------------------------------------------------------------*\
FUNCTION....: hpf
AUTHOR......: David Rowe
DATE CREATED: 16 Nov 2010
High pass filter with a -3dB point of about 160Hz.
y(n) = -HPF_BETA*y(n-1) + x(n) - x(n-1)
\*---------------------------------------------------------------------------*/
float hpf(float x, float states[])
{
states[0] = -HPF_BETA*states[0] + x - states[1];
states[1] = x;
return states[0];
}
/*---------------------------------------------------------------------------*\
FUNCTION....: dft_speech
AUTHOR......: David Rowe
DATE CREATED: 27/5/94
Finds the DFT of the current speech input speech frame.
\*---------------------------------------------------------------------------*/
void dft_speech(kiss_fft_cfg fft_fwd_cfg, COMP Sw[], float Sn[], float w[])
{
int i;
COMP sw[FFT_ENC];
for(i=0; i<FFT_ENC; i++) {
sw[i].real = 0.0;
sw[i].imag = 0.0;
}
/* Centre analysis window on time axis, we need to arrange input
to FFT this way to make FFT phases correct */
/* move 2nd half to start of FFT input vector */
for(i=0; i<NW/2; i++)
sw[i].real = Sn[i+M/2]*w[i+M/2];
/* move 1st half to end of FFT input vector */
for(i=0; i<NW/2; i++)
sw[FFT_ENC-NW/2+i].real = Sn[i+M/2-NW/2]*w[i+M/2-NW/2];
kiss_fft(fft_fwd_cfg, (kiss_fft_cpx *)sw, (kiss_fft_cpx *)Sw);
}
/*---------------------------------------------------------------------------*\
FUNCTION....: two_stage_pitch_refinement
AUTHOR......: David Rowe
DATE CREATED: 27/5/94
Refines the current pitch estimate using the harmonic sum pitch
estimation technique.
\*---------------------------------------------------------------------------*/
void two_stage_pitch_refinement(MODEL *model, COMP Sw[])
{
float pmin,pmax,pstep; /* pitch refinment minimum, maximum and step */
/* Coarse refinement */
pmax = TWO_PI/model->Wo + 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; i<bm; i++) {
den += Sw[i].real*Sw[i].real + Sw[i].imag*Sw[i].imag;
Am.real += Sw[i].real*W[i + offset].real;
Am.imag += Sw[i].imag*W[i + offset].real;
}
model->A[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 */
{
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; i<FFT_ENC; i++) {
Sw_[i].real = 0.0;
Sw_[i].imag = 0.0;
Ew[i].real = 0.0;
Ew[i].imag = 0.0;
}
Wo = model->Wo;
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<bl; m++) {
Am.real += Sw[m].real*W[offset+m].real;
Am.imag += Sw[m].imag*W[offset+m].real;
den += W[offset+m].real*W[offset+m].real;
}
Am.real = Am.real/den;
Am.imag = Am.imag/den;
/* Determine error between estimated harmonic and original */
offset = FFT_ENC/2 - l*Wo*FFT_ENC/TWO_PI + 0.5;
for(m=al; m<bl; m++) {
Sw_[m].real = Am.real*W[offset+m].real;
Sw_[m].imag = Am.imag*W[offset+m].real;
Ew[m].real = Sw[m].real - Sw_[m].real;
Ew[m].imag = Sw[m].imag - Sw_[m].imag;
error += Ew[m].real*Ew[m].real;
error += Ew[m].imag*Ew[m].imag;
}
}
snr = 10.0*log10f(sig/error);
if (snr > 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<N/2-TW; i++)
Pn[i] = 0.0;
win = 0.0;
for(i=N/2-TW; i<N/2+TW; win+=1.0/(2*TW), i++ )
Pn[i] = win;
for(i=N/2+TW; i<3*N/2-TW; i++)
Pn[i] = 1.0;
win = 1.0;
for(i=3*N/2-TW; i<3*N/2+TW; win-=1.0/(2*TW), i++)
Pn[i] = win;
for(i=3*N/2+TW; i<2*N; i++)
Pn[i] = 0.0;
}
/*---------------------------------------------------------------------------*\
FUNCTION....: synthesise
AUTHOR......: David Rowe
DATE CREATED: 20/2/95
Synthesise a speech signal in the frequency domain from the
sinusodal model parameters. Uses overlap-add with a trapezoidal
window to smoothly interpolate betwen frames.
\*---------------------------------------------------------------------------*/
void synthesise(
kiss_fft_cfg fft_inv_cfg,
float Sn_[], /* time domain synthesised signal */
MODEL *model, /* ptr to model parameters for this frame */
float Pn[], /* time domain Parzen window */
int shift /* flag used to handle transition frames */
)
{
int i,l,j,b; /* loop variables */
COMP Sw_[FFT_DEC]; /* DFT of synthesised signal */
COMP sw_[FFT_DEC]; /* synthesised signal */
if (shift) {
/* Update memories */
for(i=0; i<N-1; i++) {
Sn_[i] = Sn_[i+N];
}
Sn_[N-1] = 0.0;
}
for(i=0; i<FFT_DEC; i++) {
Sw_[i].real = 0.0;
Sw_[i].imag = 0.0;
}
/*
Nov 2010 - found that synthesis using time domain cos() functions
gives better results for synthesis frames greater than 10ms. Inverse
FFT synthesis using a 512 pt FFT works well for 10ms window. I think
(but am not sure) that the problem is related to the quantisation of
the harmonic frequencies to the FFT bin size, e.g. there is a
8000/512 Hz step between FFT bins. For some reason this makes
the speech from longer frame > 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; i<N-1; i++,j++) {
Sw_[FFT_DEC-N+1+i].real += 2.0*model->A[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<N-1; i++) {
Sn_[i] += sw_[FFT_DEC-N+1+i].real*Pn[i];
}
if (shift)
for(i=N-1,j=0; i<2*N; i++,j++)
Sn_[i] = sw_[j].real*Pn[i];
else
for(i=N-1,j=0; i<2*N; i++,j++)
Sn_[i] += sw_[j].real*Pn[i];
}
static unsigned long next = 1;
int codec2_rand(void) {
next = next * 1103515245 + 12345;
return((unsigned)(next/65536) % 32768);
}

View file

@ -1,47 +0,0 @@
/*---------------------------------------------------------------------------*\
FILE........: sine.h
AUTHOR......: David Rowe
DATE CREATED: 1/11/94
Header file for sinusoidal analysis and synthesis 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 <http://www.gnu.org/licenses/>.
*/
#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[]);
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

View file

@ -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
};

View file

@ -1,479 +0,0 @@
//==========================================================================
// Name: varicode.h
// Purpose: Varicode encoded and decode functions
// Created: Nov 24, 2012
// Authors: David Rowe
//
// To test:
// $ gcc varicode.c -o varicode -DVARICODE_UNITTEST -Wall
// $ ./varicode
//
// License:
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU 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 General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//
//==========================================================================
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "varicode.h"
#include "varicode_table.h"
/*
output is an unpacked array of bits of maximum size max_out. Note
unpacked arrays are a more suitable form for modulator input.
Code 1 covers the entire ASCII char set.
*/
int varicode_encode1(short varicode_out[], char ascii_in[], int max_out, int n_in) {
int n_out, index, n_zeros, v_len;
unsigned short byte1, byte2, packed;
n_out = 0;
while(n_in && (n_out < max_out)) {
assert((unsigned int)(*ascii_in) < 128);
index = 2*(unsigned int)(*ascii_in);
byte1 = varicode_table1[index];
byte2 = varicode_table1[index+1];
packed = (byte1 << 8) + byte2;
//printf("n_in: %d ascii_in: %c index: %d packed 0x%x\n", n_in, *ascii_in, index, packed);
ascii_in++;
n_zeros = 0;
v_len = 0;
while ((n_zeros < 2) && (n_out < max_out) && (v_len <= VARICODE_MAX_BITS)) {
if (packed & 0x8000) {
*varicode_out = 1;
n_zeros = 0;
}
else {
*varicode_out = 0;
n_zeros++;
}
//printf("packed: 0x%x *varicode_out: %d n_zeros: %d v_len: %d\n", packed, *varicode_out, n_zeros,v_len );
packed <<= 1;
varicode_out++;
n_out++;
v_len++;
}
assert(v_len <= VARICODE_MAX_BITS);
n_in--;
}
return n_out;
}
/*
Code 2 covers a subset, but is more efficient that Code 1 (282
compared to 1315 bits on unittest) Unsupported characters are
replaced by spaces. We encode/decode two bits at a time.
*/
int varicode_encode2(short varicode_out[], char ascii_in[], int max_out, int n_in) {
int n_out, n_zeros, v_len, i;
unsigned short packed;
n_out = 0;
while(n_in && (n_out < max_out)) {
packed = varicode_table2[0]; // default to space if char not found
// see if our character exists
for(i=0; i<sizeof(varicode_table2); i+=2) {
if (varicode_table2[i] == *ascii_in)
packed = (unsigned short)varicode_table2[i+1] << 8;
}
//printf("n_in: %d ascii_in: %c index: %d packed 0x%x\n", n_in, *ascii_in, index, packed);
ascii_in++;
n_zeros = 0;
v_len = 0;
while ((n_zeros < 2) && (n_out < max_out) && (v_len <= VARICODE_MAX_BITS)) {
if (packed & 0x8000)
varicode_out[0] = 1;
else
varicode_out[0] = 0;
if (packed & 0x4000)
varicode_out[1] = 1;
else
varicode_out[1] = 0;
if (packed & 0xc000)
n_zeros = 0;
else
n_zeros += 2;
//printf("packed: 0x%x *varicode_out: %d n_zeros: %d v_len: %d\n", packed, *varicode_out, n_zeros,v_len );
packed <<= 2;
varicode_out +=2;
n_out += 2;
v_len += 2;
}
assert(v_len <= VARICODE_MAX_BITS);
n_in--;
}
assert((n_out % 2) == 0); /* outputs two bits at a time */
return n_out;
}
int varicode_encode(short varicode_out[], char ascii_in[], int max_out, int n_in, int code_num) {
assert((code_num ==1) || (code_num ==2));
if (code_num == 1)
return varicode_encode1(varicode_out, ascii_in, max_out, n_in);
else
return varicode_encode2(varicode_out, ascii_in, max_out, n_in);
}
void varicode_decode_init(struct VARICODE_DEC *dec_states, int code_num)
{
assert((code_num ==1) || (code_num == 2));
dec_states->state = 0;
dec_states->n_zeros = 0;
dec_states->v_len = 0;
dec_states->packed = 0;
dec_states->code_num = code_num;
dec_states->n_in = 0;
dec_states->in[0] = dec_states->in[1] = 0;
}
/* Code 1 decode function, accepts one bit at a time */
static int decode_one_bit(struct VARICODE_DEC *s, char *single_ascii, short varicode_in, int long_code)
{
int found=0, i;
unsigned short byte1, byte2;
//printf("decode_one_bit : state: %d varicode_in: %d packed: 0x%x n_zeros: %d\n",
// s->state, varicode_in, s->packed, s->n_zeros);
if (s->state == 0) {
if (!varicode_in)
return 0;
else
s->state = 1;
}
if (s->state == 1) {
if (varicode_in) {
s->packed |= (0x8000 >> s->v_len);
s->n_zeros = 0;
}
else {
s->n_zeros++;
}
s->v_len++;
found = 0;
/* end of character code */
if (s->n_zeros == 2) {
if (s->v_len) {
/* run thru table but note with bit errors we might not actually find a match */
byte1 = s->packed >> 8;
//printf("looking for byte1 : 0x%x ... ", byte1);
byte2 = s->packed & 0xff;
for(i=0; i<128; i++) {
if ((byte1 == varicode_table1[2*i]) && (byte2 == varicode_table1[2*i+1])) {
found = 1;
*single_ascii = i;
}
}
}
varicode_decode_init(s, s->code_num);
}
/* code can run too long if we have a bit error */
if (s->v_len > VARICODE_MAX_BITS)
varicode_decode_init(s, s->code_num);
}
return found;
}
/* Code 2 decode function, accepts two bits at a time */
static int decode_two_bits(struct VARICODE_DEC *s, char *single_ascii, short varicode_in1, short varicode_in2)
{
int found=0, i;
unsigned short byte1;
if (s->state == 0) {
if (!(varicode_in1 || varicode_in2))
return 0;
else
s->state = 1;
}
if (s->state == 1) {
if (varicode_in1)
s->packed |= (0x8000 >> s->v_len);
if (varicode_in2)
s->packed |= (0x4000 >> s->v_len);
if (varicode_in1 || varicode_in2)
s->n_zeros = 0;
else
s->n_zeros+=2;
s->v_len+=2;
found = 0;
/* end of character code */
if (s->n_zeros == 2) {
if (s->v_len) {
/* run thru table but note with bit errors we might not actually find a match */
byte1 = s->packed >> 8;
//printf("looking for byte1 : 0x%x ... ", byte1);
for(i=0; i<sizeof(varicode_table2); i+=2) {
//printf("byte1: 0x%x 0x%x\n", byte1, (unsigned char)varicode_table2[i+1]);
if (byte1 == (unsigned char)varicode_table2[i+1]) {
found = 1;
*single_ascii = varicode_table2[i];
//printf("found: %d i=%d char=%c ", found, i, *single_ascii);
}
}
}
varicode_decode_init(s, s->code_num);
}
/* code can run too long if we have a bit error */
if (s->v_len > VARICODE_MAX_BITS)
varicode_decode_init(s, s->code_num);
}
return found;
}
int varicode_decode1(struct VARICODE_DEC *dec_states, char ascii_out[], short varicode_in[], int max_out, int n_in) {
int output, n_out;
char single_ascii = 0;
n_out = 0;
//printf("varicode_decode: n_in: %d\n", n_in);
while(n_in && (n_out < max_out)) {
output = decode_one_bit(dec_states, &single_ascii, varicode_in[0], 0);
varicode_in++;
n_in--;
if (output) {
*ascii_out++ = single_ascii;
n_out++;
}
}
return n_out;
}
int varicode_decode2(struct VARICODE_DEC *dec_states, char ascii_out[], short varicode_in[], int max_out, int n_in) {
int output, n_out;
char single_ascii = 0;
n_out = 0;
//printf("varicode_decode2: n_in: %d varicode_in[0] %d dec_states->n_in: %d\n", n_in, varicode_in[0], dec_states->n_in);
//printf("%d ", varicode_in[0]);
while(n_in && (n_out < max_out)) {
// keep two bit buffer so we can process two at a time
dec_states->in[0] = dec_states->in[1];
dec_states->in[1] = varicode_in[0];
dec_states->n_in++;
varicode_in++;
n_in--;
if (dec_states->n_in == 2) {
output = decode_two_bits(dec_states, &single_ascii, dec_states->in[0], dec_states->in[1]);
dec_states->n_in = 0;
if (output) {
//printf(" output: %d single_ascii: 0x%x %c\n", output, (int)single_ascii, single_ascii);
*ascii_out++ = single_ascii;
n_out++;
}
}
}
return n_out;
}
int varicode_decode(struct VARICODE_DEC *dec_states, char ascii_out[], short varicode_in[], int max_out, int n_in) {
if (dec_states->code_num == 1)
return varicode_decode1(dec_states, ascii_out, varicode_in, max_out, n_in);
else
return varicode_decode2(dec_states, ascii_out, varicode_in, max_out, n_in);
}
#ifdef VARICODE_UNITTEST
void test_varicode(int code_num) {
char *ascii_in;
short *varicode;
int i, n_varicode_bits_out, n_ascii_chars_out, length, half, n_out, j, len;
char *ascii_out;
struct VARICODE_DEC dec_states;
if (code_num == 1) {
printf("long code:\n");
length = sizeof(varicode_table1)/2;
}
else {
printf("short code:\n");
length = sizeof(varicode_table2)/2;
}
//length = 10;
ascii_in = (char*)malloc(length);
varicode = (short*)malloc(VARICODE_MAX_BITS*sizeof(short)*length);
ascii_out = (char*)malloc(length);
// 1. test all Varicode codes -------------------------------------------------------------
if (code_num == 1) {
for(i=0; i<length; i++)
ascii_in[i] = (char)i;
}
else {
for(i=0; i<length; i++)
ascii_in[i] = varicode_table2[2*i];
}
//printf(" ascii_in: %s\n", ascii_in);
n_varicode_bits_out = varicode_encode(varicode, ascii_in, VARICODE_MAX_BITS*length, length, code_num);
printf(" n_varicode_bits_out: %d\n", n_varicode_bits_out);
//for(i=0; i<n_varicode_bits_out; i++) {
// printf("%d \n", varicode[i]);
//}
// split decode in half to test how it preserves state between calls
varicode_decode_init(&dec_states, code_num);
half = n_varicode_bits_out/2;
n_ascii_chars_out = varicode_decode(&dec_states, ascii_out, varicode, length, half);
// printf(" n_ascii_chars_out: %d\n", n_ascii_chars_out);
n_ascii_chars_out += varicode_decode(&dec_states, &ascii_out[n_ascii_chars_out],
&varicode[half], length-n_ascii_chars_out, n_varicode_bits_out - half);
assert(n_ascii_chars_out == length);
printf(" n_ascii_chars_out: %d\n", n_ascii_chars_out);
printf(" average bits/character: %3.2f\n", (float)n_varicode_bits_out/n_ascii_chars_out);
//printf("ascii_out: %s\n", ascii_out);
if (memcmp(ascii_in, ascii_out, length) == 0)
printf(" Test 1 Pass\n");
else
printf(" Test 1 Fail\n");
// 2. Test some ascii with a run of zeros -----------------------------------------------------
sprintf(ascii_in, "CQ CQ CQ this is VK5DGR");
assert(strlen(ascii_in) < length);
if (code_num == 2)
for(i=0; i<strlen(ascii_in); i++)
ascii_in[i] = tolower(ascii_in[i]);
for(i=0; i<3; i++) {
n_varicode_bits_out = varicode_encode(varicode, ascii_in, VARICODE_MAX_BITS*length, strlen(ascii_in), code_num);
n_ascii_chars_out = varicode_decode(&dec_states, ascii_out, varicode, length, n_varicode_bits_out);
ascii_out[n_ascii_chars_out] = 0;
printf(" ascii_out: %s\n", ascii_out);
if (strcmp(ascii_in, ascii_out) == 0)
printf(" Test 2 Pass\n");
else
printf(" Test 2 Fail\n");
memset(varicode, 0, sizeof(short)*20);
n_ascii_chars_out = varicode_decode(&dec_states, ascii_out, varicode, length, 20);
assert(n_ascii_chars_out == 0);
}
// 3. Test receiving one bit at a time -----------------------------------------------------
sprintf(ascii_in, "s=vk5dgr qth=adelaide");
len = strlen(ascii_in);
ascii_in[len] = 13;
ascii_in[len+1] = 0;
assert(strlen(ascii_in) < length);
if (code_num == 2)
for(i=0; i<strlen(ascii_in); i++)
ascii_in[i] = tolower(ascii_in[i]);
for(i=0; i<3; i++) {
n_varicode_bits_out = varicode_encode(varicode, ascii_in, VARICODE_MAX_BITS*length, strlen(ascii_in), code_num);
printf("n_varicode_bits_out: %d\n", n_varicode_bits_out);
n_ascii_chars_out = 0;
for(j=0; j<n_varicode_bits_out; j++) {
n_out = varicode_decode(&dec_states, &ascii_out[n_ascii_chars_out], &varicode[j], 1, 1);
if (n_out)
n_ascii_chars_out++;
}
ascii_out[n_ascii_chars_out] = 0;
printf(" ascii_out: %s\n", ascii_out);
if (strcmp(ascii_in, ascii_out) == 0)
printf(" Test 3 Pass\n");
else
printf(" Test 3 Fail\n");
}
free(ascii_in);
free(ascii_out);
free(varicode);
}
int main(void) {
test_varicode(1);
test_varicode(2);
return 0;
}
#endif

View file

@ -1,51 +0,0 @@
//==========================================================================
// Name: varicode.h
// Purpose: Varicode encoded and decode functions
// Created: Nov 24, 2012
// Authors: David Rowe
//
// License:
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU 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 General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//
//==========================================================================
#ifndef __VARICODE__
#define __VARICODE__
#ifdef __cplusplus
extern "C" {
#endif
#define VARICODE_MAX_BITS (10+2) /* max varicode bits for each ascii character */
/* 10 bits for code plus 2 0 bits for inter-character space */
struct VARICODE_DEC {
int state;
int n_zeros;
int v_len;
unsigned short packed;
int code_num;
int n_in;
int in[2];
};
int varicode_encode(short varicode_out[], char ascii_in[], int max_out, int n_in, int code_num);
void varicode_decode_init(struct VARICODE_DEC *dec_states, int code_num);
int varicode_decode(struct VARICODE_DEC *dec_states, char ascii_out[], short varicode_in[], int max_out, int n_in);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,338 +0,0 @@
//==========================================================================
// Name: varicode_table.h
// Purpose: Varicode look up table
// Created: Nov 24, 2012
// Authors: Clint Turner, KA7OEI, Peter Martinez, G3PLX
//
// License:
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU 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 General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//
//==========================================================================
/* The following table defines the PKS31 varicode. There are 128 entries,
corresponding to ASCII characters 0-127 with two bytes for each entry. The bits
for the varicode are to be shifted out MSB-first for both bytes, with the first byte
in the table being the first one to be sent.
More than one zero in sequence signifies the end of the character (i.e.
two zeroes are the intercharacter sequence, so at least two zeroes should always be
sent before the next character is sent.
This file is constructed with information from the article "PSK31 Fundamentals"
by Peter Martinez, G3PLX by Clint Turner, KA7OEI
*/
unsigned char const varicode_table1[256] = {
0b10101010,
0b11000000, // 0 NUL
0b10110110,
0b11000000, // 1 SOH
0b10111011,
0b01000000, // 2 STX
0b11011101,
0b11000000, // 3 ETX
0b10111010,
0b11000000, // 4 EOT
0b11010111,
0b11000000, // 5 ENQ
0b10111011,
0b11000000, // 6 ACK
0b10111111,
0b01000000, // 7 BEL
0b10111111,
0b11000000, // 8 BS
0b11101111,
0b00000000, // 9 HT
0b11101000,
0b00000000, // 10 LF
0b11011011,
0b11000000, // 11 VT
0b10110111,
0b01000000, // 12 FF
0b11111000,
0b00000000, // 13 CR
0b11011101,
0b01000000, // 14 SO
0b11101010,
0b11000000, // 15 SI
0b10111101,
0b11000000, // 16 DLE
0b10111101,
0b01000000, // 17 DC1
0b11101011,
0b01000000, // 18 DC2
0b11101011,
0b11000000, // 19 DC3
0b11010110,
0b11000000, // 20 DC4
0b11011010,
0b11000000, // 21 NAK
0b11011011,
0b01000000, // 22 SYN
0b11010101,
0b11000000, // 23 ETB
0b11011110,
0b11000000, // 24 CAN
0b11011111,
0b01000000, // 25 EM
0b11101101,
0b11000000, // 26 SUB
0b11010101,
0b01000000, // 27 ESC
0b11010111,
0b01000000, // 28 FS
0b11101110,
0b11000000, // 29 GS
0b10111110,
0b11000000, // 30 RS
0b11011111,
0b11000000, // 31 US
0b10000000,
0b00000000, // 32 SP
0b11111111,
0b10000000, // 33 !
0b10101111,
0b10000000, // 34 "
0b11111010,
0b10000000, // 35 #
0b11101101,
0b10000000, // 36 $
0b10110101,
0b01000000, // 37 %
0b10101110,
0b11000000, // 38 &
0b10111111,
0b10000000, // 39 '
0b11111011,
0b00000000, // 40 (
0b11110111,
0b00000000, // 41 )
0b10110111,
0b10000000, // 42 *
0b11101111,
0b10000000, // 43 +
0b11101010,
0b00000000, // 44 ,
0b11010100,
0b00000000, // 45 -
0b10101110,
0b00000000, // 46 .
0b11010111,
0b10000000, // 47 /
0b10110111,
0b00000000, // 48 0
0b10111101,
0b00000000, // 49 1
0b11101101,
0b00000000, // 50 2
0b11111111,
0b00000000, // 51 3
0b10111011,
0b10000000, // 52 4
0b10101101,
0b10000000, // 53 5
0b10110101,
0b10000000, // 54 6
0b11010110,
0b10000000, // 55 7
0b11010101,
0b10000000, // 56 8
0b11011011,
0b10000000, // 57 9
0b11110101,
0b00000000, // 58 :
0b11011110,
0b10000000, // 59 ;
0b11110110,
0b10000000, // 60 <
0b10101010,
0b00000000, // 61 =
0b11101011,
0b10000000, // 62 >
0b10101011,
0b11000000, // 63 ?
0b10101111,
0b01000000, // 64 @
0b11111010,
0b00000000, // 65 A
0b11101011,
0b00000000, // 66 B
0b10101101,
0b00000000, // 67 C
0b10110101,
0b00000000, // 68 D
0b11101110,
0b00000000, // 69 E
0b11011011,
0b00000000, // 70 F
0b11111101,
0b00000000, // 71 G
0b10101010,
0b10000000, // 72 H
0b11111110,
0b00000000, // 73 I
0b11111110,
0b10000000, // 74 J
0b10111110,
0b10000000, // 75 K
0b11010111,
0b00000000, // 76 L
0b10111011,
0b00000000, // 77 M
0b11011101,
0b00000000, // 78 N
0b10101011,
0b00000000, // 79 O
0b11010101,
0b00000000, // 80 P
0b11101110,
0b10000000, // 81 Q
0b10101111,
0b00000000, // 82 R
0b11011110,
0b00000000, // 83 S
0b11011010,
0b00000000, // 84 T
0b10101011,
0b10000000, // 85 U
0b11011010,
0b10000000, // 86 V
0b10101110,
0b10000000, // 87 W
0b10111010,
0b10000000, // 88 X
0b10111101,
0b10000000, // 89 Y
0b10101011,
0b01000000, // 90 Z
0b11111011,
0b10000000, // 91 [
0b11110111,
0b10000000, // 92 "\"
0b11111101,
0b10000000, // 93 ]
0b10101111,
0b11000000, // 94 ^
0b10110110,
0b10000000, // 95 _ (underline)
0b10110111,
0b11000000, // 96 `
0b10110000,
0b00000000, // 97 a
0b10111110,
0b00000000, // 98 b
0b10111100,
0b00000000, // 99 c
0b10110100,
0b00000000, // 100 d
0b11000000,
0b00000000, // 101 e
0b11110100,
0b00000000, // 102 f
0b10110110,
0b00000000, // 103 g
0b10101100,
0b00000000, // 104 h
0b11010000,
0b00000000, // 105 i
0b11110101,
0b10000000, // 106 j
0b10111111,
0b00000000, // 107 k
0b11011000,
0b00000000, // 108 l
0b11101100,
0b00000000, // 109 m
0b11110000,
0b00000000, // 110 n
0b11100000,
0b00000000, // 111 o
0b11111100,
0b00000000, // 112 p
0b11011111,
0b10000000, // 113 q
0b10101000,
0b00000000, // 114 r
0b10111000,
0b00000000, // 115 s
0b10100000,
0b00000000, // 116 t
0b11011100,
0b00000000, // 117 u
0b11110110,
0b00000000, // 118 v
0b11010110,
0b00000000, // 119 w
0b11011111,
0b00000000, // 120 x
0b10111010,
0b00000000, // 121 y
0b11101010,
0b10000000, // 122 z
0b10101101,
0b11000000, // 123 {
0b11011101,
0b10000000, // 124 |
0b10101101,
0b01000000, // 125 }
0b10110101,
0b11000000, // 126 ~
0b11101101,
0b01000000, // 127 (del)
};
// This code was used on FDMDV version 1, and is more compact that Code 1, but only covers a subset
// of the ASCII cahacter set
char const varicode_table2[] = {
' ' ,0b11000000,
13 ,0b01000000, // CR, end of message
'=' ,0b10000000,
'1' ,0b11110000,
'2' ,0b01110000,
'3' ,0b10110000,
'4' ,0b11010000,
'5' ,0b01010000,
'6' ,0b10010000,
'7' ,0b11100000,
'8' ,0b01100000,
'9' ,0b10100000,
'a' ,0b11111100,
'b' ,0b01111100,
'c' ,0b10111100,
'd' ,0b11011100,
'e' ,0b01011100,
'f' ,0b10011100,
'g' ,0b11101100,
'h' ,0b01101100,
'i' ,0b10101100,
'j' ,0b11110100,
'k' ,0b01110100,
'l' ,0b10110100,
'm' ,0b11010100,
'n' ,0b01010100,
'o' ,0b10010100,
'p' ,0b11100100,
'q' ,0b01100100,
'r' ,0b10100100,
's' ,0b11111000,
't' ,0b01111000,
'u' ,0b10111000,
'v' ,0b11011000,
'w' ,0b01011000,
'x' ,0b10011000,
'y' ,0b11101000,
'z' ,0b01101000,
'0' ,0b10101000
};

23
DSP_API/DOCS/ThumbDV.cfg Normal file
View file

@ -0,0 +1,23 @@
[header]
Name: ThumbDV
Version: "0.0.4"
Minimum-SmartSDR-Version: 1.4.2.0
Author: FlexRadio Systems
Support-email: support@flexradio.com
Support-phone: 512-535-4713
License: GPL7.3
Executable: "thumbdv"
[setup]
waveform create name=ThumbDV mode=DSTR underlying_mode=DFM version=0.0.4
waveform set ThumbDV tx=1
waveform set ThumbDV rx_filter low_cut=-4800
waveform set ThumbDV rx_filter high_cut=4800
waveform set ThumbDV rx_filter depth=2
waveform set ThumbDV tx_filter low_cut=0
waveform set ThumbDV tx_filter high_cut=4800
waveform set ThumbDV tx_filter depth=2
waveform set ThumbDV udpport=5000
[end]

View file

@ -1,4 +0,0 @@
CODEC2_FREEDV/codebook.d: ../CODEC2_FREEDV/codebook.c \
../CODEC2_FREEDV/defines.h
../CODEC2_FREEDV/defines.h:

View file

@ -1,96 +0,0 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../CODEC2_FREEDV/codebook.c \
../CODEC2_FREEDV/codebookd.c \
../CODEC2_FREEDV/codebookdt.c \
../CODEC2_FREEDV/codebookge.c \
../CODEC2_FREEDV/codebookjnd.c \
../CODEC2_FREEDV/codebookjvm.c \
../CODEC2_FREEDV/codebookvq.c \
../CODEC2_FREEDV/codebookvqanssi.c \
../CODEC2_FREEDV/codec2.c \
../CODEC2_FREEDV/dump.c \
../CODEC2_FREEDV/fdmdv.c \
../CODEC2_FREEDV/fifo.c \
../CODEC2_FREEDV/freedv_api.c \
../CODEC2_FREEDV/golay23.c \
../CODEC2_FREEDV/interp.c \
../CODEC2_FREEDV/kiss_fft.c \
../CODEC2_FREEDV/lpc.c \
../CODEC2_FREEDV/lsp.c \
../CODEC2_FREEDV/nlp.c \
../CODEC2_FREEDV/pack.c \
../CODEC2_FREEDV/phase.c \
../CODEC2_FREEDV/postfilter.c \
../CODEC2_FREEDV/quantise.c \
../CODEC2_FREEDV/sine.c \
../CODEC2_FREEDV/varicode.c
OBJS += \
./CODEC2_FREEDV/codebook.o \
./CODEC2_FREEDV/codebookd.o \
./CODEC2_FREEDV/codebookdt.o \
./CODEC2_FREEDV/codebookge.o \
./CODEC2_FREEDV/codebookjnd.o \
./CODEC2_FREEDV/codebookjvm.o \
./CODEC2_FREEDV/codebookvq.o \
./CODEC2_FREEDV/codebookvqanssi.o \
./CODEC2_FREEDV/codec2.o \
./CODEC2_FREEDV/dump.o \
./CODEC2_FREEDV/fdmdv.o \
./CODEC2_FREEDV/fifo.o \
./CODEC2_FREEDV/freedv_api.o \
./CODEC2_FREEDV/golay23.o \
./CODEC2_FREEDV/interp.o \
./CODEC2_FREEDV/kiss_fft.o \
./CODEC2_FREEDV/lpc.o \
./CODEC2_FREEDV/lsp.o \
./CODEC2_FREEDV/nlp.o \
./CODEC2_FREEDV/pack.o \
./CODEC2_FREEDV/phase.o \
./CODEC2_FREEDV/postfilter.o \
./CODEC2_FREEDV/quantise.o \
./CODEC2_FREEDV/sine.o \
./CODEC2_FREEDV/varicode.o
C_DEPS += \
./CODEC2_FREEDV/codebook.d \
./CODEC2_FREEDV/codebookd.d \
./CODEC2_FREEDV/codebookdt.d \
./CODEC2_FREEDV/codebookge.d \
./CODEC2_FREEDV/codebookjnd.d \
./CODEC2_FREEDV/codebookjvm.d \
./CODEC2_FREEDV/codebookvq.d \
./CODEC2_FREEDV/codebookvqanssi.d \
./CODEC2_FREEDV/codec2.d \
./CODEC2_FREEDV/dump.d \
./CODEC2_FREEDV/fdmdv.d \
./CODEC2_FREEDV/fifo.d \
./CODEC2_FREEDV/freedv_api.d \
./CODEC2_FREEDV/golay23.d \
./CODEC2_FREEDV/interp.d \
./CODEC2_FREEDV/kiss_fft.d \
./CODEC2_FREEDV/lpc.d \
./CODEC2_FREEDV/lsp.d \
./CODEC2_FREEDV/nlp.d \
./CODEC2_FREEDV/pack.d \
./CODEC2_FREEDV/phase.d \
./CODEC2_FREEDV/postfilter.d \
./CODEC2_FREEDV/quantise.d \
./CODEC2_FREEDV/sine.d \
./CODEC2_FREEDV/varicode.d
# Each subdirectory must supply rules for building sources it contributes
CODEC2_FREEDV/%.o: ../CODEC2_FREEDV/%.c
@echo 'Building file: $<'
@echo 'Invoking: GCC C Compiler'
arm-linux-gnueabihf-gcc -static -I"/home/graham/workspace/smartsdr-dsp/DSP_API" -I"/home/graham/workspace/smartsdr-dsp/DSP_API/SmartSDR_Interface" -I"/home/graham/workspace/smartsdr-dsp/DSP_API/CODEC2_FREEDV" -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View file

@ -1,60 +0,0 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../SmartSDR_Interface/cmd_basics.c \
../SmartSDR_Interface/cmd_engine.c \
../SmartSDR_Interface/discovery_client.c \
../SmartSDR_Interface/hal_buffer.c \
../SmartSDR_Interface/hal_listener.c \
../SmartSDR_Interface/hal_vita.c \
../SmartSDR_Interface/io_utils.c \
../SmartSDR_Interface/sched_waveform.c \
../SmartSDR_Interface/smartsdr_dsp_api.c \
../SmartSDR_Interface/status_processor.c \
../SmartSDR_Interface/traffic_cop.c \
../SmartSDR_Interface/utils.c \
../SmartSDR_Interface/vita_output.c
OBJS += \
./SmartSDR_Interface/cmd_basics.o \
./SmartSDR_Interface/cmd_engine.o \
./SmartSDR_Interface/discovery_client.o \
./SmartSDR_Interface/hal_buffer.o \
./SmartSDR_Interface/hal_listener.o \
./SmartSDR_Interface/hal_vita.o \
./SmartSDR_Interface/io_utils.o \
./SmartSDR_Interface/sched_waveform.o \
./SmartSDR_Interface/smartsdr_dsp_api.o \
./SmartSDR_Interface/status_processor.o \
./SmartSDR_Interface/traffic_cop.o \
./SmartSDR_Interface/utils.o \
./SmartSDR_Interface/vita_output.o
C_DEPS += \
./SmartSDR_Interface/cmd_basics.d \
./SmartSDR_Interface/cmd_engine.d \
./SmartSDR_Interface/discovery_client.d \
./SmartSDR_Interface/hal_buffer.d \
./SmartSDR_Interface/hal_listener.d \
./SmartSDR_Interface/hal_vita.d \
./SmartSDR_Interface/io_utils.d \
./SmartSDR_Interface/sched_waveform.d \
./SmartSDR_Interface/smartsdr_dsp_api.d \
./SmartSDR_Interface/status_processor.d \
./SmartSDR_Interface/traffic_cop.d \
./SmartSDR_Interface/utils.d \
./SmartSDR_Interface/vita_output.d
# Each subdirectory must supply rules for building sources it contributes
SmartSDR_Interface/%.o: ../SmartSDR_Interface/%.c
@echo 'Building file: $<'
@echo 'Invoking: GCC C Compiler'
arm-linux-gnueabihf-gcc -static -I"/home/graham/workspace/smartsdr-dsp/DSP_API" -I"/home/graham/workspace/smartsdr-dsp/DSP_API/SmartSDR_Interface" -I"/home/graham/workspace/smartsdr-dsp/DSP_API/CODEC2_FREEDV" -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View file

@ -1,51 +0,0 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
-include ../makefile.init
RM := rm -rf
# All of the sources participating in the build are defined here
-include sources.mk
-include SmartSDR_Interface/subdir.mk
-include CODEC2_FREEDV/subdir.mk
-include subdir.mk
-include objects.mk
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif
-include ../makefile.defs
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: freedv
# Tool invocations
freedv: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: GCC C Linker'
arm-linux-gnueabihf-gcc -static -o "freedv" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
$(MAKE) --no-print-directory post-build
# Other Targets
clean:
-$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) freedv
-@echo ' '
post-build:
-@echo 'Install in BeagleBone at /home/debian/bin'
-scp freedv root@192.168.20.33:/home/debian/bin/
-@echo ' '
.PHONY: all clean dependents
.SECONDARY: post-build
-include ../makefile.targets

View file

@ -1,8 +0,0 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
USER_OBJS :=
LIBS := -lm -lpthread -lrt

View file

@ -1,19 +0,0 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
O_SRCS :=
C_SRCS :=
S_UPPER_SRCS :=
OBJ_SRCS :=
ASM_SRCS :=
OBJS :=
C_DEPS :=
EXECUTABLES :=
# Every subdirectory with source files must be described here
SUBDIRS := \
. \
SmartSDR_Interface \
CODEC2_FREEDV \

View file

@ -1,30 +0,0 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../circular_buffer.c \
../main.c \
../resampler.c
OBJS += \
./circular_buffer.o \
./main.o \
./resampler.o
C_DEPS += \
./circular_buffer.d \
./main.d \
./resampler.d
# Each subdirectory must supply rules for building sources it contributes
%.o: ../%.c
@echo 'Building file: $<'
@echo 'Invoking: GCC C Compiler'
arm-linux-gnueabihf-gcc -static -I"/home/graham/workspace/smartsdr-dsp/DSP_API" -I"/home/graham/workspace/smartsdr-dsp/DSP_API/SmartSDR_Interface" -I"/home/graham/workspace/smartsdr-dsp/DSP_API/CODEC2_FREEDV" -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View file

@ -54,6 +54,7 @@
#include "cmd.h"
#include "main.h"
#include "sched_waveform.h"
/* *****************************************************************************
@ -262,13 +263,49 @@ uint32 cmd_slice(int requester_fd, int argc, char **argv)
return SL_BAD_COMMAND;
}
if(strncmp(argv[2], "string", strlen("string")) == 0)
if(strncmp(argv[2], "set", strlen("set")) == 0)
{
char* new_string = argv[2]+strlen("string")+1;
charReplace(new_string, (char) 0x7F, ' ');
freedv_set_string(slc, new_string);
// charReplace(new_string, (char) 0x7F, ' ');
uint8 i = 0;
for ( i = 3 ; i < argc ; i++ ) {
if ( strncmp(argv[i], "destination_rptr", strlen("destination_rptr") ) == 0 ) {
char * rptr = argv[i] + strlen("destination_rptr") + 1;
sched_waveform_setDestinationRptr(slc, rptr);
} else if ( strncmp(argv[i], "departure_rptr", strlen("departure_rptr") ) == 0 ) {
char * rptr = argv[i] + strlen("departure_rptr") + 1;
sched_waveform_setDepartureRptr(slc, rptr);
} else if ( strncmp(argv[i], "companion_call", strlen("companion_call") ) == 0 ) {
char * call = argv[i] + strlen("companion_call") + 1;
sched_waveform_setCompanionCall(slc, call);
} else if ( strncmp(argv[i], "own_call1", strlen("own_call1") ) == 0 ) {
char * call = argv[i] + strlen("own_call1") + 1;
sched_waveform_setOwnCall1(slc, call);
} else if ( strncmp(argv[i], "own_call2", strlen("own_call2") ) == 0 ) {
char * call = argv[i] + strlen("own_call2") + 1;
sched_waveform_setOwnCall2(slc, call);
} else if ( strncmp(argv[i], "message", strlen("message")) == 0 ) {
char * message = argv[i] + strlen("message") + 1;
sched_waveform_setMessage(slc, message);
}
}
return SUCCESS;
}
else if (strncmp(argv[2], "status", strlen("status")) == 0 )
{
sched_waveform_sendStatus(slc);
}
}
return SUCCESS;

View file

@ -94,9 +94,9 @@ static command_def commands[] =
// #################################################################
unsigned int command(void)
{
char line[80];
char line[512];
char *pLine = line;
get_line(pLine, sizeof(line));
get_line(pLine, 512 * sizeof(char));
process_command(line);
@ -110,6 +110,7 @@ uint32 process_command(char* command_txt)
int argc;
char *argv[MAX_ARGC + 1]; //Add one extra so we can null terminate the array
output("CMD Received = '%s'\n", command_txt);
tokenize(command_txt, &argc, argv, MAX_ARGC);

View file

@ -57,8 +57,8 @@ typedef int16 VITAtemp_trunc;
typedef uint32 ant_port_id_type;
#define TRUE (uint32)1
#define FALSE (uint32)0
#define TRUE (uint8)1
#define FALSE (uint8)0
#define INVALID -1

View file

@ -38,6 +38,8 @@
#include <errno.h> // for errno
#include <unistd.h>
#include <sys/prctl.h>
#include "common.h"
#include "discovery_client.h"
#include "cmd.h" // for tokenize
@ -253,6 +255,7 @@ static BOOL _dc_ListenerRecv(uint8* buffer, int32* len, struct sockaddr_in* send
static void* _dc_ListenerLoop(void* param)
{
//printf("_dc_ListenerLoop\n");
prctl(PR_SET_NAME, "DV-ListenerLoop");
struct sockaddr_in sender;
uint8 buf[ETH_FRAME_LEN];

View file

@ -41,6 +41,7 @@
#include <errno.h> // for errno
#include <unistd.h> // for usleep
#include <netdb.h>
#include <sys/prctl.h>
// #define LOG_MODULE LOG_MODULE_HAL_LISTENER
@ -430,6 +431,7 @@ static void* _hal_ListenerLoop(void* param)
struct sockaddr_in sender;
uint8 buf[ETH_FRAME_LEN];
prctl(PR_SET_NAME, "DV-halListener");
while(!hal_listen_abort)
{
@ -530,9 +532,10 @@ void hal_Listener_Init(void)
{
output("Vita Listener Init: Opening socket");
errno = 0;
if((fpga_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
{
output("...failed! (socket call returned -1)\n");
output("...failed! (socket call returned -1) - errno = %d\n", errno);
return;
}

File diff suppressed because it is too large Load diff

View file

@ -35,11 +35,22 @@
#define SCHED_WAVEFORM_H_
#include "hal_buffer.h"
#include "ftd2xx.h"
void sched_waveform_Schedule(BufferDescriptor buf);
void sched_waveform_Init(void);
void sched_waveform_signal(void);
void sched_waveformTreadExit(void);
void sched_waveform_setDestinationRptr(uint32 slice , const char * destination_rptr );
void sched_waveform_setDepartureRptr(uint32 slice , const char * departure_rptr );
void sched_waveform_setCompanionCall( uint32 slice, const char * companion_call);
void sched_waveform_setOwnCall1( uint32 slice , const char * owncall1 );
void sched_waveform_setOwnCall2(uint32 slice , const char * owncall2 );
void sched_waveform_setMessage( uint32 slice, const char * message);
void sched_waveform_sendStatus(uint32 slice);
void sched_waveform_setHandle( FT_HANDLE * handle );
void sched_waveform_setEndOfTX(BOOL end_of_transmission);
void sched_waveform_setDSTARSlice( uint32 slice );
#endif /* SCHED_WAVEFORM_H_ */

View file

@ -38,6 +38,7 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/prctl.h>
#include <fcntl.h> // File Control functions
#include "common.h"
@ -92,6 +93,7 @@ void SmartSDR_API_Shutdown(void)
void* _console_thread(void* param)
{
prctl(PR_SET_NAME, "DV-Console");
cmd_banner();
output(PROMPT);
// let everybody know we're through printing

View file

@ -37,6 +37,7 @@
#include "common.h"
#include "traffic_cop.h"
#include "sched_waveform.h"
static void _handle_status(char* string)
{
@ -74,14 +75,20 @@ static void _handle_status(char* string)
{
errno = 0;
char* smode = argv[i]+strlen("mode")+1;
if (strncmp(smode,"FDV",3) == 0)
if (strncmp(smode,"DSTR", strlen("DSTR")) == 0)
{
// we are now in FDV mode
output(ANSI_MAGENTA "slice %d is now in FDV mode\n",slc);
// we are now in DSTR mode
output(ANSI_MAGENTA "slice %d is now in DSTR mode\n",slc);
char cmd[512] = {0};
sprintf(cmd, "slice s %d fm_deviation=1200 post_demod_low=0 post_demod_high=6000 dfm_pre_de_emphasis=0 post_demod_bypass=1 squelch=0", slc);
tc_sendSmartSDRcommand(cmd,FALSE, NULL);
sched_waveform_setDSTARSlice(slc);
}
else
{
// we have left FDV mode
// we have left DSTR mode
output(ANSI_MAGENTA "slice %d is in %s mode\n",slc,smode);
}
}
@ -95,7 +102,7 @@ static void _handle_status(char* string)
}
}
if(strncmp(argv[i], "tx", strlen("tx")) == 0)
if(strncmp(argv[i], "tx", strlen("tx")) == 0 && (strlen(argv[i]) == 2))
{
errno = 0;
int tx = strtoul(argv[i]+strlen("tx")+1, NULL, 0);
@ -137,6 +144,12 @@ static void _handle_status(char* string)
{
output(ANSI_MAGENTA "we are receiving\n");
}
else if ( strncmp(state, "UNKEY_REQUESTED", strlen("UNKEY_REQUESTED")) == 0 )
{
output(ANSI_MAGENTA "unkey requested - sending end bits\n");
sched_waveform_setEndOfTX(TRUE);
}
}
}

View file

@ -45,6 +45,7 @@
#include <sys/time.h>
#include <errno.h>
#include <ifaddrs.h>
#include <sys/prctl.h>
#include "common.h"
#include "traffic_cop.h"
@ -343,6 +344,8 @@ static void* _tc_thread(void* arg)
{
uint32 result;
prctl(PR_SET_NAME, "DV-TrafficCop");
memset(&__local, 0, sizeof(receive_data));
__local.last_ping.tv_sec = 0;
__local.recv_buf = safe_malloc(RECV_BUF_SIZE);
@ -359,6 +362,8 @@ static void* _tc_thread(void* arg)
tc_abort();
}
tc_sendSmartSDRcommand("sub slice all", FALSE, NULL);
/* Initialize UDP connections for TX */
vita_output_Init(_hostname);
@ -573,6 +578,8 @@ static void* _keepalive_thread(void* param)
{
char* response;
prctl(PR_SET_NAME, "DV-KeepAlive");
/* Sleep 2 seconds */
usleep(2000000);

View file

@ -135,9 +135,9 @@ static void _vita_formatWaveformPacket(Complex* buffer, uint32 samples, uint32 s
}
static uint32 _waveform_packet_count = 0;
void emit_waveform_output(BufferDescriptor buf_desc_out)
{
int samples_sent, samples_to_send;
Complex * buf_pointer;

View file

@ -0,0 +1,130 @@
/*
* Copyright (C) 2009,2012 by Jonathan Naylor, G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* 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.
*
* Modified for FlexRadio WaveformAPI by Ed Gonzalez KG5FBT
*/
/* THUMBDV_DSTARDEFINES_H_ */
#ifndef THUMBDV_DSTARDEFINES_H_
#define THUMBDV_DSTARDEFINES_H_
#include "datatypes.h"
#define DSTAR_GMSK_SYMBOL_RATE 4800U
#define DSTAR_GMSK_BT 0.5F
static const BOOL BIT_SYNC_BITS[] = {TRUE, FALSE, TRUE, FALSE};
#define BIT_SYNC_LENGTH_BITS = 4U;
static const BOOL FRAME_SYNC_BITS[] = {TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE,
TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE};
#define FRAME_SYNC_LENGTH_BITS 15U
//static const unsigned char DATA_SYNC_BYTES[] = {0x55, 0x2D, 0x16};
static const unsigned char DATA_SYNC_BYTES[] = {0xAA, 0xB4, 0x68};
static const BOOL DATA_SYNC_BITS[] = {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE,
FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE};
//static const unsigned char END_PATTERN_BYTES[] = {0x55, 0x55, 0x55, 0x55, 0xC8, 0x7A};
static const unsigned char END_PATTERN_BYTES[] = {0xAA, 0xAA, 0xAA, 0xAA, 0x13, 0x5E};
static const BOOL END_PATTERN_BITS[] = {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE,
FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE};
#define END_PATTERN_LENGTH_BITS 48U
#define END_PATTERN_LENGTH_BYTES (END_PATTERN_LENGTH_BITS / 8U)
static const unsigned char NULL_AMBE_DATA_BYTES[] = {0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8};
static const BOOL NULL_AMBE_DATA_BITS[] = {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE,
TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE,
FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE,
FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE,
FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE,
FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE,
TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE,
FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE};
// Note that these are already scrambled, 0x66 0x66 0x66 otherwise
static const BOOL NULL_SLOW_DATA_BITS[] = {FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE,
FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE,
TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE};
#define VOICE_FRAME_LENGTH_BITS 72U
#define VOICE_FRAME_LENGTH_BYTES (VOICE_FRAME_LENGTH_BITS / 8U)
#define DATA_FRAME_LENGTH_BITS 24U
#define DATA_FRAME_LENGTH_BYTES (DATA_FRAME_LENGTH_BITS / 8U)
#define DV_FRAME_LENGTH_BITS (VOICE_FRAME_LENGTH_BITS + DATA_FRAME_LENGTH_BITS)
#define DV_FRAME_LENGTH_BYTES (VOICE_FRAME_LENGTH_BYTES + DATA_FRAME_LENGTH_BYTES)
#define FEC_SECTION_LENGTH_BITS 660U
#define RADIO_HEADER_LENGTH_BITS 330U
#define RADIO_HEADER_LENGTH_BYTES 42U
#define DATA_BLOCK_SIZE_BITS (21U * DV_FRAME_LENGTH_BITS)
#define DATA_BLOCK_SIZE_BYTES (21U * DV_FRAME_LENGTH_BYTES)
#define SLOW_DATA_TYPE_MASK 0xF0
#define SLOW_DATA_TYPE_GPSDATA 0x30
#define SLOW_DATA_TYPE_MESSAGE 0x40
#define SLOW_DATA_TYPE_HEADER 0x50
#define SLOW_DATA_TYPE_SQUELCH 0xC0
#define SLOW_DATA_LENGTH_MASK 0x0F
#define DSTAR_AUDIO_BLOCK_SIZE 160U
#define DSTAR_AUDIO_BLOCK_BYTES (DSTAR_AUDIO_BLOCK_SIZE * 2U)
#define DSTAR_RADIO_SAMPLE_RATE 24000
#define DSTAR_RADIO_BLOCK_SIZE 960U
#define LONG_CALLSIGN_LENGTH 8U
#define SHORT_CALLSIGN_LENGTH 4U
#define SLOW_DATA_MESSAGE_LENGTH_BYTES 20U
#define SLOW_DATA_PACKET_LEN_BYTES 3
#define DATA_MASK 0x80U
#define REPEATER_MASK 0x40U
#define INTERRUPTED_MASK 0x20U
#define CONTROL_SIGNAL_MASK 0x10U
#define URGENT_MASK 0x08U
#define REPEATER_CONTROL_MASK 0x07U
#define REPEATER_CONTROL 0x07U
#define AUTO_REPLY 0x06U
#define RESEND_REQUESTED 0x04U
#define ACK_FLAG 0x03U
#define NO_RESPONSE 0x02U
#define RELAY_UNAVAILABLE 0x01U
#define DSTAR_BLEEP_FREQ 2000U
#define DSTAR_BLEEP_LENGTH 100U
#define DSTAR_BLEEP_AMPL 0.5F
#define DSTAR_RADIO_BIT_LENGTH (DSTAR_RADIO_SAMPLE_RATE / DSTAR_GMSK_SYMBOL_RATE)
#define FRAME_TIME_MS 20U
#define FRAMES_BETWEEN_SYNC 20U
#define TICKS_PER_SEC = 50U
#endif

View file

@ -0,0 +1,135 @@
///*! \file bit_pattern_matcher.c
// * \brief Allows matching of a pattern in an array ob gits.
// *
// * \copyright Copyright 2012-2014 FlexRadio Systems. All Rights Reserved.
// * Unauthorized use, duplication or distribution of this software is
// * strictly prohibited by law.
// *
// * \date 26-MAY-2015
// * \author Ed Gonzalez
// *
// *
// */
/* *****************************************************************************
*
* Copyright (C) 2014 FlexRadio Systems.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contact Information:
* email: gpl<at>flexradiosystems.com
* Mail: FlexRadio Systems, Suite 1-150, 4616 W. Howard LN, Austin, TX 78728
*
* ************************************************************************** */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "bit_pattern_matcher.h"
BIT_PM bitPM_create( const BOOL * to_match, uint32 length ) {
BIT_PM bpm = ( BIT_PM ) safe_malloc( sizeof( bit_pm ) );
bpm->pattern = ( BOOL * ) safe_malloc( sizeof( BOOL ) * length );
bpm->data = ( BOOL * ) safe_malloc( sizeof( BOOL ) * length );
bpm->length = length;
bpm->data_length = 0;
/* We have to put the pattern in reverse since
* the samples are fed left to right
*/
uint32 i = 0;
uint32 n = length - 1;
for ( i = 0 ; i < length; i++ ) {
bpm->pattern[n--] = to_match[i];
}
output( "Creating pattern matcher !!!!!\n" );
for ( i = 0 ; i < length ; i++ ) {
output( "%d", bpm->pattern[i] );
}
output( "\n" );
for ( i = 0 ; i < length ; i++ ) {
output( "%d", to_match[i] );
}
output( "\n" );
memset( bpm->data, 0, length * sizeof( BOOL ) );
return bpm;
}
void bitPM_destroy( BIT_PM bpm ) {
safe_free( bpm->data );
safe_free( bpm->pattern );
safe_free( bpm );
}
void bitPM_reset( BIT_PM bpm ) {
bpm->data_length = 0;
memset( bpm->data, 0, bpm->length * sizeof( BOOL ) );
}
BOOL bitPM_addBit( BIT_PM bpm, BOOL bit ) {
uint32 i = 0;
/* Shift the existing buffer to make space for new bit */
for ( i = bpm->length - 1; i >= 1 ; i-- ) {
bpm->data[i] = bpm->data[i - 1];
}
bpm->data[0] = bit;
if ( bpm->data_length < bpm->length ) {
bpm->data_length++;
}
if ( bpm->data_length != bpm->length ) {
/* If not enough data has accumulated then simply return FALSE */
return FALSE;
}
for ( i = 0; i < bpm->length ; i++ ) {
if ( bpm->pattern[i] != bpm->data[i] ) {
return FALSE;
}
}
#ifdef DEBUG_BIT_PM
output( ANSI_GREEN "Match Found\nPat: " );
for ( i = 0; i < bpm->length ; i++ ) {
output( "%d ", bpm->pattern[i] );
}
output( "\nMat: " );
for ( i = 0; i < bpm->length ; i++ ) {
output( "%d ", bpm->data[i] );
}
output( "\n" );
#endif
/* If we make it here all checks have passed */
return TRUE;
}

View file

@ -0,0 +1,54 @@
///*! \file bit_pattern_matcher.h
// * \brief Allows matching of a pattern in an array ob gits.
// *
// * \copyright Copyright 2012-2014 FlexRadio Systems. All Rights Reserved.
// * Unauthorized use, duplication or distribution of this software is
// * strictly prohibited by law.
// *
// * \date 26-MAY-2015
// * \author Ed Gonzalez
// *
// *
// */
/* *****************************************************************************
*
* Copyright (C) 2014 FlexRadio Systems.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contact Information:
* email: gpl<at>flexradiosystems.com
* Mail: FlexRadio Systems, Suite 1-150, 4616 W. Howard LN, Austin, TX 78728
*
* ************************************************************************** */
#ifndef THUMBDV_BIT_PATTERN_MATCHER_H_
#define THUMBDV_BIT_PATTERN_MATCHER_H_
#include "datatypes.h"
typedef struct _bit_pattern_matcher {
BOOL * pattern;
BOOL * data;
uint32 length;
uint32 data_length;
} bit_pm, * BIT_PM;
void bitPM_destroy( BIT_PM bpm );
BIT_PM bitPM_create( const BOOL * to_match, uint32 length );
BOOL bitPM_addBit( BIT_PM bpm, BOOL bit );
void bitPM_reset( BIT_PM bpm );
#endif /* THUMBDV_BIT_PATTERN_MATCHER_H_ */

1207
DSP_API/ThumbDV/dstar.c Normal file

File diff suppressed because it is too large Load diff

162
DSP_API/ThumbDV/dstar.h Normal file
View file

@ -0,0 +1,162 @@
///*! \file dstar.h
// *
// * Handles all DSTAR States
// *
// * \date 02-JUN-2015
// * \author Ed Gonzalez KG5FBT modified from original in OpenDV code(C) 2009 Jonathan Naylor, G4KLX
// */
/* *****************************************************************************
*
* Copyright (C) 2012-2014 FlexRadio Systems.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contact Information:
* email: gpl<at>flexradiosystems.com
* Mail: FlexRadio Systems, Suite 1-150, 4616 W. Howard LN, Austin, TX 78728
*
* ************************************************************************** */
#ifndef THUMBDV_DSTAR_H_
#define THUMBDV_DSTAR_H_
#include "bit_pattern_matcher.h"
#include "DStarDefines.h"
#include "dstar.h"
#include "gmsk_modem.h"
#include "circular_buffer.h"
enum _slow_data_decode_state {
FIRST_FRAME = 0,
HEADER_SECOND_FRAME,
MESSAGE_SECOND_FRAME
};
enum _slow_data_encode_state {
MESSAGE_TX = 0,
HEADER_TX
};
typedef struct _slow_data_decoder {
enum _slow_data_decode_state decode_state;
unsigned char header_bytes[RADIO_HEADER_LENGTH_BYTES];
uint32 header_array_index;
unsigned char message[4][5];
uint32 message_index;
char message_string[21];
} slow_data_decoder, * SLOW_DATA_DECODER;
typedef struct _slow_data_encoder {
enum _slow_data_encode_state encode_state;
unsigned char message_bytes[SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC];
uint32 message_index;
unsigned char header_bytes[SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC];
uint32 header_index;
char message[SLOW_DATA_MESSAGE_LENGTH_BYTES + 1];
} slow_data_encoder, * SLOW_DATA_ENCODER;
enum DSTAR_RX_STATE {
BIT_FRAME_SYNC = 0x1,
HEADER_PROCESSING,
VOICE_FRAME,
DATA_FRAME,
DATA_SYNC_FRAME,
END_PATTERN
};
enum STATUS_TYPE {
STATUS_RX = 0,
STATUS_TX,
STATUS_SLOW_DATA_MESSAGE,
STATUS_END_RX
};
typedef struct _dstar_header {
unsigned char flag1;
unsigned char flag2;
unsigned char flag3;
char destination_rptr[9];
char departure_rptr[9];
char companion_call[9];
char own_call1[9];
char own_call2[5];
uint16 p_fcs;
} dstar_header, * DSTAR_HEADER;
typedef struct _dstar_machine {
enum DSTAR_RX_STATE rx_state;
enum DSTAR_RX_STATE tx_state;
dstar_header incoming_header;
dstar_header outgoing_header;
uint32 bit_count;
uint32 frame_count;
/* BIT Pattern Matcher */
BIT_PM syn_pm;
BIT_PM data_sync_pm;
BIT_PM end_pm;
/* Bit Buffers */
BOOL header[FEC_SECTION_LENGTH_BITS];
BOOL voice_bits[VOICE_FRAME_LENGTH_BITS];
BOOL data_bits[DATA_FRAME_LENGTH_BITS];
SLOW_DATA_DECODER slow_decoder;
SLOW_DATA_ENCODER slow_encoder;
uint32 slice;
} dstar_machine, * DSTAR_MACHINE;
typedef struct _dstar_fec {
BOOL mem0[RADIO_HEADER_LENGTH_BITS];
BOOL mem1[RADIO_HEADER_LENGTH_BITS];
BOOL mem2[RADIO_HEADER_LENGTH_BITS];
BOOL mem3[RADIO_HEADER_LENGTH_BITS];
int metric[4];
} dstar_fec, * DSTAR_FEC;
typedef union _dstar_pfcs {
uint16 crc16;
uint8 crc8[2];
} dstar_pfcs, * DSTAR_PFCS;
void icom_byteToBits( unsigned char byte, BOOL * bits );
void dstar_updateStatus( DSTAR_MACHINE machine, uint32 slice , enum STATUS_TYPE type );
DSTAR_MACHINE dstar_createMachine( void );
void dstar_destroyMachine( DSTAR_MACHINE machine );
BOOL dstar_rxStateMachine( DSTAR_MACHINE machine, BOOL in_bit, unsigned char * ambe_out, uint32 ambe_buf_len );
void dstar_txStateMachine( DSTAR_MACHINE machine, GMSK_MOD gmsk_mod, Circular_Float_Buffer tx_cb, unsigned char * mod_audio);
void dstar_dumpHeader( DSTAR_HEADER header );
void dstar_processHeader( unsigned char * bytes, DSTAR_HEADER header );
void dstar_pfcsUpdate( DSTAR_PFCS pfcs, BOOL * bits );
BOOL dstar_pfcsCheck( DSTAR_PFCS pfcs, BOOL * bits );
void dstar_pfcsResult( DSTAR_PFCS pfcs, unsigned char * chksum );
void dstar_pfcsResultBits( DSTAR_PFCS pfcs, BOOL * bits );
void dstar_pfcsUpdateBuffer( DSTAR_PFCS pfcs, unsigned char * bytes, uint32 length );
void dstar_headerToBytes( DSTAR_HEADER header, unsigned char * bytes );
void dstar_FECTest( void );
void dstar_scramble( BOOL * in, BOOL * out, uint32 length, uint32 * scramble_count );
void dstar_interleave( const BOOL * in, BOOL * out, unsigned int length );
void dstar_deinterleave( const BOOL * in, BOOL * out, unsigned int length );
BOOL dstar_FECdecode( DSTAR_FEC fec, const BOOL * in, BOOL * out, unsigned int inLen, unsigned int * outLen );
void dstar_FECencode( const BOOL * in, BOOL * out, unsigned int inLen, unsigned int * outLen );
#endif /* THUMBDV_DSTAR_H_ */

View file

@ -0,0 +1,556 @@
///*! \file gmsk_modem.c
// * \date 02-JUN-2015
// * \author Ed Gonzalez KG5FBT
// */
/* *****************************************************************************
*
* Copyright (C) 2012-2014 FlexRadio Systems.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contact Information:
* email: gpl<at>flexradiosystems.com
* Mail: FlexRadio Systems, Suite 1-150, 4616 W. Howard LN, Austin, TX 78728
*
* ************************************************************************** */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "DStarDefines.h"
#include "gmsk_modem.h"
#include "bit_pattern_matcher.h"
/* Filters */
void gmsk_bitsToByte( BOOL * bits, unsigned char * byte ) {
if ( bits == NULL || byte == NULL ) {
output( ANSI_RED "NULL Pointer in bitsToByte\n" ANSI_WHITE );
return;
}
unsigned char new_byte = 0x0;
uint32 i = 0;
for ( i = 0 ; i < 8; i++ ) {
new_byte <<= 1;
if ( bits[i] ) {
new_byte |= 0x01;
}
}
*byte = new_byte;
}
void gmsk_bitsToBytes( BOOL * bits, unsigned char * bytes, uint32 num_of_bits ) {
if ( bits == NULL || bytes == NULL ) {
output( ANSI_RED "NULL Pointer in bitsToBytes\n" ANSI_WHITE );
return;
}
uint32 i = 0;
for ( i = 0 ; i < num_of_bits / 8 ; i++ ) {
gmsk_bitsToByte( &bits[i * 8], &bytes[i] );
}
}
void gmsk_byteToBits( unsigned char byte, BOOL * bits, uint32 num_bits ) {
if ( bits == NULL ) {
output( ANSI_RED "NULL Pointer in byteToBits\n" ANSI_WHITE );
return;
}
uint32 i = 0;
unsigned char mask = 0x80;
for ( i = 0; i < num_bits; i++ , mask >>= 1 ) {
bits[i] = ( byte & mask ) ? TRUE : FALSE;
}
}
void gmsk_bytesToBits( unsigned char * bytes, BOOL * bits, uint32 num_bits ) {
if ( bytes == NULL || bits == NULL ) {
output( ANSI_RED "NULL pointers in bytesToBits\n" ANSI_WHITE );
return;
}
int32 bits_left = num_bits;
uint32 byte_idx = 0;
while ( bits_left > 0 ) {
gmsk_byteToBits( bytes[byte_idx], &bits[byte_idx * 8], bits_left > 8 ? 8 : bits_left );
byte_idx++;
bits_left -= 8;
}
//
// uint32 i = 0;
// output("Bytes: ");
// for ( i = 0 ; i < num_bits / 8U ; i++ ) {
// output(" 0x%02X", bytes[i]);
// }
// output("\nBits: ");
// for ( i = 0 ; i < num_bits ; i++ ) {
// output("%s ", bits[i] ? "1":"0");
// if ( (i+1) % 4 == 0 ) {
// output(" ");
// }
// }
// output("\n");
}
float gmsk_FilterProcessSingle( FIR_FILTER filter, float val ) {
if ( filter == NULL ) {
output( ANSI_RED "NULL FIlter object\n"ANSI_WHITE ) ;
return val;
}
float * ptr = filter->buffer + filter->pointer++;
*ptr = val;
float * a = ptr - filter->length;
float * b = filter->taps;
float out = 0.0F;
uint32 i = 0;
for ( i = 0U; i < filter->length; i++ )
out += ( *a++ ) * ( *b++ );
if ( filter->pointer == filter->buf_len ) {
memcpy( filter->buffer, filter->buffer + filter->buf_len - filter->length, filter->length * sizeof( float ) );
filter->pointer = filter->length;
}
return out;
}
void gmsk_FilterProcessBuffer( FIR_FILTER filter, float * buffer, uint32 buffer_len ) {
if ( filter == NULL ) {
output( ANSI_RED "NULL FIlter object\n"ANSI_WHITE ) ;
return;
}
uint32 i = 0;
for ( i = 0 ; i < buffer_len; i++ ) {
buffer[i] = gmsk_FilterProcessSingle( filter, buffer[i] );
}
}
/* Demod Section */
#define PLLMAX 0x10000U
#define PLLINC ( PLLMAX / DSTAR_RADIO_BIT_LENGTH) // 2000
#define INC 32U
enum DEMOD_STATE gmsk_decode( GMSK_DEMOD demod, float val ) {
enum DEMOD_STATE state = DEMOD_UNKNOWN;
/* FIlter process */
float out = val;//gmsk_FilterProcessSingle(demod->filter, val);
BOOL bit = out > 0.0F;
if ( bit != demod->m_prev ) {
if ( demod->m_pll < ( PLLMAX / 2U ) ) {
demod->m_pll += PLLINC / INC;
} else {
demod->m_pll -= PLLINC / INC;
}
}
demod->m_prev = bit;
demod->m_pll += PLLINC;
if ( demod->m_pll >= PLLMAX ) {
if ( demod->m_invert )
state = bit ? DEMOD_TRUE : DEMOD_FALSE;
else
state = bit ? DEMOD_FALSE : DEMOD_TRUE;
demod->m_pll -= PLLMAX;
}
return state;
}
void gmskDemod_reset( GMSK_DEMOD demod ) {
demod->m_pll = 0U;
demod->m_prev = FALSE;
}
void gmsk_decodeBuffer( GMSK_DEMOD demod, float * buffer, uint32 buf_len, unsigned char * bytes, uint32 num_bits ) {
if ( num_bits * DSTAR_RADIO_BIT_LENGTH != buf_len ) {
output( ANSI_RED "Mismatched buf_len to number of encoded bits. buf_len = %d, required %d\n" ANSI_WHITE, buf_len, num_bits * DSTAR_RADIO_BIT_LENGTH );
return;
}
BOOL bits[num_bits];
memset( bits, 0, num_bits * sizeof( BOOL ) );
uint32 i = 0;
uint32 bit = 0;
enum DEMOD_STATE state;
for ( i = 0; i < buf_len ; i++ ) {
state = gmsk_decode( demod, buffer[i] );
if ( state == DEMOD_TRUE ) {
bits[bit] = TRUE;
bit++;
} else if ( state == DEMOD_FALSE ) {
bits[bit] = FALSE;
bit++;
} else {
//output("UNKNOWN DEMOD STATE");
//bits[bit] = 0x00;
}
}
for ( i = 0; i < bit; i++ ) {
output( "%d", bits[i] ? 1 : 0 );
if ( ( i + 1 ) % 4 == 0 ) output( " " );
}
output( "\n" );
// FILE * f = fopen("gmsk_demod.dat", "w");
// for ( i = 0 ; i < num_bits ; i++ ) {
// fprintf(f,"%d %d\n", i, bits[i]);
// }
// fclose(f);
for ( i = 0 ; i < num_bits / 8 ; i++ ) {
gmsk_bitsToByte( &bits[i * 8], &bytes[i] );
}
}
/* Mod Section */
// Generated by
// gaussfir(0.5, 4, 10)
const float MOD_COEFFS_TABLE[] = {
1.01839713019626E-50, 6.78135172681677E-46, 2.55482745053591E-41,
5.44569202979357E-37, 6.56735934398859E-33, 4.48099730728277E-29,
1.72983542063190E-25, 3.77816645793944E-22, 4.66878194148063E-19,
3.26416641874238E-16, 1.29118120144693E-13, 2.88967031267069E-11,
3.65894261059669E-09, 2.62125395740380E-07, 1.06245073266054E-05,
2.43643428039816E-04, 3.16116236025481E-03, 2.32051886177988E-02,
9.63761566612470E-02, 2.26464589054118E-01, 3.01076739115701E-01,
2.26464589054118E-01, 9.63761566612468E-02, 2.32051886177989E-02,
3.16116236025481E-03, 2.43643428039816E-04, 1.06245073266054E-05,
2.62125395740378E-07, 3.65894261059672E-09, 2.88967031267069E-11,
1.29118120144693E-13, 3.26416641874238E-16, 4.66878194148056E-19,
3.77816645793952E-22, 1.72983542063190E-25, 4.48099730728277E-29,
6.56735934398859E-33, 5.44569202979341E-37, 2.55482745053598E-41,
6.78135172681677E-46, 1.01839713019626E-50
};
#define MOD_COEFFS_LENGTH 41U
#define eiline(n) (iir->in_line[(n)])
#define eoline(n) (iir->out_line[(n)])
static float _process_iir_filter(IIR_FILTER iir, float sample)
{
float * a = iir->a;
float * b = iir->b;
float N = 16.0f; // Scaling value for IIR Filter Realization
float N_IV = 1.0f / N;
float N_2 = N / 2.0f;
float local_out;
//Shift Input Line
eiline( 2) = eiline( 1);
eiline( 1) = eiline( 0);
eiline( 0) = sample;
eoline( 2) = eoline( 1);
eoline( 1) = eoline( 0);
local_out = 0.0f;
local_out = 2.0f * ((-a[1]*0.5f * eoline(
1)) - (a[2]*0.5f * eoline( 2))
+ N_2 * ((b[0]*N_IV * eiline( 0)) + (b[1]*N_IV
* eiline( 1)) + (b[2]*N_IV * eiline( 2))));
eoline(0) = local_out;
return local_out;
}
uint32 gmsk_encode( GMSK_MOD mod, BOOL bit, float * buffer, unsigned int length ) {
if ( length != DSTAR_RADIO_BIT_LENGTH ) {
output( ANSI_RED "Length!= DSTAR_RADIO_BIT_LENGTH" ANSI_WHITE );
}
if ( mod->m_invert )
bit = !bit;
uint32 i = 0;
for ( i = 0; i < DSTAR_RADIO_BIT_LENGTH; i++ ) {
if ( bit ) {
buffer[i] = gmsk_FilterProcessSingle( mod->filter, -0.75f );
} else {
buffer[i] = gmsk_FilterProcessSingle( mod->filter, 0.75f );
}
buffer[i] = _process_iir_filter(mod->iir, buffer[i]);
}
return DSTAR_RADIO_BIT_LENGTH;
}
BOOL gmsk_encodeBuffer( GMSK_MOD mod, unsigned char * bytes, uint32 num_bits, float * buffer, uint32 buf_len ) {
if ( num_bits * DSTAR_RADIO_BIT_LENGTH != buf_len ) {
output( ANSI_RED "Mismatched buf_len to number of encoded bits. buf_len = %d, required %d\n" ANSI_WHITE, buf_len, num_bits * DSTAR_RADIO_BIT_LENGTH );
return FALSE;
}
uint32 i = 0;
float * idx = &buffer[0];
BOOL bits[num_bits];
memset( bits, 0, num_bits * sizeof( BOOL ) );
gmsk_bytesToBits( bytes, bits, num_bits );
for ( i = 0 ; i < num_bits ; i++, idx += DSTAR_RADIO_BIT_LENGTH ) {
gmsk_encode( mod, bits[i], idx, DSTAR_RADIO_BIT_LENGTH );
}
return TRUE;
}
/* Init */
void gmsk_resetMODFilter( GMSK_MOD mod ) {
memset( mod->filter->buffer, 0, mod->filter->buf_len * sizeof( float ) );
mod->filter->pointer = mod->filter->length;
}
FIR_FILTER gmsk_createFilter( const float * taps, uint32 length ) {
FIR_FILTER filter = ( FIR_FILTER ) safe_malloc( sizeof( fir_filter ) );
filter->length = length;
filter->buf_len = 20 * length;
filter->taps = ( float * ) safe_malloc( length * sizeof( float ) );
memcpy( filter->taps, taps, length * sizeof( float ) );
filter->buffer = ( float * ) safe_malloc( filter->buf_len * sizeof( float ) );
filter->pointer = length;
return filter;
}
void gmsk_destroyFilter( FIR_FILTER filter ) {
if ( filter == NULL ) {
output( ANSI_RED "NULL FIlter object\n"ANSI_WHITE ) ;
return;
}
safe_free( filter->taps );
safe_free( filter->buffer );
safe_free( filter );
}
GMSK_DEMOD gmsk_createDemodulator( void ) {
GMSK_DEMOD demod = ( GMSK_DEMOD ) safe_malloc( sizeof( gmsk_demod ) );
demod->m_pll = 0;
demod->m_prev = FALSE;
demod->m_invert = FALSE;
return demod;
}
float convertVITAdbToFloat(VITAdb vita)
{
int32 db = (int32)((int16)(vita & 0xFFFF));
return (float)db / 128.0;
}
// always assume the float is in dB (see the parameter name)
VITAdb convertFloatToVITAdb(float db)
{
return ((int32)(db * 128) & 0xFFFF);
}
GMSK_MOD gmsk_createModulator( void ) {
GMSK_MOD mod = ( GMSK_MOD ) safe_malloc( sizeof( gmsk_mod ) );
mod->m_invert = FALSE;
mod->filter = gmsk_createFilter( MOD_COEFFS_TABLE, MOD_COEFFS_LENGTH );
mod->iir = safe_malloc(sizeof(iir_filter));
IIR_FILTER filter = mod->iir;
float * a = filter->a;
float * b = filter->b;
uint32 freq_hz = 4800;
uint32 sample_rate_hz = 24000;
uint32 level = 10;
float q_level = 0.2;
float w0 = 2.0 * M_PI * freq_hz/
(float)sample_rate_hz;
VITAdb db_gain = convertFloatToVITAdb(level);
float q_factor;
if ( level > 0 ) {
q_factor = q_level;
} else {
q_factor = 4.0f * q_level;
}
float A = pow(10, convertVITAdbToFloat(db_gain) / 40);
float alpha = sin(w0) / (2 * A * q_factor);
//flex_printf(LOG_ALWAYS, "w0 = %lf, A = %lf, alpha = %lf", w0, A, alpha);
//float linearGain = pow(10, convertVITAdbToFloat(db_gain) / 20);
if (level != 0 ) {
// Peaking EQ from AUDIO COOKBOOK
b[0] = 1 + alpha * A;
b[1] = -2 * cos(w0);
b[2] = 1 - alpha * A;
a[0] = 1 + alpha/A;
a[1] = -2 * cos(w0);
a[2] = 1 - alpha / A;
} else {
b[0] = 0;
b[1] = 0;
b[2] = 0;
a[0] = 1;
a[1] = 0;
a[2] = 0;
}
// Normalize by a[0] so that a[0] = 1
b[0] = b[0] / a[0];
b[1] = b[1] / a[0];
b[2] = b[2] / a[0];
a[1] = a[1] / a[0];
a[2] = a[2] / a[0];
a[0] = a[0] / a[0];
return mod;
}
void gmsk_destroyDemodulator( GMSK_DEMOD demod ) {
if ( demod == NULL ) {
output( ANSI_RED "NULL GMSK_DEMOD\n" ANSI_WHITE );
return;
}
safe_free( demod );
}
void gmsk_destroyModulator( GMSK_MOD mod ) {
if ( mod == NULL ) {
output( ANSI_RED "NULL GMSK_MOD\n" ANSI_WHITE );
return;
}
gmsk_destroyFilter( mod->filter );
safe_free(mod->iir);
safe_free( mod );
}
void gmsk_testBitsAndEncodeDecode( void ) {
GMSK_DEMOD _gmsk_demod = gmsk_createDemodulator();
GMSK_MOD _gmsk_mod = gmsk_createModulator();
unsigned char pattern[1] = {0xAA};
BOOL pattern_bits[8] = {0};
gmsk_bytesToBits( pattern, pattern_bits, 8 );
BIT_PM _bit_pm = bitPM_create( pattern_bits, 8 );
float test_buffer[160 * 2];
unsigned char test_coded[8] = {0xAA, 0xAA, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00};
unsigned char output_bytes[8] = {0};
uint32 i = 0;
BOOL bits[64] = {0};
gmsk_bytesToBits( test_coded, bits, 32 );
gmsk_byteToBits( 0xF0, bits, 8 );
output( "0xF0 = " );
for ( i = 0 ; i < 8; i++ ) {
output( "%d ", bits[i] );
}
output( "\n" );
unsigned char test[4] = {0xAA, 0xAA, 0xAA, 0xAA};
gmsk_bytesToBits( test, bits, 32 );
for ( i = 0 ; i < 32 / 8 ; i++ ) {
gmsk_bitsToByte( &bits[i * 8], &output_bytes[i] );
output( "Byte = 0x%02X\n", output_bytes[i] );
}
gmsk_encodeBuffer( _gmsk_mod, test_coded, 32 * 2, test_buffer, 160 * 2 );
FILE * dat = fopen( "gmsk.dat", "w" );
for ( i = 0 ; i < 160 * 2 ; i++ ) {
fprintf( dat, "%d %.12f\n", i, test_buffer[i] );
//output("%.12f,", test_buffer[i]);
}
fclose( dat );
gmsk_decodeBuffer( _gmsk_demod, test_buffer, 160 * 2, output_bytes, 32 * 2 );
gmsk_bytesToBits( output_bytes, bits, 32 * 2 );
output( "STARTING PATTERN MATCH TEST \n" );
for ( i = 0 ; i < 32 * 2; i++ ) {
output( "%d ", bits[i] );
if ( bitPM_addBit( _bit_pm, bits[i] ) ) {
output( "MATCH!\n" );
bitPM_reset( _bit_pm );
}
}
bitPM_destroy( _bit_pm );
gmsk_destroyDemodulator( _gmsk_demod );
gmsk_destroyModulator( _gmsk_mod );
}

View file

@ -0,0 +1,93 @@
///*! \file gmsk_modem.h
// * \date 02-JUN-2015
// * \author Ed Gonzalez KG5FBT
// */
/* *****************************************************************************
*
* Copyright (C) 2012-2014 FlexRadio Systems.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contact Information:
* email: gpl<at>flexradiosystems.com
* Mail: FlexRadio Systems, Suite 1-150, 4616 W. Howard LN, Austin, TX 78728
*
* ************************************************************************** */
#ifndef THUMBDV_GMSK_MODEM_H_
#define THUMBDV_GMSK_MODEM_H_
#include "common.h"
enum DEMOD_STATE {
DEMOD_FALSE,
DEMOD_TRUE,
DEMOD_UNKNOWN
};
#define SC_EQ_MAX_DEPTH 3
#define SC_EQ_FILTER_LEN 3
typedef struct _iir_filter
{
float in_line[SC_EQ_FILTER_LEN];
float out_line[SC_EQ_FILTER_LEN];
float a[SC_EQ_FILTER_LEN];
float b[SC_EQ_FILTER_LEN];
} iir_filter, * IIR_FILTER;
typedef struct _fir_filter {
float * taps;
uint32 length;
float * buffer;
uint32 buf_len;
uint32 pointer;
} fir_filter, * FIR_FILTER ;
/* Used to hold state information for a GMSK Demodulator object */
typedef struct _gmsk_demod {
uint32 m_pll;
BOOL m_prev;
BOOL m_invert;
} gmsk_demod, * GMSK_DEMOD;
typedef struct _gmsk_mod {
BOOL m_invert;
FIR_FILTER filter;
IIR_FILTER iir;
} gmsk_mod, * GMSK_MOD;
void gmsk_testBitsAndEncodeDecode( void );
void gmsk_bitsToByte( BOOL * bits, unsigned char * byte );
void gmsk_bitsToBytes( BOOL * bits, unsigned char * bytes, uint32 num_of_bits );
void gmsk_byteToBits( unsigned char byte, BOOL * bits, uint32 num_bits );
void gmsk_bytesToBits( unsigned char * bytes, BOOL * bits, uint32 num_bits );
BOOL gmsk_encodeBuffer( GMSK_MOD mod, unsigned char * bytes, uint32 num_bits, float * buffer, uint32 buf_len );
void gmsk_decodeBuffer( GMSK_DEMOD demod, float * buffer, uint32 buf_len, unsigned char * bytes, uint32 num_bits );
void gmsk_resetMODFilter( GMSK_MOD mod );
uint32 gmsk_encode( GMSK_MOD mod, BOOL bit, float * buffer, unsigned int length );
enum DEMOD_STATE gmsk_decode( GMSK_DEMOD demod, float val );
void gmskDemod_reset( GMSK_DEMOD demod );
GMSK_MOD gmsk_createModulator( void );
GMSK_DEMOD gmsk_createDemodulator( void );
void gmsk_destroyModulator( GMSK_MOD mod );
void gmsk_destroyDemodulator( GMSK_DEMOD demod );
#endif /* THUMBDV_GMSK_MODEM_H_ */

321
DSP_API/ThumbDV/slow_data.c Normal file
View file

@ -0,0 +1,321 @@
///*! \file slow_data.c
// *
// * Handles scrambling and descrambling of DSTAR Header
// *
// * \date 25-AUG-2015
// * \author Ed Gonzalez KG5FBT
// */
/* *****************************************************************************
*
* Copyright (C) 2012-2014 FlexRadio Systems.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contact Information:
* email: gpl<at>flexradiosystems.com
* Mail: FlexRadio Systems, Suite 1-150, 4616 W. Howard LN, Austin, TX 78728
*
* ************************************************************************** */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "slow_data.h"
#include "DStarDefines.h"
#include "dstar.h"
#include "gmsk_modem.h"
#include "thumbDV.h"
uint32 slow_data_createDecoder(SLOW_DATA_DECODER slow_decoder)
{
SLOW_DATA_DECODER decoder = ( SLOW_DATA_DECODER ) safe_malloc(sizeof(slow_data_decoder)) ;
if ( decoder == NULL ) {
output("Could not allocate slow data decoder\n");
return FAIL;
}
memset(decoder, 0, sizeof(slow_data_decoder));
decoder->decode_state = FIRST_FRAME;
slow_decoder = decoder;
return SUCCESS;
}
static void _slow_data_processHeaderBytes(DSTAR_MACHINE dstar)
{
uint32 i = 0;
dstar_pfcs pfcs;
pfcs.crc16 = 0xFFFF;
SLOW_DATA_DECODER slow_decoder = (SLOW_DATA_DECODER) dstar->slow_decoder;
BOOL bits[RADIO_HEADER_LENGTH_BITS] = {0};
gmsk_bytesToBits(slow_decoder->header_bytes, bits, RADIO_HEADER_LENGTH_BITS);
for ( i = 0 ; i < 312 ; i += 8 ) {
dstar_pfcsUpdate( &pfcs, bits + i);
}
BOOL pfcs_match = FALSE;
pfcs_match = dstar_pfcsCheck( &pfcs, bits + 312 );
if ( pfcs_match ) {
output("SLOW DATA HEADER PARSED\n");
dstar_processHeader(slow_decoder->header_bytes, &dstar->incoming_header);
dstar_updateStatus( dstar, dstar->slice, STATUS_RX );
}
slow_data_resetDecoder(dstar);
}
static void _slow_data_processMessage(DSTAR_MACHINE dstar)
{
char message[21];
uint32 i, j;
for ( i = 0 ; i < 4 ; i++ ) {
for ( j = 0 ; j < 5 ; j++ ) {
message[(i*5) + j] = dstar->slow_decoder->message[i][j];
}
}
message[20] = '\0';
strncpy(dstar->slow_decoder->message_string, message, 21);
output("SLOW DATA MESSAGE PARSED = '%s'\n", message);
dstar_updateStatus(dstar, dstar->slice, STATUS_SLOW_DATA_MESSAGE);
slow_data_resetDecoder(dstar);
}
void slow_data_createEncodeBytes(DSTAR_MACHINE dstar)
{
uint32 i = 0;
uint32 j = 0;
SLOW_DATA_ENCODER encoder = dstar->slow_encoder;
uint32 message_index = 0;
dstar_pfcs pfcs;
/* Set all bytes to 0x66 */
memset(encoder->message_bytes, 0x66, SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC);
/* Generate Message Bytes */
for ( i = 0 ; i < 4 ; i++ ) {
encoder->message_bytes[(i * 6)] = SLOW_DATA_TYPE_MESSAGE | i;
for ( j = 1 ; j < 6 ; j++ ) {
encoder->message_bytes[(i * 6) + j] = encoder->message[message_index++];
}
}
thumbDV_dump("MESSAGE BYTES", encoder->message_bytes, SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC);
/* Generate HEADER Bytes */
/* Set all bytes to 0x66 */
memset(encoder->header_bytes, 0x66, SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC);
uint32 header_index = 0;
unsigned char header_bytes[RADIO_HEADER_LENGTH_BYTES] = {0};
dstar_headerToBytes(&dstar->outgoing_header, header_bytes);
pfcs.crc16 = 0xFFFF;
dstar_pfcsUpdateBuffer( &pfcs, header_bytes, 312 / 8 );
dstar_pfcsResult( &pfcs, header_bytes + 312 / 8 );
uint32 bits_left = RADIO_HEADER_LENGTH_BYTES;
uint32 second_loop_limit = 0;
for ( i = 0 ; i < RADIO_HEADER_LENGTH_BYTES / 5 + 1; i++ ) {
if ( bits_left >= 5 )
second_loop_limit = 6;
else
second_loop_limit = bits_left;
encoder->header_bytes[(i * 6)] = SLOW_DATA_TYPE_HEADER | (second_loop_limit - 1);
for ( j = 1 ; j < second_loop_limit ; j++ ) {
encoder->header_bytes[(i * 6) + j] = header_bytes[header_index++];
}
bits_left -= 5;
}
thumbDV_dump("Header bytes", encoder->header_bytes, SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC);
slow_data_resetEncoder(dstar);
}
void slow_data_getEncodeBytes( DSTAR_MACHINE dstar, unsigned char * bytes , uint32 num_bytes)
{
uint32 i = 0;
memset(bytes, 0x66, num_bytes);
SLOW_DATA_ENCODER encoder = dstar->slow_encoder;
switch ( encoder->encode_state ) {
case MESSAGE_TX:
if ( encoder->message_index != 0 && encoder->message_index % 3 != 0 ) {
output("Message indexing problem. message_index = %d\n", encoder->message_index);
slow_data_resetEncoder(dstar);
break;
}
for ( i = 0 ; i < SLOW_DATA_PACKET_LEN_BYTES ; i++ ) {
bytes[i] = encoder->message_bytes[encoder->message_index++];
}
if ( encoder->message_index >= SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC ) {
/* Done sending the message change to header state */
encoder->message_index = 0;
encoder->encode_state = HEADER_TX;
}
break;
case HEADER_TX:
if ( encoder->header_index != 0 && encoder->header_index % 3 != 0 ) {
output("Header indexing problem. header_index = %d\n", encoder->header_index);
slow_data_resetEncoder(dstar);
break;
}
for ( i = 0 ; i < SLOW_DATA_PACKET_LEN_BYTES ; i++ ) {
bytes[i] = encoder->header_bytes[encoder->header_index++];
}
if ( encoder->header_index >= SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC ) {
/* Done sending header. Reset index and keep sending header slow data */
encoder->header_index = 0;
}
break;
}
}
void slow_data_resetEncoder(DSTAR_MACHINE dstar)
{
dstar->slow_encoder->encode_state = MESSAGE_TX;
dstar->slow_encoder->message_index = 0;
dstar->slow_encoder->header_index = 0;
}
void slow_data_resetDecoder(DSTAR_MACHINE dstar)
{
dstar->slow_decoder->decode_state = FIRST_FRAME;
dstar->slow_decoder->header_array_index = 0;
dstar->slow_decoder->message_index = 0;
}
void slow_data_addDecodeData(DSTAR_MACHINE dstar, unsigned char * data, uint32 data_len)
{
if ( data_len != SLOW_DATA_PACKET_LEN_BYTES ) {
output("Invalid data length - slow_data_addData\n");
return;
}
SLOW_DATA_DECODER slow_decoder = (SLOW_DATA_DECODER) (dstar->slow_decoder);
if ( slow_decoder == NULL ) {
output("NULL slow_decoder\n");
return;
}
uint32 i = 0;
switch(slow_decoder->decode_state) {
case FIRST_FRAME:
{
//output("FIRST FRAME\n");
switch(data[0] & SLOW_DATA_TYPE_MASK ) {
case SLOW_DATA_TYPE_HEADER:
{
for ( i = 1 ; i < 3 ; i++ ) {
slow_decoder->header_bytes[slow_decoder->header_array_index++] =
data[i];
if ( slow_decoder->header_array_index >= RADIO_HEADER_LENGTH_BYTES )
{
_slow_data_processHeaderBytes(dstar);
break;
}
}
slow_decoder->decode_state = HEADER_SECOND_FRAME;
break;
}
case SLOW_DATA_TYPE_MESSAGE:
{
uint32 message_index = data[0] & SLOW_DATA_LENGTH_MASK;
if ( message_index != slow_decoder->message_index ) {
output("Out of order SLOW DATA MESSAGE setting to new index\n");
slow_decoder->message_index = message_index;
break;
}
for ( i = 1 ; i < 3 ; i++ ) {
slow_decoder->message[message_index][i - 1 ] = data[i];
}
slow_decoder->decode_state = MESSAGE_SECOND_FRAME;
break;
}
default:
//output("SLOW DATA BYTES 0x%X 0x%X 0x%X \n", data[0], data[1], data[2]);
break;
}
break;
}
case HEADER_SECOND_FRAME:
{
//output("HEADER SECOND FRAME\n");
if ( slow_decoder->header_array_index == 0 ) {
/* We reached the end of the array so we need to reset and find the first frame again */
slow_decoder->decode_state = FIRST_FRAME;
break;
}
for ( i = 0 ; i < 3 ; i++ ) {
slow_decoder->header_bytes[slow_decoder->header_array_index++] =
data[i];
if ( slow_decoder->header_array_index >= RADIO_HEADER_LENGTH_BYTES )
{
_slow_data_processHeaderBytes(dstar);
break;
}
}
slow_decoder->decode_state = FIRST_FRAME;
break;
}
case MESSAGE_SECOND_FRAME:
{
for ( i = 0 ; i < 3 ; i++ ) {
slow_decoder->message[slow_decoder->message_index][i+2] = data[i];
}
slow_decoder->message_index++;
if ( slow_decoder->message_index >= 4 ) {
_slow_data_processMessage(dstar);
}
slow_decoder->decode_state = FIRST_FRAME;
break;
}
}
}

View file

@ -0,0 +1,43 @@
///*! \file slow_data.h
// *
// * Handles scrambling and descrambling of DSTAR Header
// *
// * \date 25-AUG-2015
// * \author Ed Gonzalez KG5FBT
// */
/* *****************************************************************************
*
* Copyright (C) 2012-2014 FlexRadio Systems.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contact Information:
* email: gpl<at>flexradiosystems.com
* Mail: FlexRadio Systems, Suite 1-150, 4616 W. Howard LN, Austin, TX 78728
*
* ************************************************************************** */
#ifndef THUMBDV_SLOW_DATA_H_
#define THUMBDV_SLOW_DATA_H_
#include "dstar.h"
#include "common.h"
#include "DStarDefines.h"
void slow_data_addDecodeData(DSTAR_MACHINE dstar, unsigned char * data, uint32 data_len);
void slow_data_resetDecoder(DSTAR_MACHINE dstar);
void slow_data_resetEncoder(DSTAR_MACHINE dstar);
void slow_data_getEncodeBytes( DSTAR_MACHINE dstar, unsigned char * bytes, uint32 num_bytes );
void slow_data_createEncodeBytes(DSTAR_MACHINE dstar);
#endif /* THUMBDV_SLOW_DATA_H_*/

824
DSP_API/ThumbDV/thumbDV.c Normal file
View file

@ -0,0 +1,824 @@
///*! \file thumbdv.c
// * \brief Functions required to communicate and decode packets from ThumbDV
// *
// * \copyright Copyright 2012-2014 FlexRadio Systems. All Rights Reserved.
// * Unauthorized use, duplication or distribution of this software is
// * strictly prohibited by law.
// *
// * \date 26-MAY-2015
// * \author Ed Gonzalez
// *
// *
// */
/* *****************************************************************************
*
* Copyright (C) 2014 FlexRadio Systems.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contact Information:
* email: gpl<at>flexradiosystems.com
* Mail: FlexRadio Systems, Suite 1-150, 4616 W. Howard LN, Austin, TX 78728
*
* ************************************************************************** */
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#include <termios.h>
#include <string.h>
#include <fcntl.h>
#include <pthread.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/prctl.h>
#include <netinet/in.h>
#include "common.h"
#include "datatypes.h"
#include "hal_buffer.h"
#include "vita_output.h"
#include "thumbDV.h"
#include "sched_waveform.h"
#include "ftd2xx.h"
#define AMBE3000_HEADER_LEN 4U
#define AMBE3000_START_BYTE 0x61U
#define AMBE3000_SPEECHD_HEADER_LEN 3U
#define AMBE3000_CTRL_PKT_TYPE 0x00
#define AMBE3000_SPEECH_PKT_TYPE 0x02
#define AMBE3000_CHAN_PKT_TYPE 0x01
#define BUFFER_LENGTH 400U
#define THUMBDV_MAX_PACKET_LEN 2048U
static pthread_t _read_thread;
BOOL _readThreadAbort = FALSE;
static uint32 _buffering_target = 1;
static pthread_rwlock_t _encoded_list_lock;
static BufferDescriptor _encoded_root;
static BOOL _encoded_buffering = TRUE;
static uint32 _encoded_count = 0;
static pthread_rwlock_t _decoded_list_lock;
static BufferDescriptor _decoded_root;
static BOOL _decoded_buffering = TRUE;
static uint32 _decoded_count = 0;
static void * _thumbDV_readThread( void * param );
static BufferDescriptor _thumbDVEncodedList_UnlinkHead( void ) {
BufferDescriptor buf_desc = NULL;
pthread_rwlock_wrlock( &_encoded_list_lock );
if ( _encoded_root == NULL || _encoded_root->next == NULL ) {
output( "Attempt to unlink from a NULL head" );
pthread_rwlock_unlock( &_encoded_list_lock );
return NULL;
}
if ( _encoded_buffering ) {
pthread_rwlock_unlock( &_encoded_list_lock );
return NULL;
}
if ( _encoded_root->next != _encoded_root )
buf_desc = _encoded_root->next;
if ( buf_desc != NULL ) {
// make sure buffer exists and is actually linked
if ( !buf_desc || !buf_desc->prev || !buf_desc->next ) {
output( "Invalid buffer descriptor" );
buf_desc = NULL;
} else {
buf_desc->next->prev = buf_desc->prev;
buf_desc->prev->next = buf_desc->next;
buf_desc->next = NULL;
buf_desc->prev = NULL;
if ( _encoded_count > 0 ) _encoded_count--;
}
} else {
if ( !_encoded_buffering ) output( "Encoded list now buffering\n" );
_encoded_buffering = TRUE;
}
pthread_rwlock_unlock( &_encoded_list_lock );
return buf_desc;
}
static void _thumbDVEncodedList_LinkTail( BufferDescriptor buf_desc ) {
pthread_rwlock_wrlock( &_encoded_list_lock );
buf_desc->next = _encoded_root;
buf_desc->prev = _encoded_root->prev;
_encoded_root->prev->next = buf_desc;
_encoded_root->prev = buf_desc;
_encoded_count++;
if ( _encoded_count > _buffering_target ) {
if ( _encoded_buffering ) output( "Encoded Buffering is now FALSE\n" );
_encoded_buffering = FALSE;
}
pthread_rwlock_unlock( &_encoded_list_lock );
}
static BufferDescriptor _thumbDVDecodedList_UnlinkHead( void ) {
BufferDescriptor buf_desc = NULL;
pthread_rwlock_wrlock( &_decoded_list_lock );
if ( _decoded_root == NULL || _decoded_root->next == NULL ) {
output( "Attempt to unlink from a NULL head" );
pthread_rwlock_unlock( &_decoded_list_lock );
return NULL;
}
if ( _decoded_buffering ) {
pthread_rwlock_unlock( &_decoded_list_lock );
return NULL;
}
if ( _decoded_root->next != _decoded_root ) {
buf_desc = _decoded_root->next;
}
if ( buf_desc != NULL ) {
//output("0");
// make sure buffer exists and is actually linked
if ( !buf_desc || !buf_desc->prev || !buf_desc->next ) {
output( "Invalid buffer descriptor" );
buf_desc = NULL;
} else {
buf_desc->next->prev = buf_desc->prev;
buf_desc->prev->next = buf_desc->next;
buf_desc->next = NULL;
buf_desc->prev = NULL;
if ( _decoded_count > 0 ) _decoded_count--;
}
} else {
if ( !_decoded_buffering )
output( "DecodedList now Buffering \n" );
_decoded_buffering = TRUE;
}
pthread_rwlock_unlock( &_decoded_list_lock );
return buf_desc;
}
static void _thumbDVDecodedList_LinkTail( BufferDescriptor buf_desc ) {
pthread_rwlock_wrlock( &_decoded_list_lock );
buf_desc->next = _decoded_root;
buf_desc->prev = _decoded_root->prev;
_decoded_root->prev->next = buf_desc;
_decoded_root->prev = buf_desc;
_decoded_count++;
if ( _decoded_count > _buffering_target ) {
if ( _decoded_buffering ) output( "Decoded Buffering is now FALSE\n" );
_decoded_buffering = FALSE;
}
pthread_rwlock_unlock( &_decoded_list_lock );
}
static void delay( unsigned int delay ) {
struct timespec tim, tim2;
tim.tv_sec = 0;
tim.tv_nsec = delay * 1000UL;
nanosleep( &tim, &tim2 );
};
void thumbDV_flushLists(void)
{
BufferDescriptor buf_desc = NULL;
do
{
buf_desc = _thumbDVEncodedList_UnlinkHead();
if ( buf_desc != NULL )
hal_BufferRelease(&buf_desc);
} while (buf_desc != NULL );
do
{
buf_desc = _thumbDVDecodedList_UnlinkHead();
if ( buf_desc != NULL )
hal_BufferRelease(&buf_desc);
} while (buf_desc != NULL );
}
void thumbDV_dump( char * text, unsigned char * data, unsigned int length ) {
unsigned int offset = 0U;
unsigned int i;
output( "%s", text );
output( "\n" );
while ( length > 0U ) {
unsigned int bytes = ( length > 16U ) ? 16U : length;
output( "%04X: ", offset );
for ( i = 0U; i < bytes; i++ )
output( "%02X ", data[offset + i] );
for ( i = bytes; i < 16U; i++ )
output( " " );
output( " *" );
for ( i = 0U; i < bytes; i++ ) {
unsigned char c = data[offset + i];
if ( isprint( c ) )
output( "%c", c );
else
output( "." );
}
output( "*\n" );
offset += 16U;
if ( length >= 16U )
length -= 16U;
else
length = 0U;
}
}
static void thumbDV_writeSerial( FT_HANDLE handle , unsigned char * buffer, uint32 bytes )
{
FT_STATUS status = FT_OK;
DWORD written = 0;
if ( handle != NULL )
{
status = FT_Write(handle, buffer, bytes, &written);
if ( status != FT_OK || written != bytes ) {
output( ANSI_RED "Could not write to serial port. status = %d\n", status );
return;
}
}
else
{
output( ANSI_RED "Could not write to serial port. Timeout\n" ANSI_WHITE );
}
}
static int _check_serial( FT_HANDLE handle )
{
unsigned char reset[5] = { 0x61, 0x00, 0x01, 0x00, 0x33 };
thumbDV_writeSerial( handle, reset, 5 );
int ret = thumbDV_processSerial(handle);
if ( ret != 0 )
{
output( "Could not reset serial port FD = %d \n", handle );
return -1;
}
unsigned char get_prodID[5] = {0x61, 0x00, 0x01, 0x00, 0x30 };
thumbDV_writeSerial( handle, get_prodID, 5 );
ret = thumbDV_processSerial(handle);
if ( ret != 0 )
{
output( "Could not reset serial port FD = %d \n", handle );
return -1;
}
return 0 ;
}
FT_HANDLE thumbDV_openSerial( FT_DEVICE_LIST_INFO_NODE device )
{
//struct termios tty;
FT_HANDLE handle = NULL;
FT_STATUS status = FT_OK;
output("Trying to open serial port %s", device.SerialNumber);
status = FT_OpenEx(device.SerialNumber, FT_OPEN_BY_SERIAL_NUMBER, &handle);
if ( status != FT_OK || handle == NULL )
{
if ( device.SerialNumber )
output("Error opening device %s - error 0x%X\n", device.SerialNumber, status);
else
output("Error opening device - error 0x%X\n", status);
return NULL;
}
FT_SetBaudRate(handle, FT_BAUD_460800);
// Set read and write timeout to 2seconds */
FT_SetTimeouts(handle, 0, 0);
FT_SetDataCharacteristics(handle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_NONE);
FT_SetFlowControl(handle, FT_FLOW_NONE, 0, 0);
/*
tty.c_cflag = ( tty.c_cflag & ~CSIZE ) | CS8;
tty.c_iflag &= ~IGNBRK;
tty.c_lflag = 0;
tty.c_oflag = 0;
tty.c_cc[VMIN] = 1;
tty.c_cc[VTIME] = 5;
tty.c_iflag &= ~( IXON | IXOFF | IXANY );
tty.c_cflag |= ( CLOCAL | CREAD );
tty.c_cflag &= ~( PARENB | PARODD );
tty.c_cflag &= ~CSTOPB;
tty.c_cflag &= ~CRTSCTS;
if ( tcsetattr( fd, TCSANOW, &tty ) != 0 ) {
output( "ThumbDV: error %d from tcsetattr\n", errno );
close( fd );
return -1;
}
*/
if ( _check_serial(handle) != 0 ) {
output( "Could not detect ThumbDV at 460800 Baud. Trying 230400\n" );
FT_Close(handle);
handle = (FT_HANDLE)NULL;
} else {
return handle;
}
status = FT_OpenEx(device.SerialNumber, FT_OPEN_BY_SERIAL_NUMBER, &handle);
if ( status != FT_OK || handle == NULL )
{
if ( device.SerialNumber )
output("Error opening device %s - error 0x%X\n", device.SerialNumber, status);
else
output("Error opening device - error 0x%X\n", status);
return NULL;
}
FT_SetBaudRate(handle, FT_BAUD_230400 );
FT_SetTimeouts(handle, 0, 0);
FT_SetDataCharacteristics(handle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_NONE);
FT_SetFlowControl(handle, FT_FLOW_NONE, 0, 0);
if ( _check_serial( handle ) != 0 ) {
output( "Could not detect THumbDV at 230400 Baud\n" );
FT_Close(handle);
handle = NULL;
return NULL;
}
return handle;
}
int thumbDV_processSerial( FT_HANDLE handle )
{
unsigned char buffer[BUFFER_LENGTH];
unsigned int respLen;
uint32 offset = 0;
unsigned char packet_type;
FT_STATUS status = FT_OK;
DWORD rx_bytes = 0;
DWORD tx_bytes = 0 ;
DWORD event_word = 0;
uint32 max_us_sleep = 100000; // 100 ms
uint32 us_slept = 0;
do
{
status = FT_GetStatus(handle, &rx_bytes, &tx_bytes, &event_word);
if ( rx_bytes >= AMBE3000_HEADER_LEN )
break;
usleep(100);
us_slept += 100;
if ( us_slept > max_us_sleep )
{
output("TimeOut\n");
return 1;
}
} while (rx_bytes < AMBE3000_HEADER_LEN && status == FT_OK );
status = FT_Read(handle, buffer, AMBE3000_HEADER_LEN, &rx_bytes);
if ( status != FT_OK || rx_bytes != AMBE3000_HEADER_LEN)
{
output( ANSI_RED "ThumbDV: Process serial. error when reading from the serial port, len = %d, status=%d\n" ANSI_WHITE, rx_bytes, status );
return 1;
}
if ( buffer[0U] != AMBE3000_START_BYTE ) {
output( ANSI_RED "ThumbDV: unknown byte from the DV3000, 0x%02X\n" ANSI_WHITE, buffer[0U] );
return 1;
}
offset = 0U;
respLen = buffer[1U] * 256U + buffer[2U];
us_slept = 0;
do
{
status = FT_GetStatus(handle, &rx_bytes, &tx_bytes, &event_word);
if ( rx_bytes >= respLen )
break;
usleep(1000);
us_slept += 1000 ;
if ( us_slept > max_us_sleep )
{
output("TimeOut\n");
return 1;
}
} while (rx_bytes < respLen && status == FT_OK);
status = FT_Read(handle, buffer + AMBE3000_HEADER_LEN , respLen, &rx_bytes);
if ( status != FT_OK || rx_bytes != respLen )
{
output( ANSI_RED "ThumbDV: Process serial. error when reading from the serial port, len = %d, status=%d\n" ANSI_WHITE, rx_bytes, status );
}
respLen += AMBE3000_HEADER_LEN;
BufferDescriptor desc = NULL;
packet_type = buffer[3];
//thumbDV_dump("Serial data", buffer, respLen);
if ( packet_type == AMBE3000_CTRL_PKT_TYPE ) {
thumbDV_dump( ANSI_YELLOW "Serial data" ANSI_WHITE, buffer, respLen );
} else if ( packet_type == AMBE3000_CHAN_PKT_TYPE ) {
desc = hal_BufferRequest( respLen, sizeof( unsigned char ) );
memcpy( desc->buf_ptr, buffer, respLen );
//thumbDV_dump(ANSI_BLUE "Coded Packet" ANSI_WHITE, buffer, respLen);
/* Encoded data */
_thumbDVEncodedList_LinkTail( desc );
} else if ( packet_type == AMBE3000_SPEECH_PKT_TYPE ) {
desc = hal_BufferRequest( respLen, sizeof( unsigned char ) );
memcpy( desc->buf_ptr, buffer, respLen );
//thumbDV_dump("SPEECH Packet", buffer, respLen);
/* Speech data */
_thumbDVDecodedList_LinkTail( desc );
} else {
output( ANSI_RED "Unrecognized packet type 0x%02X ", packet_type );
return 1;
}
return 0;
}
int thumbDV_decode( FT_HANDLE handle, unsigned char * packet_in, short * speech_out, uint8 bytes_in_packet ) {
uint32 i = 0;
unsigned char full_packet[15] = {0};
if ( packet_in != NULL && handle != NULL ) {
full_packet[0] = 0x61;
full_packet[1] = 0x00;
full_packet[2] = 0x0B;
full_packet[3] = 0x01;
full_packet[4] = 0x01;
full_packet[5] = 0x48;
uint32 j = 0;
for ( i = 0, j = 8 ; i < 9 ; i++ , j-- ) {
full_packet[i + 6] = packet_in[i];
}
// thumbDV_dump("Just AMBE", packet_in, 9);
// thumbDV_dump("Encoded packet:", full_packet, 15);
thumbDV_writeSerial( handle, full_packet, 15 );
}
int32 samples_returned = 0;
BufferDescriptor desc = _thumbDVDecodedList_UnlinkHead();
uint32 samples_in_speech_packet = 0;
uint32 length = 0;
if ( desc != NULL ) {
length = ( ( ( unsigned char * )desc->buf_ptr )[1] << 8 ) + ( ( unsigned char * )desc->buf_ptr )[2];;
if ( length != 0x142 ) {
output( ANSI_YELLOW, "WARNING LENGHT DOESN'T Match %d " ANSI_WHITE, length );
thumbDV_dump( "MISMATHCED", ( ( unsigned char * ) desc->buf_ptr ), desc->num_samples );
}
samples_in_speech_packet = ( ( unsigned char * )desc->buf_ptr )[5];
unsigned char * idx = &( ( ( unsigned char * )desc->buf_ptr )[6] );
uint32 i = 0;
for ( i = 0; i < samples_in_speech_packet; i++, idx += 2 ) {
speech_out[i] = ( idx[0] << 8 ) + idx[1];
}
samples_returned = samples_in_speech_packet;
if ( samples_returned != 160 ) output( "Rate Mismatch expected %d got %d\n", 160, samples_returned );
// safe_free( desc );
hal_BufferRelease(&desc);
} else {
/* Do nothing for now */
}
return samples_returned;
}
int thumbDV_encode( FT_HANDLE handle, short * speech_in, unsigned char * packet_out, uint8 num_of_samples )
{
unsigned char packet[THUMBDV_MAX_PACKET_LEN];
uint16 speech_d_bytes = num_of_samples * sizeof( uint16 ); /* Should be 2 times the number of samples */
/* Calculate length of packet NOT including the full header just the type field*/
uint16 length = 0;
/* Includes Channel Field and SpeechD Field Header */
length += AMBE3000_SPEECHD_HEADER_LEN;
length += speech_d_bytes;
/* Will be used to write fields into packet */
unsigned char * idx = &packet[0];
*( idx++ ) = AMBE3000_START_BYTE;
/* Length split into two bytes */
*( idx++ ) = length >> 8;
*( idx++ ) = length & 0xFF;
/* SPEECHD Type */
*( idx++ ) = AMBE3000_SPEECH_PKT_TYPE;
/* Channel0 Identifier */
*( idx++ ) = 0x40;
/* SPEEECHD Identifier */
*( idx++ ) = 0x00;
/* SPEECHD No of Samples */
*( idx++ ) = num_of_samples;
uint32 i = 0;
// output("Num of Samples = 0x%X\n", num_of_samples);
#ifdef WOOT
output( "Encode Packet Header = " );
unsigned char * p = &packet[0];
i = 0;
for ( i = 0 ; i < 7 ; i++ ) {
output( "%02X ", *p );
p++;
}
output( "\n" );
#endif
//memcpy(idx, speech_in, speech_d_bytes);
i = 0;
for ( i = 0 ; i < num_of_samples ; i++, idx += 2 ) {
idx[0] = speech_in[i] >> 8;
idx[1] = ( speech_in[i] & 0x00FF ) ;
}
if ( handle != NULL )
thumbDV_writeSerial( handle, packet, length + AMBE3000_HEADER_LEN );
int32 samples_returned = 0;
BufferDescriptor desc = _thumbDVEncodedList_UnlinkHead();
if ( desc != NULL ) {
memcpy( packet_out, desc->buf_ptr + 6, desc->sample_size * ( desc->num_samples - 6 ) );
samples_returned = desc->num_samples - 6;
//safe_free( desc );
hal_BufferRelease(&desc);
//thumbDV_dump(ANSI_BLUE "Coded Packet" ANSI_WHITE, packet_out, desc->num_samples - 6);
} else {
/* Do nothing for now */
}
return samples_returned;
}
static void _connectSerial( FT_HANDLE * ftHandle )
{
int i = 0 ;
output("ConnectSerial\n");
DWORD numDevs = 0;
FT_DEVICE_LIST_INFO_NODE *devInfo = NULL;
FT_STATUS status = FT_OK;
do {
status = FT_CreateDeviceInfoList(&numDevs);
devInfo = (FT_DEVICE_LIST_INFO_NODE *) safe_malloc(sizeof(FT_DEVICE_LIST_INFO_NODE) * numDevs);
status = FT_GetDeviceInfoList(devInfo, &numDevs);
for ( i = 0 ; i < numDevs ; i++ )
{
*ftHandle = thumbDV_openSerial(devInfo[i]);
if ( *ftHandle != NULL )
{
/* We opened a valid port and detected the ThumbDV */
break;
}
}
safe_free(devInfo);
if ( *ftHandle == NULL ) {
output( "Could not open serial. Waiting 1 second before trying again.\n" );
usleep( 1000 * 1000 );
}
} while ( *ftHandle == NULL ) ;
unsigned char reset[5] = { 0x61, 0x00, 0x01, 0x00, 0x33 };
thumbDV_writeSerial( *ftHandle, reset, 5 );
/* Block until we get data from serial port after reset */
thumbDV_processSerial( *ftHandle );
//
// unsigned char reset_softcfg[11] = {0x61, 0x00, 0x07, 0x00, 0x34, 0x05, 0x03, 0xEB, 0xFF, 0xFF, 0xFF};
// thumbDV_writeSerial(*ftHandle, reset_softcfg, 11);
// thumbDV_processSerial(*ftHandle);
unsigned char disable_parity[6] = {0x61, 0x00, 0x02, 0x00, 0x3F, 0x00};
thumbDV_writeSerial( *ftHandle, disable_parity, 6 );
thumbDV_processSerial( *ftHandle );
unsigned char get_prodID[5] = {0x61, 0x00, 0x01, 0x00, 0x30 };
unsigned char get_version[5] = {0x61, 0x00, 0x01, 0x00, 0x31};
unsigned char read_cfg[5] = {0x61, 0x00, 0x01, 0x00, 0x37};
unsigned char dstar_mode[17] = {0x61, 0x00, 0x0D, 0x00, 0x0A, 0x01, 0x30, 0x07, 0x63, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48};
thumbDV_writeSerial( *ftHandle, get_prodID, 5 );
thumbDV_writeSerial( *ftHandle, get_version, 5 );
thumbDV_writeSerial( *ftHandle, read_cfg, 5 );
thumbDV_writeSerial( *ftHandle, dstar_mode, 17 );
//// /* Init */
unsigned char pkt_init[6] = { 0x61, 0x00, 0x02, 0x00, 0x0B, 0x07 };
thumbDV_writeSerial( *ftHandle, pkt_init, 6 );
/* PKT GAIN - set to 0dB */
unsigned char pkt_gain[7] = { 0x61, 0x00, 0x03, 0x00, 0x4B, 0x00, 0x00 };
thumbDV_writeSerial( *ftHandle, pkt_gain, 7 );
/* Companding off so it uses 16bit linear */
unsigned char pkt_compand[6] = { 0x61, 0x00, 0x02, 0x00, 0x32, 0x00 };
thumbDV_writeSerial( *ftHandle, pkt_compand, 6 );
unsigned char test_coded[15] = {0x61, 0x00 , 0x0B , 0x01 , 0x01 , 0x48 , 0x5E , 0x83 , 0x12 , 0x3B , 0x98 , 0x79 , 0xDE , 0x13 , 0x90};
thumbDV_writeSerial( *ftHandle, test_coded, 15 );
unsigned char pkt_fmt[7] = {0x61, 0x00, 0x3, 0x00, 0x15, 0x00, 0x00};
thumbDV_writeSerial( *ftHandle, pkt_fmt, 7 );
}
static void * _thumbDV_readThread( void * param )
{
int ret;
DWORD rx_bytes;
DWORD tx_bytes;
DWORD event_dword;
FT_STATUS status = FT_OK;
FT_HANDLE handle = *( FT_HANDLE * )param;
EVENT_HANDLE event_handle;
prctl(PR_SET_NAME, "DV-Read");
pthread_mutex_init(&event_handle.eMutex, NULL);
pthread_cond_init(&event_handle.eCondVar, NULL);
while ( !_readThreadAbort )
{
// Setup RX or Status change event notification
status = FT_SetEventNotification(handle, FT_EVENT_RXCHAR , (PVOID)&event_handle);
struct timespec timeout;
clock_gettime(CLOCK_REALTIME, &timeout);
timeout.tv_sec += 2; // 2 second timeout
// Will block until
pthread_mutex_lock(&event_handle.eMutex);
pthread_cond_timedwait(&event_handle.eCondVar, &event_handle.eMutex, &timeout);
pthread_mutex_unlock(&event_handle.eMutex);
rx_bytes = 0;
status = FT_GetStatus(handle, &rx_bytes, &tx_bytes, &event_dword);
if ( status != FT_OK )
{
fprintf( stderr, "ThumbDV: error from status, status=%d\n", status );
/* Set invalid FD in sched_waveform so we don't call write functions */
handle = NULL;
sched_waveform_setHandle(&handle);
/* This function hangs until a new connection is made */
_connectSerial( &handle );
/* Update the sched_waveform to new valid serial */
sched_waveform_setHandle( &handle );
}
else if ( rx_bytes >= AMBE3000_HEADER_LEN )
{
ret = thumbDV_processSerial( handle );
}
}
output( ANSI_YELLOW "thumbDV_readThread has exited\n" ANSI_WHITE );
return 0;
}
void thumbDV_init( FT_HANDLE * handle ) {
pthread_rwlock_init( &_encoded_list_lock, NULL );
pthread_rwlock_init( &_decoded_list_lock, NULL );
pthread_rwlock_wrlock( &_encoded_list_lock );
_encoded_root = ( BufferDescriptor )safe_malloc( sizeof( buffer_descriptor ) );
memset( _encoded_root, 0, sizeof( buffer_descriptor ) );
_encoded_root->next = _encoded_root;
_encoded_root->prev = _encoded_root;
pthread_rwlock_unlock( &_encoded_list_lock );
pthread_rwlock_wrlock( &_decoded_list_lock );
_decoded_root = ( BufferDescriptor )safe_malloc( sizeof( buffer_descriptor ) );
memset( _decoded_root, 0, sizeof( buffer_descriptor ) );
_decoded_root->next = _decoded_root;
_decoded_root->prev = _decoded_root;
pthread_rwlock_unlock( &_decoded_list_lock );
_connectSerial( handle );
pthread_create( &_read_thread, NULL, &_thumbDV_readThread, handle );
struct sched_param fifo_param;
fifo_param.sched_priority = 30;
pthread_setschedparam( _read_thread, SCHED_FIFO, &fifo_param );
}

50
DSP_API/ThumbDV/thumbDV.h Normal file
View file

@ -0,0 +1,50 @@
///*! \file thumbdv.h
// * \brief Functions required to communicate and decode packets from ThumbDV
// *
// * \copyright Copyright 2012-2014 FlexRadio Systems. All Rights Reserved.
// * Unauthorized use, duplication or distribution of this software is
// * strictly prohibited by law.
// *
// * \date 26-MAY-2015
// * \author Ed Gonzalez
// *
// *
// */
/* *****************************************************************************
*
* Copyright (C) 2014 FlexRadio Systems.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contact Information:
* email: gpl<at>flexradiosystems.com
* Mail: FlexRadio Systems, Suite 1-150, 4616 W. Howard LN, Austin, TX 78728
*
* ************************************************************************** */
#ifndef THUMBDV_THUMBDV_H_
#define THUMBDV_THUMBDV_H_
#include "ftd2xx.h"
void thumbDV_init( FT_HANDLE * serial_fd );
FT_HANDLE thumbDV_openSerial( FT_DEVICE_LIST_INFO_NODE device );
int thumbDV_processSerial( FT_HANDLE handle );
int thumbDV_encode( FT_HANDLE handle, short * speech_in, unsigned char * packet_out, uint8 num_of_samples );
int thumbDV_decode( FT_HANDLE handle, unsigned char * packet_in, short * speech_out, uint8 bytes_in_packet );
void thumbDV_dump( char * text, unsigned char * data, unsigned int length );
void thumbDV_flushLists(void);
#endif /* THUMBDV_THUMBDV_ */

Binary file not shown.

View file

@ -0,0 +1,23 @@
[header]
Name: ThumbDV
Version: "1.1.0"
Minimum-SmartSDR-Version: 1.10.3.0
Author: FlexRadio Systems
Support-email: support@flexradio.com
Support-phone: 512-535-4713
License: GPL7.3
Executable: "thumbdv"
[setup]
waveform create name=ThumbDV mode=DSTR underlying_mode=DFM version=1.1.0
waveform set ThumbDV tx=1
waveform set ThumbDV rx_filter low_cut=-3500
waveform set ThumbDV rx_filter high_cut=3500
waveform set ThumbDV rx_filter depth=2
waveform set ThumbDV tx_filter low_cut=0
waveform set ThumbDV tx_filter high_cut=4800
waveform set ThumbDV tx_filter depth=2
waveform set ThumbDV udpport=5000
[end]

View file

@ -65,6 +65,7 @@
#include <stdio.h>
#include "circular_buffer.h"
#include "utils.h"
@ -102,8 +103,12 @@ void cbWriteFloat(Circular_Float_Buffer cb, float sample)
{
cb->elems[cb->end] = sample;
cb->end = (cb->end + 1) % cb->size;
if (cb->end == cb->start)
if (cb->end == cb->start) {
cb->start = (cb->start + 1) % cb->size; /* full, overwrite */
output(ANSI_RED "Overwrite! in Circular Float Buffer - Name %s\n"
"Size %d Start %d End %d\n "ANSI_WHITE, cb->name, cb->size, cb->start, cb->end);
}
}
@ -194,8 +199,10 @@ void cbWriteShort(Circular_Short_Buffer cb, short sample)
{
cb->elems[cb->end] = sample;
cb->end = (cb->end + 1) % cb->size;
if (cb->end == cb->start)
if (cb->end == cb->start) {
cb->start = (cb->start + 1) % cb->size; /* full, overwrite */
output(ANSI_RED "Overwrite! in Circular Short Buffer - Name %s\n" ANSI_WHITE, cb->name);
}
}

View file

@ -37,6 +37,7 @@ typedef struct {
unsigned int start; // Index of oldest element
unsigned int end; // Index at which to write new element
short *elems; // Vector of elements
char name[20];
} circular_short_buffer, *Circular_Short_Buffer;
typedef struct {
@ -44,6 +45,7 @@ typedef struct {
unsigned int start; // Index of oldest element
unsigned int end; // Index at which to write new element
float *elems; // Vector of elements
char name[20];
} circular_float_buffer, *Circular_Float_Buffer;

View file

@ -45,9 +45,10 @@
#define SUCCESS 0
#define FAIL 1
#define SMARTSDR_API_PORT "4992"
#define VITA_49_PORT 4999
#define VITA_49_PORT 5000
#define VITA_49_SOURCE_PORT VITA_49_PORT
#define VITA_49_FFT_SOURCE_PORT 30003
#define VITA_49_METER_SOURCE_PORT 30002

136
DSP_API/include/WinTypes.h Normal file
View file

@ -0,0 +1,136 @@
#ifndef __WINDOWS_TYPES__
#define __WINDOWS_TYPES__
#define WINAPI
typedef unsigned int DWORD;
typedef unsigned int ULONG;
typedef unsigned short USHORT;
typedef unsigned short SHORT;
typedef unsigned char UCHAR;
typedef unsigned short WORD;
typedef unsigned char BYTE;
typedef BYTE *LPBYTE;
typedef unsigned int BOOLU;
typedef unsigned char BOOLEAN;
typedef unsigned char CHAR;
typedef BOOLU *LPBOOL;
typedef UCHAR *PUCHAR;
typedef const char *LPCSTR;
typedef char *PCHAR;
typedef void *PVOID;
typedef void *HANDLE;
typedef unsigned int LONG;
typedef int INT;
typedef unsigned int UINT;
typedef char *LPSTR;
typedef char *LPTSTR;
typedef const char *LPCTSTR;
typedef DWORD *LPDWORD;
typedef WORD *LPWORD;
typedef ULONG *PULONG;
typedef LONG *LPLONG;
typedef PVOID LPVOID;
typedef void VOID;
typedef unsigned long long int ULONGLONG;
typedef struct _OVERLAPPED {
DWORD Internal;
DWORD InternalHigh;
DWORD Offset;
DWORD OffsetHigh;
HANDLE hEvent;
} OVERLAPPED, *LPOVERLAPPED;
typedef struct _SECURITY_ATTRIBUTES {
DWORD nLength;
LPVOID lpSecurityDescriptor;
BOOL bInheritHandle;
} SECURITY_ATTRIBUTES , *LPSECURITY_ATTRIBUTES;
#include <pthread.h>
// Substitute for HANDLE returned by Windows CreateEvent API.
// FT_SetEventNotification expects parameter 3 to be the address
// of one of these structures.
typedef struct _EVENT_HANDLE
{
pthread_cond_t eCondVar;
pthread_mutex_t eMutex;
int iVar;
} EVENT_HANDLE;
typedef struct timeval SYSTEMTIME;
typedef struct timeval FILETIME;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
//
// Modem Status Flags
//
#define MS_CTS_ON ((DWORD)0x0010)
#define MS_DSR_ON ((DWORD)0x0020)
#define MS_RING_ON ((DWORD)0x0040)
#define MS_RLSD_ON ((DWORD)0x0080)
//
// Error Flags
//
#define CE_RXOVER 0x0001 // Receive Queue overflow
#define CE_OVERRUN 0x0002 // Receive Overrun Error
#define CE_RXPARITY 0x0004 // Receive Parity Error
#define CE_FRAME 0x0008 // Receive Framing error
#define CE_BREAK 0x0010 // Break Detected
#define CE_TXFULL 0x0100 // TX Queue is full
#define CE_PTO 0x0200 // LPTx Timeout
#define CE_IOE 0x0400 // LPTx I/O Error
#define CE_DNS 0x0800 // LPTx Device not selected
#define CE_OOP 0x1000 // LPTx Out-Of-Paper
#define CE_MODE 0x8000 // Requested mode unsupported
//
// Events
//
#define EV_RXCHAR 0x0001 // Any Character received
#define EV_RXFLAG 0x0002 // Received certain character
#define EV_TXEMPTY 0x0004 // Transmit Queue Empty
#define EV_CTS 0x0008 // CTS changed state
#define EV_DSR 0x0010 // DSR changed state
#define EV_RLSD 0x0020 // RLSD changed state
#define EV_BREAK 0x0040 // BREAK received
#define EV_ERR 0x0080 // Line status error occurred
#define EV_RING 0x0100 // Ring signal detected
#define EV_PERR 0x0200 // Printer error occured
#define EV_RX80FULL 0x0400 // Receive buffer is 80 percent full
#define EV_EVENT1 0x0800 // Provider specific event 1
#define EV_EVENT2 0x1000 // Provider specific event 2
//
// Escape Functions
//
#define SETXOFF 1 // Simulate XOFF received
#define SETXON 2 // Simulate XON received
#define SETRTS 3 // Set RTS high
#define CLRRTS 4 // Set RTS low
#define SETDTR 5 // Set DTR high
#define CLRDTR 6 // Set DTR low
#define RESETDEV 7 // Reset device if possible
#define SETBREAK 8 // Set the device break line.
#define CLRBREAK 9 // Clear the device break line.
//
// PURGE function flags.
//
#define PURGE_TXABORT 0x0001 // Kill the pending/current writes to the comm port.
#define PURGE_RXABORT 0x0002 // Kill the pending/current reads to the comm port.
#define PURGE_TXCLEAR 0x0004 // Kill the transmit queue if there.
#define PURGE_RXCLEAR 0x0008 // Kill the typeahead buffer if there.
#ifndef INVALID_HANDLE_VALUE
#define INVALID_HANDLE_VALUE 0xFFFFFFFF
#endif
#endif /* __WINDOWS_TYPES__ */

1427
DSP_API/include/ftd2xx.h Normal file

File diff suppressed because it is too large Load diff

BIN
DSP_API/lib/libftd2xx.a Normal file

Binary file not shown.

View file

@ -59,8 +59,8 @@
#include "common.h"
const char* APP_NAME = "FreeDV"; // Name of Application
//const char* CFG_FILE = "FreeDV.cfg"; // Name of associated configuration file
const char* APP_NAME = "ThumbDV"; // Name of Application - must match .cfg filename
char * cfg_path = NULL;
static sem_t shutdown_sem;
@ -100,7 +100,7 @@ void segfault_sigaction(int signal, siginfo_t *si, void *arg)
// Get's line number of fault
char syscom[256];
sprintf(syscom,"eu-addr2line -e %s %p","./freedv" , array[i]);
sprintf(syscom,"eu-addr2line -e %s %p","./thumbdv" , array[i]);
system(syscom);
}

View file

@ -1,8 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeDV", "CODEC2 GUI\FreeDV.csproj", "{19634B34-7569-4D1D-8182-B10AC27E13FF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlexLib", "..\..\..\smartsdr-win\FlexLib\FlexLib.csproj", "{7927817C-D5EF-4A9E-B38E-29668F308343}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UiWpfFramework", "..\..\..\smartsdr-win\UiWpfFramework\UiWpfFramework.csproj", "{9C0AD871-92FD-461B-84FF-3738D701814F}"
@ -12,6 +10,11 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vita", "..\..\..\smartsdr-win\Vita\Vita.csproj", "{6ED364FB-7444-44DA-9196-1D8679425B3E}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "CODEC2_GUI_INSTALLER", "CODEC2_GUI_INSTALLER\CODEC2_GUI_INSTALLER.vdproj", "{AABE6A3C-F038-4448-981F-F68A6D5069C3}"
ProjectSection(ProjectDependencies) = postProject
{19634B34-7569-4D1D-8182-B10AC27E13FF} = {19634B34-7569-4D1D-8182-B10AC27E13FF}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CODEC2 GUI", "CODEC2 GUI\CODEC2 GUI.csproj", "{19634B34-7569-4D1D-8182-B10AC27E13FF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -21,14 +24,6 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Debug|Any CPU.ActiveCfg = Debug|x86
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Debug|Any CPU.Build.0 = Debug|x86
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Debug|x86.ActiveCfg = Debug|x86
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Debug|x86.Build.0 = Debug|x86
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Release|Any CPU.ActiveCfg = Release|x86
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Release|Any CPU.Build.0 = Release|x86
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Release|x86.ActiveCfg = Release|x86
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Release|x86.Build.0 = Release|x86
{7927817C-D5EF-4A9E-B38E-29668F308343}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7927817C-D5EF-4A9E-B38E-29668F308343}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7927817C-D5EF-4A9E-B38E-29668F308343}.Debug|x86.ActiveCfg = Debug|x86
@ -65,6 +60,14 @@ Global
{AABE6A3C-F038-4448-981F-F68A6D5069C3}.Debug|x86.ActiveCfg = Debug
{AABE6A3C-F038-4448-981F-F68A6D5069C3}.Release|Any CPU.ActiveCfg = Release
{AABE6A3C-F038-4448-981F-F68A6D5069C3}.Release|x86.ActiveCfg = Release
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Debug|Any CPU.ActiveCfg = Debug|x86
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Debug|Any CPU.Build.0 = Debug|x86
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Debug|x86.ActiveCfg = Debug|x86
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Debug|x86.Build.0 = Debug|x86
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Release|Any CPU.ActiveCfg = Release|x86
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Release|Any CPU.Build.0 = Release|x86
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Release|x86.ActiveCfg = Release|x86
{19634B34-7569-4D1D-8182-B10AC27E13FF}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="CODEC2_GUI.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="CODEC2_GUI.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<userSettings>
<CODEC2_GUI.Properties.Settings>
<setting name="URList" serializeAs="String">
<value />
</setting>
<setting name="MainPosition" serializeAs="String">
<value />
</setting>
<setting name="RPT1List" serializeAs="String">
<value />
</setting>
<setting name="RPT2List" serializeAs="String">
<value />
</setting>
<setting name="MYCallSign" serializeAs="String">
<value />
</setting>
<setting name="MESSAGEList" serializeAs="String">
<value />
</setting>
</CODEC2_GUI.Properties.Settings>
</userSettings>
<applicationSettings>
<CODEC2_GUI.Properties.Settings>
<setting name="LogEntryMax" serializeAs="String">
<value>1000</value>
</setting>
</CODEC2_GUI.Properties.Settings>
</applicationSettings>
</configuration>

Some files were not shown because too many files have changed in this diff Show more