1 #ifndef SND_1_H 2 #define SND_1_H 3 4 #define WITH_RELATIVE_PANES (USE_MOTIF && (XmVERSION > 1)) 5 6 #define Snd_assert_sound(Origin, Snd, Offset) \ 7 if (!((Xen_is_integer(Snd)) || (xen_is_sound(Snd)) || (Xen_is_false(Snd)) || (!Xen_is_bound(Snd)))) \ 8 Xen_wrong_type_arg_error(Origin, Offset, Snd, "a sound object, an integer (sound index), or " PROC_FALSE); 9 10 #define Snd_assert_channel(Origin, Snd, Chn, Offset) \ 11 if (!((Xen_is_integer(Snd)) || (xen_is_sound(Snd)) || (Xen_is_false(Snd)) || (!Xen_is_bound(Snd)))) \ 12 Xen_wrong_type_arg_error(Origin, Offset, Snd, "a sound object, an integer (sound index), or " PROC_FALSE); \ 13 else \ 14 if (!((Xen_is_integer(Chn)) || (Xen_is_false(Chn)) || (!Xen_is_bound(Chn)))) \ 15 Xen_wrong_type_arg_error(Origin, Offset + 1, Chn, "an integer (0-based channel number) or " PROC_FALSE); 16 17 18 #if HAVE_SCHEME 19 /* these macros fix up argument order for setter procs in Scheme: (set! (proc a b) c) */ 20 21 #define with_two_setter_args(name_reversed, name) \ 22 static s7_pointer name_reversed(s7_scheme *sc, s7_pointer args) \ 23 { \ 24 if (Xen_is_null(Xen_cdr(args))) \ 25 return(name(Xen_car(args), Xen_undefined)); \ 26 return(name(Xen_cadr(args), Xen_car(args))); \ 27 } 28 29 #define with_three_setter_args(name_reversed, name) \ 30 static s7_pointer name_reversed(s7_scheme *sc, s7_pointer args) \ 31 { \ 32 if (Xen_is_null(Xen_cdr(args))) \ 33 return(name(Xen_car(args), Xen_undefined, Xen_undefined)); \ 34 else { \ 35 if (Xen_is_null(Xen_cddr(args))) \ 36 return(name(Xen_cadr(args), Xen_car(args), Xen_undefined)); \ 37 else return(name(Xen_caddr(args), Xen_car(args), Xen_cadr(args))); \ 38 }} 39 40 #define with_four_setter_args(name_reversed, name) \ 41 static s7_pointer name_reversed(s7_scheme *sc, s7_pointer args) \ 42 { \ 43 if (Xen_is_null(Xen_cdr(args))) \ 44 return(name(Xen_car(args), Xen_undefined, Xen_undefined, Xen_undefined)); \ 45 else { \ 46 if (Xen_is_null(Xen_cddr(args))) \ 47 return(name(Xen_cadr(args), Xen_car(args), Xen_undefined, Xen_undefined)); \ 48 else { \ 49 if (Xen_is_null(Xen_cdddr(args))) \ 50 return(name(Xen_caddr(args), Xen_car(args), Xen_cadr(args), Xen_undefined)); \ 51 else return(name(Xen_cadddr(args), Xen_car(args), Xen_cadr(args), Xen_caddr(args))); \ 52 }}} 53 54 #else 55 56 #define with_two_setter_args(name_reversed, name) 57 #define with_three_setter_args(name_reversed, name) 58 #define with_four_setter_args(name_reversed, name) 59 #endif 60 61 #define Snd_assert_sample_type(Origin, Beg, Offset) \ 62 Xen_check_type(Xen_is_integer(Beg) || Xen_is_false(Beg) || (!Xen_is_bound(Beg)), Beg, Offset, Origin, "an integer or " PROC_FALSE) 63 64 typedef struct { 65 char **values; 66 int num_values, values_size; 67 bool exact_match; 68 } list_completer_info; 69 70 typedef struct { 71 int samps_per_bin, peak_env_size; 72 mus_float_t fmax, fmin; 73 mus_float_t *data_max, *data_min; 74 bool completed; 75 int bin, top_bin; 76 } peak_env_info; 77 78 typedef struct snd_io snd_io; 79 80 typedef struct { 81 char *name; /* full name */ 82 mus_long_t samples; /* total samples = chans * framples */ 83 mus_long_t data_location; /* bytes */ 84 int srate; 85 int chans; 86 mus_sample_t sample_type; /* sample type (mus_bshort etc) */ 87 mus_header_t type; /* header type (mus_aifc etc) */ 88 char *comment; /* output case, not input */ 89 int *loops; 90 } file_info; 91 92 typedef struct { 93 snd_data_file_t type; 94 mus_float_t *buffered_data; 95 snd_io *io; 96 char *filename; 97 file_info *hdr; 98 file_delete_t temporary; 99 int edit_ctr; 100 fd_open_t open; 101 bool inuse; 102 bool copy; 103 int chan; 104 mus_long_t data_bytes; /* used only for edit-history descriptions (snd-edits.c display_ed_list) */ 105 bool free_me; 106 } snd_data; 107 108 typedef struct mark mark; 109 typedef struct enved_fft enved_fft; 110 111 typedef struct { 112 int size, allocated_size; 113 struct ed_fragment **fragments; 114 mus_long_t beg, len; /* beg and len of changed portion */ 115 char *origin; 116 edit_t edit_type; 117 int sound_location; 118 mus_long_t selection_beg, selection_end; /* selection needs to follow edit list */ 119 mus_float_t maxamp, selection_maxamp; 120 mus_long_t maxamp_position, selection_maxamp_position; 121 int edpos; 122 bool backed_up; 123 mus_long_t samples, cursor; 124 int mark_size, mark_ctr; 125 mark **marks; /* mark positions */ 126 peak_env_info *peak_env; 127 enved_fft *fft; /* overall fft data for envelope editor */ 128 void *readers; /* current readers of this edit (g++ stupidity forces us to use void* here -- type is sf_info, snd-edits.c) */ 129 void *mixes; 130 Xen properties; 131 int properties_gc_loc; 132 } ed_list; 133 134 typedef struct snd_fd { 135 mus_float_t (*runf)(struct snd_fd *sf); 136 mus_float_t (*rev_runf)(struct snd_fd *sf); 137 ed_list *current_state; 138 struct ed_fragment *cb; 139 mus_long_t loc, first, last; 140 int cbi; 141 read_direction_t direction; 142 bool at_eof, freed; 143 mus_float_t *data; 144 snd_data *current_sound; 145 mus_long_t initial_samp; 146 struct chan_info *cp; 147 struct snd_info *local_sp; 148 mus_float_t fscaler; 149 mus_long_t frag_pos; 150 int edit_ctr, region; 151 reader_t type; 152 void *ramps, *mixes; 153 } snd_fd; 154 155 typedef struct {mus_float_t freq; mus_float_t amp;} fft_peak; 156 157 typedef struct { 158 mus_float_t y0, y1; /* scroller-dependent axis bounds */ 159 double x0, x1; 160 double xmin, xmax; 161 mus_float_t ymin, ymax; /* data-dependent absolute limits */ 162 mus_float_t y_scale, y_base, y_ambit; 163 double x_scale, x_base, x_ambit; 164 char *xlabel, *ylabel, *default_xlabel; 165 int y_axis_x0, x_axis_x0, y_axis_y0, x_axis_y0, x_axis_x1, y_axis_y1, x_label_x, x_label_y; 166 bool graph_active; 167 mus_long_t losamp, hisamp; /* displayed x-axis bounds in terms of sound sample numbers */ 168 int graph_x0; /* x axis offset relative to window (for double graphs) */ 169 struct tick_descriptor *x_ticks, *y_ticks; 170 graphics_context *ax; 171 int width, height; 172 struct chan_info *cp; 173 mus_float_t sy, zy; /* as set by user, 0.0 - 1.0 */ 174 double sx, zx; 175 int y_offset; 176 int window_width; 177 bool no_data, changed; 178 #if HAVE_GL 179 bool use_gl, used_gl; 180 #endif 181 } axis_info; 182 183 typedef struct { 184 mus_float_t *data; 185 int pts, data_size; /* data_size is independent of actual number of points of data (can be much larger) */ 186 mus_float_t base; 187 } env; 188 189 typedef struct { 190 int mix_id; 191 mus_long_t beg, len; 192 mus_float_t scaler, speed; 193 env *amp_env; 194 int index; /* cp->sounds index (src writes a new temp file) */ 195 } mix_state; 196 197 typedef struct env_editor { 198 int *current_xs; 199 int *current_ys; 200 int current_size; 201 axis_info *axis; 202 oclock_t down_time; 203 bool env_dragged; 204 int env_pos; 205 bool click_to_delete, in_dB, with_dots, clipping; 206 bool edited; 207 } env_editor; 208 209 typedef struct { 210 mus_long_t size; 211 mus_long_t current_size; 212 mus_fft_window_t window; 213 mus_float_t alpha, beta; 214 mus_float_t scale; 215 axis_info *axis; 216 mus_float_t *data, *phases; 217 char *xlabel; 218 struct chan_info *chan; 219 } fft_info; 220 221 typedef struct { 222 int total_slices; /* size of the data array (max for allocation checks) */ 223 int total_bins; /* size other axis data array */ 224 int active_slices; /* how many slices contain current data */ 225 int target_bins; /* this many bins Y-side */ 226 int target_slices; /* how many slices in full display (current) */ 227 mus_float_t **data; /* data[total_slices][bins] -> each is a spectral magnitude */ 228 mus_long_t *begs; /* associated begin times (for data reuse) */ 229 struct chan_info *cp; 230 mus_float_t scale; 231 } sono_info; 232 233 typedef struct { 234 int chans, fields; 235 double *axis_data; 236 bool *fftp, *wavep; 237 } axes_data; 238 239 typedef struct chan_info { 240 int chan; /* which chan are we */ 241 bool graph_transform_on; /* f button state */ 242 bool graph_time_on; /* w button state */ 243 bool graph_lisp_on; /* is lisp graph active */ 244 struct lisp_grf *lisp_info; /* defined in snd-chn.c */ 245 bool cursor_on; /* channel's cursor */ 246 bool cursor_visible, fft_cursor_visible; /* for XOR decisions */ 247 int cursor_size; 248 cursor_style_t cursor_style, tracking_cursor_style; 249 int cx, cy, fft_cx; /* , old_cy; */ /* graph-relative cursor loc (for XOR in Motif, erase-via-overwrite in cairo) */ 250 int edit_ctr; /* channel's edit history */ 251 int edit_size; /* current edit list size */ 252 ed_list **edits; /* the edit list */ 253 int sound_size; /* edit_list associated temp sound buffers */ 254 int sound_ctr; /* current location in sounds list */ 255 snd_data **sounds; /* the associated temp buffer/file/struct list */ 256 fft_info *fft; /* possibly null fft data */ 257 struct snd_info *sound; /* containing sound */ 258 axis_info *axis; /* time domain axis */ 259 260 idle_t fft_in_progress; 261 idle_t peak_env_in_progress; 262 struct env_state *peak_env_state; 263 graphics_context *ax; 264 bool selected; 265 mus_float_t progress_pct; 266 267 #if USE_MOTIF 268 Widget *widgets; 269 Pixmap fft_pix; 270 uint32_t fft_pix_width, fft_pix_height; 271 int fft_pix_x0, fft_pix_y0; 272 bool fft_pix_ready; 273 mus_float_t fft_pix_cutoff; 274 Cursor current_cursor; 275 Pixel combined_data_color; 276 #endif 277 #if USE_NO_GUI 278 int current_cursor, combined_data_color; 279 #endif 280 281 sono_info *sonogram_data; 282 struct sonogram_state *last_sonogram, *temp_sonogram; /* defined in snd-fft.c */ 283 struct wavogram_state *last_wavogram; /* defined in snd-chn.c */ 284 bool show_sonogram_cursor; 285 struct fft_state *fft_data; /* parallels sonogram -- try to avoid repeating large ffts needlessly */ 286 printing_t printing; 287 fft_change_t fft_changed; 288 mus_float_t gsy, gzy; 289 int height; 290 mus_long_t original_cursor, original_left_sample, original_window_size; /* for cursor reset after cursor-moving play */ 291 with_hook_t hookable; 292 mus_long_t selection_transform_size; 293 bool squelch_update, previous_squelch_update, waiting_to_make_graph; 294 int in_as_one_edit, as_one_edit_positions_size; 295 int *as_one_edit_positions; 296 /* moved from global to channel-local 4-Aug-00 */ 297 mus_float_t spectro_x_scale, spectro_y_scale, spectro_z_scale, spectro_z_angle, spectro_x_angle, spectro_y_angle; 298 mus_float_t spectrum_end, spectrum_start; 299 mus_float_t lin_dB, min_dB, fft_window_alpha, fft_window_beta, beats_per_minute, grid_density; 300 bool show_y_zero, show_marks, with_verbose_cursor; 301 with_grid_t show_grid; 302 int wavo_hop, wavo_trace, zero_pad, wavelet_type, max_transform_peaks, beats_per_measure; 303 x_axis_style_t x_axis_style; 304 show_axes_t show_axes; 305 mus_long_t transform_size; 306 mus_fft_window_t fft_window; 307 graph_type_t transform_graph_type, time_graph_type; 308 bool show_transform_peaks, fft_log_frequency, fft_log_magnitude, fft_with_phases; 309 graph_style_t time_graph_style, lisp_graph_style, transform_graph_style; 310 int dot_size; 311 fft_normalize_t transform_normalization; 312 int transform_type, spectro_hop, edhist_base; 313 bool show_mix_waveforms, graphs_horizontal; 314 Xen edit_hook; 315 Xen undo_hook; 316 Xen cursor_proc; 317 Xen after_edit_hook; 318 Xen properties; 319 int cursor_proc_loc, edit_hook_loc, undo_hook_loc, after_edit_hook_loc, properties_loc; 320 bool selection_visible; 321 channel_state_t active; 322 int old_x0, old_x1; 323 mus_float_t *amp_control; /* local amp controls in snd-dac; should it be extended to other controls? */ 324 bool just_zero, new_peaks, editable, updating; 325 struct inset_graph_info_t *inset_graph; /* defined in snd-chn.c */ 326 #if HAVE_GL 327 int gl_fft_list, gl_wavo_list; 328 #endif 329 } chan_info; 330 331 #define current_samples(Cp) (Cp)->edits[(Cp)->edit_ctr]->samples 332 #define cursor_sample(Cp) (Cp)->edits[(Cp)->edit_ctr]->cursor 333 334 typedef struct snd_info { 335 sound_inuse_t inuse; 336 int index; 337 int playing; 338 int sync, previous_sync; 339 bool expand_control_on; 340 bool contrast_control_on; 341 bool reverb_control_on; 342 bool filter_control_on, filter_control_in_dB, filter_control_in_hz; 343 mus_float_t amp_control; 344 mus_float_t speed_control; 345 int speed_control_direction, speed_control_tones, speed_control_numerator, speed_control_denominator; 346 speed_style_t speed_control_style; 347 mus_float_t last_speed_control, last_amp_control, last_expand_control, last_contrast_control; 348 mus_float_t last_reverb_control_length, last_reverb_control_scale; 349 mus_float_t saved_speed_control, saved_amp_control, saved_expand_control, saved_contrast_control; 350 mus_float_t saved_reverb_control_length, saved_reverb_control_scale; 351 mus_float_t expand_control, expand_control_length, expand_control_ramp, expand_control_hop, expand_control_jitter; 352 mus_float_t contrast_control, contrast_control_amp; 353 mus_float_t reverb_control_length, reverb_control_scale, reverb_control_feedback, reverb_control_lowpass; 354 mus_float_t reverb_control_decay, filter_control_xmax; 355 mus_float_t contrast_control_min, contrast_control_max, expand_control_min, expand_control_max, speed_control_min, speed_control_max; 356 mus_float_t amp_control_min, amp_control_max, reverb_control_scale_min, reverb_control_scale_max; 357 mus_float_t reverb_control_length_min, reverb_control_length_max; 358 int filter_control_order; 359 bool filter_control_changed; 360 env *filter_control_envelope; 361 int selected_channel; 362 char *filename; 363 char *short_filename; 364 uint32_t nchans; /* "unsigned" to make gcc 7.1 happy */ 365 Xen properties; 366 int properties_loc; 367 bool remembering; 368 read_only_t user_read_only, file_read_only; 369 chan_info **chans; 370 371 struct env_editor *flt; 372 #if USE_MOTIF 373 Widget *widgets; 374 Widget *progress_widgets; 375 int num_progress_widgets; 376 Widget tab; 377 Widget dialog; 378 int bomb_ctr; 379 #endif 380 #if USE_NO_GUI 381 bool widgets; 382 #endif 383 384 file_info *hdr; /* header of file that would be affected if we were to save current edits */ 385 time_t write_date, update_warning_write_date; /* check for change behind back while editing */ 386 bool need_update, file_unreadable; /* current in-core data does not match actual file (someone wrote it behind our back) */ 387 channel_style_t channel_style; 388 int allocated_chans, selectpos; 389 struct region *edited_region; 390 void *delete_me; 391 chan_info *lacp; 392 struct ctrl_state *saved_controls; 393 bool apply_ok, applying; 394 bool active; 395 char *name_string; 396 void *file_watcher; 397 bool writing, bomb_in_progress; 398 } snd_info; 399 400 #define snd_srate(Sp) (((Sp)->hdr)->srate) 401 #define has_widgets(Sp) ((Sp) && ((Sp)->widgets)) 402 403 typedef struct snd_state { 404 int selected_sound; /* NO_SELECTION = none selected = which sound is currently receiving user's attention */ 405 int active_sounds; 406 int channel_min_height; 407 snd_info **sounds; 408 char *search_expr, *startup_title, *startup_errors; 409 Xen search_proc; 410 int file_sorters_size, file_filters_size; 411 Xen file_sorters, file_filters; 412 int search_proc_loc, local_errno, local_open_errno; 413 int position_slider_width, zoom_slider_width, toggle_size, channel_sash_indent, sash_size, channel_sash_size, sash_indent; 414 int max_sounds, sound_sync_max; 415 char *translated_filename; 416 print_choice_t print_choice; 417 snd_apply_t apply_choice; 418 bool gl_has_double_buffer; 419 bool stopped_explicitly, checking_explicitly, selection_play_stop; 420 int reloading_updated_file; 421 int init_window_width, init_window_height; 422 int init_window_x, init_window_y; 423 bool graph_hook_active, lisp_graph_hook_active; 424 425 bool Show_Transform_Peaks, Show_Y_Zero, Show_Marks; 426 with_grid_t Show_Grid; 427 bool Fft_Log_Frequency, Fft_Log_Magnitude, Fft_With_Phases; 428 channel_style_t Channel_Style; 429 sync_style_t Sync_Style; 430 sound_style_t Sound_Style; 431 show_axes_t Show_Axes; 432 char *Eps_File, *Temp_Dir, *Save_Dir, *Ladspa_Dir, *Peak_Env_Dir; 433 char *Listener_Font, *Axis_Label_Font, *Axis_Numbers_Font, *Tiny_Font, *Peaks_Font, *Bold_Peaks_Font; 434 char *orig_listener_font, *orig_axis_label_font, *orig_axis_numbers_font, *orig_tiny_font, *orig_peaks_font, *orig_bold_peaks_font; 435 bool With_Verbose_Cursor, With_Inset_Graph, With_Pointer_Focus, With_Smpte_Label, With_Interrupts; 436 int Enved_Filter_Order; 437 mus_float_t Eps_Left_Margin, Eps_Bottom_Margin, Eps_Size, Log_Freq_Start; 438 mus_float_t Spectro_X_Scale, Spectro_Y_Scale, Spectro_Z_Scale, Spectro_Z_Angle, Spectro_X_Angle, Spectro_Y_Angle; 439 mus_float_t Spectrum_End, Spectrum_Start; 440 mus_header_t Default_Output_Header_Type; 441 mus_sample_t Default_Output_Sample_Type; 442 int Default_Output_Chans, Default_Output_Srate; 443 int Spectro_Hop, Color_Map, Color_Map_Size, Wavelet_Type, Transform_Type; 444 int Dot_Size; 445 int Zero_Pad, Wavo_Hop, Wavo_Trace; 446 mus_long_t Transform_Size; 447 mus_fft_window_t Fft_Window; 448 graph_type_t Transform_Graph_Type, Time_Graph_Type; 449 bool Ask_Before_Overwrite, Ask_About_Unsaved_Edits, Show_Full_Duration, Show_Full_Range, Remember_Sound_State; 450 bool Save_As_Dialog_Src, Save_As_Dialog_Auto_Comment, With_Toolbar, With_Tooltips, With_Menu_Icons; 451 mus_float_t Fft_Window_Alpha, Fft_Window_Beta, Grid_Density, Initial_Beg, Initial_Dur; 452 mus_float_t Color_Scale, Color_Cutoff, Beats_Per_Minute; 453 bool Color_Inverted, Show_Mix_Waveforms; 454 int Mix_Waveform_Height, Beats_Per_Measure; 455 fft_normalize_t Transform_Normalization; 456 int Sinc_Width; 457 x_axis_style_t X_Axis_Style; 458 zoom_focus_t Zoom_Focus_Style; 459 graph_style_t Graph_Style, Region_Graph_Style; 460 bool Auto_Resize, Auto_Update; 461 int Max_Regions, Max_Transform_Peaks; 462 bool With_GL, With_Relative_Panes; 463 int Print_Length, Dac_Size, View_Files_Sort; 464 bool Dac_Combines_Channels, Show_Selection_Transform, With_Mix_Tags, Selection_Creates_Region; 465 char *Save_State_File, *Listener_Prompt, *Stdin_Prompt; 466 mus_float_t Enved_Base, Enved_Power, Auto_Update_Interval; 467 bool Enved_With_Wave, Graphs_Horizontal, With_Background_Processes, With_File_Monitor; 468 env_type_t Enved_Style; 469 int Mix_Tag_Width, Mix_Tag_Height, Mark_Tag_Height, Mark_Tag_Width; 470 enved_target_t Enved_Target; 471 bool Clipping, Show_Indices, Just_Sounds; 472 int Cursor_Size; 473 cursor_style_t Cursor_Style, Tracking_Cursor_Style; 474 bool Filter_Control_In_Db, Filter_Control_In_Hz, Show_Sonogram_Cursor; 475 int Speed_Control_Tones; 476 speed_style_t Speed_Control_Style; 477 mus_float_t Expand_Control_Length, Expand_Control_Ramp, Expand_Control_Hop, Expand_Control_Jitter; 478 mus_float_t Contrast_Control_Amp; 479 mus_float_t Reverb_Control_Feedback, Reverb_Control_Lowpass; 480 mus_float_t Reverb_Control_Decay, Cursor_Update_Interval; 481 mus_float_t Contrast_Control_Min, Contrast_Control_Max, Expand_Control_Min, Expand_Control_Max, Speed_Control_Min, Speed_Control_Max; 482 mus_float_t Amp_Control_Min, Amp_Control_Max, Reverb_Control_Scale_Min, Reverb_Control_Scale_Max; 483 mus_float_t Reverb_Control_Length_Min, Reverb_Control_Length_Max; 484 int Filter_Control_Order, Cursor_Location_Offset, Play_Arrow_Size; 485 mus_float_t Min_dB; 486 bool Show_Controls; 487 tracking_cursor_t With_Tracking_Cursor; 488 char *HTML_Dir, *HTML_Program, *Open_File_Dialog_Directory; 489 490 #if HAVE_SCHEME 491 s7_pointer show_transform_peaks_symbol, show_y_zero_symbol, show_marks_symbol, 492 show_grid_symbol, 493 fft_log_frequency_symbol, fft_log_magnitude_symbol, fft_with_phases_symbol, 494 channel_style_symbol, 495 sync_style_symbol, 496 show_axes_symbol, 497 eps_file_symbol, temp_dir_symbol, save_dir_symbol, ladspa_dir_symbol, peak_env_dir_symbol, 498 listener_font_symbol, axis_label_font_symbol, axis_numbers_font_symbol, tiny_font_symbol, peaks_font_symbol, bold_peaks_font_symbol, 499 with_verbose_cursor_symbol, with_inset_graph_symbol, with_pointer_focus_symbol, with_smpte_label_symbol, with_interrupts_symbol, 500 enved_filter_order_symbol, 501 eps_left_margin_symbol, eps_bottom_margin_symbol, eps_size_symbol, log_freq_start_symbol, 502 spectro_x_scale_symbol, spectro_y_scale_symbol, spectro_z_scale_symbol, spectro_z_angle_symbol, spectro_x_angle_symbol, spectro_y_angle_symbol, 503 spectrum_end_symbol, spectrum_start_symbol, 504 default_output_header_type_symbol, default_output_sample_type_symbol, default_output_chans_symbol, default_output_srate_symbol, 505 spectro_hop_symbol, color_map_symbol, color_map_size_symbol, wavelet_type_symbol, transform_type_symbol, 506 dot_size_symbol, 507 zero_pad_symbol, wavo_hop_symbol, wavo_trace_symbol, 508 transform_size_symbol, 509 fft_window_symbol, 510 transform_graph_type_symbol, time_graph_type_symbol, 511 ask_before_overwrite_symbol, ask_about_unsaved_edits_symbol, show_full_duration_symbol, show_full_range_symbol, remember_sound_state_symbol, 512 save_as_dialog_src_symbol, save_as_dialog_auto_comment_symbol, with_toolbar_symbol, with_tooltips_symbol, with_menu_icons_symbol, 513 fft_window_alpha_symbol, fft_window_beta_symbol, grid_density_symbol, initial_beg_symbol, initial_dur_symbol, 514 color_scale_symbol, color_cutoff_symbol, beats_per_minute_symbol, 515 color_inverted_symbol, show_mix_waveforms_symbol, 516 mix_waveform_height_symbol, beats_per_measure_symbol, 517 transform_normalization_symbol, 518 sinc_width_symbol, 519 x_axis_style_symbol, 520 zoom_focus_style_symbol, 521 graph_style_symbol, region_graph_style_symbol, 522 auto_resize_symbol, auto_update_symbol, 523 max_regions_symbol, max_transform_peaks_symbol, 524 with_gl_symbol, with_relative_panes_symbol, 525 print_length_symbol, dac_size_symbol, view_files_sort_symbol, 526 dac_combines_channels_symbol, show_selection_transform_symbol, with_mix_tags_symbol, selection_creates_region_symbol, 527 save_state_file_symbol, listener_prompt_symbol, stdin_prompt_symbol, 528 enved_base_symbol, enved_power_symbol, auto_update_interval_symbol, 529 enved_with_wave_symbol, graphs_horizontal_symbol, with_background_processes_symbol, with_file_monitor_symbol, 530 enved_style_symbol, 531 graph_cursor_symbol, mix_tag_width_symbol, mix_tag_height_symbol, mark_tag_height_symbol, mark_tag_width_symbol, 532 enved_target_symbol, 533 clipping_symbol, show_indices_symbol, just_sounds_symbol, 534 cursor_size_symbol, 535 cursor_style_symbol, tracking_cursor_style_symbol, 536 filter_control_in_db_symbol, filter_control_in_hz_symbol, show_sonogram_cursor_symbol, 537 speed_control_tones_symbol, 538 speed_control_style_symbol, 539 expand_control_length_symbol, expand_control_ramp_symbol, expand_control_hop_symbol, expand_control_jitter_symbol, 540 contrast_control_amp_symbol, 541 reverb_control_feedback_symbol, reverb_control_lowpass_symbol, 542 reverb_control_decay_symbol, cursor_update_interval_symbol, 543 filter_control_order_symbol, cursor_location_offset_symbol, play_arrow_size_symbol, 544 min_db_symbol, 545 show_controls_symbol, 546 with_tracking_cursor_symbol, 547 html_dir_symbol, html_program_symbol, open_file_dialog_directory_symbol; 548 #endif 549 int Graph_Cursor; 550 551 bool tracking; 552 Xen cursor_proc; 553 int cursor_proc_loc, listener_prompt_length; 554 Xen zoom_focus_proc; 555 int zoom_focus_proc_loc; 556 mus_float_t lin_dB; 557 char *io_error_info; 558 int deferred_regions; 559 open_requestor_t open_requestor; 560 void *open_requestor_data; 561 bool batch_mode; 562 bool jump_ok, exiting; 563 env_editor *enved; 564 oclock_t click_time; 565 bool file_monitor_ok, C_g_typed, squelch_mark_drag_info; 566 void (*snd_error_handler)(const char *error_msg, void *data); 567 void *snd_error_data; 568 void (*snd_warning_handler)(const char *warning_msg, void *data); 569 void *snd_warning_data; 570 void (*xen_error_handler)(const char *error_msg, void *data); 571 void *xen_error_data; 572 void (*snd_print_handler)(const char *msg, void *data); 573 void *snd_print_data; 574 channel_style_t update_sound_channel_style; 575 #if HAVE_GL && WITH_GL2PS 576 bool gl_printing; 577 #endif 578 Xen mus_error_hook; 579 Xen snd_error_hook; 580 Xen snd_warning_hook; 581 Xen snd_open_file_hook; 582 Xen effects_hook; 583 584 #if USE_MOTIF 585 XtAppContext mainapp; 586 Widget mainshell; 587 Widget mainpane; 588 Widget soundpane; 589 Widget soundpanebox; 590 Widget toolbar; 591 Display *mdpy; 592 xm_font_t peaks_fontlist; 593 XFontStruct *peaks_fontstruct; 594 xm_font_t bold_peaks_fontlist; 595 XFontStruct *bold_peaks_fontstruct; 596 xm_font_t listener_fontlist; 597 XFontStruct *listener_fontstruct; 598 XFontStruct *axis_label_fontstruct; 599 XFontStruct *axis_numbers_fontstruct; 600 xm_font_t tiny_fontlist; 601 XFontStruct *tiny_fontstruct; 602 603 Pixel white, black, red, yellow, green, blue, light_blue, lighter_blue; 604 Pixel data_color, selected_data_color, mark_color, graph_color, selected_graph_color, listener_color, listener_text_color; 605 Pixel basic_color, selection_color, zoom_color, position_color, highlight_color, enved_waveform_color, cursor_color; 606 Pixel text_focus_color, filter_control_waveform_color, mix_color, sash_color; 607 Pixel selected_grid_color, grid_color, axis_color; 608 Pixel orig_data_color, orig_selected_data_color, orig_mark_color, orig_mix_color; 609 Pixel orig_graph_color, orig_selected_graph_color, orig_listener_color, orig_listener_text_color, orig_cursor_color; 610 Pixel orig_basic_color, orig_selection_color, orig_zoom_color, orig_position_color, orig_highlight_color; 611 612 GC basic_gc, selected_basic_gc, combined_basic_gc; 613 GC cursor_gc, selected_cursor_gc; 614 GC selection_gc, selected_selection_gc; 615 GC erase_gc, selected_erase_gc; 616 GC mark_gc, selected_mark_gc; 617 GC mix_gc; 618 GC fltenv_basic_gc, fltenv_data_gc; 619 Widget listener_pane; 620 Widget *dialogs; 621 int num_dialogs, dialogs_size; 622 Cursor graph_cursor, wait_cursor, bounds_cursor, play_cursor, loop_play_cursor, yaxis_cursor; 623 Widget requestor_dialog; 624 #if HAVE_GL 625 #if USE_MOTIF 626 GLXContext cx; 627 #endif 628 #endif 629 Widget *mw; 630 bool axis_color_set; 631 #endif 632 633 #if USE_NO_GUI 634 int data_color, selected_data_color, mix_color, basic_color, grid_color, selected_grid_color, mark_color, axis_color; 635 int white, black, red, yellow, green, blue, light_blue; 636 int fltenv_basic_gc, fltenv_data_gc; 637 int basic_gc, selected_basic_gc, combined_basic_gc; 638 int cursor_gc, selected_cursor_gc; 639 int selection_gc, selected_selection_gc; 640 int erase_gc, selected_erase_gc; 641 int mark_gc, selected_mark_gc; 642 int mix_gc; 643 void *ignore_me; 644 int requestor_dialog; 645 bool axis_color_set; 646 int bounds_cursor, graph_cursor, play_cursor, loop_play_cursor, yaxis_cursor; 647 #endif 648 #if HAVE_SCHEME 649 s7_pointer data_color_symbol, selected_data_color_symbol, mark_color_symbol, graph_color_symbol, 650 selected_graph_color_symbol, listener_color_symbol, listener_text_color_symbol, 651 basic_color_symbol, selection_color_symbol, zoom_color_symbol, position_color_symbol, 652 highlight_color_symbol, enved_waveform_color_symbol, cursor_color_symbol, 653 text_focus_color_symbol, filter_control_waveform_color_symbol, mix_color_symbol, 654 sash_color_symbol, axis_color_symbol; 655 #endif 656 } snd_state; 657 658 extern snd_state *ss; 659 660 typedef struct { 661 int chans; 662 mus_long_t *begs; 663 chan_info **cps; 664 } sync_info; 665 666 typedef struct { 667 int len; 668 char **name; 669 } region_state; 670 671 typedef struct { 672 const char *key; 673 bool c, m, x; 674 } key_info; 675 676 677 678 /* -------- snd-io.c -------- */ 679 680 int snd_creat(const char *filename, mode_t mode); 681 FILE *snd_fopen(const char *filename, const char *modes); 682 int snd_open(const char *filename, int flags, mode_t mode); 683 684 void snd_remove(const char *name, cache_remove_t forget); 685 void snd_close(int fd, const char *name); 686 void snd_fclose(FILE *fd, const char *name); 687 io_error_t copy_file(const char *oldname, const char *newname); 688 io_error_t move_file(const char *oldfile, const char *newfile); 689 690 int snd_open_read(const char *arg); 691 int snd_reopen_write(const char *arg); 692 io_error_t snd_write_header(const char *name, mus_header_t type, int srate, int chans, mus_long_t samples, 693 mus_sample_t sample_type, const char *comment, int *loops); 694 io_error_t sndlib_error_to_snd(int sndlib_err); 695 int snd_file_open_descriptors(int tfd, const char *name, mus_sample_t sample_type, mus_long_t location, int chans, mus_header_t type); 696 snd_io *make_file_state(int fd, file_info *hdr, int chan, mus_long_t beg, int suggested_bufsize); 697 void file_buffers_forward(mus_long_t ind0, mus_long_t ind1, mus_long_t indx, snd_fd *sf, snd_data *cur_snd); 698 void file_buffers_back(mus_long_t ind0, mus_long_t ind1, mus_long_t indx, snd_fd *sf, snd_data *cur_snd); 699 700 void remember_temp(const char *filename, int chans); 701 void forget_temp(const char *filename, int chan); 702 void forget_temps(void); 703 704 snd_data *make_snd_data_file(const char *name, snd_io *io, file_info *hdr, file_delete_t temp, int ctr, int temp_chan); 705 snd_data *copy_snd_data(snd_data *sd, mus_long_t beg, int bufsize); 706 snd_data *free_snd_data(snd_data *sf); 707 snd_data *make_snd_data_buffer(mus_float_t *data, int len, int ctr); 708 snd_data *make_snd_data_buffer_for_simple_channel(int len); 709 int open_temp_file(const char *ofile, int chans, file_info *hdr, io_error_t *err); 710 io_error_t close_temp_file(const char *filename, int ofd, mus_header_t type, mus_long_t bytes); 711 712 void set_up_snd_io(chan_info *cp, int i, int fd, const char *filename, file_info *hdr, bool post_close); 713 mus_long_t io_beg(snd_io *io); 714 mus_long_t io_end(snd_io *io); 715 716 717 718 /* -------- snd-help.c -------- */ 719 720 void about_snd_help(void); 721 void controls_help(void); 722 void fft_help(void); 723 void find_help(void); 724 void undo_help(void); 725 void sync_help(void); 726 void debug_help(void); 727 void env_help(void); 728 void marks_help(void); 729 void mix_help(void); 730 void sound_files_help(void); 731 void init_file_help(void); 732 void region_help(void); 733 void selection_help(void); 734 void colors_help(void); 735 char *version_info(void); 736 void transform_dialog_help(void); 737 void color_orientation_dialog_help(void); 738 void envelope_editor_dialog_help(void); 739 void region_dialog_help(void); 740 void raw_data_dialog_help(const char *info); 741 void new_file_dialog_help(void); 742 void edit_header_dialog_help(void); 743 void print_dialog_help(void); 744 void view_files_dialog_help(void); 745 void mix_dialog_help(void); 746 void find_dialog_help(void); 747 void open_file_dialog_help(void); 748 void mix_file_dialog_help(void); 749 void insert_file_dialog_help(void); 750 void save_as_dialog_help(void); 751 char* word_wrap(const char *text, int widget_len); 752 void g_init_help(void); 753 Xen g_snd_help_with_search(Xen text, int widget_wid, bool search); 754 Xen g_snd_help(Xen text, int widget_wid); 755 const char *snd_url(const char *name); 756 void set_html_dir(char *new_dir); 757 void key_help(void); 758 void play_help(void); 759 void save_help(void); 760 void reverb_help(void); 761 void resample_help(void); 762 void filter_help(void); 763 void insert_help(void); 764 void delete_help(void); 765 void name_to_html_viewer(const char *red_text); 766 void url_to_html_viewer(const char *url); 767 bool snd_topic_help(const char *topic); 768 const char **help_name_to_xrefs(const char *name); 769 770 771 772 /* -------- snd-menu.c -------- */ 773 774 void reflect_file_revert_in_label(snd_info *sp); 775 void set_menu_label(widget_t w, const char *label); 776 void g_init_menu(void); 777 778 779 /* -------- snd-main.c -------- */ 780 781 const char *save_options_in_prefs(void); 782 void open_save_sound_block(snd_info *sp, FILE *fd, bool with_nth); 783 void close_save_sound_block(FILE *fd, bool need_f); 784 void save_sound_state(snd_info *sp, void *ptr); 785 bool snd_exit_cleanly(bool force_exit); 786 void sound_not_current(snd_info *sp); 787 void save_state(const char *save_state_name); 788 void global_control_panel_state(void); 789 void global_fft_state(void); 790 int handle_next_startup_arg(int auto_open_ctr, char **auto_open_file_names, bool with_title, int args); 791 792 void g_init_main(void); 793 794 795 /* -------- snd-completion.c -------- */ 796 797 char *expression_completer(widget_t w, const char *text, void *data); 798 void preload_best_completions(void); 799 void save_completion_choice(const char *selection); 800 int find_best_completion(char **choices, int num_choices); 801 int add_completer_func(char *(*func)(widget_t w, const char *text, void *context), void *data); 802 int add_completer_func_with_multicompleter(char *(*func)(widget_t w, const char *text, void *context), void *data, void (*multi_func)(widget_t w, void *data)); 803 int get_completion_matches(void); 804 void set_completion_matches(int matches); 805 void set_save_completions(bool save); 806 void add_possible_completion(const char *text); 807 int get_possible_completions_size(void); 808 char **get_possible_completions(void); 809 void clear_possible_completions(void); 810 void handle_completions(widget_t w, int completer); 811 char *complete_text(widget_t w, const char *text, int func); 812 char *filename_completer(widget_t w, const char *text, void *data); 813 char *sound_filename_completer(widget_t w, const char *text, void *data); 814 char *srate_completer(widget_t w, const char *text, void *data); 815 char *list_completer(widget_t w, const char *text, void *data); 816 char *complete_listener_text(char *old_text, int end, bool *try_completion, char **to_file_text); 817 void add_srate_to_completion_list(int srate); 818 char *direct_completions(const char *str); 819 #if HAVE_FORTH || HAVE_RUBY 820 void call_read_hook_or_eval(const char *text); 821 #endif 822 823 824 825 /* -------- snd-print.c -------- */ 826 827 void ps_set_grf_points(double x, int j, mus_float_t ymin, mus_float_t ymax); 828 void ps_set_grf_point(double x, int j, mus_float_t y); 829 void ps_allocate_grf_points(void); 830 void ps_draw_grf_points(axis_info *ap, int j, mus_float_t y0, graph_style_t graph_style, int dot_size); 831 void ps_draw_both_grf_points(axis_info *ap, int j, graph_style_t graph_style, int dot_size); 832 void ps_draw_sono_rectangle(axis_info *ap, int color, mus_float_t x, mus_float_t y, mus_float_t width, mus_float_t height); 833 void ps_reset_color(void); 834 void ps_bg(axis_info *ap, graphics_context *ax); 835 void ps_fg(chan_info *cp, graphics_context *ax); 836 void ps_draw_line(axis_info *ap, int x0, int y0, int x1, int y1); 837 void ps_draw_spectro_line(axis_info *ap, int color, mus_float_t x0, mus_float_t y0, mus_float_t x1, mus_float_t y1); 838 void ps_fill_rectangle(axis_info *ap, int x0, int y0, int width, int height); 839 void ps_draw_string(axis_info *ap, int x0, int y0, const char *str); 840 void ps_set_number_font(void); 841 void ps_set_label_font(void); 842 void ps_set_bold_peak_numbers_font(void); 843 void ps_set_peak_numbers_font(void); 844 void ps_set_tiny_numbers_font(void); 845 bool snd_print(const char *output); 846 void print_enved(const char *output, int y0); 847 void g_init_print(void); 848 849 850 851 /* -------- snd-marks.c -------- */ 852 853 int mark_sync_max(void); 854 void set_mark_sync(mark *m, int val); 855 int mark_to_int(mark *m); 856 int mark_sync(mark *m); 857 mus_long_t mark_sample(mark *m); 858 void marks_off(chan_info *cp); 859 mark *hit_mark(chan_info *cp, int x, int y); 860 void set_mark_control(chan_info *cp, mark *mp, int key_state); 861 mark *hit_mark_triangle(chan_info *cp, int x, int y); 862 void move_mark(chan_info *cp, mark *mp, int x); 863 void play_syncd_mark(chan_info *cp, mark *mp); 864 void finish_moving_mark(chan_info *cp, mark *m); 865 mark *add_mark(mus_long_t samp, const char *name, chan_info *cp); 866 bool delete_mark_samp(mus_long_t samp, chan_info *cp); 867 void free_mark_list(ed_list *ed); 868 bool goto_mark(chan_info *cp, int count); 869 mark *active_mark(chan_info *cp); 870 mus_long_t mark_beg(chan_info *cp); 871 void display_channel_marks(chan_info *cp); 872 void ripple_marks(chan_info *cp, mus_long_t beg, mus_long_t change); 873 bool mark_define_region(chan_info *cp, int count); 874 void save_mark_list(FILE *fd, chan_info *cp, bool all_chans); 875 void reverse_marks(chan_info *cp, mus_long_t beg, mus_long_t dur); 876 void src_marks(chan_info *cp, mus_float_t ratio, mus_long_t old_samps, mus_long_t new_samps, mus_long_t beg, bool over_selection); 877 void reset_marks(chan_info *cp, int cur_marks, mus_long_t *samps, mus_long_t end, mus_long_t extension, bool over_selection); 878 void ripple_trailing_marks(chan_info *cp, mus_long_t beg, mus_long_t old_len, mus_long_t new_len); 879 void swap_marks(chan_info *cp0, chan_info *cp1); 880 void g_init_marks(void); 881 void *sound_store_marks(snd_info *sp); 882 void sound_restore_marks(snd_info *sp, void *marks); 883 mus_long_t mark_id_to_sample(int id); 884 885 Xen new_xen_mark(int n); 886 bool xen_is_mark(Xen obj); 887 int xen_mark_to_int(Xen n); 888 #define Xen_mark_to_C_int(n) xen_mark_to_int(n) 889 Xen g_mark_sync(Xen mark_n); 890 Xen g_set_mark_sync(Xen mark_n, Xen sync_n); 891 892 893 894 /* -------- snd-data.c -------- */ 895 896 chan_info *make_chan_info(chan_info *cip, int chan, snd_info *sound); 897 snd_info *make_snd_info(snd_info *sip, const char *filename, file_info *hdr, int snd_slot, read_only_t read_only); 898 snd_info *make_basic_snd_info(int chans); 899 void initialize_control_panel(snd_info *sp); 900 void free_snd_info(snd_info *sp); 901 snd_info *completely_free_snd_info(snd_info *sp); 902 void for_each_chan_with_int(void (*func)(chan_info *ncp, int val), int value); 903 void for_each_chan_with_mus_long_t(void (*func)(chan_info *ncp, mus_long_t val), mus_long_t value); 904 void for_each_chan_with_bool(void (*func)(chan_info *ncp, bool val), bool value); 905 void for_each_chan_with_float(void (*func)(chan_info *ncp, mus_float_t val), mus_float_t value); 906 void for_each_chan(void (*func)(chan_info *ncp)); 907 void for_each_normal_chan(void (*func)(chan_info *ncp)); 908 void for_each_normal_chan_with_void(void (*func)(chan_info *ncp, void *ptr), void *userptr); 909 void for_each_normal_chan_with_int(void (*func)(chan_info *ncp, int val), int value); 910 void for_each_normal_chan_with_refint(void (*func)(chan_info *ncp, int *val), int *value); 911 void for_each_sound_chan(snd_info *sp, void (*func)(chan_info *ncp)); 912 void for_each_sound_chan_with_int(snd_info *sp, void (*func)(chan_info *ncp, int val1), int value); 913 void for_each_sound(void (*func)(snd_info *usp)); 914 void for_each_sound_with_void(void (*func)(snd_info *usp, void *ptr), void *userptr); 915 void for_each_separate_chan(void (*func)(chan_info *ncp)); 916 bool map_over_sound_chans(snd_info *sp, bool (*func)(chan_info *ncp)); 917 bool snd_ok(snd_info *sp); 918 int active_channels(virtual_channels_t count_virtual_channels); 919 int syncd_channels(int sync); 920 int find_free_sound_slot(int desired_chans); 921 int find_free_sound_slot_for_channel_display(void); 922 snd_info *selected_sound(void); 923 chan_info *selected_channel(void); 924 chan_info *color_selected_channel(snd_info *sp); 925 snd_info *any_selected_sound(void); 926 chan_info *any_selected_channel(snd_info *sp); 927 void select_channel(snd_info *sp, int chan); 928 chan_info *current_channel(void); 929 sync_info *free_sync_info(sync_info *si); 930 sync_info *snd_sync(int sync); 931 sync_info *sync_to_chan(chan_info *cp); 932 sync_info *make_simple_sync(chan_info *cp, mus_long_t beg); 933 snd_info *find_sound(const char *name, int nth); 934 void mix_display_during_drag(int mix_id, mus_long_t drag_beg, mus_long_t drag_end); 935 void g_init_data(void); 936 937 938 939 /* -------- snd-edits.c -------- */ 940 941 mus_float_t channel_maxamp(chan_info *cp, int edpos); 942 mus_long_t channel_maxamp_position(chan_info *cp, int edpos); 943 mus_float_t channel_maxamp_and_position(chan_info *cp, int edpos, mus_long_t *maxpos); 944 ed_list *initial_ed_list(mus_long_t beg, mus_long_t end); 945 snd_info *sound_is_silence(snd_info *sp); 946 mus_long_t edit_changes_begin_at(chan_info *cp, int edpos); 947 mus_long_t edit_changes_end_at(chan_info *cp, int edpos); 948 bool has_unsaved_edits(snd_info *sp); 949 char *run_save_state_hook(const char *filename); 950 void edit_history_to_file(FILE *fd, chan_info *cp, bool with_save_state_hook); 951 char *edit_to_string(chan_info *cp, int edit); 952 void free_edit_list(chan_info *cp); 953 void backup_edit_list(chan_info *cp); 954 void as_one_edit(chan_info *cp, int one_edit); 955 void free_sound_list(chan_info *cp); 956 void after_edit(chan_info *cp); 957 bool extend_with_zeros(chan_info *cp, mus_long_t beg, mus_long_t num, int edpos, const char *origin); 958 bool insert_samples(mus_long_t beg, mus_long_t num, mus_float_t *vals, chan_info *cp, const char *origin, int edpos); 959 bool file_insert_samples(mus_long_t beg, mus_long_t num, const char *tempfile, chan_info *cp, int chan, 960 file_delete_t auto_delete, const char *origin, int edpos); 961 bool insert_complete_file_at_cursor(snd_info *sp, const char *filename); 962 bool insert_complete_file(snd_info *sp, const char *str, mus_long_t chan_beg, file_delete_t auto_delete); 963 bool delete_samples(mus_long_t beg, mus_long_t num, chan_info *cp, int edpos); 964 bool change_samples(mus_long_t beg, mus_long_t num, mus_float_t *vals, chan_info *cp, const char *origin, int edpos, mus_float_t mx); 965 bool file_change_samples(mus_long_t beg, mus_long_t num, const char *tempfile, chan_info *cp, int chan, file_delete_t auto_delete, const char *origin, int edpos); 966 bool file_override_samples(mus_long_t num, const char *tempfile, chan_info *cp, int chan, file_delete_t auto_delete, const char *origin); 967 mus_float_t chn_sample(mus_long_t samp, chan_info *cp, int pos); 968 void check_saved_temp_file(const char *type, Xen filename, Xen date_and_length); 969 bool is_editable(chan_info *cp); 970 file_delete_t xen_to_file_delete_t(Xen auto_delete, const char *caller); 971 snd_fd *free_snd_fd(snd_fd *sf); 972 char *sampler_to_string(snd_fd *fd); 973 bool is_sampler(Xen obj); 974 snd_fd *xen_to_sampler(Xen obj); 975 snd_fd *free_snd_fd_almost(snd_fd *sf); 976 bool scale_channel(chan_info *cp, mus_float_t scaler, mus_long_t beg, mus_long_t num, int pos, bool in_as_one_edit); 977 bool scale_channel_with_origin(chan_info *cp, mus_float_t scl, mus_long_t beg, mus_long_t num, int pos, bool in_as_one_edit, const char *origin); 978 bool ramp_channel(chan_info *cp, double start, double incr, mus_long_t beg, mus_long_t num, int pos, bool in_as_one_edit); 979 bool xramp_channel(chan_info *cp, double start, double incr, double scaler, double offset, 980 mus_long_t beg, mus_long_t num, int pos, bool in_as_one_edit, mus_any *e, int xramp_seg_loc); 981 snd_fd *init_sample_read(mus_long_t samp, chan_info *cp, read_direction_t direction); 982 snd_fd *init_sample_read_any(mus_long_t samp, chan_info *cp, read_direction_t direction, int edit_position); 983 snd_fd *init_sample_read_any_with_bufsize(mus_long_t samp, chan_info *cp, read_direction_t direction, int edit_position, int bufsize); 984 void read_sample_change_direction(snd_fd *sf, read_direction_t dir); 985 void sampler_set_safe(snd_fd *sf, mus_long_t dur); 986 bool unrampable(chan_info *cp, mus_long_t beg, mus_long_t dur, int pos, bool is_xramp); 987 bool sound_fragments_in_use(chan_info *cp, int pos); 988 #define read_sample(Sf) (*((Sf)->runf))(Sf) 989 mus_float_t channel_local_maxamp(chan_info *cp, mus_long_t beg, mus_long_t num, int edpos, mus_long_t *maxpos); 990 bool undo_edit_with_sync(chan_info *cp, int count); 991 bool redo_edit_with_sync(chan_info *cp, int count); 992 bool undo_edit(chan_info *cp, int count); 993 bool redo_edit(chan_info *cp, int count); 994 io_error_t save_channel_edits(chan_info *cp, const char *ofile, int pos); 995 io_error_t channel_to_file_with_settings(chan_info *cp, const char *new_name, int srate, 996 mus_sample_t samp_type, mus_header_t hd_type, const char *comment, int pos); 997 io_error_t save_edits(snd_info *sp); 998 io_error_t save_edits_without_asking(snd_info *sp); 999 io_error_t save_edits_and_update_display(snd_info *sp); 1000 io_error_t save_edits_without_display(snd_info *sp, const char *new_name, mus_header_t type, 1001 mus_sample_t sample_type, int srate, const char *comment, int pos); 1002 void revert_edits(chan_info *cp); 1003 mus_long_t current_location(snd_fd *sf); 1004 void g_init_edits(void); 1005 void set_ed_maxamp(chan_info *cp, int edpos, mus_float_t val); 1006 mus_float_t ed_maxamp(chan_info *cp, int edpos); 1007 void set_ed_maxamp_position(chan_info *cp, int edpos, mus_long_t val); 1008 mus_long_t ed_maxamp_position(chan_info *cp, int edpos); 1009 void set_ed_selection_maxamp(chan_info *cp, mus_float_t val); 1010 mus_float_t ed_selection_maxamp(chan_info *cp); 1011 void set_ed_selection_maxamp_position(chan_info *cp, mus_long_t val); 1012 mus_long_t ed_selection_maxamp_position(chan_info *cp); 1013 void copy_then_swap_channels(chan_info *cp0, chan_info *cp1, int pos0, int pos1); 1014 void reflect_file_change_in_label(chan_info *cp); 1015 void reflect_file_change_in_title(void); 1016 int mix_buffer_with_tag(chan_info *cp, mus_float_t *data, mus_long_t beg, mus_long_t num, const char *origin); 1017 1018 int mix_file_with_tag(chan_info *cp, const char *filename, int chan, mus_long_t beg, file_delete_t auto_delete, const char *origin); 1019 void unmix(chan_info *cp, mix_state *ms); 1020 void remix(chan_info *cp, mix_state *ms); 1021 snd_fd *make_virtual_mix_reader(chan_info *cp, mus_long_t beg, mus_long_t len, int index, mus_float_t scl, read_direction_t direction); 1022 bool virtual_mix_ok(chan_info *cp, int edpos); 1023 bool begin_mix_op(chan_info *cp, mus_long_t old_beg, mus_long_t old_len, mus_long_t new_beg, mus_long_t new_len, int edpos, const char *caller); 1024 void end_mix_op(chan_info *cp, mus_long_t old_beg, mus_long_t old_len); 1025 void prepare_sound_list(chan_info *cp); 1026 Xen g_sampler_file_name(Xen obj); 1027 char *edit_list_to_function(chan_info *cp, int start_pos, int end_pos); 1028 vct *samples_to_vct(mus_long_t beg, mus_long_t len, chan_info *cp, int pos, mus_float_t *buf, snd_fd *reader); 1029 vct *samples_to_vct_with_reader(mus_long_t len, mus_float_t *buf, snd_fd *reader); 1030 1031 1032 1033 /* -------- snd-fft.c -------- */ 1034 1035 int find_and_sort_transform_peaks(mus_float_t *buf, fft_peak *found, int num_peaks, mus_long_t losamp, mus_long_t hisamp, mus_float_t samps_per_pixel, mus_float_t fft_scale); 1036 int find_and_sort_peaks(mus_float_t *buf, fft_peak *found, int num_peaks, mus_long_t losamp, mus_long_t hisamp); 1037 fft_info *free_fft_info(fft_info *fp); 1038 void free_sonogram_fft_state(void *ptr); 1039 bool fft_window_beta_in_use(mus_fft_window_t win); 1040 bool fft_window_alpha_in_use(mus_fft_window_t win); 1041 void free_sono_info(chan_info *cp); 1042 void sono_update(chan_info *cp); 1043 void c_convolve(const char *fname, mus_float_t amp, int filec, mus_long_t filehdr, int filterc, mus_long_t filterhdr, mus_long_t filtersize, 1044 mus_long_t fftsize, int filter_chans, int filter_chan, mus_long_t data_size, snd_info *gsp); 1045 void *make_sonogram_state(chan_info *cp, bool force_recalc); 1046 void single_fft(chan_info *cp, bool update_display, bool force_recalc); 1047 idle_func_t sonogram_in_slices(void *sono); 1048 void clear_transform_edit_ctrs(chan_info *cp); 1049 void g_init_fft(void); 1050 mus_float_t fft_beta_max(mus_fft_window_t win); 1051 void cp_free_fft_state(chan_info *cp); 1052 void set_fft_info_xlabel(chan_info *cp, const char *new_label); 1053 void fourier_spectrum(snd_fd *sf, mus_float_t *data, mus_long_t fft_size, mus_long_t data_len, mus_float_t *window, chan_info *cp); 1054 const char *wavelet_name(int i); 1055 const char **wavelet_names(void); 1056 void set_log_freq_start(mus_float_t base); 1057 1058 const char *transform_name(int type); 1059 const char *transform_program_name(int type); 1060 int transform_position_to_type(int pos); 1061 int transform_type_to_position(int type); 1062 int max_transform_type(void); 1063 void set_transform_position(int i, int j); 1064 bool is_transform(int type); 1065 1066 Xen new_xen_transform(int n); 1067 bool xen_is_transform(Xen obj); 1068 int xen_transform_to_int(Xen n); 1069 #define C_int_to_Xen_transform(Val) new_xen_transform(Val) 1070 #define Xen_transform_to_C_int(n) xen_transform_to_int(n) 1071 1072 1073 1074 /* -------- snd-xen.c -------- */ 1075 1076 const char *io_error_name(io_error_t err); 1077 #ifdef __GNUC__ 1078 void snd_error(const char *format, ...) __attribute__ ((format (printf, 1, 2))); 1079 void snd_warning(const char *format, ...) __attribute__ ((format (printf, 1, 2))); 1080 #else 1081 void snd_error(const char *format, ...); 1082 void snd_warning(const char *format, ...); 1083 #endif 1084 void snd_error_without_format(const char *msg); 1085 void snd_warning_without_format(const char *msg); 1086 void redirect_snd_error_to(void (*handler)(const char *error_msg, void *ufd), void *data); 1087 void redirect_snd_warning_to(void (*handler)(const char *warning_msg, void *ufd), void *data); 1088 1089 char *stdin_check_for_full_expression(const char *newstr); 1090 void stdin_free_str(void); 1091 1092 void redirect_xen_error_to(void (*handler)(const char *msg, void *ufd), void *data); 1093 void redirect_errors_to(void (*handler)(const char *msg, void *ufd), void *data); 1094 void redirect_everything_to(void (*handler)(const char *msg, void *ufd), void *data); 1095 Xen snd_catch_any(Xen_catch_t body, void *body_data, const char *caller); 1096 Xen snd_no_such_file_error(const char *caller, Xen filename); 1097 Xen snd_no_such_channel_error(const char *caller, Xen snd, Xen chn); 1098 Xen snd_bad_arity_error(const char *caller, Xen errstr, Xen proc); 1099 Xen snd_no_active_selection_error(const char *caller); 1100 void g_xen_initialize(void); 1101 Xen eval_str_wrapper(void *data); 1102 Xen g_c_make_sampler(snd_fd *fd); 1103 char *procedure_ok(Xen proc, int args, const char *caller, const char *arg_name, int argn); 1104 bool procedure_arity_ok(Xen proc, int args); 1105 int snd_protect(Xen obj); 1106 void snd_unprotect_at(int loc); 1107 1108 Xen run_or_hook(Xen hook, Xen args, const char *caller); 1109 Xen run_progn_hook(Xen hook, Xen args, const char *caller); 1110 Xen run_hook(Xen hook, Xen args, const char *caller); 1111 void check_features_list(const char *features); 1112 #if (!USE_NO_GUI) 1113 mus_float_t check_color_range(const char *caller, Xen val); 1114 #endif 1115 void set_basic_color(color_t color); 1116 void set_highlight_color(color_t color); 1117 void set_position_color(color_t color); 1118 void set_zoom_color(color_t color); 1119 void set_data_color(color_t color); 1120 void set_selected_data_color(color_t color); 1121 void set_graph_color(color_t color); 1122 void set_selected_graph_color(color_t color); 1123 mus_float_t string_to_mus_float_t(const char *str, mus_float_t lo, const char *file_name); 1124 int string_to_int(const char *str, int lo, const char *field_name); 1125 mus_long_t string_to_mus_long_t(const char *str, mus_long_t lo, const char *field_name); 1126 char *output_comment(file_info *hdr); 1127 void snd_load_init_file(bool nog, bool noi); 1128 void snd_load_file(const char *filename); 1129 void snd_display_result(const char *str, const char *endstr); 1130 void snd_report_result(Xen result, const char *buf); 1131 void snd_report_listener_result(Xen form); 1132 void snd_eval_stdin_str(const char *buf); 1133 void clear_stdin(void); 1134 #if HAVE_RUBY 1135 void snd_rb_raise(Xen type, Xen info); 1136 #endif 1137 bool is_source_file(const char *name); 1138 void save_added_source_file_extensions(FILE *fd); 1139 1140 1141 1142 /* -------- snd-select.c -------- */ 1143 1144 bool selection_is_active(void); 1145 bool selection_is_active_in_channel(chan_info *cp); 1146 bool selection_is_visible_in_channel(chan_info *cp); 1147 mus_long_t selection_beg(chan_info *cp); 1148 mus_long_t selection_end(chan_info *cp); 1149 mus_long_t selection_len(void); 1150 int selection_chans(void); 1151 int selection_srate(void); 1152 mus_float_t selection_maxamp(chan_info *cp); 1153 void deactivate_selection(void); 1154 void reactivate_selection(chan_info *cp, mus_long_t beg, mus_long_t end); 1155 void ripple_selection(ed_list *new_ed, mus_long_t beg, mus_long_t num); 1156 sync_info *selection_sync(void); 1157 void start_selection_creation(chan_info *cp, mus_long_t samp); 1158 void update_possible_selection_in_progress(mus_long_t samp); 1159 void restart_selection_creation(chan_info *cp, bool right); 1160 bool hit_selection_triangle(chan_info *cp, int x, int y); 1161 bool hit_selection_loop_triangle(chan_info *cp, int x, int y); 1162 void cp_delete_selection(chan_info *cp); 1163 1164 int make_region_from_selection(void); 1165 void display_selection(chan_info *cp); 1166 bool delete_selection(cut_selection_regraph_t regraph); 1167 void move_selection(chan_info *cp, int x); 1168 void finish_selection_creation(void); 1169 int select_all(chan_info *cp); 1170 io_error_t save_selection(const char *ofile, int srate, mus_sample_t samp_type, mus_header_t head_type, const char *comment, int chan); 1171 bool selection_creation_in_progress(void); 1172 void add_selection_or_region(int reg, chan_info *cp); 1173 void insert_selection_from_menu(void); 1174 void cancel_selection_watch(void); 1175 void show_selection(void); 1176 bool xen_is_selection(Xen obj); 1177 Xen g_selection_chans(void); 1178 Xen g_selection_srate(void); 1179 Xen g_selection_maxamp(Xen snd, Xen chn); 1180 Xen g_selection_framples(Xen snd, Xen chn); 1181 1182 void g_init_selection(void); 1183 1184 1185 /* -------- snd-region.c -------- */ 1186 1187 void allocate_regions(int numreg); 1188 bool region_ok(int n); 1189 int region_chans(int n); 1190 int region_srate(int n); 1191 const char *region_file_name(int n); 1192 mus_long_t region_len(int n); 1193 mus_float_t region_maxamp(int n); 1194 int region_list_position_to_id(int n); 1195 int region_id_to_list_position(int id); 1196 file_info *fixup_region_data(chan_info *cp, int chan, int n); 1197 region_state *region_report(void); 1198 void free_region_state(region_state *r); 1199 int remove_region_from_list(int pos); 1200 io_error_t paste_region(int n, chan_info *cp); 1201 io_error_t add_region(int n, chan_info *cp); 1202 int define_region(sync_info *si, mus_long_t *ends); 1203 snd_fd *init_region_read(mus_long_t beg, int n, int chan, read_direction_t direction); 1204 void cleanup_region_temp_files(void); 1205 int snd_regions(void); 1206 void save_regions(FILE *fd); 1207 io_error_t save_region(int rg, const char *name, mus_sample_t samp_type, mus_header_t head_type, const char *comment); 1208 void region_edit(int reg); 1209 void clear_region_backpointer(snd_info *sp); 1210 void save_region_backpointer(snd_info *sp); 1211 void sequester_deferred_regions(chan_info *cp, int edit_top); 1212 void g_init_regions(void); 1213 void for_each_region_chan_with_refint(void (*func)(chan_info *ncp, int *val), int *value); 1214 mus_long_t region_current_location(snd_fd *fd); 1215 char *region_description(int rg); 1216 1217 Xen new_xen_region(int n); 1218 bool xen_is_region(Xen obj); 1219 int xen_region_to_int(Xen n); 1220 #define C_int_to_Xen_region(Val) new_xen_region(Val) 1221 #define Xen_region_to_C_int(n) xen_region_to_int(n) 1222 Xen g_region_srate(Xen n); 1223 Xen g_region_chans(Xen n); 1224 Xen g_region_framples(Xen n, Xen chan); 1225 Xen g_region_maxamp(Xen n); 1226 Xen g_play_region(Xen n, play_process_t back, Xen stop_proc); 1227 Xen g_region_to_vct(Xen reg_n, Xen beg_n, Xen num, Xen chn_n, Xen v); 1228 1229 1230 1231 /* -------- snd-env.c -------- */ 1232 1233 env *copy_env(env *e); 1234 env *free_env(env *e); 1235 char *env_to_string(env *e); 1236 env *make_envelope_with_offset_and_scaler(mus_float_t *env_buffer, int len, mus_float_t offset, mus_float_t scaler); 1237 env *default_env(mus_float_t x1, mus_float_t y); 1238 bool is_default_env(env *e); 1239 bool envs_equal(env *e1, env *e2); 1240 env_editor *new_env_editor(void); 1241 void env_editor_button_motion_with_xy(env_editor *edp, int evx, int evy, oclock_t motion_time, env *e, mus_float_t *new_x, mus_float_t *new_y); 1242 void env_editor_button_motion(env_editor *edp, int evx, int evy, oclock_t motion_time, env *e); 1243 bool env_editor_button_press(env_editor *edp, int evx, int evy, oclock_t time, env *e); 1244 void env_editor_button_release(env_editor *edp, env *e); 1245 double env_editor_ungrf_y_dB(env_editor *edp, int y); 1246 void init_env_axes(axis_info *ap, const char *name, int x_offset, int ey0, int width, int height, 1247 mus_float_t xmin, mus_float_t xmax, mus_float_t ymin, mus_float_t ymax, printing_t printing); 1248 void env_editor_display_env(env_editor *edp, env *e, graphics_context *ax, const char *name, 1249 int x0, int y0, int width, int height, printing_t printing); 1250 void view_envs(int env_window_width, int env_window_height, printing_t printing); 1251 int hit_env(int xe, int ye, int env_window_width, int env_window_height); 1252 void prepare_enved_edit(env *new_env); 1253 void redo_env_edit(void); 1254 void undo_env_edit(void); 1255 void revert_env_edit(void); 1256 int enved_all_envs_top(void); 1257 char *enved_all_names(int n); 1258 void set_enved_env_list_top(int n); 1259 /* env *enved_all_envs(int pos); */ 1260 void alert_envelope_editor(const char *name, env *val); 1261 void enved_show_background_waveform(axis_info *ap, axis_info *gray_ap, bool apply_to_selection, bool show_fft, printing_t printing); 1262 void save_envelope_editor_state(FILE *fd); 1263 char *env_name_completer(widget_t w, const char *text, void *data); 1264 env *enved_next_env(void); 1265 env *string_to_env(const char *str); 1266 void add_or_edit_symbol(const char *name, env *val); 1267 env* name_to_env(const char *str); 1268 env *position_to_env(int pos); 1269 /* void delete_envelope(const char *name); */ 1270 enved_fft *free_enved_fft(enved_fft *ef); 1271 void reflect_enved_fft_change(chan_info *cp); 1272 1273 Xen env_to_xen(env *e); 1274 env *xen_to_env(Xen res); 1275 env *get_env(Xen e, const char *origin); 1276 void g_init_env(void); 1277 1278 1279 /* -------- snd-dac.c -------- */ 1280 1281 void cleanup_dac(void); 1282 void stop_playing_sound(snd_info *sp, play_stop_t reason); 1283 void stop_playing_sound_without_hook(snd_info *sp, play_stop_t reason); 1284 void stop_playing_sound_no_toggle(snd_info *sp, play_stop_t reason); 1285 void stop_playing_all_sounds(play_stop_t reason); 1286 void stop_playing_region(int n, play_stop_t reason); 1287 void play_region(int n, play_process_t background); 1288 void play_region_1(int region, play_process_t background, Xen stop_proc); 1289 void play_channel(chan_info *cp, mus_long_t start, mus_long_t end); 1290 void play_channel_with_sync(chan_info *cp, mus_long_t start, mus_long_t end); 1291 void play_sound(snd_info *sp, mus_long_t start, mus_long_t end); 1292 void play_channels(chan_info **cps, int chans, mus_long_t *starts, mus_long_t *ur_ends, 1293 play_process_t background, Xen edpos, bool selection, const char *caller, int arg_pos); 1294 void play_selection(play_process_t background); 1295 void loop_play_selection(void); 1296 bool add_mix_to_play_list(mix_state *ms, chan_info *cp, mus_long_t beg_within_mix, bool start_playing); 1297 void toggle_dac_pausing(void); /* snd-dac.c */ 1298 bool play_in_progress(void); 1299 void initialize_apply(snd_info *sp, int chans, mus_long_t beg, mus_long_t framples); 1300 void finalize_apply(snd_info *sp); 1301 int run_apply(int ofd); 1302 mus_float_t *sample_linear_env(env *e, int order); 1303 1304 void g_init_dac(void); 1305 void clear_players(void); 1306 1307 bool xen_is_player(Xen obj); 1308 #define is_player_sound(Sp) ((Sp) && ((Sp)->index < 0)) 1309 snd_info *get_player_sound(Xen player); 1310 Xen no_such_player_error(const char *caller, Xen player); 1311 1312 void dac_set_expand(snd_info *sp, mus_float_t newval); 1313 void dac_set_expand_length(snd_info *sp, mus_float_t newval); 1314 void dac_set_expand_ramp(snd_info *sp, mus_float_t newval); 1315 void dac_set_expand_hop(snd_info *sp, mus_float_t newval); 1316 void dac_set_contrast_amp(snd_info *sp, mus_float_t newval); 1317 void dac_set_reverb_feedback(snd_info *sp, mus_float_t newval); 1318 void dac_set_reverb_lowpass(snd_info *sp, mus_float_t newval); 1319 1320 1321 1322 /* -------- snd-chn.c -------- */ 1323 1324 bool is_graph_style(int grf); 1325 chan_info *get_cp(Xen snd_n, Xen chn_n, const char *caller); 1326 snd_info *make_simple_channel_display(int srate, int initial_length, fw_button_t with_arrows, graph_style_t grf_style, widget_t container, bool with_events); 1327 axis_info *lisp_info_axis(chan_info *cp); 1328 void free_lisp_info(chan_info *cp); 1329 void zx_incremented(chan_info *cp, double amount); 1330 kbd_cursor_t cursor_decision(chan_info *cp); 1331 void reset_x_display(chan_info *cp, double sx, double zx); 1332 void set_x_axis_x0x1(chan_info *cp, double x0, double x1); 1333 void cursor_move(chan_info *cp, mus_long_t samps); 1334 void cursor_moveto_without_verbosity(chan_info *cp, mus_long_t samp); 1335 void cursor_moveto_with_window(chan_info *cp, mus_long_t samp, mus_long_t left_samp, mus_long_t window_size); 1336 void sync_cursors(chan_info *cp, mus_long_t samp); 1337 void set_wavo_trace(int uval); 1338 void set_dot_size(int val); 1339 chan_info *virtual_selected_channel(chan_info *cp); 1340 void handle_cursor(chan_info *cp, kbd_cursor_t redisplay); 1341 void handle_cursor_with_sync(chan_info *cp, kbd_cursor_t redisplay); 1342 void chans_field(fcp_t field, mus_float_t val); 1343 void in_set_transform_graph_type(graph_type_t val); 1344 void in_set_fft_window(mus_fft_window_t val); 1345 void set_max_transform_peaks(int val); 1346 void combine_sound(snd_info *sp); 1347 void separate_sound(snd_info *sp); 1348 void superimpose_sound(snd_info *sp); 1349 void set_sound_channel_style(snd_info *sp, channel_style_t val); 1350 void set_chan_fft_in_progress(chan_info *cp, idle_t fp); 1351 void stop_fft_in_progress(chan_info *cp); 1352 void goto_graph(chan_info *cp); 1353 void start_peak_env(chan_info *cp); 1354 void stop_peak_env(chan_info *cp); 1355 void write_transform_peaks(FILE *fd, chan_info *ucp); 1356 bool chan_fft_in_progress(chan_info *cp); 1357 void force_fft_clear(chan_info *cp); 1358 void chan_info_cleanup(chan_info *cp); 1359 void display_channel_data_for_print(chan_info *cp); 1360 void update_graph(chan_info *cp); 1361 void update_graph_or_warn(chan_info *cp); 1362 void make_partial_graph(chan_info *cp, mus_long_t beg, mus_long_t end); 1363 void add_channel_data(char *filename, chan_info *cp, channel_graph_t graphed); 1364 bool add_channel_data_1(chan_info *cp, int srate, mus_long_t framples, channel_graph_t graphed); 1365 void set_x_bounds(axis_info *ap); 1366 void set_show_axes(show_axes_t val); 1367 void display_channel_data(chan_info *cp); 1368 void display_channel_fft_data(chan_info *cp); 1369 void display_channel_time_data(chan_info *cp); 1370 void show_cursor_info(chan_info *cp); 1371 void apply_x_axis_change(chan_info *cp); 1372 void apply_y_axis_change(chan_info *cp); 1373 void sx_incremented(chan_info *cp, double amount); 1374 int move_axis(chan_info *cp, int x); 1375 void set_axes(chan_info *cp, double x0, double x1, mus_float_t y0, mus_float_t y1); 1376 void focus_x_axis_change(chan_info *cp, int focus_style); 1377 void key_press_callback(chan_info *ur_cp, int x, int y, int key_state, int keysym); 1378 void graph_button_press_callback(chan_info *cp, void *ev, int x, int y, int key_state, int button, oclock_t time); 1379 void graph_button_release_callback(chan_info *cp, int x, int y, int key_state, int button); 1380 void graph_button_motion_callback(chan_info *cp, int x, int y, oclock_t time); 1381 void channel_resize(chan_info *cp); 1382 void edit_history_select(chan_info *cp, int row); 1383 int make_background_graph(chan_info *cp, int srate, bool *two_sided); 1384 int make_dragged_marks_graph(chan_info *cp); 1385 void reset_spectro(void); 1386 void cursor_moveto(chan_info *cp, mus_long_t samp); 1387 chan_info *which_channel(snd_info *sp, int y); 1388 void set_show_grid(with_grid_t val); 1389 void set_grid_density(mus_float_t val); 1390 void set_cursor_size(int val); 1391 void set_cursor_style(cursor_style_t val); 1392 void set_show_mix_waveforms(bool val); 1393 void clear_inset_graph(chan_info *cp); 1394 void free_inset_graph(chan_info *cp); 1395 void draw_inset_line_cursor(chan_info *cp, graphics_context *ax); 1396 void make_sonogram(chan_info *cp); 1397 1398 void g_init_chn(void); 1399 Xen make_graph_data(chan_info *cp, int edit_pos, mus_long_t losamp, mus_long_t hisamp); 1400 void draw_graph_data(chan_info *cp, mus_long_t losamp, mus_long_t hisamp, int data_size, mus_float_t *data, mus_float_t *data1, graphics_context *ax, graph_style_t style); 1401 1402 void fftb(chan_info *cp, bool on); 1403 void waveb(chan_info *cp, bool on); 1404 void f_button_callback(chan_info *cp, bool on, bool with_control); 1405 void w_button_callback(chan_info *cp, bool on, bool with_control); 1406 graphics_context *set_context(chan_info *cp, chan_gc_t gc); 1407 graphics_context *copy_context(chan_info *cp); 1408 graphics_context *erase_context(chan_info *cp); 1409 graphics_context *selection_context(chan_info *cp); 1410 graphics_context *mark_tag_context(chan_info *cp); 1411 graphics_context *mix_waveform_context(chan_info *cp); 1412 graphics_context *cursor_context(chan_info *cp); 1413 void calculate_fft(chan_info *cp); 1414 void set_min_db(mus_float_t db); 1415 void set_x_axis_style(x_axis_style_t val); 1416 void set_with_verbose_cursor(bool val); 1417 void set_graph_style(graph_style_t val); 1418 void set_show_marks(bool val); 1419 void set_show_y_zero(bool val); 1420 1421 Xen g_framples(Xen snd_n, Xen chn_n, Xen edpos); 1422 void check_cursor_shape(chan_info *cp, int x, int y); 1423 widget_t channel_to_widget(chan_info *cp); 1424 chan_info *channel_to_chan(chan_info *cp); 1425 1426 1427 1428 /* -------- snd-axis.c -------- */ 1429 1430 bool is_x_axis_style(int n); 1431 bool shows_axes(int n); 1432 axis_info *free_axis_info(axis_info *ap); 1433 char *x_axis_location_to_string(chan_info *cp, double loc); 1434 int grf_x(double val, axis_info *ap); 1435 int grf_y(mus_float_t val, axis_info *ap); 1436 void init_axis_scales(axis_info *ap); 1437 void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t axes, printing_t printing, 1438 with_x_axis_t show_x_axis, with_grid_t grid, log_axis_t log_axes, mus_float_t grid_scale); 1439 1440 #define ungrf_x(AP, X) (((X) - (AP)->x_base) / (AP)->x_scale) 1441 #define ungrf_y(AP, Y) (((Y) - (AP)->y_base) / (AP)->y_scale) 1442 1443 axis_info *make_axis_info(chan_info *cp, double xmin, double xmax, mus_float_t ymin, mus_float_t ymax, 1444 const char *xlabel, double x0, double x1, mus_float_t y0, mus_float_t y1, 1445 axis_info *old_ap); 1446 void set_numbers_font(graphics_context *ax, printing_t printing, bool use_tiny_font); 1447 1448 #if (!USE_NO_GUI) 1449 void g_init_axis(void); 1450 #endif 1451 #if HAVE_GL 1452 void reload_label_font(void); 1453 void reload_number_font(void); 1454 #endif 1455 1456 1457 1458 /* -------- snd-snd.c -------- */ 1459 1460 snd_info *get_sp(Xen snd_n); 1461 peak_env_info *free_peak_env(chan_info *cp, int pos); 1462 void free_peak_env_state(chan_info *cp); 1463 peak_env_info *free_peak_env_info(peak_env_info *ep); 1464 void start_peak_env_state(chan_info *cp); 1465 idle_func_t get_peak_env(any_pointer_t ptr); 1466 void finish_peak_env(chan_info *cp); 1467 bool peak_env_maxamp_ok(chan_info *cp, int edpos); 1468 mus_float_t peak_env_maxamp(chan_info *cp, int edpos); 1469 bool peak_env_usable(chan_info *cp, mus_float_t samples_per_pixel, mus_long_t hisamp, bool start_new, int edit_pos, bool finish_env); 1470 int peak_env_graph(chan_info *cp, mus_float_t samples_per_pixel, int srate); 1471 int peak_env_partial_graph(chan_info *cp, mus_long_t beg, mus_long_t end, mus_float_t samples_per_pixel, int srate); 1472 char *shortname(snd_info *sp); 1473 char *shortname_indexed(snd_info *sp); 1474 void add_sound_data(char *filename, snd_info *sp, channel_graph_t graphed); 1475 mus_float_t speed_changed(mus_float_t ival, char *srcbuf, speed_style_t style, int tones, int srcbuf_size); 1476 char *sp_name_click(snd_info *sp); 1477 void free_controls(snd_info *sp); 1478 void save_controls(snd_info *sp); 1479 void restore_controls(snd_info *sp); 1480 void reset_controls(snd_info *sp); 1481 void set_show_controls(bool val); 1482 void stop_applying(snd_info *sp); 1483 void expand_control_set_hop(mus_float_t hop); 1484 void expand_control_set_length(mus_float_t hop); 1485 void expand_control_set_ramp(mus_float_t hop); 1486 void expand_control_set_jitter(mus_float_t hop); 1487 void contrast_control_set_amp(mus_float_t hop); 1488 void reverb_control_set_lowpass(mus_float_t hop); 1489 void reverb_control_set_feedback(mus_float_t hop); 1490 void amp_env_env(chan_info *cp, mus_float_t *brkpts, int npts, int pos, mus_float_t base, mus_float_t scaler, mus_float_t offset); 1491 peak_env_info *copy_peak_env_info(peak_env_info *old_ep, bool reversed); 1492 void amp_env_env_selection_by(chan_info *cp, mus_any *e, mus_long_t beg, mus_long_t num, int pos); 1493 void peak_env_insert_zeros(chan_info *cp, mus_long_t beg, mus_long_t num, int pos); 1494 snd_info *snd_new_file(const char *newname, int chans, int srate, mus_sample_t sample_type, 1495 mus_header_t header_type, const char *new_comment, mus_long_t samples); 1496 #if XEN_HAVE_RATIOS 1497 void snd_rationalize(mus_float_t a, int *num, int *den); 1498 #endif 1499 void status_report(snd_info *sp, const char *format, ...); 1500 void errors_to_status_area(const char *msg, void *data); 1501 void printout_to_status_area(const char *msg, void *data); 1502 void clear_status_area(snd_info *sp);; 1503 1504 void g_init_snd(void); 1505 Xen snd_no_such_sound_error(const char *caller, Xen n); 1506 1507 void peak_env_scale_by(chan_info *cp, mus_float_t scl, int pos); 1508 void peak_env_scale_selection_by(chan_info *cp, mus_float_t scl, mus_long_t beg, mus_long_t num, int pos); 1509 peak_env_info *peak_env_copy(chan_info *cp, bool reversed, int edpos); 1510 peak_env_info *peak_env_section(chan_info *cp, mus_long_t beg, mus_long_t num, int edpos); 1511 void pick_one_bin(peak_env_info *ep, int bin, mus_long_t cursamp, chan_info *cp, int edpos); 1512 void set_channel_style(channel_style_t val); 1513 1514 Xen new_xen_sound(int n); 1515 bool xen_is_sound(Xen obj); 1516 int xen_sound_to_int(Xen n); 1517 #define C_int_to_Xen_sound(Val) new_xen_sound(Val) 1518 #define Xen_sound_to_C_int(n) xen_sound_to_int(n) 1519 1520 const char *read_peak_env_info_file(chan_info *cp); 1521 bool write_peak_env_info_file(chan_info *cp); 1522 void delete_peak_env_info_file(chan_info *cp); 1523 1524 1525 1526 /* -------- snd-file -------- */ 1527 1528 axes_data *free_axes_data(axes_data *sa); 1529 axes_data *make_axes_data(snd_info *sp); 1530 void restore_axes_data(snd_info *sp, axes_data *sa, mus_float_t new_duration, bool need_edit_history_update); 1531 mus_long_t disk_kspace(const char *filename); 1532 time_t file_write_date(const char *filename); 1533 bool is_link_file(const char *filename); 1534 int recent_files_size(void); 1535 char **recent_files(void); 1536 bool is_directory(const char *filename); 1537 file_info *make_file_info(const char *fullname, read_only_t read_only, bool selected); 1538 file_info *free_file_info(file_info *hdr); 1539 file_info *copy_header(const char *fullname, file_info *ohdr); 1540 file_info *make_temp_header(const char *fullname, int srate, int chans, mus_long_t samples, const char *caller); 1541 bool is_sound_file(const char *name); 1542 void init_sound_file_extensions(void); 1543 void save_added_sound_file_extensions(FILE *fd); 1544 const char **get_sound_file_extensions(void); 1545 int sound_file_extensions_length(void); 1546 snd_info *snd_open_file(const char *filename, read_only_t read_only); 1547 void snd_close_file(snd_info *sp); 1548 snd_info *make_sound_readable(const char *filename, bool post_close); 1549 snd_info *snd_update(snd_info *sp); 1550 snd_info *snd_update_within_xen(snd_info *sp, const char *caller); 1551 int snd_decode(mus_header_t type, const char *input_filename, const char *output_filename); 1552 void set_fallback_srate(int sr); 1553 void set_fallback_chans(int ch); 1554 void set_fallback_sample_type(mus_sample_t fr); 1555 void set_with_tooltips(bool val); 1556 void run_after_save_as_hook(snd_info *sp, const char *already_saved_as_name, bool from_save_as_dialog); 1557 bool run_before_save_as_hook(snd_info *sp, const char *save_as_filename, bool selection, int srate, 1558 mus_sample_t smp_type, mus_header_t hd_type, const char *comment); 1559 void during_open(int fd, const char *file, open_reason_t reason); 1560 void after_open(snd_info *sp); 1561 void set_with_toolbar_and_display(bool val); 1562 #if (!USE_NO_GUI) 1563 void display_info(snd_info *sp); 1564 #endif 1565 void g_init_file(void); 1566 void initialize_sample_type_lists(void); 1567 void set_with_menu_icons(bool val); 1568 Xen g_expand_vector(Xen vector, int new_size); 1569 1570 1571 1572 /* -------- snd-utils -------- */ 1573 1574 int snd_round(double x); 1575 mus_long_t snd_round_mus_long_t(double x); 1576 mus_long_t snd_abs_mus_long_t(mus_long_t val); 1577 int snd_int_pow2(int n); 1578 mus_long_t snd_mus_long_t_pow2(int n); 1579 int snd_to_int_pow2(int n); 1580 int snd_int_log2(int n); 1581 bool snd_feq(mus_float_t val1, mus_float_t val2); 1582 1583 #if defined(__GNUC__) && (!(defined(__cplusplus))) 1584 #define in_dB(Min_Db, Lin_Db, Val) ({ mus_float_t _snd_1_h_1 = Val; (_snd_1_h_1 <= Lin_Db) ? Min_Db : (20.0 * log10(_snd_1_h_1)); }) 1585 #else 1586 mus_float_t in_dB(mus_float_t min_dB, mus_float_t lin_dB, mus_float_t val); 1587 #endif 1588 1589 char *snd_local_time(void); 1590 char *snd_io_strerror(void); 1591 char *snd_open_strerror(void); 1592 char *string_to_colon(char *val); 1593 char *filename_without_directory(const char *name); 1594 char *just_filename(char *name); 1595 char *just_directory(const char *name); 1596 char *file_to_string(const char *filename); 1597 1598 #ifdef __GNUC__ 1599 char *vstr(const char *format, va_list ap) __attribute__ ((format (printf, 1, 0))); 1600 char *snd_strftime(const char *format, time_t date) __attribute__ ((format (strftime, 1, 0))); 1601 #else 1602 char *vstr(const char *format, va_list ap); 1603 char *snd_strftime(const char *format, time_t date); 1604 #endif 1605 1606 disk_space_t disk_has_space(mus_long_t bytes, const char *filename); 1607 char *prettyf(double num, int tens); 1608 char *shorter_tempnam(const char *dir, const char *prefix); 1609 char *snd_tempnam(void); 1610 void snd_exit(int val); 1611 void g_init_utils(void); 1612 1613 1614 1615 /* -------- snd-listener -------- */ 1616 1617 void g_init_listener(void); 1618 #if HAVE_SCHEME 1619 void listener_begin_hook(s7_scheme *sc, bool *val); 1620 #endif 1621 void set_listener_prompt(const char *new_prompt); 1622 bool listener_is_visible(void); 1623 Xen run_read_hook(char *str); 1624 bool have_read_hook(void); 1625 1626 1627 1628 /* -------- snd-mix.c -------- */ 1629 1630 void free_ed_mixes(void *ptr); 1631 bool mix_exists(int n); 1632 bool mix_is_active(int n); 1633 bool channel_has_mixes(chan_info *cp); 1634 bool channel_has_active_mixes(chan_info *cp); 1635 const char *mix_name(int id); 1636 const char *mix_file_name(int id); 1637 int mix_name_to_id(const char *name); 1638 void goto_mix(chan_info *cp, int count); 1639 mus_long_t zoom_focus_mix_in_channel_to_position(chan_info *cp); 1640 int any_mix_id(void); 1641 int next_mix_id(int id); 1642 int previous_mix_id(int id); 1643 int lowest_mix_id(void); 1644 int highest_mix_id(void); 1645 void reset_mix_ctr(void); 1646 void preload_mixes(mix_state **mixes, int low_id, ed_list *ed); 1647 void free_channel_mixes(chan_info *cp); 1648 void delete_any_remaining_mix_temp_files_at_exit(chan_info *cp); 1649 void mix_info_to_file(FILE *fd, chan_info *cp); 1650 int mix_sync_from_id(int id); 1651 int mix_set_sync_from_id(int id, int new_sync); 1652 void set_mix_waveform_height(int new_val); 1653 Xen new_xen_mix(int n); 1654 Xen g_make_mix_sampler(Xen mix_id, Xen ubeg); 1655 bool xen_is_mix(Xen obj); 1656 snd_fd *xen_mix_to_snd_fd(Xen obj); 1657 int xen_mix_to_int(Xen n); 1658 #define Xen_mix_to_C_int(n) xen_mix_to_int(n) 1659 Xen g_mix_length(Xen n); 1660 Xen g_mix_sync(Xen n); 1661 Xen g_set_mix_sync(Xen n, Xen val); 1662 Xen g_mix_maxamp(Xen mix_id); 1663 Xen g_mix_to_vct(Xen mix_n, Xen beg_n, Xen num); 1664 1665 mus_long_t mix_position_from_id(int id); 1666 mus_long_t mix_length_from_id(int id); 1667 mus_float_t mix_amp_from_id(int id); 1668 mus_float_t mix_speed_from_id(int id); 1669 env *mix_amp_env_from_id(int id); 1670 chan_info *mix_chan_info_from_id(int id); 1671 int copy_mix(int id); 1672 1673 mix_state *prepare_mix_state_for_channel(chan_info *cp, int mix_loc, mus_long_t beg, mus_long_t len); 1674 void add_ed_mix(ed_list *ed, mix_state *ms); 1675 mix_state *copy_mix_state(mix_state *old_ms); 1676 1677 void g_init_mix(void); 1678 1679 bool mix_set_position_edit(int id, mus_long_t pos); 1680 bool mix_set_amp_env_edit(int id, env *e); 1681 bool mix_set_amp_edit(int id, mus_float_t amp); 1682 bool mix_set_speed_edit(int id, mus_float_t spd); 1683 void after_mix_edit(int id); 1684 1685 void syncd_mix_set_color(int id, color_t col); 1686 void syncd_mix_unset_color(int id); 1687 void syncd_mix_set_amp(int id, mus_float_t amp); 1688 void syncd_mix_set_speed(int id, mus_float_t amp); 1689 void syncd_mix_set_amp_env(int id, env *e); 1690 void syncd_mix_play(int id); 1691 void mix_unset_color_from_id(int id); 1692 color_t mix_color_from_id(int mix_id); 1693 color_t mix_set_color_from_id(int id, color_t new_color); 1694 void start_dragging_syncd_mixes(int mix_id); 1695 void keep_dragging_syncd_mixes(int mix_id); 1696 void stop_dragging_syncd_mixes(int mix_id); 1697 void after_syncd_mix_edit(int id); 1698 void syncd_mix_change_position(int mix_id, mus_long_t change); 1699 1700 int mix_complete_file(snd_info *sp, mus_long_t beg, const char *fullname, bool with_tag, file_delete_t auto_delete, mix_sync_t all_chans, int *out_chans); 1701 int mix_complete_file_at_cursor(snd_info *sp, const char *str); 1702 int mix_file(mus_long_t beg, mus_long_t num, int chans, chan_info **cps, const char *mixinfile, file_delete_t temp, const char *origin, bool with_tag, int start_chan); 1703 1704 bool is_mix_sampler(Xen obj); 1705 Xen g_copy_mix_sampler(Xen obj); 1706 Xen g_mix_sampler_home(Xen obj); 1707 Xen g_mix_sampler_is_at_end(Xen obj); 1708 Xen g_mix_sampler_position(Xen obj); 1709 Xen g_free_mix_sampler(Xen obj); 1710 char *edit_list_mix_init(chan_info *cp); 1711 void channel_set_mix_tags_erased(chan_info *cp); 1712 void color_mixes(color_t color); 1713 void move_mix_tag(int mix_tag, int x, int y); 1714 void finish_moving_mix_tag(int mix_tag, int x); 1715 int hit_mix(chan_info *cp, int x, int y); 1716 int hit_mix_triangle(chan_info *cp, int x, int y); 1717 int prepare_mix_dialog_waveform(int mix_id, axis_info *ap, bool *two_sided); 1718 void display_channel_mixes(chan_info *cp); 1719 1720 bool play_mix_from_id(int mix_id); 1721 Xen g_play_mix(Xen num, mus_long_t beg); 1722 void drag_and_drop_mix_at_x_y(int data, const char *filename, int x, int y); 1723 1724 snd_fd *mf_to_snd_fd(void *p); 1725 1726 1727 /* -------- snd-find.c -------- */ 1728 1729 #if HAVE_EXTENSION_LANGUAGE && (!USE_NO_GUI) 1730 void find_dialog_find(char *str, read_direction_t direction, chan_info *cp); 1731 #endif 1732 void g_init_find(void); 1733 1734 1735 1736 /* -------- snd-trans.c -------- */ 1737 1738 int snd_translate(const char *oldname, const char *newname, mus_header_t type); 1739 1740 1741 /* -------- snd.c -------- */ 1742 1743 void snd_set_global_defaults(bool need_cleanup); 1744 void g_init_base(void); 1745 1746 1747 /* -------- snd-kbd.c -------- */ 1748 1749 int in_keymap(int key, int state, bool cx_extended); 1750 void set_keymap_entry(int key, int state, int args, Xen func, bool cx_extended, const char *origin, const char *prefs_info); 1751 char *key_description(int key, int state, bool cx_extended); 1752 char *make_key_name(char *buf, int buf_size, int key, int state, bool extended); 1753 void map_over_keys(bool (*func)(int key, int state, bool cx, Xen xf)); 1754 key_info *find_prefs_key(const char *prefs_name); 1755 1756 void save_edits_from_kbd(snd_info *sp); 1757 void keyboard_command(chan_info *cp, int keysym, int state); 1758 void control_g(snd_info *sp); 1759 void g_init_kbd(void); 1760 1761 1762 /* -------- snd-sig.c -------- */ 1763 1764 void scale_by(chan_info *cp, mus_float_t *scalers, int len, bool selection); 1765 bool scale_to(snd_info *sp, chan_info *cp, mus_float_t *scalers, int len, bool selection); 1766 void src_env_or_num(chan_info *cp, env *e, mus_float_t ratio, bool just_num, 1767 const char *origin, bool over_selection, mus_any *gen, Xen edpos, int arg_pos); 1768 void apply_filter(chan_info *ncp, int order, env *e, const char *caller, const char *origin, 1769 bool over_selection, mus_float_t *ur_a, mus_any *gen, Xen edpos, int arg_pos, bool truncate); 1770 void apply_env(chan_info *cp, env *e, mus_long_t beg, mus_long_t dur, bool over_selection, 1771 const char *origin, mus_any *gen, Xen edpos, int arg_pos); 1772 void cos_smooth(chan_info *cp, mus_long_t beg, mus_long_t num, bool over_selection); 1773 void display_frequency_response(env *e, axis_info *ap, graphics_context *gax, int order, bool dBing); 1774 void cursor_delete(chan_info *cp, mus_long_t count); 1775 void cursor_zeros(chan_info *cp, mus_long_t count, bool over_selection); 1776 void cursor_insert(chan_info *cp, mus_long_t beg, mus_long_t count); 1777 void cut_and_smooth(chan_info *cp); 1778 void src_file(const char *file, double ratio); 1779 mus_long_t scan_channel(chan_info *cp, mus_long_t start, mus_long_t end, Xen proc); 1780 1781 void g_init_sig(void); 1782 int to_c_edit_position(chan_info *cp, Xen edpos, const char *caller, int arg_pos); 1783 mus_long_t to_c_edit_samples(chan_info *cp, Xen edpos, const char *caller, int arg_pos); 1784 mus_long_t beg_to_sample(Xen beg, const char *caller); 1785 mus_long_t dur_to_samples(Xen dur, mus_long_t beg, chan_info *cp, int edpos, int argn, const char *caller); 1786 #if USE_MOTIF 1787 char *scale_and_src(char **files, int len, int max_chans, mus_float_t amp, mus_float_t speed, env *amp_env, bool *err); 1788 #endif 1789 Xen g_scale_selection_by(Xen scalers); 1790 void reverse_sound(chan_info *ncp, bool over_selection, Xen edpos, int arg_pos); 1791 1792 1793 /* -------- snd-draw.c -------- */ 1794 1795 point_t *get_grf_points(void); 1796 point_t *get_grf_points1(void); 1797 void draw_cursor(chan_info *cp); 1798 void set_grf_points(int xi, int j, int ymin, int ymax); 1799 void set_grf_point(int xi, int j, int yi); 1800 void draw_grf_points(int dot_size, graphics_context *ax, int j, axis_info *ap, mus_float_t y0, graph_style_t graph_style); 1801 void draw_both_grf_points(int dot_size, graphics_context *ax, int j, graph_style_t graph_style); 1802 void g_init_draw(void); 1803 void set_dialog_widget(snd_dialog_t which, widget_t wid); 1804 void run_new_widget_hook(widget_t w); 1805 bool foreground_color_ok(Xen color, graphics_context *ax); 1806 1807 #if HAVE_GL 1808 void sgl_save_currents(void); 1809 void sgl_set_currents(bool with_dialogs); 1810 #endif 1811 1812 1813 /* -------- snd-ladspa.c -------- */ 1814 #if HAVE_LADSPA 1815 void g_ladspa_to_snd(void); 1816 #endif 1817 1818 #endif 1819 1820