# This file is generated by autd_wrapper_generator (https://github.com/shinolab/autd-wrapper-generator)

function get_lib_ext()
    if Sys.iswindows()
        return ".dll"
    elseif Sys.isapple()
        return ".dylib"
    elseif Sys.islinux()
        return ".so"
    end
end

function get_lib_prefix()
    if Sys.iswindows()
        return ""
    else
        return "lib"
    end
end

@enum GainMode duty_phase_full = 1 phase_full = 2 phase_half = 4


const _autd3capi = joinpath(@__DIR__, "bin", get_lib_prefix() * "autd3capi" * get_lib_ext())
autd_create_controller(out) = ccall((:AUTDCreateController, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}},), out)

autd_open_controller(handle, p_link) = ccall((:AUTDOpenController, _autd3capi), Bool, (Ptr{Cvoid}, Ptr{Cvoid},), handle, p_link)

autd_add_device(handle, x, y, z, rz1, ry, rz2) = ccall((:AUTDAddDevice, _autd3capi), Int32, (Ptr{Cvoid}, Float64, Float64, Float64, Float64, Float64, Float64,), handle, x, y, z, rz1, ry, rz2)

autd_add_device_quaternion(handle, x, y, z, qw, qx, qy, qz) = ccall((:AUTDAddDeviceQuaternion, _autd3capi), Int32, (Ptr{Cvoid}, Float64, Float64, Float64, Float64, Float64, Float64, Float64,), handle, x, y, z, qw, qx, qy, qz)

autd_close_controller(handle) = ccall((:AUTDCloseController, _autd3capi), Int32, (Ptr{Cvoid},), handle)

autd_clear(handle) = ccall((:AUTDClear, _autd3capi), Int32, (Ptr{Cvoid},), handle)

autd_free_controller(handle) = ccall((:AUTDFreeController, _autd3capi), Cvoid, (Ptr{Cvoid},), handle)

autd_is_open(handle) = ccall((:AUTDIsOpen, _autd3capi), Bool, (Ptr{Cvoid},), handle)

autd_get_output_enable(handle) = ccall((:AUTDGetOutputEnable, _autd3capi), Bool, (Ptr{Cvoid},), handle)

autd_get_silent_mode(handle) = ccall((:AUTDGetSilentMode, _autd3capi), Bool, (Ptr{Cvoid},), handle)

autd_get_force_fan(handle) = ccall((:AUTDGetForceFan, _autd3capi), Bool, (Ptr{Cvoid},), handle)

autd_get_reads_fpga_info(handle) = ccall((:AUTDGetReadsFPGAInfo, _autd3capi), Bool, (Ptr{Cvoid},), handle)

autd_get_output_balance(handle) = ccall((:AUTDGetOutputBalance, _autd3capi), Bool, (Ptr{Cvoid},), handle)

autd_get_check_ack(handle) = ccall((:AUTDGetCheckAck, _autd3capi), Bool, (Ptr{Cvoid},), handle)

autd_set_output_enable(handle, enable) = ccall((:AUTDSetOutputEnable, _autd3capi), Cvoid, (Ptr{Cvoid}, Bool,), handle, enable)

autd_set_silent_mode(handle, mode) = ccall((:AUTDSetSilentMode, _autd3capi), Cvoid, (Ptr{Cvoid}, Bool,), handle, mode)

autd_set_reads_fpga_info(handle, reads_fpga_info) = ccall((:AUTDSetReadsFPGAInfo, _autd3capi), Cvoid, (Ptr{Cvoid}, Bool,), handle, reads_fpga_info)

autd_set_output_balance(handle, output_balance) = ccall((:AUTDSetOutputBalance, _autd3capi), Cvoid, (Ptr{Cvoid}, Bool,), handle, output_balance)

autd_set_check_ack(handle, check_ack) = ccall((:AUTDSetCheckAck, _autd3capi), Cvoid, (Ptr{Cvoid}, Bool,), handle, check_ack)

autd_set_force_fan(handle, force) = ccall((:AUTDSetForceFan, _autd3capi), Cvoid, (Ptr{Cvoid}, Bool,), handle, force)

