Open ghost opened 3 years ago
I'm using this code:
local ao = require("ao")
-- ao.initialize() is done automatically :-)
-- you will only need it if you have to restart the environment
-- Setup the default live driver
local default_driver = ao.defaultDriverId()
local format = { bits=16; channels=2; rate=44100; byteFormat="little"; }
local info = ao.driverInfoList()
for _,key in pairs(info) do
print("=================================================")
for option, value in pairs(key) do
if option == "options" then
print("=> "..option..":")
for k, v in ipairs(value) do
print("\t - "..v)
end
else
print("=> "..option..":\t"..value)
end
end
end
print("=================================================")
print("=> Device ID: "..default_driver)
print("=================================================")
-- Open the driver
local device = ao.openLive(default_driver, format)
if not device then error("Error opening device.") end
-- Play a one second sine-wave
local freq = 440.0
local buf_size = format.bits/8 * format.channels * format.rate
local buffer = {}
for i = 0,format.rate do -- one second
sample = 0.75 * math.sin(2*math.pi*freq*i / format.rate)
buffer[2*i+1] = sample -- left
buffer[2*i+2] = sample -- right
end
device:play( ao.array2string(buffer) ) -- assumes 16 bits ...
-- Close and shutdown is handled by the garbage collector :-)
i'm using the example
ao_live.lua
but show this error, my operating system is GNU/Linux: