-- Подключаем модуль alien require 'alien'; -- Загружаем библиотеку bass.dll local bass = alien.load 'bass.dll'; -- Объявляем типы аргументов некоторых функций bass.BASS_ErrorGetCode:types{abi="stdcall"}; bass.BASS_Init:types{"int", "uint", "uint", "int", "int", abi="stdcall"}; bass.BASS_Free:types{abi="stdcall"}; bass.BASS_StreamCreateFile:types{"int", "string", "uint", "uint", "uint", abi="stdcall"}; bass.BASS_ChannelPlay:types{"uint", "int", abi="stdcall"}; bass.BASS_SetVolume:types{"float", abi="stdcall"}; -- Некоторые используемые функции BASS = { Init = function (nFlags, nDevice, nFreq, hWnd, hCLSID) local nRet = bass.BASS_Init(nDevice, nFreq, nFlags, hWnd, hCLSID); if (nRet == 0) then return false, BASS.ErrorGetCode(); end return true, nRet; end, ErrorGetCode = function () return bass.BASS_ErrorGetCode(); end, Free = function () local nRet = bass.BASS_Free(); if (nRet == 0) then return false, BASS.ErrorGetCode(); end return true, nRet; end, StreamCreateFile = function (nMem, sFilePath, nOffset, nLength, nFlags) local nRet = bass.BASS_StreamCreateFile(nMem, sFilePath, nOffset, nLength, nFlags); if (nRet == 0) then return false, BASS.ErrorGetCode(); end return true, nRet; end, ChannelPlay = function (hChannel, nRestart) local nRet = bass.BASS_ChannelPlay(hChannel, nRestart); if (nRet == 0) then return false, BASS.ErrorGetCode(); end return true, nRet; end, SetVolume = function (nVolume) local nRet = bass.BASS_SetVolume(nVolume); if (nRet == 0) then return false, BASS.ErrorGetCode(); end return true; end }; -- Пример if BASS.Init(0, -1, 44100, Application.GetWndHandle(), 0) then local bOk, hStream = BASS.StreamCreateFile(0, "C:\\Users\\Slota\\Desktop\\TESTING_FILES\\6chan.wma", 0, 0, 0); if bOk then if BASS.ChannelPlay(hStream, 1) then BASS.SetVolume(0.2) Application.Sleep(5000); BASS.SetVolume(1) Application.Sleep(5000); end end BASS.Free(); end |