/** * Entry point for C core of \b distiller diagnostic. */ int main (int argc, char *argv[]) { if (argc != 5) error ("Usage: %s rec_first rec_last rec_step use_filter", argv[0]); int rec0 = fmax (0, atoi (argv[1])) + 0.1, rec1 = fmin (INT_MAX - 3, atoi (argv[2])) + 0.1, step = fmax (1, atoi (argv[3])) + 0.1, use_filter = atoi (argv[4]); // Loads units to get [r0] -> [micron] factor. units_load (); // Loads component parameters if they were defined before. FILE *fp = fopen ("output/markers/map.txt", "rt"); if (fp) { double qDivM; while (1 == fscanf (fp, "%le ", &qDivM)) open_gate (qDivM, -1); fclose (fp); } for (record = rec0 ; record <= rec1 ; record += step) { // Checks if record exists. if (access (IO_plasmaName (record, 0), R_OK)) break; // Reopens streams for the components (new record => new file name). for (int i = 0 ; i < gateN ; ++i) open_gate (gate[i].qDivM, record); // Filters markers. process_record (use_filter); // Closes all open streams. for (int i = 0 ; i < gateN ; ++i) fclose (gate[i].fp); } // Saves updated "component number <=> q/M" definitions. fp = fopen ("output/markers/map.txt", "wt"); for (int i = 0 ; i < gateN ; ++i) fprintf (fp, "%+.14le\n", gate[i].qDivM); fclose (fp); msg_send ("Done"); return EXIT_SUCCESS; }
void THRESHOLD_GATE::analyze(SAMPLE_BUFFER* sbuf) { if (rms_rep == true) avolume_rep = SAMPLE_BUFFER_FUNCTIONS::RMS_volume(*sbuf) / SAMPLE_SPECS::max_amplitude; else avolume_rep = SAMPLE_BUFFER_FUNCTIONS::average_amplitude(*sbuf) / SAMPLE_SPECS::max_amplitude; if (is_opened_rep == false) { if (avolume_rep > openlevel_rep) { open_gate(); ECA_LOG_MSG(ECA_LOGGER::user_objects, "Threshold gate opened (reopen count = " + kvu_numtostr(reopens_left_rep) + ")"); is_opened_rep = true; is_closed_rep = false; } } else if (is_closed_rep == false) { if (avolume_rep < closelevel_rep) { close_gate(); ECA_LOG_MSG(ECA_LOGGER::user_objects, "Threshold gate closed (reopens left = " + kvu_numtostr(reopens_left_rep) + ")"); is_closed_rep = true; if (reopens_left_rep != 0) { is_opened_rep = false; if (reopens_left_rep > 0) --reopens_left_rep; } else { // - Could we stop the engine and exit here, maybe? -AL/2008-Jul // - Not from a chain operator, but the audio object // that writes the stream to a file could in // theory react in a special way to the 0-length // samplebuffers we generate when the gate is closed... -KV/2008-Jul } } } }
void TIME_CROP_GATE::analyze(SAMPLE_BUFFER* sbuf) { parameter_t etime = begtime_rep + durtime_rep; parameter_t curtime = static_cast<parameter_t>(position_in_samples_rep) / samples_per_second(); if (curtime >= begtime_rep) { /* note: handle the special case where a zero open time * has been requested */ if (begtime_rep == etime) open_gate(); else if (curtime < etime) open_gate(); else close_gate(); } else close_gate(); position_in_samples_rep += sbuf->length_in_samples(); }
void MANUAL_GATE::analyze(SAMPLE_BUFFER* sbuf) { if (is_open() == true && open_rep != true) { close_gate(); ECA_LOG_MSG(ECA_LOGGER::user_objects, "Manual gate closed"); } else if (is_open() != true && open_rep == true) { open_gate(); ECA_LOG_MSG(ECA_LOGGER::user_objects, "Manual gate opened"); } }
/** * Finds output stream or creates one. */ static inline void save_marker (marker_t *p) { FILE *fp = NULL; for (int i = 0 ; i < gateN && !fp ; ++i) if (fabs (p->qDivM - gate[i].qDivM) < MC_EPSILON*(fabs (p->qDivM) + fabs (gate[i].qDivM))) fp = gate[i].fp; if (!fp) fp = open_gate (p->qDivM, record); fprintf (fp, "%le %le %le %le %le %le %e\n", p->x, p->y, p->z, p->vx, p->vy, p->vz, p->rho); }