void ReplWindow::evaluate(Glib::ustring &expression) { Scheme *scm = Application::get()->get_scheme(); if (!expression.empty()) { const char *errmsg; s7_pointer old_port, result; int gc_loc = -1; // // Open a port to catch error info // old_port = s7_set_current_error_port(scm, s7_open_output_string(scm)); if (old_port != s7_nil(scm)) { gc_loc = s7_gc_protect(scm, old_port); } result = s7_eval_c_string(scm, expression.data()); errmsg = s7_get_output_string(scm, s7_current_error_port(scm)); append_text( "\n" ); if ((errmsg) && (*errmsg)) { append_text(errmsg); } else { char *result_as_string; result_as_string = s7_object_to_c_string(scm, result); if (result_as_string) { append_text(result_as_string); free(result_as_string); } } s7_close_output_port(scm, s7_current_error_port(scm)); s7_set_current_error_port(scm, old_port); if (gc_loc != -1) s7_gc_unprotect_at(scm, gc_loc); } }
void mus_sndlib_xen_initialize(void) { mus_sound_initialize(); sound_path = Xen_empty_list; #if HAVE_RUBY Init_Hook(); #endif Xen_define_constant(S_mus_out_format, MUS_OUT_SAMPLE_TYPE, "sample type for fastest IO"); Xen_define_constant(S_mus_unknown_header, MUS_UNKNOWN_HEADER, "unknown header type"); Xen_define_constant(S_mus_next, MUS_NEXT, "NeXT (Sun) sound header id"); Xen_define_constant(S_mus_aifc, MUS_AIFC, "AIFC sound header id"); Xen_define_constant(S_mus_rf64, MUS_RF64, "RF64 sound header id"); Xen_define_constant(S_mus_riff, MUS_RIFF, "RIFF (MS wave) sound header id"); Xen_define_constant(S_mus_nist, MUS_NIST, "NIST (Sphere) sound header id"); Xen_define_constant(S_mus_raw, MUS_RAW, "raw (headerless) sound header id"); Xen_define_constant(S_mus_ircam, MUS_IRCAM, "IRCAM sound header id"); Xen_define_constant(S_mus_aiff, MUS_AIFF, "AIFF (old-style) sound header id"); Xen_define_constant(S_mus_bicsf, MUS_BICSF, "BICSF header id"); Xen_define_constant(S_mus_voc, MUS_VOC, "VOC header id"); Xen_define_constant(S_mus_svx, MUS_SVX, "SVX (IFF) header id"); Xen_define_constant(S_mus_soundfont, MUS_SOUNDFONT, "soundfont header id"); Xen_define_constant(S_mus_caff, MUS_CAFF, "Apple Core Audio File Format header id"); Xen_define_constant(S_mus_unknown_sample, MUS_UNKNOWN_SAMPLE, "unknown sample type"); Xen_define_constant(S_mus_bshort, MUS_BSHORT, "big-endian short sample type id"); Xen_define_constant(S_mus_lshort, MUS_LSHORT, "little-endian short sample type id"); Xen_define_constant(S_mus_mulaw, MUS_MULAW, "mulaw (8-bit) sample type id"); Xen_define_constant(S_mus_alaw, MUS_ALAW, "alaw (8-bit) sample type id"); Xen_define_constant(S_mus_byte, MUS_BYTE, "signed byte sample type id"); Xen_define_constant(S_mus_ubyte, MUS_UBYTE, "unsigned byte sample type id"); Xen_define_constant(S_mus_bfloat, MUS_BFLOAT, "big-endian float sample type id"); Xen_define_constant(S_mus_lfloat, MUS_LFLOAT, "little-endian float sample type id"); Xen_define_constant(S_mus_bint, MUS_BINT, "big-endian int sample type id"); Xen_define_constant(S_mus_lint, MUS_LINT, "little-endian int sample type id"); Xen_define_constant(S_mus_bintn, MUS_BINTN, "normalized big-endian int sample type id"); Xen_define_constant(S_mus_lintn, MUS_LINTN, "normalized little-endian int sample type id"); Xen_define_constant(S_mus_b24int, MUS_B24INT, "big-endian 24-bit sample type id"); Xen_define_constant(S_mus_l24int, MUS_L24INT, "little-endian 24-bit sample type id"); Xen_define_constant(S_mus_bdouble, MUS_BDOUBLE, "big-endian double sample type id"); Xen_define_constant(S_mus_ldouble, MUS_LDOUBLE, "little-endian double sample type id"); Xen_define_constant(S_mus_ubshort, MUS_UBSHORT, "unsigned big-endian short sample type id"); Xen_define_constant(S_mus_ulshort, MUS_ULSHORT, "unsigned little-endian short sample type id"); Xen_define_constant(S_mus_bdouble_unscaled, MUS_BDOUBLE_UNSCALED, "unscaled big-endian double sample type id"); Xen_define_constant(S_mus_ldouble_unscaled, MUS_LDOUBLE_UNSCALED, "unscaled little-endian double sample type id"); Xen_define_constant(S_mus_bfloat_unscaled, MUS_BFLOAT_UNSCALED, "unscaled big-endian float sample type id"); Xen_define_constant(S_mus_lfloat_unscaled, MUS_LFLOAT_UNSCALED, "unscaled little-endian float sample type id"); Xen_define_dilambda(S_mus_sound_samples, g_mus_sound_samples_w, H_mus_sound_samples, S_set S_mus_sound_samples, g_mus_sound_set_samples_w, 1, 0, 2, 0); Xen_define_dilambda(S_mus_sound_data_location, g_mus_sound_data_location_w, H_mus_sound_data_location, S_set S_mus_sound_data_location, g_mus_sound_set_data_location_w, 1, 0, 2, 0); Xen_define_dilambda(S_mus_sound_chans, g_mus_sound_chans_w, H_mus_sound_chans, S_set S_mus_sound_chans, g_mus_sound_set_chans_w, 1, 0, 2, 0); Xen_define_dilambda(S_mus_sound_srate, g_mus_sound_srate_w, H_mus_sound_srate, S_set S_mus_sound_srate, g_mus_sound_set_srate_w, 1, 0, 2, 0); Xen_define_dilambda(S_mus_sound_header_type, g_mus_sound_header_type_w, H_mus_sound_header_type, S_set S_mus_sound_header_type, g_mus_sound_set_header_type_w, 1, 0, 2, 0); Xen_define_dilambda(S_mus_sound_sample_type, g_mus_sound_sample_type_w, H_mus_sound_sample_type, S_set S_mus_sound_sample_type, g_mus_sound_set_sample_type_w, 1, 0, 2, 0); /* -------------------------------------------------------------------------------- */ Xen_define_safe_procedure(S_mus_sound_framples, g_mus_sound_framples_w, 1, 0, 0, H_mus_sound_framples); Xen_define_safe_procedure("mus-sound-frames", g_mus_sound_framples_w, 1, 0, 0, H_mus_sound_framples); Xen_define_safe_procedure(S_mus_sound_duration, g_mus_sound_duration_w, 1, 0, 0, H_mus_sound_duration); Xen_define_safe_procedure(S_mus_sound_datum_size, g_mus_sound_datum_size_w, 1, 0, 0, H_mus_sound_datum_size); Xen_define_safe_procedure(S_mus_sound_length, g_mus_sound_length_w, 1, 0, 0, H_mus_sound_length); Xen_define_safe_procedure(S_mus_sound_type_specifier, g_mus_sound_type_specifier_w, 1, 0, 0, H_mus_sound_type_specifier); Xen_define_safe_procedure(S_mus_header_type_name, g_mus_header_type_name_w, 1, 0, 0, H_mus_header_type_name); Xen_define_safe_procedure(S_mus_header_type_to_string,g_mus_header_type_to_string_w, 1, 0, 0, H_mus_header_type_to_string); Xen_define_safe_procedure(S_mus_header_writable, g_mus_header_writable_w, 2, 0, 0, H_mus_header_writable); Xen_define_safe_procedure(S_mus_sample_type_name, g_mus_sample_type_name_w, 1, 0, 0, H_mus_sample_type_name); Xen_define_safe_procedure(S_mus_sample_type_to_string,g_mus_sample_type_to_string_w, 1, 0, 0, H_mus_sample_type_to_string); #if HAVE_SCHEME Xen_define_dilambda(S_mus_sound_sample_type, g_mus_sound_sample_type_w, H_mus_sound_sample_type, S_set S_mus_sound_sample_type, g_mus_sound_set_sample_type_w, 1, 0, 2, 0); #endif Xen_define_safe_procedure(S_mus_sound_comment, g_mus_sound_comment_w, 1, 0, 0, H_mus_sound_comment); Xen_define_safe_procedure(S_mus_sound_write_date, g_mus_sound_write_date_w, 1, 0, 0, H_mus_sound_write_date); Xen_define_safe_procedure(S_mus_bytes_per_sample, g_mus_bytes_per_sample_w, 1, 0, 0, H_mus_bytes_per_sample); Xen_define_safe_procedure(S_mus_sound_loop_info, g_mus_sound_loop_info_w, 1, 0, 0, H_mus_sound_loop_info); Xen_define_safe_procedure(S_mus_sound_mark_info, g_mus_sound_mark_info_w, 1, 0, 0, H_mus_sound_mark_info); Xen_define_safe_procedure(S_mus_sound_maxamp_exists, g_mus_sound_maxamp_exists_w, 1, 0, 0, H_mus_sound_maxamp_exists); Xen_define_safe_procedure(S_mus_sound_forget, g_mus_sound_forget_w, 1, 0, 0, H_mus_sound_forget); Xen_define_safe_procedure(S_mus_sound_prune, g_mus_sound_prune_w, 0, 0, 0, H_mus_sound_prune); Xen_define_safe_procedure(S_mus_expand_filename, g_mus_expand_filename_w, 1, 0, 0, H_mus_expand_filename); Xen_define_safe_procedure(S_mus_sound_report_cache, g_mus_sound_report_cache_w, 0, 1, 0, H_mus_sound_report_cache); Xen_define_safe_procedure(S_mus_error_type_to_string, g_mus_error_type_to_string_w, 1, 0, 0, H_mus_error_type_to_string); Xen_define_safe_procedure(S_mus_oss_set_buffers, g_mus_oss_set_buffers_w, 2, 0, 0, H_mus_oss_set_buffers); Xen_define_safe_procedure(S_array_to_file, g_array_to_file_w, 5, 0, 0, H_array_to_file); Xen_define_safe_procedure(S_file_to_array, g_file_to_array_w, 5, 0, 0, H_file_to_array); Xen_define_safe_procedure(S_mus_sound_preload, g_mus_sound_preload_w, 1, 0, 0, H_mus_sound_preload); Xen_define_dilambda(S_mus_header_raw_defaults, g_mus_header_raw_defaults_w, H_mus_header_raw_defaults, S_set S_mus_header_raw_defaults, g_mus_header_set_raw_defaults_w, 0, 0, 1, 0); Xen_define_dilambda(S_mus_clipping, g_mus_clipping_w, H_mus_clipping, S_set S_mus_clipping, g_mus_set_clipping_w, 0, 0, 1, 0); Xen_define_dilambda(S_mus_file_clipping, g_mus_file_clipping_w, H_mus_file_clipping, S_set S_mus_file_clipping, g_mus_file_set_clipping_w, 1, 0, 2, 0); Xen_define_dilambda(S_mus_sound_maxamp, g_mus_sound_maxamp_w, H_mus_sound_maxamp, S_set S_mus_sound_maxamp, g_mus_sound_set_maxamp_w, 1, 0, 2, 0); /* these are no-ops if not ALSA, but that makes it easier to maintain global initialization files */ Xen_define_dilambda(S_mus_alsa_buffers, g_mus_alsa_buffers_w, H_mus_alsa_buffers, S_set S_mus_alsa_buffers, g_mus_alsa_set_buffers_w, 0, 0, 1, 0); Xen_define_dilambda(S_mus_alsa_buffer_size, g_mus_alsa_buffer_size_w, H_mus_alsa_buffer_size, S_set S_mus_alsa_buffer_size, g_mus_alsa_set_buffer_size_w, 0, 0, 1, 0); Xen_define_dilambda(S_mus_alsa_device, g_mus_alsa_device_w, H_mus_alsa_device, S_set S_mus_alsa_device, g_mus_alsa_set_device_w, 0, 0, 1, 0); Xen_define_dilambda(S_mus_alsa_playback_device, g_mus_alsa_playback_device_w, H_mus_alsa_playback_device, S_set S_mus_alsa_playback_device, g_mus_alsa_set_playback_device_w, 0, 0, 1, 0); Xen_define_dilambda(S_mus_alsa_capture_device, g_mus_alsa_capture_device_w, H_mus_alsa_capture_device, S_set S_mus_alsa_capture_device, g_mus_alsa_set_capture_device_w, 0, 0, 1, 0); Xen_define_dilambda(S_mus_alsa_squelch_warning, g_mus_alsa_squelch_warning_w, H_mus_alsa_squelch_warning, S_set S_mus_alsa_squelch_warning, g_mus_alsa_set_squelch_warning_w, 0, 0, 1, 0); Xen_define_dilambda(S_mus_max_malloc, g_mus_max_malloc_w, H_mus_max_malloc, S_set S_mus_max_malloc, g_mus_set_max_malloc_w, 0, 0, 1, 0); Xen_define_dilambda(S_mus_max_table_size, g_mus_max_table_size_w, H_mus_max_table_size, S_set S_mus_max_table_size, g_mus_set_max_table_size_w, 0, 0, 1, 0); Xen_define_dilambda(S_mus_sound_path, g_mus_sound_path_w, H_mus_sound_path, S_set S_mus_sound_path, g_mus_set_sound_path_w, 0, 0, 1, 0); #if HAVE_SCHEME mus_max_table_size_symbol = s7_define_variable(s7, "*" S_mus_max_table_size "*", s7_make_integer(s7, MUS_MAX_TABLE_SIZE_DEFAULT)); s7_symbol_set_documentation(s7, mus_max_table_size_symbol, "*mus-max-table-size*: maximum table size."); s7_symbol_set_access(s7, mus_max_table_size_symbol, s7_make_function(s7, "[acc-mus-max-table-size]", acc_mus_max_table_size, 2, 0, false, "accessor")); mus_max_malloc_symbol = s7_define_variable(s7, "*" S_mus_max_malloc "*", s7_make_integer(s7, MUS_MAX_MALLOC_DEFAULT)); s7_symbol_set_documentation(s7, mus_max_malloc_symbol, "*mus-max-malloc*: maximum number of bytes we will try to malloc."); s7_symbol_set_access(s7, mus_max_malloc_symbol, s7_make_function(s7, "[acc-mus-max-malloc]", acc_mus_max_malloc, 2, 0, false, "accessor")); mus_sound_path_symbol = s7_define_variable(s7, "*" S_mus_sound_path "*", s7_nil(s7)); s7_symbol_set_documentation(s7, mus_sound_path_symbol, "*" S_mus_sound_path "* is a list of directories to search for sound files"); s7_symbol_set_access(s7, mus_sound_path_symbol, s7_make_function(s7, "[acc-mus-sound-path]", acc_mus_sound_path, 2, 0, false, "accessor")); #endif #if __APPLE__ Xen_define_procedure(S_mus_audio_output_properties_mutable, g_mus_audio_output_properties_mutable_w, 1, 0, 0, H_mus_audio_output_properties_mutable); #endif #define H_new_sound_hook S_new_sound_hook "(name): called when a new sound file is being created" new_sound_hook = Xen_define_hook(S_new_sound_hook, "(make-hook 'name)", 1, H_new_sound_hook); mus_header_write_set_hook(g_new_sound_hook); Xen_provide_feature("sndlib"); }