Kaynağa Gözat

Makefile.am : Added binural encoder code file sa/cmSaProc.h/c and sa/ss0

and sa/ss1.
master
Kevin Larke 9 yıl önce
ebeveyn
işleme
58a861d6e5
3 değiştirilmiş dosya ile 229 ekleme ve 0 silme
  1. 7
    0
      Makefile.am
  2. 183
    0
      sa/cmSaProc.c
  3. 39
    0
      sa/cmSaProc.h

+ 7
- 0
Makefile.am Dosyayı Görüntüle

@@ -80,6 +80,13 @@ cmSRC += src/libcm/app/cmSdb.c  src/libcm/app/cmTakeSeqBldr.c
80 80
 cmHDR += src/libcm/app/cmPickup.h src/libcm/cmRbm.h src/libcm/cmTaskMgr.h  src/libcm/cmSyncRecd.h
81 81
 cmSRC += src/libcm/app/cmPickup.c src/libcm/cmRbm.c src/libcm/cmTaskMgr.c  src/libcm/cmSyncRecd.c
82 82
 
83
+cmHDR += src/libcm/sa/cmSaProc.h  
84
+cmSRC += src/libcm/sa/cmSaProc.c
85
+
86
+if INC_SONICART
87
+  cmSRC += src/libcm/sa/ss0/surroundstereo.c src/libcm/sa/ss1/surroundstereo_1.c
88
+endif
89
+
83 90
 if OS_LINUX
84 91
  cmSRC += src/libcm/linux/cmFileSysLinux.c  src/libcm/linux/cmAudioPortAlsa.c src/libcm/linux/cmMidiAlsa.c
85 92
  cmHDR += src/libcm/linux/cmFileSysLinux.h  src/libcm/linux/cmAudioPortAlsa.h

+ 183
- 0
sa/cmSaProc.c Dosyayı Görüntüle