autd_get_wavelength(handle) = ccall((:AUTDGetWavelength, _autd3capi), Float64, (Ptr{Cvoid},), handle)

autd_get_attenuation(handle) = ccall((:AUTDGetAttenuation, _autd3capi), Float64, (Ptr{Cvoid},), handle)

autd_set_wavelength(handle, wavelength) = ccall((:AUTDSetWavelength, _autd3capi), Cvoid, (Ptr{Cvoid}, Float64,), handle, wavelength)

autd_set_attenuation(handle, attenuation) = ccall((:AUTDSetAttenuation, _autd3capi), Cvoid, (Ptr{Cvoid}, Float64,), handle, attenuation)

autd_get_fpga_info(handle, out) = ccall((:AUTDGetFPGAInfo, _autd3capi), Bool, (Ptr{Cvoid}, Ptr{UInt8},), handle, out)

autd_update_ctrl_flags(handle) = ccall((:AUTDUpdateCtrlFlags, _autd3capi), Int32, (Ptr{Cvoid},), handle)

autd_set_delay_offset(handle, delay, offset) = ccall((:AUTDSetDelayOffset, _autd3capi), Int32, (Ptr{Cvoid}, Array{UInt8,1}, Array{UInt8,1},), handle, delay, offset)

autd_get_last_error(error) = ccall((:AUTDGetLastError, _autd3capi), Int32, (Ref{UInt8},), error)

autd_num_devices(handle) = ccall((:AUTDNumDevices, _autd3capi), Int32, (Ptr{Cvoid},), handle)

autd_trans_position(handle, device_idx, local_trans_idx, x, y, z) = ccall((:AUTDTransPosition, _autd3capi), Cvoid, (Ptr{Cvoid}, Int32, Int32, Ptr{Float64}, Ptr{Float64}, Ptr{Float64},), handle, device_idx, local_trans_idx, x, y, z)

autd_device_x_direction(handle, device_idx, x, y, z) = ccall((:AUTDDeviceXDirection, _autd3capi), Cvoid, (Ptr{Cvoid}, Int32, Ptr{Float64}, Ptr{Float64}, Ptr{Float64},), handle, device_idx, x, y, z)

autd_device_y_direction(handle, device_idx, x, y, z) = ccall((:AUTDDeviceYDirection, _autd3capi), Cvoid, (Ptr{Cvoid}, Int32, Ptr{Float64}, Ptr{Float64}, Ptr{Float64},), handle, device_idx, x, y, z)

autd_device_z_direction(handle, device_idx, x, y, z) = ccall((:AUTDDeviceZDirection, _autd3capi), Cvoid, (Ptr{Cvoid}, Int32, Ptr{Float64}, Ptr{Float64}, Ptr{Float64},), handle, device_idx, x, y, z)

autd_get_firmware_info_list_pointer(handle, out) = ccall((:AUTDGetFirmwareInfoListPointer, _autd3capi), Int32, (Ptr{Cvoid}, Ref{Ptr{Cvoid}},), handle, out)

autd_get_firmware_info(p_firm_info_list, index, cpu_ver, fpga_ver) = ccall((:AUTDGetFirmwareInfo, _autd3capi), Cvoid, (Ptr{Cvoid}, Int32, Ref{UInt8}, Ref{UInt8},), p_firm_info_list, index, cpu_ver, fpga_ver)

autd_free_firmware_info_list_pointer(p_firm_info_list) = ccall((:AUTDFreeFirmwareInfoListPointer, _autd3capi), Cvoid, (Ptr{Cvoid},), p_firm_info_list)

autd_gain_null(gain) = ccall((:AUTDGainNull, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}},), gain)

autd_gain_grouped(gain, handle) = ccall((:AUTDGainGrouped, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}}, Ptr{Cvoid}), gain, handle)

autd_gain_grouped_add(grouped_gain, device_id, gain) = ccall((:AUTDGainGroupedAdd, _autd3capi), Cvoid, (Ptr{Cvoid}, Int32, Ptr{Cvoid},), grouped_gain, device_id, gain)

autd_gain_focal_point(gain, x, y, z, duty) = ccall((:AUTDGainFocalPoint, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}}, Float64, Float64, Float64, UInt8,), gain, x, y, z, duty)

autd_gain_bessel_beam(gain, x, y, z, n_x, n_y, n_z, theta_z, duty) = ccall((:AUTDGainBesselBeam, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}}, Float64, Float64, Float64, Float64, Float64, Float64, Float64, UInt8,), gain, x, y, z, n_x, n_y, n_z, theta_z, duty)

autd_gain_plane_wave(gain, n_x, n_y, n_z, duty) = ccall((:AUTDGainPlaneWave, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}}, Float64, Float64, Float64, UInt8,), gain, n_x, n_y, n_z, duty)

autd_gain_custom(gain, data, data_length) = ccall((:AUTDGainCustom, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}}, Array{UInt16,1}, Int32,), gain, data, data_length)

autd_gain_transducer_test(gain, idx, duty, phase) = ccall((:AUTDGainTransducerTest, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}}, Int32, UInt8, UInt8,), gain, idx, duty, phase)

autd_delete_gain(gain) = ccall((:AUTDDeleteGain, _autd3capi), Cvoid, (Ptr{Cvoid},), gain)

autd_modulation_static(mod, duty) = ccall((:AUTDModulationStatic, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}}, UInt8,), mod, duty)

autd_modulation_custom(mod, buf, size) = ccall((:AUTDModulationCustom, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}}, Array{UInt8,1}, UInt32,), mod, buf, size)

autd_modulation_sine(mod, freq, amp, offset) = ccall((:AUTDModulationSine, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}}, Int32, Float64, Float64,), mod, freq, amp, offset)

autd_modulation_sine_squared(mod, freq, amp, offset) = ccall((:AUTDModulationSineSquared, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}}, Int32, Float64, Float64,), mod, freq, amp, offset)

autd_modulation_sine_legacy(mod, freq, amp, offset) = ccall((:AUTDModulationSineLegacy, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}}, Float64, Float64, Float64,), mod, freq, amp, offset)

autd_modulation_square(mod, freq, low, high, duty) = ccall((:AUTDModulationSquare, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}}, Int32, UInt8, UInt8, Float64,), mod, freq, low, high, duty)

autd_modulation_sampling_freq_div(mod) = ccall((:AUTDModulationSamplingFreqDiv, _autd3capi), UInt32, (Ptr{Cvoid},), mod)

autd_modulation_set_sampling_freq_div(mod, freq_div) = ccall((:AUTDModulationSetSamplingFreqDiv, _autd3capi), Cvoid, (Ptr{Cvoid}, UInt32), mod, freq_div)

autd_modulation_sampling_freq(mod) = ccall((:AUTDModulationSamplingFreq, _autd3capi), Float64, (Ptr{Cvoid},), mod)

autd_delete_modulation(mod) = ccall((:AUTDDeleteModulation, _autd3capi), Cvoid, (Ptr{Cvoid},), mod)

autd_sequence(out) = ccall((:AUTDSequence, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}},), out)

autd_gain_sequence(out, handle, gain_mode) = ccall((:AUTDGainSequence, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}}, Ptr{Cvoid}, UInt16,), out, handle, gain_mode)

autd_sequence_add_point(seq, x, y, z, duty) = ccall((:AUTDSequenceAddPoint, _autd3capi), Bool, (Ptr{Cvoid}, Float64, Float64, Float64, UInt8,), seq, x, y, z, duty)

autd_sequence_add_gain(seq, gain) = ccall((:AUTDSequenceAddGain, _autd3capi), Bool, (Ptr{Cvoid}, Ptr{Cvoid},), seq, gain)

autd_sequence_set_freq(seq, freq) = ccall((:AUTDSequenceSetFreq, _autd3capi), Float64, (Ptr{Cvoid}, Float64,), seq, freq)

autd_sequence_freq(seq) = ccall((:AUTDSequenceFreq, _autd3capi), Float64, (Ptr{Cvoid},), seq)

autd_sequence_period(seq) = ccall((:AUTDSequencePeriod, _autd3capi), UInt32, (Ptr{Cvoid},), seq)

autd_sequence_sampling_period(seq) = ccall((:AUTDSequenceSamplingPeriod, _autd3capi), UInt32, (Ptr{Cvoid},), seq)

autd_sequence_sampling_freq(seq) = ccall((:AUTDSequenceSamplingFreq, _autd3capi), Float64, (Ptr{Cvoid},), seq)

autd_sequence_sampling_freq_div(seq) = ccall((:AUTDSequenceSamplingFreqDiv, _autd3capi), UInt32, (Ptr{Cvoid},), seq)

autd_sequence_set_sampling_freq_div(seq, freq_div) = ccall((:AUTDSequenceSetSamplingFreqDiv, _autd3capi), Cvoid, (Ptr{Cvoid}, UInt32), seq, freq_div)

autd_delete_sequence(seq) = ccall((:AUTDDeleteSequence, _autd3capi), Cvoid, (Ptr{Cvoid},), seq)

autd_stop(handle) = ccall((:AUTDStop, _autd3capi), Int32, (Ptr{Cvoid},), handle)

autd_pause(handle) = ccall((:AUTDPause, _autd3capi), Int32, (Ptr{Cvoid},), handle)

autd_resume(handle) = ccall((:AUTDResume, _autd3capi), Int32, (Ptr{Cvoid},), handle)

autd_send_header(handle, header) = ccall((:AUTDSendHeader, _autd3capi), Int32, (Ptr{Cvoid}, Ptr{Cvoid},), handle, header)

autd_send_body(handle, body) = ccall((:AUTDSendBody, _autd3capi), Int32, (Ptr{Cvoid}, Ptr{Cvoid},), handle, body)

autd_send_header_body(handle, header, body) = ccall((:AUTDSendHeaderBody, _autd3capi), Int32, (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid},), handle, header, body)

autd_stm_controller(out, handle) = ccall((:AUTDSTMController, _autd3capi), Cvoid, (Ref{Ptr{Cvoid}}, Ptr{Cvoid},), out, handle)

autd_add_stm_gain(handle, gain) = ccall((:AUTDAddSTMGain, _autd3capi), Bool, (Ptr{Cvoid}, Ptr{Cvoid},), handle, gain)

autd_start_stm(handle, freq) = ccall((:AUTDStartSTM, _autd3capi), Bool, (Ptr{Cvoid}, Float64,), handle, freq)

autd_stop_stm(handle) = ccall((:AUTDStopSTM, _autd3capi), Bool, (Ptr{Cvoid},), handle)

autd_finish_stm(handle) = ccall((:AUTDFinishSTM, _autd3capi), Bool, (Ptr{Cvoid},), handle)

const _autd3capi_emulator_link = joinpath(@__DIR__, "bin", get_lib_prefix() * "autd3capi-emulator-link" * get_lib_ext())
autd_link_emulator(out, port, cnt) = ccall((:AUTDLinkEmulator, _autd3capi_emulator_link), Cvoid, (Ref{Ptr{Cvoid}}, UInt16, Ptr{Cvoid},), out, port, cnt)

const _autd3capi_from_file_modulation = joinpath(@__DIR__, "bin", get_lib_prefix() * "autd3capi-from-file-modulation" * get_lib_ext())
autd_modulation_raw_pcm(mod, filename, sampling_freq, mod_sampling_freq_div) = ccall((:AUTDModulationRawPCM, _autd3capi_from_file_modulation), Cvoid, (Ref{Ptr{Cvoid}}, Cstring, Float64, UInt16,), mod, filename, sampling_freq, mod_sampling_freq_div)

autd_modulation_wav(mod, filename, mod_sampling_freq_div) = ccall((:AUTDModulationWav, _autd3capi_from_file_modulation), Cvoid, (Ref{Ptr{Cvoid}}, Cstring, UInt16,), mod, filename, mod_sampling_freq_div)

