pthread
)
-add_executable(core
+add_executable(odascore
demo/main.c
demo/configs.c
demo/objects.c
demo/profiler.c
demo/threads.c
)
-target_link_libraries(core
+target_link_libraries(odascore
odas
)
-add_executable(server
- demo/server.c
-)
+#add_executable(server
+# demo/server.c
+#)
-add_executable(debug
- demo/debug.c
-)
-target_link_libraries(debug
- odas
-)
+#add_executable(debug
+# demo/debug.c
+#)
+#target_link_libraries(debug
+# odas
+#)
install(TARGETS odas DESTINATION lib)
--- /dev/null
+# Configuration file for ReSpeaker circular sound card
+
+version = "2.0";
+author = "François Grondin";
+date = "21/09/2017"
+
+# Raw
+
+raw:
+{
+
+ fS = 16000;
+ hopSize = 128;
+ nChannels = 8;
+
+}
+
+# Mapping
+
+mapping:
+{
+
+ map: (1, 2, 3, 4, 5, 6, 7);
+
+}
+
+# General
+
+general:
+{
+
+ epsilon = 1E-20;
+
+ size:
+ {
+ hopSize = 128;
+ frameSize = 256;
+ };
+
+ samplerate:
+ {
+ mu = 16000;
+ sigma2 = 0.01;
+ };
+
+ speedofsound:
+ {
+ mu = 343.0;
+ sigma2 = 25.0;
+ };
+
+ mics = (
+
+ # Microphone 1
+ {
+ mu = ( +0.0000, +0.0000, +0.0000 );
+ sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = ( 80.0, 90.0 );
+ },
+
+ # Microphone 2
+ {
+ mu = ( -0.0160, +0.0277, +0.0000 );
+ sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = ( 80.0, 90.0 );
+ },
+
+ # Microphone 3
+ {
+ mu = ( -0.0320, +0.0000, +0.0000 );
+ sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = ( 80.0, 90.0 );
+ },
+
+ # Microphone 4
+ {
+ mu = ( -0.0160, -0.0277, +0.0000 );
+ sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = ( 80.0, 90.0 );
+ },
+
+ # Microphone 5
+ {
+ mu = ( +0.0160, -0.0277, +0.0000 );
+ sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = ( 80.0, 90.0 );
+ },
+
+ # Microphone 6
+ {
+ mu = ( +0.0320, +0.0000, +0.0000 );
+ sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = ( 80.0, 90.0 );
+ },
+
+ # Microphone 7
+ {
+ mu = ( +0.0160, +0.0277, +0.0000 );
+ sigma2 = ( +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000, +0.000 );
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = ( 80.0, 90.0 );
+ }
+
+ );
+
+ # Spatial filter to include only a range of direction if required
+ # (may be useful to remove false detections from the floor)
+ spatialfilter: {
+
+ direction = ( +0.000, +0.000, +1.000 );
+ angle = (80.0, 90.0);
+
+ };
+
+};
+
+# Sound Source Localization
+
+ssl:
+{
+
+ nPots = 4;
+ nMatches = 10;
+ probMin = 0.5;
+ nRefinedLevels = 1;
+ gainMin = 0.25;
+ nThetas = 181;
+ interpRate = 4;
+
+ # Number of scans: level is the resolution of the sphere
+ # and delta is the size of the maximum sliding window
+ # (delta = -1 means the size is automatically computed)
+ scans = (
+ { level = 2; delta = -1; },
+ { level = 4; delta = -1; }
+ );
+
+};
+
+# Sound Source Tracking
+
+sst:
+{
+
+ # Mode is either "kalman" or "particle"
+
+ mode = "kalman";
+
+ # Parameters used by both the Kalman and particle filter
+
+ active = (
+ { weight = 1.0; mu = 0.5; sigma2 = 0.0025 }
+ );
+
+ inactive = (
+ { weight = 1.0; mu = 0.15; sigma2 = 0.0025 }
+ );
+
+ sigmaR2_prob = 0.0025;
+ sigmaR2_active = 0.0225;
+ Pfalse = 0.1;
+ Pnew = 0.1;
+ Ptrack = 0.8;
+
+ theta_new = 0.9;
+ N_prob = 5;
+ theta_prob = 0.8;
+ N_inactive = ( 150, 200, 250, 250 );
+ theta_inactive = 0.9;
+
+ # Parameters used by the Kalman filter only
+
+ kalman: {
+
+ sigmaQ = 0.001;
+
+ }
+
+ # Parameters used by the particle filter only
+
+ particle: {
+
+ nParticles = 1000;
+ st_alpha = 2.0;
+ st_beta = 0.04;
+ st_ratio = 0.5;
+ ve_alpha = 0.05;
+ ve_beta = 0.2;
+ ve_ratio = 0.3;
+ ac_alpha = 0.5;
+ ac_beta = 0.2;
+ ac_ratio = 0.2;
+ Nmin = 0.7;
+
+ }
+
+}
+
+# Sound source separation
+
+sss: {
+
+ nThetas = 181;
+ gainMin = 0.01;
+
+}
+
+# Sound source post-filtering
+
+sspf: {
+
+ alpha = 10.0;
+ beta = 0.95;
+ Ginterf = 0.01;
+
+}
+
+# Playback of separated streams
+
+playback: {
+
+ volume = 10.0;
+
+}
\ No newline at end of file
--- /dev/null
+# Input
+
+input:
+{
+
+ #ReSpeaker Device, 16bits.
+ raw: { type = "soundcard"; card = 3; device = 0; format = "bin16"; }
+
+};
+
+# Output:
+
+output:
+{
+
+ # No raw output for now...
+ raw: (
+ { type = "file"; path = "recorded.raw"; format = "bin16"; }
+ );
+
+ # For debug purpose, leave empty.
+ mapping: ();
+ resample: ();
+ stft: ();
+
+ # Sound Source Localization Results
+ ssl: (
+ { type = "file"; path = "potential.bin"; format = "float"; }
+ );
+
+ # Sound Source Tracking Results
+ sst:
+ (
+ { type = "terminal"; format = "json"; }
+ );
+
+ # For debug purpose, leave empty.
+ sss: ();
+ sspf: ();
+ istft: ();
+
+ # Separated signal, for now leave empty.
+ playback: ();
+
+}
cfg->interface = interface_construct_socket(tmpStr2, tmpInt1);
free((void *) tmpStr2);
+ }
+ else if (strcmp(tmpStr1, "terminal") == 0) {
+
+ cfg->interface = interface_construct_terminal();
+
}
else {
free((void *) tmpStr2);
}
+ else if (strcmp(tmpStr1, "terminal") == 0) {
+
+ cfg->interface = interface_construct_terminal();
+
+ }
else {
printf("Invalid type\n");
obj->card = 0;
obj->device = 0;
+ // +----------------------------------------------------------+
+ // | Terminal |
+ // +----------------------------------------------------------+
+
+ // (Empty)
+
return obj;
}
obj->card = 0;
obj->device = 0;
+ // +----------------------------------------------------------+
+ // | Terminal |
+ // +----------------------------------------------------------+
+
+ // (Empty)
+
return obj;
}
obj->card = 0;
obj->device = 0;
+ // +----------------------------------------------------------+
+ // | Terminal |
+ // +----------------------------------------------------------+
+
+ // (Empty)
+
return obj;
}
obj->card = card;
obj->device = device;
+ // +----------------------------------------------------------+
+ // | Terminal |
+ // +----------------------------------------------------------+
+
+ // (Empty)
+
+ return obj;
+
+ }
+
+ interface_obj * interface_construct_terminal(void) {
+
+ interface_obj * obj;
+
+ obj = (interface_obj *) malloc(sizeof(interface_obj));
+
+ // +----------------------------------------------------------+
+ // | Type |
+ // +----------------------------------------------------------+
+
+ obj->type = interface_terminal;
+
+ // +----------------------------------------------------------+
+ // | File |
+ // +----------------------------------------------------------+
+
+ obj->fileName = (char *) NULL;
+
+ // +----------------------------------------------------------+
+ // | Socket |
+ // +----------------------------------------------------------+
+
+ obj->ip = (char *) NULL;
+ obj->port = 0;
+
+ // +----------------------------------------------------------+
+ // | Soundcard |
+ // +----------------------------------------------------------+
+
+ obj->card = 0;
+ obj->device = 0;
+
+ // +----------------------------------------------------------+
+ // | Terminal |
+ // +----------------------------------------------------------+
+
+ // (Empty)
+
return obj;
}
}
+ // +----------------------------------------------------------+
+ // | Terminal |
+ // +----------------------------------------------------------+
+
+ // (Empty)
+
return clone;
}
break;
+ case interface_terminal:
+
+ printf("type = terminal\n");
+
+ break;
+
}
}
interface_file = 1,
interface_socket = 2,
interface_soundcard = 3,
+ interface_terminal = 4,
} interface_type;
interface_obj * interface_construct_soundcard(const unsigned int card, const unsigned int device);
+ interface_obj * interface_construct_terminal(void);
+
interface_obj * interface_clone(const interface_obj * obj);
void interface_destroy(interface_obj * obj);
break;
+ case interface_terminal:
+
+ // (Empty)
+
+ break;
+
default:
printf("Invalid interface type.\n");
break;
+ case interface_terminal:
+
+ // (Empty)
+
+ break;
+
default:
printf("Invalid interface type.\n");
break;
+ case interface_terminal:
+
+ rtnValue = snk_tracks_process_terminal(obj);
+
+ break;
+
default:
printf("Invalid interface type.\n");
}
+ int snk_tracks_process_terminal(snk_tracks_obj * obj) {
+
+ int rtnValue;
+ unsigned int iTrack;
+
+ if (obj->in->timeStamp != 0) {
+
+ switch(obj->format->type) {
+
+ case format_json:
+
+ printf("{\n");
+ printf(" \"timeStamp\": %llu,\n",obj->in->timeStamp);
+ printf(" \"src\": [\n");
+
+ for (iTrack = 0; iTrack < obj->nTracks; iTrack++) {
+
+ printf(" { \"id\": %llu, \"x\": %1.3f, \"y\": %1.3f, \"z\": %1.3f }",
+ obj->in->tracks->ids[iTrack],
+ obj->in->tracks->array[iTrack*3+0], obj->in->tracks->array[iTrack*3+1], obj->in->tracks->array[iTrack*3+2]);
+
+ if (iTrack != (obj->nTracks - 1)) {
+
+ printf(",");
+
+ }
+
+ printf("\n");
+
+ }
+
+ printf(" ]\n");
+ printf("}\n");
+
+ rtnValue = 0;
+
+ break;
+
+ }
+
+ }
+ else {
+
+ rtnValue = -1;
+
+ }
+
+ return rtnValue;
+
+ }
+
snk_tracks_cfg * snk_tracks_cfg_construct(void) {
snk_tracks_cfg * cfg;
int snk_tracks_process_socket(snk_tracks_obj * obj);
+ int snk_tracks_process_terminal(snk_tracks_obj * obj);
+
snk_tracks_cfg * snk_tracks_cfg_construct(void);
void snk_tracks_cfg_destroy(snk_tracks_cfg * snk_tracks_config);
void xcorr2xcorr_process_reset(xcorr2xcorr_obj * obj, const tdoas_obj * tdoas, const deltas_obj * deltas, const pairs_obj * pairs, const unsigned int iPoint, xcorrs_obj * xcorrs) {
unsigned int iSignal;
+
+ signed int iMiddle;
+ float vMiddle;
+ signed int iLeft;
+ float vLeft;
+ signed int iRight;
+ float vRight;
+
unsigned int iSample;
unsigned int nSamples;
unsigned int delta;
if (pairs->array[iSignal] == 0x01) {
+ iMiddle = tdoas->array[iPoint * tdoas->nPairs + iSignal];
+ vMiddle = xcorrs->array[iSignal][iMiddle];
+
+ for (iLeft = (iMiddle-1); iLeft >= 0; iLeft--) {
+
+ vLeft = xcorrs->array[iSignal][iLeft];
+
+ if (vLeft > vMiddle) {
+ break;
+ }
+
+ xcorrs->array[iSignal][iLeft] = 0.0f;
+
+ }
+ for (iRight = (iMiddle+1); iRight < obj->frameSize; iRight++) {
+
+ vRight = xcorrs->array[iSignal][iRight];
+
+ if (vRight > vMiddle) {
+ break;
+ }
+
+ xcorrs->array[iSignal][iRight] = 0.0f;
+
+ }
+
delta = deltas->array[iSignal];
iSample = tdoas->array[iPoint * tdoas->nPairs + iSignal] - delta;
nSamples = 2 * delta + 1;