📄 play_data.c
字号:
return (FALSE);}/*************************************************************************/dac_mem(s, start, end) Signal *s; double start, end;{ if (s && (start < end) && s->data) { short *data = ((short **) (s->data))[0]; int imax = get_estimated_signal_maximum(s), i; double freq = s->freq; if (!data) return; /* Board is reputed to be present, so use it. */ for (i = 0; i < 123456; i++) if (da_done) break; /* provide for detection of location of potential interrupts */ da_location = (start - s->start_time) * s->freq;#if defined(SUN4) || defined(SG) || defined(HP700) || defined(LINUX) dacmaster_indigo(-1, (short *) ((int) ((start - BUF_START_TIME(s)) * s->freq) + data), (int) ((end - start) * s->freq), &freq, imax, NULL, NULL);#else if (dsp_type == DSP32_FAB2) dacmaster_32(-1, (short *) ((int) ((start - BUF_START_TIME(s)) * s->freq) + data), (int) ((end - start) * s->freq), &freq, imax, NULL, NULL); else dacmaster_32C(-1, (short *) ((int) ((start - BUF_START_TIME(s)) * s->freq) + data), (int) ((end - start) * s->freq), &freq, imax, NULL, NULL);#endif }}/*************************************************************************//* D/A from disk *//* for files not all in memory, but playable via built-in hardware */dac_file(s, ehead_to_use, start, end) Signal *s; struct header *ehead_to_use; double start, end;{ if (s && (start < end)) { int fd = -1, sam_to_skip = s->freq * (start - s->start_time); int imax = 32767, nsamps; double freq; struct header *head = NULL; Header *h = s->header; extern int channel; char *get_sphere_hdr(); if (debug_level) fprintf(stderr, "dac_file: s: %x, ehead_to_use: %x, start: %f, end: %f\n", s, ehead_to_use, start, end); if (is_feasd_sphere(s)) close_sig_file(s); if (s->file == SIG_CLOSED) { if ((fd = open(s->name, 0)) < 0) { sprintf(notice_msg, "Cannot open %s for audio output", s->name); show_notice(1, notice_msg); return (FALSE); } else { s->file = fd; if (h->magic == ESPS_MAGIC) { char *sp; h->strm = fdopen(fd, "r"); } } } if (h->magic == ESPS_MAGIC) head = h->esps_hdr; if (s->file < 0) return (FALSE); fd = s->file; /* in case it was already open */ /* One way or another, seek to the start of playable segment. */ if (h->strm) { if (debug_level > 2) fprintf(stderr, "stream is open; skipping %d\n", s->bytes_skip); if (!is_feasd_sphere(s)) fseek(h->strm, s->bytes_skip, 0); if (head) { if (debug_level > 2) fprintf(stderr, "using skiprec %d\n", sam_to_skip); fea_skiprec(h->strm, (long) sam_to_skip, head); } else { if (debug_level > 2) fprintf(stderr, "using fseek %d\n", (int) (sam_to_skip * sizeof(short) * s->dim)); fseek(h->strm, sam_to_skip * sizeof(short) * s->dim, 1); } } else { if (debug_level > 2) fprintf(stderr, "No stream; skipping %d\n", s->bytes_skip + (int) (sam_to_skip * sizeof(short) * s->dim)); lseek(fd, s->bytes_skip + (sam_to_skip * sizeof(short) * s->dim), 0); } /* provide for detection of location of potential interrupts */ da_location = sam_to_skip; imax = get_estimated_signal_maximum(s); /* so data can be scaled for * output */ freq = s->freq; /* actual frequency used is returned in freq */ nsamps = s->freq * (end - start); if (debug_level > 2) fprintf(stderr, "channel %d nsamps %d\n", channel, nsamps); /* D/A conversion directly from a disc file */#if defined(SUN4) || defined(SG) || defined(HP700) || defined(LINUX) dacmaster_indigo(fd, (short *) 0, nsamps, &freq, imax, h->strm, ehead_to_use);#else if (dsp_type == DSP32_FAB2) dacmaster_32(fd, (short *) 0, nsamps, &freq, imax, h->strm, ehead_to_use); else dacmaster_32C(fd, (short *) 0, nsamps, &freq, imax, h->strm, ehead_to_use);#endif }}/*************************************************************************//* * Stop D/A operation. If running under xwaves, this could mean stop an * external play program. External programs are killed with the * distinguished SIGUSR1 so that play-programs-in-the-know can catch the * signal intelligently and use a send_xwaves mechanism to set da_location * appropriately. */intstop_da(client_data) caddr_t client_data;{ if (debug_level) fprintf(stderr, "stop_da: da_done=%d play_pid=%d play_program=%s\n", da_done, play_pid, play_program); /* external play may be in progress */ if (play_program && *play_program && !da_done && (play_pid > 0)) { set_esps_callback_data(play_pid, client_data); kill(play_pid + 1, SIGUSR1); /* +1 since it's execv'd from a fork */ da_done = TRUE; /* force it here, just in case no SIGCHILD */ return (FALSE); /* i.e. it's not really stopped yet! */ } else#if defined(SUN4) || defined(SG) || defined(HP700) || defined(LINUX) stop_indigo_da();#else#ifdef DSP_BOARD_VERSION switch (dsp_type) { case DSP32C_VME: stop_32c_vme_da(); break; case DSP32_FAB2: stop_fab2_da(); break; default: if (debug_level) fprintf(stderr, "Board type %d; (external process?)\n", dsp_type); break; }#endif#endif return (TRUE);}/*************************************************************************/intplayable_dimension(d) int d;{ if (use_dsp32#if defined(SUN4) || defined(SG) || defined(HP700) || defined(LINUX) ) {#else && (dsp_type == DSP32C_VME)) {#endif if ((d == 1) || (d == 2)) { extern int channel; channel = (d == 1) ? 3 : 0; return (TRUE); } } return (d == 1);}/*************************************************************************//* * This highly-specialized type check determines if the general-purpose * reading function read_any_file() can handle the signal in question. It * returns TRUE or FALSE. It also sets its required argument, ehead, to a * valid ESPS header, if get_sd_recs can be used, or NULL, if it can't, but * the file otherwise can be handled by read_any_file(). */ereader_can_handle(s, ehead) Signal *s; struct header **ehead;{ struct header *sdtofea(); if (s && playable_dimension(s->dim)) { Header *h = s->header; if (h->magic == ESPS_MAGIC) { if (h->esps_hdr->common.type == FT_SD) { *ehead = sdtofea(h->esps_hdr); return (TRUE); } else if (h->esps_hdr->common.type == FT_FEA && h->esps_hdr->hd.fea->fea_type == FEA_SD) { *ehead = h->esps_hdr; return (TRUE); } else if ((type_of_signal(s) & VECTOR_SIGNALS) == P_SHORTS) return (TRUE); else return (FALSE); } else { /* might be a SIGnal file... */ if ((type_of_signal(s) & VECTOR_SIGNALS) == P_SHORTS) { return (TRUE); } } } return (FALSE);}#define ITIMER_NULL ((struct itimerval*)0)/*************************************************************************/staticxv_dac_handle(who, what) Panel_item who; int what;{ if (what == ITIMER_REAL) {#if defined(SUN4) || defined(SG) || defined(HP700) || defined(LINUX) indigo_handle(1);#else surf_handle(who);#endif } else fprintf(stderr, "Unexpected interrupt in xv_dac_handle(%d)\n", what); return (NOTIFY_DONE);}/*************************************************************************/clear_dac_callbacks(){ extern Frame daddy; notify_set_itimer_func(daddy, xv_dac_handle, ITIMER_REAL, ITIMER_NULL, ITIMER_NULL);}/*************************************************************************/set_fab2_dac_callbacks(){ if (debug_level) fprintf(stderr, "set_fab2_dac_callbacks()\n");}/*************************************************************************/clear_fab2_dac_callbacks(){ if (debug_level) fprintf(stderr, "clear_fab2_dac_callbacks()\n");}/*************************************************************************/voidset_dac_callbacks(timer_usec) int timer_usec;{ int ret; static int my_client_object; extern Frame daddy; struct itimerval dac_timer; dac_timer.it_interval.tv_usec = timer_usec; dac_timer.it_interval.tv_sec = 0; dac_timer.it_value.tv_usec = timer_usec; dac_timer.it_value.tv_sec = 0; (void) notify_set_itimer_func(daddy, xv_dac_handle, ITIMER_REAL, &dac_timer, ITIMER_NULL); return;}#if defined(SUN4) || defined(SG) || defined(HP700) || defined(LINUX)/*************************************************************************/stop_indigo_da(){ extern int indigo_sent, da_location; extern int indigo_error_at; indigo_error_at = indigo_sent; indigo_completion(); if (debug_level) fprintf(stderr, "stopping indigo D/A; da_location:%d\n", da_location);}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -