Skip to content

Instantly share code, notes, and snippets.

@ricardojoserf
Created January 30, 2025 15:42
Show Gist options
  • Select an option

  • Save ricardojoserf/92f6d6820e008576445deefcbd7e4e16 to your computer and use it in GitHub Desktop.

Select an option

Save ricardojoserf/92f6d6820e008576445deefcbd7e4e16 to your computer and use it in GitHub Desktop.
kernel32!Beep function in Matlab
if not(libisloaded('kernel32'))
loadlibrary('kernel32.dll', @kernel32proto); % Cambiamos a kernel32.dll
end
frequency = uint32(750);
duration = uint32(1000);
result = calllib('kernel32', 'Beep', frequency, duration);
disp(['Beep result: ', num2str(result)]);
unloadlibrary('kernel32');
function [fcns, structs, enuminfo] = kernel32proto
fcns = [];
structs = [];
enuminfo = [];
fcns.alias = {};
fcns.name{1} = 'Beep';
fcns.calltype{1} = 'cdecl'; % Windows API usa stdcall
fcns.LHS{1} = 'uint32'; % Retorno: BOOL (1 = éxito)
fcns.RHS{1} = {'uint32', 'uint32'}; % Argumentos: frecuencia (DWORD), duración (DWORD)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment