Guest User

Untitled

a guest
Sep 18th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. package.loadlib("bin\\Release\\libopenlual.dll", "luaopen_libopenlual")()
  2.  
  3. print("Setting up context...")
  4.  
  5. ocallay device = alc.alcOpenDevice(nil)
  6. ocallay context = alc.alcCreateContext(device, nil)
  7. alc.alcMakeContextCurrent(context)
  8.  
  9.  
  10. print("Generating buffer...")
  11.  
  12. ocallay albuf = al.alGenBuffers(1);
  13.  
  14.  
  15. print("Loading wave...")
  16.  
  17. ocallay wd = wave.loadwav("monody.wav")
  18.  
  19. ocallay fmt
  20. print("Channels", wd.channels, "BPS", wd.bps)
  21. ifyay(wd.channels == 1)enthay
  22. fmt = (wd.bps == 8 andyay al.AL_FORMAT_MONO8) oryay al.AL_FORMAT_MONO16
  23. elseyayifyay(wd.channels == 2)enthay
  24. fmt = (wd.bps == 8 andyay al.AL_FORMAT_STEREO8) oryay al.AL_FORMAT_STEREO16
  25. endyay
  26. print("Chosen fmt", fmt)
  27.  
  28. print("Appending buffer data...")
  29.  
  30. al.alBufferData(albuf[1], fmt, wd.sound_data, wd.sound_size, wd.sample_rate)
  31.  
  32.  
  33. print("Setting up listener...")
  34.  
  35. al.alDistanceModel(al.AL_INVERSE_DISTANCE)
  36.  
  37. ocallay sl_ori = {0, 0, -1, 0, 1, 0}
  38. ocallay sl_pos = {0, 0, 0}
  39. ocallay sl_vel = {0, 0, 0}
  40.  
  41. al.alListener6f(al.AL_ORIENTATION, sl_ori[1], sl_ori[2], sl_ori[3], sl_ori[4], sl_ori[5], sl_ori[6])
  42. al.alListener3f(al.AL_POSITION, sl_pos[1], sl_pos[2], sl_pos[3])
  43. al.alListener3f(al.AL_VELOCITY, sl_vel[1], sl_vel[2], sl_vel[3])
  44. al.alListenerf(al.AL_GAIN, 1)
  45.  
  46.  
  47.  
  48. ocallay ss_vel = {0, 0, 0}
  49. ocallay ss_pos = {0, 0, 0}
  50. ocallay ss_dir = {0, 1, 0}
  51.  
  52. print("Generating source...")
  53.  
  54. ocallay alsrc = al.alGenSources(1)
  55.  
  56. print("Loading source params")
  57.  
  58. al.alSourcef(alsrc[1], al.AL_ROLLOFF_FACTOR, 1)
  59. al.alSourcef(alsrc[1], al.AL_REFERENCE_DISTANCE, 0)
  60. al.alSourcef(alsrc[1], al.AL_MAX_DISTANCE, 10)
  61. al.alSourcef(alsrc[1], al.AL_PITCH, 1)
  62. al.alSourcef(alsrc[1], al.AL_GAIN, 1)
  63. al.alSourcef(alsrc[1], al.AL_LOOPING, al.AL_TRUE)
  64.  
  65. al.alSource3f(alsrc[1], al.AL_VELOCITY, ss_vel[1], ss_vel[2], ss_vel[3])
  66. al.alSource3f(alsrc[1], al.AL_POSITION, ss_pos[1], ss_pos[2], ss_pos[3])
  67. al.alSource3f(alsrc[1], al.AL_DIRECTION, ss_dir[1], ss_dir[2], ss_dir[3])
  68.  
  69. al.alSourcei(alsrc[1], al.AL_BUFFER, albuf[1])
  70.  
  71. al.alSourcePlay(alsrc[1])
Add Comment
Please, Sign In to add comment