set_sample_data_   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/external/instruments_ext.xtm

Implementation

;; helper function for adding sample data to sampler
;; this assumes stereo files at the moment!!
;; passing 0 for length means read to end of file.
;;
;; for example:
;; ;; this reads the whole file into index 60
;; (set-sampler-data sampler "/tmp/piano-C.aif" 60 0 0)
;; ;; this reads 5000 frames starting 1000 frames into the file
;; (set-sampler-data sampler "/tmp/piano-C.aif" 60 1000 5000)
(bind-func set_sample_data_
  (lambda (inst:[SAMPLE,SAMPLE,i64,i64,SAMPLE*]* filename index:i64 offset lgth bank:i32 print_p:i64)
    (let ((info:SF_INFO* (salloc))
          (audiofile (sf_open filename SFM_READ info))
          (channels:i64 (convert (tref info 2)))
          (num (if (= 0 lgth)
                   (- (tref info 0) offset)
                   lgth)))
      (if (not (null? audiofile))
          (let ((adat:SAMPLE* (halloc (* num channels)))
                (samples:|20,|128,SAMPLE*||* (inst.samples))
                (samples_channels:|20,|128,i64||* (inst.samples_channels))
                (samples_length:|20,|128,i64||* (inst.samples_length))
                (samples_read (sf_read_file_into_buffer filename adat (* offset channels) num (i64toi1 print_p)))
                (olddat (if (<> 0 (aref (aref-ptr samples_length bank) index))
                            (bitcast (aref (aref-ptr samples bank) index) i8*)
                            null)))
            ;;(printf "%lld samples read into: %lld\n" samples_read index)
            (aset! (aref-ptr samples_length bank) index (/ samples_read channels)) ;num)
            (aset! (aref-ptr samples_channels bank) index (convert channels))
            (aset! (aref-ptr samples bank) index adat)
            (sf_close audiofile)
            (if (not (null? olddat)) (free olddat))
            1)
          (begin
            (printf "libsndfile error: could not read audio file at '%s' (%s)\n" filename (sf_strerror audiofile))
            (sf_close audiofile)
            0)))))


Back to Index

Similar Entries

  • *midioffset*    scheme
  • AudioBuffer_data_b64    xtlang
  • AudioBuffer_data_b64_cstring    xtlang
  • AudioBuffer_set_data_b64    xtlang
  • AudioBuffer_shared_data    xtlang
  • CefColorSetARGB    xtlang
  • GSL_SET_COMPLEX    xtlang
  • GSL_SET_IMAG    xtlang
  • GSL_SET_REAL    xtlang
  • GUI_set_root    xtlang
  • Pm_Event_Data1    xtlang
  • Pm_Event_Data2    xtlang
  • Pm_Message_Data1    xtlang
  • Pm_Message_Data2    xtlang
  • QRcode_data    xtlang
  • Texture_bind_data    xtlang
  • Texture_bind_data    xtlang
  • VBO_data    xtlang
  • VBO_update_data    xtlang
  • Vset    xtlang
  • Vsetall    xtlang
  • Widget_set_cb    xtlang
  • Widget_set_left_child    xtlang
  • Widget_set_parent    xtlang
  • Widget_set_right_child    xtlang
  • Widget_set_split    xtlang
  • Widget_set_type    xtlang
  • _dsp:set!    scheme
  • aiProcess_FindInvalidData    scheme
  • aiProcess_ValidateDataStructure    scheme
  • analogue-load-preset    scheme
  • analogue-reset    scheme
  • analogue-save-preset    scheme
  • analogue_reset    xtlang
  • analogue_set_mod_matrix    xtlang
  • arrows_set_head_vert    xtlang
  • attrib_set_p    xtlang
  • audiofile_16bitPCM_to_sample_be    xtlang
  • audiofile_16bitPCM_to_sample_le    xtlang
  • audiofile_24bitPCM_to_sample_be    xtlang
  • audiofile_24bitPCM_to_sample_le    xtlang
  • audiofile_aiff_read_samples    xtlang
  • audiofile_copy_samples    xtlang
  • audiofile_float_to_sample_be    xtlang
  • audiofile_float_to_sample_le    xtlang
  • audiofile_read_samples    xtlang
  • audiofile_wave_read_samples    xtlang
  • bind-data    macro
  • bind-data-constructors    scheme
  • bind-data-deconstructors    scheme
  • bind-data-deconstructors-macros    scheme
  • bind-data-getters    scheme
  • bind-data-type    scheme
  • bind-data-type-constructor    scheme
  • bind-data-types    scheme
  • cef_string_set    xtlang
  • cell_set_value    xtlang
  • cerberus-load-preset    scheme
  • cerberus-reset    scheme
  • cerberus-save-preset    scheme
  • cerberus_get_noisetype    xtlang
  • cerberus_reset    xtlang
  • cerberus_reset_lfos    xtlang
  • cerberus_set_mod_matrix    xtlang
  • cl:set-difference    scheme
  • cl:subset?    scheme
  • clear-sampler    scheme
  • clear_sample_data_    xtlang
  • clock->samples    scheme
  • clock-set-bpm    scheme
  • clock-set-cycle    scheme
  • clock:offset-from-server    scheme
  • create_data    xtlang
  • curl_setopts_authenticate    xtlang
  • curl_setopts_basic    xtlang
  • curl_setopts_header    xtlang
  • curl_setup    xtlang
  • data    xtlang
  • data    xtlang
  • dict_set    xtlang
  • dsp:set!    macro
  • fits-image-data-R32    xtlang
  • fits-image-data-R32    xtlang
  • fits-image-data-RGBA32    xtlang
  • fits-image-data-RGBA32    xtlang
  • fits-image-data-RGBA32-false    xtlang
  • fits-image-data-RGBA32-false    xtlang
  • fleet_set_unit_state    xtlang
  • fleet_set_unit_state    xtlang
  • fluid-cube-set-column    xtlang
  • fluid-cube-set-first-column    xtlang
  • fluid-cube-set-first-row    xtlang
  • fluid-cube-set-last-column    xtlang
  • fluid-cube-set-last-row    xtlang
  • fluid-cube-set-row    xtlang
  • fluid-set-boundary    xtlang
  • fluid-set-boundary    xtlang
  • fluid-set-boundary    xtlang
  • fluid_set_boundary    xtlang
  • get_hand_data    xtlang
  • get_noisetype    xtlang
  • ghttp_perform_request_with_setup_fn    xtlang
  • ghttp_set_content_type_html    xtlang
  • ghttp_set_content_type_json    xtlang
  • ghttp_set_content_type_octet_stream    xtlang
  • ghttp_set_content_type_plaintext    xtlang
  • ghttp_set_extempore_user_agent    xtlang
  • gl_set_proc_address    xtlang
  • gl_set_view    xtlang
  • gl_setup    xtlang
  • glfw_set_compatibility_profile    xtlang
  • glfw_set_core_profile    xtlang
  • godot_color_set_r    xtlang
  • godot_vector2_set_x    xtlang
  • godot_vector2_set_y    xtlang
  • gui_reset    xtlang
  • gui_set_default_theme    xtlang
  • gui_set_monokai_color_theme    xtlang
  • gui_set_monokai_opensans_theme    xtlang
  • icr:set-zone    scheme
  • icr:set-zone-default    scheme
  • impc:compiler:reset-jit-compilation-queue    scheme
  • impc:ir:compiler:array-set    scheme
  • impc:ir:compiler:closure-set    scheme
  • impc:ir:compiler:closure-set    scheme
  • impc:ir:compiler:pointer-set    scheme
  • impc:ir:compiler:set!    scheme
  • impc:ir:compiler:tuple-set    scheme
  • impc:ir:compiler:vector-set    scheme
  • impc:ir:genericfunc-type-setup    scheme
  • impc:ti:array-set-check    scheme
  • impc:ti:closure-set-check    scheme
  • impc:ti:compile-type-dataconstructors    scheme
  • impc:ti:multicset    scheme
  • impc:ti:pointer-set-check    scheme
  • impc:ti:reset-builtin-cache    scheme
  • impc:ti:reset-closure-cache    scheme
  • impc:ti:reset-genericfunc-cache    scheme
  • impc:ti:reset-generictype-cache    scheme
  • impc:ti:reset-globalvar-cache    scheme
  • impc:ti:reset-namedtype-cache    scheme
  • impc:ti:reset-nativefunc-cache    scheme
  • impc:ti:reset-polyfunc-cache    scheme
  • impc:ti:reset-polytype-cache    scheme
  • impc:ti:reset-typealias-cache    scheme
  • impc:ti:reset-xtmacro-cache    scheme
  • impc:ti:reverse-set-bangs-from-reified    scheme
  • impc:ti:set-builtin-args    scheme
  • impc:ti:set-builtin-docstring    scheme
  • impc:ti:set-builtin-type-str    scheme
  • impc:ti:set-check    scheme
  • impc:ti:set-closure-body    scheme
  • impc:ti:set-closure-docstring    scheme
  • impc:ti:set-closure-type    scheme
  • impc:ti:set-closure-zone-size    scheme
  • impc:ti:set-globalvar-docstring    scheme
  • impc:ti:set-namedtype-docstring    scheme
  • impc:ti:set-nativefunc-arg-names    scheme
  • impc:ti:set-nativefunc-docstring    scheme
  • impc:ti:set-nativefunc-type    scheme
  • impc:ti:set-typealias-docstring    scheme
  • impc:ti:set-xtmacro-docstring    scheme
  • impc:ti:tuple-set-check    scheme
  • impc:ti:vector-set-check    scheme
  • init_sample_data    xtlang
  • init_sample_data    xtlang
  • ipc:set-local-remote-mapping    scheme
  • llvm:get-closure-setter    scheme
  • load-sample    scheme
  • load-sampler    scheme
  • load_cube_data    xtlang
  • load_data    xtlang
  • new_sample    xtlang
  • new_sample    xtlang
  • nnsock_set_recv_timeout    xtlang
  • nnsock_set_send_timeout    xtlang
  • nnsock_set_timeout    xtlang
  • ocv_dataPtr    xtlang
  • ocv_dataPtr    xtlang
  • ocv_set    xtlang
  • offset_momentum    xtlang
  • psystem-set-particle    xtlang
  • psystem-set-particle    xtlang
  • reset-zone    xtlang
  • reset_view_matrix    xtlang
  • reset_zone    xtlang
  • sampler    scheme
  • sampler    scheme
  • sampler-parse-filename    scheme
  • sampler-parse-midinote-filename    scheme
  • sampler-parse-spn-filename    scheme
  • sampler-populate-slot    scheme
  • sampler-set-slot-offset    scheme
  • sampler_fx    xtlang
  • sampler_note    xtlang
  • sampler_note_linear    xtlang
  • samples->clock    scheme
  • set-chord    scheme
  • set-data-arrays-lines    xtlang
  • set-data-arrays-points    xtlang
  • set-data-particles    xtlang
  • set-mouse-pos    xtlang
  • set-offset-x    xtlang
  • set-offset-y    xtlang
  • set-scale-x    xtlang
  • set-scale-y    xtlang
  • set-signal!    macro
  • set_amp_env    xtlang
  • set_attribute    xtlang
  • set_attribute    xtlang
  • set_attribute    xtlang
  • set_attribute    xtlang
  • set_attribute    xtlang
  • set_attribute    xtlang
  • set_beta    xtlang
  • set_bg    xtlang
  • set_cairo_source_with_colour    xtlang
  • set_car    xtlang
  • set_cdr    xtlang
  • set_delay    xtlang
  • set_dl_core    xtlang
  • set_dl_envs    xtlang
  • set_dl_filter    xtlang
  • set_dl_fm    xtlang
  • set_dl_main    xtlang
  • set_dl_osc    xtlang
  • set_filter    xtlang
  • set_filter_env    xtlang
  • set_flanger    xtlang
  • set_float_nans_    xtlang
  • set_instance_matrices    xtlang
  • set_lfo1    scheme
  • set_lfo1_type    scheme
  • set_lfo2    scheme
  • set_lfo2_type    scheme
  • set_lfo3    scheme
  • set_lfo3_type    scheme
  • set_lfo4    scheme
  • set_lfo4_type    scheme
  • set_midi_in    xtlang
  • set_midi_out    xtlang
  • set_mod_matrix    xtlang
  • set_monophonic    xtlang
  • set_noise_amp    xtlang
  • set_noise_type    xtlang
  • set_osc    xtlang
  • set_peq_hmid    xtlang
  • set_peq_hmid    xtlang
  • set_peq_hshelf    xtlang
  • set_peq_hshelf    xtlang
  • set_peq_lmid    xtlang
  • set_peq_lmid    xtlang
  • set_peq_lshelf    xtlang
  • set_peq_lshelf    xtlang
  • set_pitch_env    xtlang
  • set_polyphonic    xtlang
  • set_polyphony    xtlang
  • set_range    xtlang
  • set_reverb    xtlang
  • set_sample_offset_    xtlang
  • set_sampler_audiobuffer    xtlang
  • set_slide    xtlang
  • set_slide_texture    xtlang
  • set_speed    xtlang
  • set_trigger    xtlang
  • set_up_reply_socket    xtlang
  • set_up_request_socket    xtlang
  • set_up_sockets    xtlang
  • set_width_and_height    xtlang
  • set_window_wndproc    xtlang
  • sf_samplerate    xtlang
  • sf_samples_from_file    xtlang
  • sf_set_channels    xtlang
  • sf_set_format    xtlang
  • sf_set_frames    xtlang
  • sf_set_samplerate    xtlang
  • sf_set_sections    xtlang
  • sf_set_seekable    xtlang
  • shader_set_grid_offsets    xtlang
  • shader_setup_convolution_filter    xtlang
  • sys_env_set    xtlang
  • sys_file_datasync    xtlang
  • sys_file_datasync    xtlang
  • texture_setup    xtlang
  • unset_attribute    xtlang
  • update_data_points    xtlang
  • world_data    xtlang
  • world_data_index    xtlang
  • world_data_size    xtlang
  • world_reset    xtlang
  • world_set_generation    xtlang
  • world_set_to_checkerboard    xtlang
  • world_set_to_inverse    xtlang
  • world_texture_setup    xtlang
  • xobj_database    xtlang
  • xtm-setup-and-start-gl-loop    scheme
  • xtm_frame_data_to_tex    xtlang
  • xtm_paint_set_color    xtlang
  • xtm_paint_set_fill    xtlang
  • xtm_paint_set_pattern    xtlang
  • xtm_paint_set_stroke    xtlang
  • xtm_set_color32    xtlang
  • xtm_set_color32_alpha    xtlang
  • xtm_set_color32_blue    xtlang
  • xtm_set_color32_green    xtlang
  • xtm_set_color32_red    xtlang
  • xtm_set_vgimage_subdata    xtlang
  • xtm_vg_reset_matrices    xtlang
  • xtmtest-reset-results    scheme
  • xtmtest-reset-results    scheme