const _autd3capi_holo_gain = joinpath(@__DIR__, "bin", get_lib_prefix() * "autd3capi-holo-gain" * get_lib_ext())
autd_eigen_backend(out) = ccall((:AUTDEigen3Backend, _autd3capi_holo_gain), Cvoid, (Ref{Ptr{Cvoid}},), out)

autd_delete_backend(backend) = ccall((:AUTDDeleteBackend, _autd3capi_holo_gain), Cvoid, (Ptr{Cvoid},), backend)

autd_gain_holo_sdp(gain, backend, points, amps, size, alpha, lambda, repeat, normalize) = ccall((:AUTDGainHoloSDP, _autd3capi_holo_gain), Cvoid, (Ref{Ptr{Cvoid}}, Ptr{Cvoid}, Array{Float64,1}, Array{Float64,1}, Int32, Float64, Float64, UInt64, Bool,), gain, backend, points, amps, size, alpha, lambda, repeat, normalize)

autd_gain_holo_evd(gain, backend, points, amps, size, gamma, normalize) = ccall((:AUTDGainHoloEVD, _autd3capi_holo_gain), Cvoid, (Ref{Ptr{Cvoid}}, Ptr{Cvoid}, Array{Float64,1}, Array{Float64,1}, Int32, Float64, Bool,), gain, backend, points, amps, size, gamma, normalize)

autd_gain_holo_naive(gain, backend, points, amps, size) = ccall((:AUTDGainHoloNaive, _autd3capi_holo_gain), Cvoid, (Ref{Ptr{Cvoid}}, Ptr{Cvoid}, Array{Float64,1}, Array{Float64,1}, Int32,), gain, backend, points, amps, size)

autd_gain_holo_gs(gain, backend, points, amps, size, repeat) = ccall((:AUTDGainHoloGS, _autd3capi_holo_gain), Cvoid, (Ref{Ptr{Cvoid}}, Ptr{Cvoid}, Array{Float64,1}, Array{Float64,1}, Int32, UInt64,), gain, backend, points, amps, size, repeat)

autd_gain_holo_gspat(gain, backend, points, amps, size, repeat) = ccall((:AUTDGainHoloGSPAT, _autd3capi_holo_gain), Cvoid, (Ref{Ptr{Cvoid}}, Ptr{Cvoid}, Array{Float64,1}, Array{Float64,1}, Int32, UInt64,), gain, backend, points, amps, size, repeat)

autd_gain_holo_lm(gain, backend, points, amps, size, eps_1, eps_2, tau, k_max, initial, initial_size) = ccall((:AUTDGainHoloLM, _autd3capi_holo_gain), Cvoid, (Ref{Ptr{Cvoid}}, Ptr{Cvoid}, Array{Float64,1}, Array{Float64,1}, Int32, Float64, Float64, Float64, UInt64, Array{Float64,1}, Int32,), gain, backend, points, amps, size, eps_1, eps_2, tau, k_max, initial, initial_size)

autd_gain_holo_gauss_newton(gain, backend, points, amps, size, eps_1, eps_2, k_max, initial, initial_size) = ccall((:AUTDGainHoloGaussNewton, _autd3capi_holo_gain), Cvoid, (Ref{Ptr{Cvoid}}, Ptr{Cvoid}, Array{Float64,1}, Array{Float64,1}, Int32, Float64, Float64, UInt64, Array{Float64,1}, Int32,), gain, backend, points, amps, size, eps_1, eps_2, k_max, initial, initial_size)

autd_gain_holo_gradient_descent(gain, backend, points, amps, size, eps, step, k_max, initial, initial_size) = ccall((:AUTDGainHoloGradientDescent, _autd3capi_holo_gain), Cvoid, (Ref{Ptr{Cvoid}}, Ptr{Cvoid}, Array{Float64,1}, Array{Float64,1}, Int32, Float64, Float64, UInt64, Array{Float64,1}, Int32,), gain, backend, points, amps, size, eps, step, k_max, initial, initial_size)