@@ -0,0 +1,183 @@
1
+#include "cmPrefix.h"
2
+#include "cmGlobal.h"
3
+#include "cmRpt.h"
4
+#include "cmErr.h"
5
+#include "cmCtx.h"
6
+#include "cmMem.h"
7
+#include "cmMallocDebug.h"
8
+#include "cmLinkedHeap.h"
9
+#include "cmFloatTypes.h"
10
+#include "cmComplexTypes.h"
11
+#include "cmFileSys.h"
12
+#include "cmJson.h"
13
+#include "cmSymTbl.h"
14
+#include "cmAudioFile.h"
15
+#include "cmText.h"
16
+#include "cmProcObj.h"
17
+#include "cmProcTemplate.h"
18
+#include "cmMath.h"
19
+#include "cmProc.h"
20
+#include "cmSaProc.h"
21
+#include "cmVectOps.h"
22
+
23
+#define SS_IMPL
24
+#ifdef SS_IMPL
25
+#include "ss0/surroundstereo.h"
26
+#include "ss1/surroundstereo_1.h"
27
+#else
28
+void binauralEncoderProcessInit(long pNumInputs, long frames, int hrtfSet) {}
29
+void binauralEncoderProcessSetPosition(int clientNum, float cazimuth, float celevation) {}
30
+void binauralEncoderProcess(float **inputs, float **outputs, long numInputs, long sampleFrames){}
31
+
32
+typedef struct
33
+{
34
+  void* h;
35
+} binauralEncoderH_t;
36
+
37
+binauralEncoderH_t binauralEncoderNullH = cmSTATIC_NULL_HANDLE;
38
+
39
+void  binauralEncProcessInit(binauralEncoderH_t* hp, long pNumInputs, long frames, int hrtfSet)
40
+{ if(hp!=NULL) hp->h=NULL; }
41
+
42
+void  binauralEncProcessFree( binauralEncoderH_t* hp ){}
43
+void	binauralEncProcessSetPosition(binauralEncoderH_t h, int clientNum, float cazimuth, float celevation){}
44
+void	binauralEncProcess(binauralEncoderH_t h, float **inputs, float **outputs, long numInputs, long sampleFrames){}
45
+#endif
46
+
47
+cmBinEnc* cmBinEncAlloc( cmCtx* c, cmBinEnc* p, double srate, unsigned procSmpCnt )
48
+{
49
+  cmBinEnc* op = cmObjAlloc(cmBinEnc,c,p);
50
+  
51
+  if( srate > 0 )  
52
+    if( cmBinEncInit(op,srate,procSmpCnt) != cmOkRC )
53
+      cmBinEncFree(&op);
54
+
55
+  return op;
56
+
57
+}
58
+
59
+cmRC_t    cmBinEncFree( cmBinEnc** pp )
60
+{
61
+  cmRC_t rc = cmOkRC;
62
+  if( pp==NULL || *pp==NULL )
63
+    return rc;
64
+
65
+  cmBinEnc* p = *pp;
66
+  if((rc = cmBinEncFinal(p)) != cmOkRC )
67
+    return rc;
68
+
69
+  cmObjFree(pp);
70
+  return rc;
71
+
72
+}
73
+
74
+cmRC_t    cmBinEncInit( cmBinEnc* p, double srate, unsigned procSmpCnt )
75
+{
76
+  cmRC_t rc;
77
+  binauralEncoderH_t h = binauralEncoderNullH;
78
+
79
+  if((rc = cmBinEncFinal(p)) != cmOkRC )
80
+    return rc;
81
+
82
+  p->srate      = srate;
83
+  p->procSmpCnt = procSmpCnt;
84
+  p->freeFl     = false;
85
+  
86
+  long numInputs = 1;
87
+  int  hrtfSet   = 1;
88
+
89
+  switch(p->mode)
90
+  {
91
+    case 0:
92
+      binauralEncoderProcessInit(numInputs, procSmpCnt, hrtfSet);
93
+      break;
94
+
95
+    case 1:
96
+      binauralEncProcessInit(&h,numInputs, procSmpCnt, hrtfSet);
97
+      p->freeFl = true;
98
+      p->h      = h.h;
99
+      break;
100
+  }
101
+
102
+  return rc;
103
+}
104
+
105
+cmRC_t    cmBinEncFinal(cmBinEnc* p )
106
+{ 
107
+  if( p->h != NULL && p->freeFl )
108
+  {
109
+    binauralEncoderH_t h;
110
+    h.h = p->h;
111
+    binauralEncProcessFree(&h);
112
+    p->freeFl = false;
113
+  }
114
+  return cmOkRC; 
115
+}
116
+
117
+cmRC_t    cmBinEncSetMode(cmBinEnc* p, unsigned mode )
118
+{
119
+  if( mode != p->mode )
120
+  {
121
+    p->mode = mode;
122
+    return cmBinEncInit(p,p->srate,p->procSmpCnt);
123
+  }
124
+
125
+  return cmOkRC;
126
+}
127
+
128
+cmRC_t    cmBinEncSetLoc( cmBinEnc* p, float azimDegrees, float elevDegrees, float dist )
129
+{
130
+  int clientNum = 0;
131
+
132
+  if( elevDegrees > 90.0f )
133
+    elevDegrees = 90.0f;
134
+
135
+  if( elevDegrees < -40.0f )
136
+    elevDegrees = -40.0f;
137
+
138
+  float elev = (elevDegrees + 40.0f) / (90.0f + 40.0f);
139
+
140
+  //printf("az:%f el:%f dist:%f\n",azimDegrees,elev,dist);
141
+
142
+  switch( p->mode )
143
+  {
144
+    case 0:
145
+      binauralEncoderProcessSetPosition(clientNum, azimDegrees/360.0f, elev);
146
+      break;
147
+
148
+    case 1:
149
+      {      
150
+        binauralEncoderH_t h;
151
+        h.h = p->h;
152
+        binauralEncProcessSetPosition(h,clientNum, azimDegrees/360.0f, elev);
153
+      }
154
+      break;
155
+  }
156
+
157
+  return cmOkRC;
158
+}
159
+
160
+cmRC_t    cmBinEncExec( cmBinEnc* p, const cmSample_t* x, cmSample_t* y0, cmSample_t* y1, unsigned xyN )
161
+{
162
+  float *inputs[]  = {(float*)x};
163
+  float *outputs[] = {y0,y1};
164
+  int numInputs    = sizeof(inputs)/sizeof(inputs[0]);
165
+
166
+
167
+  switch( p->mode )
168
+  {
169
+    case 0:
170
+      binauralEncoderProcess(inputs,outputs,numInputs,xyN);
171
+      break;
172
+
173
+    case 1:
174
+      {
175
+        binauralEncoderH_t h;
176
+        h.h = p->h;
177
+        binauralEncProcess(h,inputs,outputs,numInputs,xyN);
178
+      }
179
+      break;
180
+  }
181
+
182
+  return cmOkRC;
183
+}

+ 39
- 0
sa/cmSaProc.h Dosyayı Görüntüle

@@ -0,0 +1,39 @@
1
+
2
+#ifndef cmSaProc_h
3
+#define cmSaProc_h
4
+
5
+#ifdef __cplusplus
6
+extern "C" {
7
+#endif
8
+
9
+  
10
+
11
+  typedef struct
12
+  {
13
+    cmObj    obj;
14
+    void*    h;
15
+    unsigned mode;
16
+    double   srate;
17
+    unsigned procSmpCnt;
18
+    bool     freeFl;
19
+
20
+    double  azimDegrees;
21
+    double  elevDegrees;
22
+    double  dist;
23
+    
24
+  } cmBinEnc;
25
+
26
+  cmBinEnc* cmBinEncAlloc( cmCtx* c, cmBinEnc* p, double srate, unsigned procSmpCnt );
27
+  cmRC_t    cmBinEncFree(   cmBinEnc** pp );
28
+  cmRC_t    cmBinEncInit(   cmBinEnc* p, double srate, unsigned procSmpCnt );
29
+  cmRC_t    cmBinEncFinal(  cmBinEnc* p );
30
+  cmRC_t    cmBinEncSetMode(cmBinEnc* p, unsigned mode );
31
+  cmRC_t    cmBinEncSetLoc( cmBinEnc* p, float azimDegrees, float elevDegrees, float dist );
32
+  cmRC_t    cmBinEncExec(   cmBinEnc* p, const cmSample_t* x, cmSample_t* y0, cmSample_t* y1, unsigned xyN );
33
+
34
+
35
+#ifdef __cplusplus
36
+}
37
+#endif
38
+
39
+#endif

Loading…
İptal
Kaydet