WaveSwissKnife 0.2.0.20120302

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/AUTHORS +4 -0
  2. data/ChangeLog +31 -0
  3. data/Credits +3 -0
  4. data/LICENSE +31 -0
  5. data/README +15 -0
  6. data/ReleaseInfo +8 -0
  7. data/bin/WSK.rb +14 -0
  8. data/ext/WSK/AnalyzeUtils/AnalyzeUtils.c +272 -0
  9. data/ext/WSK/AnalyzeUtils/extconf.rb +7 -0
  10. data/ext/WSK/ArithmUtils/ArithmUtils.c +862 -0
  11. data/ext/WSK/ArithmUtils/extconf.rb +15 -0
  12. data/ext/WSK/CommonBuild.rb +29 -0
  13. data/ext/WSK/FFTUtils/FFTUtils.c +662 -0
  14. data/ext/WSK/FFTUtils/extconf.rb +15 -0
  15. data/ext/WSK/FunctionUtils/FunctionUtils.c +182 -0
  16. data/ext/WSK/FunctionUtils/extconf.rb +15 -0
  17. data/ext/WSK/SilentUtils/SilentUtils.c +431 -0
  18. data/ext/WSK/SilentUtils/extconf.rb +7 -0
  19. data/ext/WSK/VolumeUtils/VolumeUtils.c +494 -0
  20. data/ext/WSK/VolumeUtils/extconf.rb +15 -0
  21. data/external/CommonUtils/build.rb +28 -0
  22. data/external/CommonUtils/include/CommonUtils.h +177 -0
  23. data/external/CommonUtils/src/CommonUtils.c +639 -0
  24. data/lib/WSK/Actions/Analyze.rb +176 -0
  25. data/lib/WSK/Actions/ApplyMap.desc.rb +15 -0
  26. data/lib/WSK/Actions/ApplyMap.rb +57 -0
  27. data/lib/WSK/Actions/ApplyVolumeFct.desc.rb +30 -0
  28. data/lib/WSK/Actions/ApplyVolumeFct.rb +72 -0
  29. data/lib/WSK/Actions/Compare.desc.rb +25 -0
  30. data/lib/WSK/Actions/Compare.rb +238 -0
  31. data/lib/WSK/Actions/ConstantCompare.desc.rb +20 -0
  32. data/lib/WSK/Actions/ConstantCompare.rb +61 -0
  33. data/lib/WSK/Actions/Cut.desc.rb +20 -0
  34. data/lib/WSK/Actions/Cut.rb +60 -0
  35. data/lib/WSK/Actions/CutFirstSignal.desc.rb +25 -0
  36. data/lib/WSK/Actions/CutFirstSignal.rb +72 -0
  37. data/lib/WSK/Actions/DCShifter.desc.rb +15 -0
  38. data/lib/WSK/Actions/DCShifter.rb +67 -0
  39. data/lib/WSK/Actions/DrawFct.desc.rb +20 -0
  40. data/lib/WSK/Actions/DrawFct.rb +59 -0
  41. data/lib/WSK/Actions/FFT.rb +104 -0
  42. data/lib/WSK/Actions/GenAllValues.rb +67 -0
  43. data/lib/WSK/Actions/GenConstant.desc.rb +20 -0
  44. data/lib/WSK/Actions/GenConstant.rb +56 -0
  45. data/lib/WSK/Actions/GenSawtooth.rb +57 -0
  46. data/lib/WSK/Actions/GenSine.desc.rb +20 -0
  47. data/lib/WSK/Actions/GenSine.rb +73 -0
  48. data/lib/WSK/Actions/Identity.rb +43 -0
  49. data/lib/WSK/Actions/Mix.desc.rb +15 -0
  50. data/lib/WSK/Actions/Mix.rb +149 -0
  51. data/lib/WSK/Actions/Multiply.desc.rb +15 -0
  52. data/lib/WSK/Actions/Multiply.rb +73 -0
  53. data/lib/WSK/Actions/NoiseGate.desc.rb +35 -0
  54. data/lib/WSK/Actions/NoiseGate.rb +129 -0
  55. data/lib/WSK/Actions/SilenceInserter.desc.rb +20 -0
  56. data/lib/WSK/Actions/SilenceInserter.rb +87 -0
  57. data/lib/WSK/Actions/SilenceRemover.desc.rb +30 -0
  58. data/lib/WSK/Actions/SilenceRemover.rb +74 -0
  59. data/lib/WSK/Actions/VolumeProfile.desc.rb +35 -0
  60. data/lib/WSK/Actions/VolumeProfile.rb +63 -0
  61. data/lib/WSK/Common.rb +292 -0
  62. data/lib/WSK/FFT.rb +527 -0
  63. data/lib/WSK/Functions.rb +770 -0
  64. data/lib/WSK/Launcher.rb +216 -0
  65. data/lib/WSK/Maps.rb +29 -0
  66. data/lib/WSK/Model/CachedBufferReader.rb +151 -0
  67. data/lib/WSK/Model/Header.rb +133 -0
  68. data/lib/WSK/Model/InputData.rb +193 -0
  69. data/lib/WSK/Model/RawReader.rb +78 -0
  70. data/lib/WSK/Model/WaveReader.rb +91 -0
  71. data/lib/WSK/OutputInterfaces/DirectStream.rb +146 -0
  72. data/lib/WSK/RIFFReader.rb +60 -0
  73. metadata +155 -0
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
+ * Licensed under the terms specified in LICENSE file. No warranty is provided.
4
+ **/
5
+
6
+ #ifndef __COMMONUTILS_COMMONUTILS_H__
7
+ #define __COMMONUTILS_COMMONUTILS_H__
8
+
9
+ #include "ruby.h"
10
+
11
+ // Struct used to interpret raw buffers data of 24 bits
12
+ typedef struct {
13
+ signed int value:24;
14
+ } t24bits;
15
+
16
+ // Type used to identify each sample value
17
+ typedef int tSampleValue;
18
+
19
+ // Type used to identify each sample index
20
+ typedef long long int tSampleIndex;
21
+
22
+ // Pointer to a function that can be called when parsing a raw buffer
23
+ typedef int(*tPtrFctProcess)(const tSampleValue, const tSampleIndex, const int, void*);
24
+ // Pointer to a function that can be called when parsing a raw buffer and writing another raw buffer
25
+ typedef int(*tPtrFctProcessOutput)(const tSampleValue, tSampleValue*, const tSampleIndex, const int, void*);
26
+ // Pointer to a function that can be called when writing a raw buffer
27
+ typedef int(*tPtrFctProcessOutputOnly)(tSampleValue*, const tSampleIndex, const int, void*);
28
+
29
+ // Struct containing data for a threshold information
30
+ typedef struct {
31
+ tSampleValue min;
32
+ tSampleValue max;
33
+ } tThresholdInfo;
34
+
35
+ // Function types, as defined in Functions.rb
36
+ #define FCTTYPE_PIECEWISE_LINEAR 0
37
+
38
+ // Function pointer for free
39
+ typedef void(*tPtrFctFree)(void*);
40
+
41
+ // Struct used to store piecewise linear function data
42
+ typedef struct {
43
+ int nbrPoints;
44
+ // The array of points coordinates, sorted by X value
45
+ tSampleIndex* pointsX;
46
+ long double* pointsY;
47
+ } tFunction_PiecewiseLinear;
48
+
49
+ // Struct used to store a function
50
+ typedef struct {
51
+ // The function type
52
+ int fctType;
53
+ // The pointer to the free method (it will be called by the GC)
54
+ tPtrFctFree freeFct;
55
+ // The function object (should be a tFunction_Xxxx* type)
56
+ void* fctData;
57
+ } tFunction;
58
+
59
+ /**
60
+ * Invoke each_raw_buffer on an input data.
61
+ * This is meant to be used with rb_iterate.
62
+ *
63
+ * Parameters::
64
+ * * *iValArgs* (<em>list<Object></em>): List of arguments:
65
+ * ** *iValInputData* (<em>WSK::Model::InputData</em>): The input data
66
+ * ** *iValIdxBeginSample* (_Integer_): Index of the first sample to search from
67
+ */
68
+ VALUE commonutils_callEachRawBuffer(
69
+ VALUE iValArgs);
70
+
71
+ /**
72
+ * Invoke each_reverse_raw_buffer on an input data.
73
+ * This is meant to be used with rb_iterate.
74
+ *
75
+ * Parameters::
76
+ * * *iValArgs* (<em>list<Object></em>): List of arguments:
77
+ * ** *iValInputData* (<em>WSK::Model::InputData</em>): The input data
78
+ * ** *iValIdxBeginSample* (_Integer_): Index of the first sample to search from
79
+ */
80
+ VALUE commonutils_callEachReverseRawBuffer(
81
+ VALUE iValArgs);
82
+
83
+ /**
84
+ * Iterate through a raw buffer.
85
+ *
86
+ * Parameters::
87
+ * * *iPtrRawBuffer* (<em>const char*</em>): The raw buffer
88
+ * * *iNbrBitsPerSample* (<em>const int</em>): The number of bits per sample
89
+ * * *iNbrChannels* (<em>const int</em>): The number of channels
90
+ * * *iNbrSamples* (<em>const tSampleIndex</em>): The number of samples
91
+ * * *iIdxOffsetSample* (<em>const tSampleIndex</em>): The base offset of samples to be counted and given to the processing method
92
+ * * *iPtrProcessMethod* (<em>const tPtrFctProcess</em>): Pointer to the method to call for processing
93
+ * * *iPtrArgs* (<em>void*</em>): Pointer to a user specific struct that will be given to the processing function
94
+ */
95
+ void commonutils_iterateThroughRawBuffer(
96
+ const char* iPtrRawBuffer,
97
+ const int iNbrBitsPerSample,
98
+ const int iNbrChannels,
99
+ const tSampleIndex iNbrSamples,
100
+ const tSampleIndex iIdxOffsetSample,
101
+ const tPtrFctProcess iPtrProcessMethod,
102
+ void* iPtrArgs);
103
+
104
+ /**
105
+ * Iterate through a raw buffer, and writes another raw buffer.
106
+ *
107
+ * Parameters::
108
+ * * *iSelf* (_Object_): Object used to call log methods
109
+ * * *iPtrRawBuffer* (<em>const char*</em>): The raw buffer
110
+ * * *oPtrRawBufferOut* (<em>char*</em>): The raw buffer to write
111
+ * * *iNbrBitsPerSample* (<em>const int</em>): The number of bits per sample
112
+ * * *iNbrChannels* (<em>const int</em>): The number of channels
113
+ * * *iNbrSamples* (<em>const tSampleIndex</em>): The number of samples
114
+ * * *iIdxOffsetSample* (<em>const tSampleIndex</em>): The base offset of samples to be counted and given to the processing method
115
+ * * *iNeedCheck* (<em>const int</em>): Do we need checking output value ranges ? 0 = no, 1 = yes
116
+ * * *iPtrProcessMethod* (<em>const tPtrFctProcessOutput</em>): Pointer to the method to call for processing
117
+ * * *iPtrArgs* (<em>void*</em>): Pointer to a user specific struct that will be given to the processing function
118
+ */
119
+ void commonutils_iterateThroughRawBufferOutput(
120
+ VALUE iSelf,
121
+ const char* iPtrRawBuffer,
122
+ char* oPtrRawBufferOut,
123
+ const int iNbrBitsPerSample,
124
+ const int iNbrChannels,
125
+ const tSampleIndex iNbrSamples,
126
+ const tSampleIndex iIdxOffsetSample,
127
+ const int iNeedCheck,
128
+ const tPtrFctProcessOutput iPtrProcessMethod,
129
+ void* iPtrArgs);
130
+
131
+ /**
132
+ * Iterate through an output raw buffer only, without input raw buffer.
133
+ *
134
+ * Parameters::
135
+ * * *iSelf* (_Object_): Object used to call log methods
136
+ * * *oPtrRawBufferOut* (<em>char*</em>): The raw buffer to write
137
+ * * *iNbrBitsPerSample* (<em>const int</em>): The number of bits per sample
138
+ * * *iNbrChannels* (<em>const int</em>): The number of channels
139
+ * * *iNbrSamples* (<em>const tSampleIndex</em>): The number of samples
140
+ * * *iIdxOffsetSample* (<em>const tSampleIndex</em>): The base offset of samples to be counted and given to the processing method
141
+ * * *iNeedCheck* (<em>const int</em>): Do we need checking output value ranges ? 0 = no, 1 = yes
142
+ * * *iPtrProcessMethod* (<em>const tPtrFctProcessOutputOnly</em>): Pointer to the method to call for processing
143
+ * * *iPtrArgs* (<em>void*</em>): Pointer to a user specific struct that will be given to the processing function
144
+ */
145
+ void commonutils_iterateThroughRawBufferOutputOnly(
146
+ VALUE iSelf,
147
+ char* oPtrRawBufferOut,
148
+ const int iNbrBitsPerSample,
149
+ const int iNbrChannels,
150
+ const tSampleIndex iNbrSamples,
151
+ const tSampleIndex iIdxOffsetSample,
152
+ const int iNeedCheck,
153
+ const tPtrFctProcessOutputOnly iPtrProcessMethod,
154
+ void* iPtrArgs);
155
+
156
+ /**
157
+ * Iterate through a raw buffer in reverse mode.
158
+ *
159
+ * Parameters::
160
+ * * *iPtrRawBuffer* (<em>const char*</em>): The raw buffer
161
+ * * *iNbrBitsPerSample* (<em>const int</em>): The number of bits per sample
162
+ * * *iNbrChannels* (<em>const int</em>): The number of channels
163
+ * * *iNbrSamples* (<em>const tSampleIndex</em>): The number of samples
164
+ * * *iIdxOffsetSample* (<em>const tSampleIndex</em>): The base offset of samples to be counted and given to the processing method
165
+ * * *iPtrProcessMethod* (<em>const tPtrFctProcess</em>): Pointer to the method to call for processing
166
+ * * *iPtrArgs* (<em>void*</em>): Pointer to a user specific struct that will be given to the processing function
167
+ */
168
+ void commonutils_iterateReverseThroughRawBuffer(
169
+ const char* iPtrRawBuffer,
170
+ const int iNbrBitsPerSample,
171
+ const int iNbrChannels,
172
+ const tSampleIndex iNbrSamples,
173
+ const tSampleIndex iIdxOffsetSample,
174
+ const tPtrFctProcess iPtrProcessMethod,
175
+ void* iPtrArgs);
176
+
177
+ #endif