autd_gain_holo_apo(gain, backend, points, amps, size, eps, lambda, k_max) = ccall((:AUTDGainHoloAPO, _autd3capi_holo_gain), Cvoid, (Ref{Ptr{Cvoid}}, Ptr{Cvoid}, Array{Float64,1}, Array{Float64,1}, Int32, Float64, Float64, UInt64,), gain, backend, points, amps, size, eps, lambda, k_max)

autd_gain_holo_greedy(gain, backend, points, amps, size, phase_div) = ccall((:AUTDGainHoloGreedy, _autd3capi_holo_gain), Cvoid, (Ref{Ptr{Cvoid}}, Ptr{Cvoid}, Array{Float64,1}, Array{Float64,1}, Int32, Int32,), gain, backend, points, amps, size, phase_div)

const _autd3capi_remote_twincat_link = joinpath(@__DIR__, "bin", get_lib_prefix() * "autd3capi-remote-twincat-link" * get_lib_ext())
autd_link_remote_twincat(out, remote_ip_addr, remote_ams_net_id, local_ams_net_id) = ccall((:AUTDLinkRemoteTwinCAT, _autd3capi_remote_twincat_link), Cvoid, (Ref{Ptr{Cvoid}}, Cstring, Cstring, Cstring,), out, remote_ip_addr, remote_ams_net_id, local_ams_net_id)

const _autd3capi_soem_link = joinpath(@__DIR__, "bin", get_lib_prefix() * "autd3capi-soem-link" * get_lib_ext())
autd_get_adapter_pointer(out) = ccall((:AUTDGetAdapterPointer, _autd3capi_soem_link), Int32, (Ref{Ptr{Cvoid}},), out)

autd_get_adapter(p_adapter, index, desc, name) = ccall((:AUTDGetAdapter, _autd3capi_soem_link), Cvoid, (Ptr{Cvoid}, Int32, Ref{UInt8}, Ref{UInt8},), p_adapter, index, desc, name)

autd_free_adapter_pointer(p_adapter) = ccall((:AUTDFreeAdapterPointer, _autd3capi_soem_link), Cvoid, (Ptr{Cvoid},), p_adapter)

autd_link_soem(out, ifname, device_num, cycle_ticks) = ccall((:AUTDLinkSOEM, _autd3capi_soem_link), Cvoid, (Ref{Ptr{Cvoid}}, Cstring, Int32, UInt32,), out, ifname, device_num, cycle_ticks)

autd_set_soem_on_lost(link, callback) = ccall((:AUTDSetSOEMOnLost, _autd3capi_soem_link), Cvoid, (Ptr{Cvoid}, Ptr{Cvoid},), link, callback)

const _autd3capi_twincat_link = joinpath(@__DIR__, "bin", get_lib_prefix() * "autd3capi-twincat-link" * get_lib_ext())
autd_link_twincat(out) = ccall((:AUTDLinkTwinCAT, _autd3capi_twincat_link), Cvoid, (Ref{Ptr{Cvoid}},), out)

const _autd3capi_arrayfire_backend = joinpath(@__DIR__, "bin", get_lib_prefix() * "autd3capi-arrayfire-backend" * get_lib_ext())
autd_array_fire_backend(out) = ccall((:AUTDArrayFireBackend, _autd3capi_arrayfire_backend), Cvoid, (Ref{Ptr{Cvoid}},), out)

const _autd3capi_blas_backend = joinpath(@__DIR__, "bin", get_lib_prefix() * "autd3capi-blas-backend" * get_lib_ext())
autd_blas_backend(out) = ccall((:AUTDBLASBackend, _autd3capi_blas_backend), Cvoid, (Ref{Ptr{Cvoid}},), out)

const _autd3capi_cuda_backend = joinpath(@__DIR__, "bin", get_lib_prefix() * "autd3capi-cuda-backend" * get_lib_ext())
autd_cuda_backend(out) = ccall((:AUTDCUDABackend, _autd3capi_cuda_backend), Cvoid, (Ref{Ptr{Cvoid}},), out)


