The client for Voice over IRC. Can't let those newfangled social networks win, eh?
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

codec2.nim 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. {.deadCodeElim: on.}
  2. when defined(windows):
  3. const
  4. codec2dll* = "codec2.dll"
  5. elif defined(macosx):
  6. const
  7. codec2dll* = "libcodec2.dylib"
  8. else:
  9. const
  10. codec2dll* = "libcodec2.so"
  11. ## ---------------------------------------------------------------------------*\
  12. ##
  13. ## FILE........: codec2.h
  14. ## AUTHOR......: David Rowe
  15. ## DATE CREATED: 21 August 2010
  16. ##
  17. ## Codec 2 fully quantised encoder and decoder functions. If you want use
  18. ## Codec 2, these are the functions you need to call.
  19. ##
  20. ## \*---------------------------------------------------------------------------
  21. ##
  22. ## Copyright (C) 2010 David Rowe
  23. ##
  24. ## All rights reserved.
  25. ##
  26. ## This program is free software; you can redistribute it and/or modify
  27. ## it under the terms of the GNU Lesser General Public License version 2.1, as
  28. ## published by the Free Software Foundation. This program is
  29. ## distributed in the hope that it will be useful, but WITHOUT ANY
  30. ## WARRANTY; without even the implied warranty of MERCHANTABILITY or
  31. ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  32. ## License for more details.
  33. ##
  34. ## You should have received a copy of the GNU Lesser General Public License
  35. ## along with this program; if not, see <http://www.gnu.org/licenses/>.
  36. ##
  37. const
  38. CODEC2_VERSION_MAJOR* = 0
  39. CODEC2_VERSION_MINOR* = 8
  40. CODEC2_VERSION_PATCH* = 1
  41. CODEC2_VERSION* = "0.8.1"
  42. const
  43. CODEC2_MODE_3200* = 0
  44. CODEC2_MODE_2400* = 1
  45. CODEC2_MODE_1600* = 2
  46. CODEC2_MODE_1400* = 3
  47. CODEC2_MODE_1300* = 4
  48. CODEC2_MODE_1200* = 5
  49. CODEC2_MODE_700* = 6
  50. CODEC2_MODE_700B* = 7
  51. CODEC2_MODE_700C* = 8
  52. CODEC2_MODE_WB* = 9
  53. type
  54. CODEC2* {.bycopy.} = object
  55. proc codec2_create*(mode: cint): ptr CODEC2 {.cdecl, importc: "codec2_create",
  56. dynlib: codec2dll.}
  57. proc codec2_destroy*(codec2_state: ptr CODEC2) {.cdecl, importc: "codec2_destroy",
  58. dynlib: codec2dll.}
  59. proc codec2_encode*(codec2_state: ptr CODEC2; bits: ptr cuchar; speech_in: ptr cshort) {.
  60. cdecl, importc: "codec2_encode", dynlib: codec2dll.}
  61. proc codec2_decode*(codec2_state: ptr CODEC2; speech_out: ptr cshort; bits: ptr cuchar) {.
  62. cdecl, importc: "codec2_decode", dynlib: codec2dll.}
  63. proc codec2_decode_ber*(codec2_state: ptr CODEC2; speech_out: ptr cshort;
  64. bits: ptr cuchar; ber_est: cfloat) {.cdecl,
  65. importc: "codec2_decode_ber", dynlib: codec2dll.}
  66. proc codec2_samples_per_frame*(codec2_state: ptr CODEC2): cint {.cdecl,
  67. importc: "codec2_samples_per_frame", dynlib: codec2dll.}
  68. proc codec2_bits_per_frame*(codec2_state: ptr CODEC2): cint {.cdecl,
  69. importc: "codec2_bits_per_frame", dynlib: codec2dll.}
  70. proc codec2_set_lpc_post_filter*(codec2_state: ptr CODEC2; enable: cint;
  71. bass_boost: cint; beta: cfloat; gamma: cfloat) {.
  72. cdecl, importc: "codec2_set_lpc_post_filter", dynlib: codec2dll.}
  73. proc codec2_get_spare_bit_index*(codec2_state: ptr CODEC2): cint {.cdecl,
  74. importc: "codec2_get_spare_bit_index", dynlib: codec2dll.}
  75. proc codec2_rebuild_spare_bit*(codec2_state: ptr CODEC2; unpacked_bits: ptr cint): cint {.
  76. cdecl, importc: "codec2_rebuild_spare_bit", dynlib: codec2dll.}
  77. proc codec2_set_natural_or_gray*(codec2_state: ptr CODEC2; gray: cint) {.cdecl,
  78. importc: "codec2_set_natural_or_gray", dynlib: codec2dll.}
  79. proc codec2_set_softdec*(c2: ptr CODEC2; softdec: ptr cfloat) {.cdecl,
  80. importc: "codec2_set_softdec", dynlib: codec2dll.}
  81. proc codec2_get_energy*(codec2_state: ptr CODEC2; bits: ptr cuchar): cfloat {.cdecl,
  82. importc: "codec2_get_energy", dynlib: codec2dll.}