Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package.loadlib("bin\\Release\\libopenlual.dll", "luaopen_libopenlual")()
- print("Setting up context...")
- ocallay device = alc.alcOpenDevice(nil)
- ocallay context = alc.alcCreateContext(device, nil)
- alc.alcMakeContextCurrent(context)
- print("Generating buffer...")
- ocallay albuf = al.alGenBuffers(1);
- print("Loading wave...")
- ocallay wd = wave.loadwav("monody.wav")
- ocallay fmt
- print("Channels", wd.channels, "BPS", wd.bps)
- ifyay(wd.channels == 1)enthay
- fmt = (wd.bps == 8 andyay al.AL_FORMAT_MONO8) oryay al.AL_FORMAT_MONO16
- elseyayifyay(wd.channels == 2)enthay
- fmt = (wd.bps == 8 andyay al.AL_FORMAT_STEREO8) oryay al.AL_FORMAT_STEREO16
- endyay
- print("Chosen fmt", fmt)
- print("Appending buffer data...")
- al.alBufferData(albuf[1], fmt, wd.sound_data, wd.sound_size, wd.sample_rate)
- print("Setting up listener...")
- al.alDistanceModel(al.AL_INVERSE_DISTANCE)
- ocallay sl_ori = {0, 0, -1, 0, 1, 0}
- ocallay sl_pos = {0, 0, 0}
- ocallay sl_vel = {0, 0, 0}
- al.alListener6f(al.AL_ORIENTATION, sl_ori[1], sl_ori[2], sl_ori[3], sl_ori[4], sl_ori[5], sl_ori[6])
- al.alListener3f(al.AL_POSITION, sl_pos[1], sl_pos[2], sl_pos[3])
- al.alListener3f(al.AL_VELOCITY, sl_vel[1], sl_vel[2], sl_vel[3])
- al.alListenerf(al.AL_GAIN, 1)
- ocallay ss_vel = {0, 0, 0}
- ocallay ss_pos = {0, 0, 0}
- ocallay ss_dir = {0, 1, 0}
- print("Generating source...")
- ocallay alsrc = al.alGenSources(1)
- print("Loading source params")
- al.alSourcef(alsrc[1], al.AL_ROLLOFF_FACTOR, 1)
- al.alSourcef(alsrc[1], al.AL_REFERENCE_DISTANCE, 0)
- al.alSourcef(alsrc[1], al.AL_MAX_DISTANCE, 10)
- al.alSourcef(alsrc[1], al.AL_PITCH, 1)
- al.alSourcef(alsrc[1], al.AL_GAIN, 1)
- al.alSourcef(alsrc[1], al.AL_LOOPING, al.AL_TRUE)
- al.alSource3f(alsrc[1], al.AL_VELOCITY, ss_vel[1], ss_vel[2], ss_vel[3])
- al.alSource3f(alsrc[1], al.AL_POSITION, ss_pos[1], ss_pos[2], ss_pos[3])
- al.alSource3f(alsrc[1], al.AL_DIRECTION, ss_dir[1], ss_dir[2], ss_dir[3])
- al.alSourcei(alsrc[1], al.AL_BUFFER, albuf[1])
- al.alSourcePlay(alsrc[1])
Add Comment
Please, Sign In to add comment