Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ Lua
➜ Problem with proteaAudio
Posting of new messages is disabled at present.
Refresh page
Posted by
| Cage_fire_2000
USA (119 posts) Bio
|
Date
| Fri 01 Apr 2011 10:12 PM (UTC) Amended on Fri 01 Apr 2011 10:33 PM (UTC) by Cage_fire_2000
|
Message
| I'm trying to get this lua package to work in mushclient so I can play musical tones, I copy the .dll to the mushclient folder, and try the scale.lua script, and it seems to error on the 'require' saying it can't find the module.
Here's the link to the package:
http://viremo.eludi.net/proteaAudio/index.html
Could anybody tell me what I'm doing wrong? Is the package not compatible with mushclient's version of lua? Or is it something that I might actually fix?
Edit: Failing to find a solution, can anybody recommend another package that would allow this? I'm basically trying to emulate the PLAY command from old versions of BASIC.
Here is the script I'm using:
-- function creating a sine wave sample:
function sampleSine(freq, duration, sampleRate)
local data = { }
for i = 1,duration*sampleRate do
data = math.sin( (i*freq/sampleRate)*math.pi*2)
end
return proAudio.sampleFromMemory(data, sampleRate)
end
-- plays a sample shifted by a number of halftones for a definable period of time
function playNote(sample, pitch, duration, volumeL, volumeR, disparity)
local scale = 2^(pitch/12)
local sound = proAudio.soundLoop(sample, volumeL, volumeR, disparity, scale)
proAudio.sleep(duration)
proAudio.soundStop(sound)
end
-- create an audio device using default parameters and exit in case of errors
require("proAudioRt")
if not proAudio.create() then os.exit(1) end
-- generate a sample:
local sample = sampleSine(440, 0.5, 88200)
-- play scale (a major):
local duration = 0.5
for i,note in ipairs({ 0, 2, 4, 5, 7, 9, 11, 12 }) do
playNote(sample, note, duration)
end
-- cleanup
proAudio.destroy()
It seems to find the file, but it says it can't find the module, I'm not sure what this means. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sat 02 Apr 2011 07:39 AM (UTC) |
Message
| Sounds like the entry point isn't right. Maybe use package.loadlib instead or require?
I don't know the exact entry point name, as I haven't used this before. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Cage_fire_2000
USA (119 posts) Bio
|
Date
| Reply #2 on Sat 02 Apr 2011 03:46 PM (UTC) |
Message
| Hmm, that wouldn't explain why that script works just fine in the stand-alone version of lua that came with the library, but won't work in mushclient. I think they're supposed to be the same version, although the one with the library the file says lua51.dll and MC says lua5.1.dll just a minor difference. Looking further, the package's lua .dll is only 65 KB while mushclient's is 194 KB, so they're not identical, but they should be close enough to work I assume. It's the same language. If the require works in one, shouldn't it work in the other?
Regardless, I've tried package.loadlib, but I'm not sure how to determine the loading point. I've looked at the C++ source, but I don't know what the loading point is. I've tried a bunch of variations, but not matter what I try, it says can't find module.
Sigh... I just don't understand why it works fine with lua by itself, but not within mushclient. Maybe I'll have to try to search for some other library.
Update: I managed to get it working, I figured out how to check the dependencies, and apparently lua51.dll was a dependancy, so I copied it over and it now works. | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #3 on Sat 02 Apr 2011 09:37 PM (UTC) |
Message
|
Cage_fire_2000 said: Update: I managed to get it working, I figured out how to check the dependencies, and apparently lua51.dll was a dependancy, so I copied it over and it now works.
Unless lua51.dll proxies to lua5.1.dll, that's asking for trouble. You now have two separate instantiations of the Lua library in memory, which leads to a bunch of problems like memory allocation and ownership. Here's a post (by Nick at that!) on the Lua-L mailing list describing this: http://lua-users.org/lists/lua-l/2008-06/msg00076.html |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Cage_fire_2000
USA (119 posts) Bio
|
Date
| Reply #4 on Sat 02 Apr 2011 10:06 PM (UTC) Amended on Sat 02 Apr 2011 10:09 PM (UTC) by Cage_fire_2000
|
Message
| Hmm, I don't know, I looked at some of the replies to that post and they seem to disagree, and I haven't seen any problems, also, what does 'proxied' mean?
Edit: Anyway, I don't have much choice in the matter, as I can't recompile it to use 5.1 instead of 51, as I don't have the right software, if somebody wanted to do that for me, I'd be grateful I guess, as it'd be one less file I'd have to include with the plugin. | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #5 on Sat 02 Apr 2011 10:15 PM (UTC) |
Message
|
Cage_fire_2000 said: Hmm, I don't know, I looked at some of the replies to that post and they seem to disagree, and I haven't seen any problems, also, what does 'proxied' mean?
It depends on where you got lua51.dll. Did it come with, say, LuaBinaries? In that case it's safe, because that DLL just proxies (i.e. passes function calls on) to lua5.1.dll. Also, how does its size compare to MUSHclient's lua5.1.dll? |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #6 on Sat 02 Apr 2011 10:16 PM (UTC) |
Message
|
Quote:
... they seem to disagree ...
They would! I don't read that mailing list that often. Rant omitted.
In summary, it is hard to find agreement on many points regarding Lua future development. Even something fairly straightforward like the name of a DLL.
You would think, wouldn't you, that the logical name for a DLL for Lua 5.1 would be lua5.1.dll (and not lua51.dll which implies we are up to version 51) but no, no such agreement was reached.
Anyway, the workaround, basically needed because no other agreement could be reached, was that a "proxy" DLL was invented (I think it was lua51.dll) which does not implement any code, but just has entry and exit points which basically link all the relevant function names to the "real" ones in lua5.1.dll.
So if you can grab a copy of that from LuaBinaries, or wherever, then things should work. It should be small, like 10 Kb or so (or less) because it doesn't actually have code in it, it just links the entry points.
As Twisol said, if you simply *copy* one DLL and give it a different name, then you now have two copies of the code as well, and that may lead to crashes (eg. because memory is allocated in one copy and garbage-collected in the other).
Try Googling "lua51.dll proxy".
If you find a proxy "the wrong way around" then just rename the current lua5.1.dll as lua51.dll and have the proxy lua5.1.dll. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Cage_fire_2000
USA (119 posts) Bio
|
Date
| Reply #7 on Sat 02 Apr 2011 10:58 PM (UTC) |
Message
| I think I found one from LuaBinaries, but I tried putting it in and it broke it. Now it says procedure not found. Also the lua5.1.dll that came with it is a different size. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #8 on Sun 03 Apr 2011 05:01 AM (UTC) |
Message
| To be honest I found that making DLLs work with Lua one of the more frustrating aspects to it. Plus the attitude on the mailing list can largely be summed up as "don't use Windows".
You have the lua5.1.dll / lua51.dll fiasco. And then with the upgrade to Lua 5.2, you have the issue of the way things inside Lua changing, you have to link (at runtime) against the right DLL, which isn't obvious which it is, and is very hard to do if you are using Lua 5.1 and Lua 5.2 on the same machine.
Here are some of the responses I got when I raised all that:
Quote:
... it's not Luas problem per se
and:
Quote:
... this is a windows problem.
and:
Quote:
... just link statically
Right, thanks. But it's a problem for users of Lua, who happen to use Windows. The "it's not our problem" approach is rather off-putting. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
25,542 views.
Posting of new messages is disabled at present.
Refresh page
top