📄 sound.h
字号:
double snd_sref(sound_type s, time_type t); /* LISP: (SND-SREF SOUND ANYNUM) */double snd_sref_inverse(sound_type s, double val); /* LISP: (SREF-INVERSE SOUND ANYNUM) */double snd_stop_time(sound_type s); /* LISP: (SND-STOP-TIME SOUND) */#define snd_time(s) (s)->time /* LISP: double (SND-TIME SOUND) */#define snd_srate(s) (s)->sr /* LISP: double (SND-SRATE SOUND) */#define snd_t0(s) (s)->t0 /* LISP: double (SND-T0 SOUND) */sound_type snd_xform(sound_type snd, rate_type sr, time_type time, time_type start_time, time_type stop_time, promoted_sample_type scale); /* LISP: (SND-XFORM SOUND ANYNUM ANYNUM ANYNUM ANYNUM ANYNUM) */sound_type sound_create(snd_susp_type susp, time_type t0, rate_type sr, promoted_sample_type scale);void min_cnt(long *cnt_ptr, sound_type sound, snd_susp_type susp, long cnt);void indent(int n);void sound_prepend_zeros(sound_type snd, time_type t0);#ifndef GCBUG#define blocks_to_watch_max 50extern long blocks_to_watch_len;extern sample_block_type blocks_to_watch[blocks_to_watch_max];void block_watch(long sample_block); /* LISP: (BLOCK-WATCH FIXNUM) */long sound_nth_block(sound_type snd, long n); /* LISP: (SOUND-NTH-BLOCK SOUND FIXNUM) */#endifsound_type sound_copy(sound_type snd); /* LISP: (SND-COPY SOUND) */void sound_xlmark(sound_type s);void sound_print(LVAL snd_expr, long n); /* LISP: (SND-PRINT ANY FIXNUM) */void sound_play(LVAL snd_expr); /* LISP: (SND-PLAY ANY) */void stats(); /* LISP: (STATS) */void sound_print_tree(sound_type snd); /* LISP: (SND-PRINT-TREE SOUND) */void sound_print_tree_1(sound_type snd, int n);sound_type sound_scale(double factor, sound_type snd); /* LISP: (SND-SCALE ANYNUM SOUND) */void sound_init(void);void sound_symbols(void);table_type sound_to_table(sound_type s);void table_unref(table_type table);sound_type sound_zero(time_type t0, rate_type sr); /* LISP: (SND-ZERO ANYNUM ANYNUM) */#define sound_get_next(s, n) ((*(s->get_next))(s, n))#define susp_print_tree(s, n) (*((s)->print_tree))(s, n)double step_to_hz(); /* LISP: (STEP-TO-HZ ANYNUM) *//* macros for access to samples within a suspension *//* NOTE: assume suspension structure is named "susp" *//* susp_check_samples points sample_ptr to a new sample block if necessary */#define susp_check_samples(sound, sample_ptr, sample_cnt) \ if (susp->sample_cnt == 0) \ susp_get_samples(sound, sample_ptr, sample_cnt)/* susp_check_samples_break is similar to susp_check_samples - "_break" * normally means that this code will break out of the inner loop, but in * this case, there is no reason (neither log nor term) to break. * x2_sample is taken from sound */#define susp_check_samples_break(sound, sample_ptr, sample_cnt, x2_sample) \ if (susp->sample_cnt == 0) { \ susp_get_samples(sound, sample_ptr, sample_cnt); \ x2_sample = susp_current_sample(sound, sample_ptr); }/* susp_get_samples always gets next block (useful only in initialization code) */#define susp_get_samples(sound, sample_ptr, sample_cnt) \ susp->sample_ptr = sound_get_next(susp->sound, &(susp->sample_cnt))->samples/* susp_get_block_samples always gets next block (useful only in initialization code) */#define susp_get_block_samples(sound, sample_block_ptr, sample_ptr, sample_cnt) \ susp->sample_block_ptr = sound_get_next(susp->sound, &susp->sample_cnt); \ susp->sample_ptr = susp->sample_block_ptr->samples/* susp_took is called after you've taken n samples */#define susp_took(sample_cnt, n) susp->sample_cnt -= n/* susp_fetch_sample is used to grab just one sample, doesn't check for samples!, * but applies scale factor: */#define susp_fetch_sample(sound, sample_ptr, sample_cnt) \ (susp->sound->scale * (susp->sample_cnt--, *(susp->sample_ptr++)))/* susp_current_sample grabs sample without advancing to next, applies scale * factor: */#define susp_current_sample(sound, sample_ptr) \ (susp->sound->scale * (*(susp->sample_ptr)))/* susp_check_term_samples checks for samples; if new ones are fetched, then * run termination test on signal and record result. */#define susp_check_term_samples(sound, sample_ptr, sample_cnt) \ if (susp->sample_cnt == 0) { \ susp_get_samples(sound, sample_ptr, sample_cnt); \ terminate_test(sample_ptr, sound, susp->sample_cnt); }/* susp_check_term_log_samples checks for samples * if new ones are fetched, then run termination test and logical stop * test on signal and record results. */#define susp_check_term_log_samples(sound, sample_ptr, sample_cnt) \ if (susp->sample_cnt == 0) { \ susp_get_samples(sound, sample_ptr, sample_cnt); \ logical_stop_test(sound, susp->sample_cnt); \ terminate_test(sample_ptr, sound, susp->sample_cnt); }/* susp_check_term_log_block_samples checks for samples * if new ones are fetched, then run termination test and logical stop * test on signal and record results. In this case, termination and logical * stop happen at the MAXIMUM of termination and logical stop times, resp. */#define susp_check_term_log_block_samples(sound, sample_block_ptr, sample_ptr, sample_cnt, bit, all) \ if (susp->sample_cnt == 0) { \ susp_get_block_samples(sound, sample_block_ptr, sample_ptr, sample_cnt); \ if (susp->sound->logical_stop_cnt ==\ susp->sound->current - susp->sample_cnt) { \ susp->logical_stop_bits |= bit; \ if (susp->logical_stop_bits == all) { \ susp->susp.log_stop_cnt = (long) \ ((((susp->sound->current - susp->sample_cnt) / \ susp->sound->sr + susp->sound->t0) - \ susp->susp.t0) * susp->susp.sr + 0.5); } } \ if (susp->sample_ptr == zero_block->samples) { \ susp->terminate_bits |= bit; \ if (susp->terminate_bits == all) { \ susp->terminate_cnt = (long) \ ((((susp->sound->current - susp->sample_cnt) / \ susp->sound->sr + susp->sound->t0) - \ susp->susp.t0) * susp->susp.sr + 0.5); \ } } }/* logical_stop_cnt_cvt is used to convert from the logical stop count * at one sample rate to that of another sample rate -- this macro is * used by the snd_make_<op> routine in every <op>.c file, and assumes * the target sample rate is susp->susp.sr. * * NOTE: this macro does not take into account the possibility of different * start times - maybe it should. */#define logical_stop_cnt_cvt(sound) \ (sound->logical_stop_cnt == UNKNOWN ? UNKNOWN : \ ROUND((sound->logical_stop_cnt / sound->sr) * susp->susp.sr))/* logical_stop_test tests to see if sound has logically stopped; if so, * sets susp->susp.log_stop_cnt. The resulting logical_stop_cnt will reflect * the minimum logical_stop time of all sounds to which this test is applied. */#define logical_stop_test(sound, cnt) \ if (susp->sound->logical_stop_cnt == susp->sound->current - (cnt)) {\ min_cnt(&susp->susp.log_stop_cnt, susp->sound, (snd_susp_type) susp, cnt); }/* terminate_test checks to see if sound has terminated; if so, * sets susp->terminate_cnt. The resulting terminate_cnt will reflect * the minimum termination time of all sounds to which this test is applied. */#define terminate_test(sample_ptr, sound, cnt) \ if (susp->sample_ptr == zero_block->samples) { \ min_cnt(&susp->terminate_cnt, susp->sound, (snd_susp_type) susp, cnt); }/* susp_check_log_samples checks for new samples then checks for * termination and logical stop conditions */#define susp_check_log_samples(sound, sample_ptr, sample_cnt) \ if (susp->sample_cnt == 0) { \ susp_get_samples(sound, sample_ptr, sample_cnt); \ logical_stop_test(sound, susp->sample_cnt); }/* susp_check_term_samples_break checks for new samples then checks for * termination condition; breaks from inner loop */#define susp_check_term_samples_break( \ sound, sample_ptr, sample_cnt, x2_sample) \ if (susp->sample_cnt == 0) { \ susp_get_samples(sound, sample_ptr, sample_cnt); \ x2_sample = susp_current_sample(sound, sample_ptr); \ terminate_test(sample_ptr, sound, susp->sample_cnt); \ if (susp->terminate_cnt < susp->susp.current + cnt + togo) { \ break; }} \ else x2_sample = susp_current_sample(sound, sample_ptr); /* susp_check_log_samples_break checks for new samples then checks for * logical stop conditions; breaks from inner loop */#define susp_check_log_samples_break( \ sound, sample_ptr, sample_cnt, x2_sample) \ if (susp->sample_cnt == 0) { \ susp_get_samples(sound, sample_ptr, sample_cnt); \ x2_sample = susp_current_sample(sound, sample_ptr); \ logical_stop_test(sound, susp->sample_cnt); \ if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN && \ (susp->susp.log_stop_cnt < susp->susp.current + cnt + togo)) { \ break; }} \ else x2_sample = susp_current_sample(sound, sample_ptr);/* susp_check_term_log_samples_break checks for new samples then checks for * termination and logical stop conditions; breaks from inner loop */#define susp_check_term_log_samples_break( \ sound, sample_ptr, sample_cnt, x2_sample) \ if (susp->sample_cnt == 0) { \ susp_get_samples(sound, sample_ptr, sample_cnt); \ x2_sample = susp_current_sample(sound, sample_ptr); \ terminate_test(sample_ptr, sound, susp->sample_cnt); \ logical_stop_test(sound, susp->sample_cnt); \ if ((susp->terminate_cnt != UNKNOWN && \ susp->terminate_cnt < susp->susp.current + cnt + togo) || \ (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN && \ susp->susp.log_stop_cnt < susp->susp.current + cnt + togo)) { \ break; }} \ else x2_sample = susp_current_sample(sound, sample_ptr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -