note description: "Tools to capture audio from a capturing audio device" author: "Louis Marchand" date: "Thu, 15 Jun 2017 19:17:55 +0000" revision: "0.1" class interface AUDIO_CAPTURE_CONTROLLER create {AUDIO_LIBRARY_CONTROLLER} make feature -- Access is_capturing: BOOLEAN -- Current is presently capturing sound is_device_closed: BOOLEAN -- The capturing device id closed channel_count: INTEGER_32 -- The channel number of Current (1=mono, 2=stereo, etc.). frequency: INTEGER_32 -- The frequency (sample rate) of Current. bits_per_sample: INTEGER_32 -- The bit resolution of one frame of Current (without channel count). buffer_sample_count: INTEGER_32 -- The number of samples that the buffer will be able to contain (for example, -- a stereo 16 bits capture with a buffer count of 1024 will have the size 1024*2*2 = 5096 bytes) buffer: MANAGED_POINTER -- The data that has been read by update start_capture -- Strart the capture (use update to fill the buffer) require device_open: not is_device_closed not_already_started: not is_capturing ensure capture_started: not has_error implies is_capturing stop_capture -- Stop the capture require device_open: not is_device_closed not_already_stopped: is_capturing ensure captue_stopped: not is_capturing update -- Update a_buffer with the new value of the capture require device_open: not is_device_closed is_capturing: is_capturing has_samples: BOOLEAN -- Samples has been found by the last call to update get_sample (a_index: INTEGER_32): LIST [INTEGER_16] -- Get the sample at the position a_index in the buffer (start at 1). -- The number of value in Result represent the channel_count -- If bits_per_sample is 8, the values are unsigned from 0 to 255 with 128 being an ouput level of 0 -- If bits_per_sample is 16, the values are signed from -32768 to 32767 with 0 being an ouput level of 0 require index_valid: a_index >= 1 and a_index <= buffer_sample_count ensure sample_count_valid: Result.count ~ channel_count invariant buffer_count_valid: buffer.count ~ buffer_sample_count * channel_count * (bits_per_sample // 8) end -- class AUDIO_CAPTURE_CONTROLLER
Generated by ISE EiffelStudio