Music like in Nintendo games

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
zorg
Party member
Posts: 2653
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Music like in Nintendo games

Post by zorg » Wed Jun 14, 2017 12:20 am

therektafire wrote:
Wed Jun 14, 2017 12:07 am
Now how do you create multiple threads in lua? :/ I know about coroutines but I don't think those are the same thing?
You don't, you create them with löve; love.thread uses real os treads, so they're truly paralell, unlike lua coroutines.
Fair warning though, you can only pass data to threads by channels (and when starting the thread itself), and channels don't support non-flat tables, nor foreign lua userdata stuff... that said, you can segue around things if you (ab)use data objects. This is kinda the reason why i've been putting off threading my player, because i can't be arsed to think about what would be the most optimal with regards to inter-thread communication.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

User avatar
raidho36
Party member
Posts: 1833
Joined: Mon Jun 17, 2013 12:00 pm

Re: Music like in Nintendo games

Post by raidho36 » Wed Jun 14, 2017 1:26 am

Fastest IPC is shared memory, it can't possibly be any faster. You can use Data objects for that. But you will need to somehow ensure that there would be no write clashing. Alternatively, you can send messages containing relevant data, which is the implemented method, but due to having to copy memory it's not very fast. Realistically​, unless you work with FFI mostly, you cannot utilize shared memory - you'd be copying it around either way, rendering this pointless. But if you do, you can use hybrid method: store relevant data in shared memory and send a message when it should be read or written. Note that you will need to use structs by pointer within shared memory, otherwise you're again wind up copying memory.

User avatar
zorg
Party member
Posts: 2653
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Music like in Nintendo games

Post by zorg » Wed Jun 14, 2017 3:12 am

raidho, löve objects through channels only have their pointers copied, and you don't need to use FFI for that. And for this specific use-case, sounddata can be used as it is.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

User avatar
raidho36
Party member
Posts: 1833
Joined: Mon Jun 17, 2013 12:00 pm

Re: Music like in Nintendo games

Post by raidho36 » Wed Jun 14, 2017 5:17 am

If you just want to send SoundData object which itself is light userdata then sure. I was describing general purpose method of inter-process communication involving heavy data.

MasterLee
Party member
Posts: 141
Joined: Tue Mar 07, 2017 4:03 pm
Contact:

Re: Music like in Nintendo games

Post by MasterLee » Wed Jun 14, 2017 7:55 am

PC Speaker has way better sound than you might expect
https://www.youtube.com/watch?v=J42iN3HMB68
Sadly there is no emulator capable to run those programs these days.
But maybe you are searching something like QBasic PLAY command.

User avatar
zorg
Party member
Posts: 2653
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Music like in Nintendo games

Post by zorg » Wed Jun 14, 2017 9:40 am

MasterLee wrote:
Wed Jun 14, 2017 7:55 am
PC Speaker has way better sound than you might expect
https://www.youtube.com/watch?v=J42iN3HMB68
That's an Amstrad PC1512, an IBM PC Clone, with some interesting added features:
"The series was somewhat unusual for the fact that it had a physical volume control on the internal speaker. This allowed the user to make the machine beep quietly, or silently, from boot time onwards. This innovation is still not present in most modern PCs: the legacy beeper is typically still a fixed-volume device, though external speakers connected via dedicated sound hardware do usually have a volume control." - Wikipedia

But yes, the pc speaker could (if it had a membrane, and wasn't piezo-electric) behave more like a "regular" speaker than a 1-bit buzzer for the following reason: Having a fast enough sampling rate (as in, small enough delay between state changes) can actually change the speaker magnet's polarity -before- it reaches any of the two extremes, thereby simulating more than a 1-bit bit depth.

This only works with membrane speakers because piezos don't have "in-between" states (they do, but the transition is magnitudes faster for any data signal to compensate for it).
MasterLee wrote:
Wed Jun 14, 2017 7:55 am
Sadly there is no emulator capable to run those programs these days.
DOSBox would argue about that with you, but its emulation isn't perfect in that regard, last i checked anyway.
MasterLee wrote:
Wed Jun 14, 2017 7:55 am
But maybe you are searching something like QBasic PLAY command.
Who exactly? therektafire probably knows what he wants, and Nutte was already done with the thread.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

MasterLee
Party member
Posts: 141
Joined: Tue Mar 07, 2017 4:03 pm
Contact:

Re: Music like in Nintendo games

Post by MasterLee » Wed Jun 14, 2017 10:21 am

zorg wrote:
Wed Jun 14, 2017 9:40 am
MasterLee wrote:
Wed Jun 14, 2017 7:55 am
PC Speaker has way better sound than you might expect
https://www.youtube.com/watch?v=J42iN3HMB68
That's an Amstrad PC1512, an IBM PC Clone, with some interesting added features:
It also worked on Highscreen Kompakt Serie III 286-16 also an PC Clone, also it worked on my uncles PC and all PCs of my friends. But at that time we had no video equipment and no youtube available.
zorg wrote:
Wed Jun 14, 2017 9:40 am
DOSBox would argue about that with you, but its emulation isn't perfect in that regard, last i checked anyway.
It definitly doesn't work on DOSBox.
zorg wrote:
Wed Jun 14, 2017 9:40 am
MasterLee wrote:
Wed Jun 14, 2017 7:55 am
But maybe you are searching something like QBasic PLAY command.
Who exactly? therektafire probably knows what he wants, and Nutte was already done with the thread.
Ok i thought Nutte wanted something to program sound like it was done in old AGI games. I tried to read everything here but maybe i missed the part.

User avatar
zorg
Party member
Posts: 2653
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Music like in Nintendo games

Post by zorg » Wed Jun 14, 2017 3:43 pm

MasterLee wrote:
Wed Jun 14, 2017 10:21 am
zorg wrote:
Wed Jun 14, 2017 9:40 am
That's an Amstrad PC1512, an IBM PC Clone, with some interesting added features:
It also worked on Highscreen Kompakt Serie III 286-16 also an PC Clone, also it worked on my uncles PC and all PCs of my friends. But at that time we had no video equipment and no youtube available.
As i said, as long as the speaker had membranes, it could be made to produce digital audio:
https://en.wikipedia.org/wiki/PC_speake ... modulation
http://www.oldskool.org/sound/pc/#digitized
MasterLee wrote:
Wed Jun 14, 2017 10:21 am
zorg wrote:
Wed Jun 14, 2017 9:40 am
DOSBox would argue about that with you, but its emulation isn't perfect in that regard, last i checked anyway.
It definitly doesn't work on DOSBox.
I meant that programs that utilize the pc speaker are emulated, but it will sound through your normal speakers/headphones, and not your real computer's "pc speaker", if it even has one; nowadays it may not even be there. (And it may not support a high enough rate for the PCM shenanigans mentioned above)
MasterLee wrote:
Wed Jun 14, 2017 10:21 am
zorg wrote:
Wed Jun 14, 2017 9:40 am
Who exactly? therektafire probably knows what he wants, and Nutte was already done with the thread.
Ok i thought Nutte wanted something to program sound like it was done in old AGI games. I tried to read everything here but maybe i missed the part.
He kinda did, though this thread ceased to be about him after he left.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

dewgstrom
Prole
Posts: 10
Joined: Thu Apr 13, 2017 9:06 pm

Re: Music like in Nintendo games

Post by dewgstrom » Thu Jun 15, 2017 3:10 pm

I think this is at least an interesting enough topic to keep up, there's a lot of different ways to handle this sort of thing.

Is there much documentation available on the .xm format? I can't imagine it would be too hard to write something in pure Lua to tinker with non-playing XM files in memory, like for key or instrument changes, and swap them around or crossfade using love.audio. You could probably end up with something similar to iMUSE or the Rare style of doing music on the N64 with a little bit of legwork.

User avatar
zorg
Party member
Posts: 2653
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Music like in Nintendo games

Post by zorg » Thu Jun 15, 2017 3:26 pm

dewgstrom wrote:
Thu Jun 15, 2017 3:10 pm
I think this is at least an interesting enough topic to keep up, there's a lot of different ways to handle this sort of thing.

Is there much documentation available on the .xm format? I can't imagine it would be too hard to write something in pure Lua to tinker with non-playing XM files in memory, like for key or instrument changes, and swap them around or crossfade using love.audio. You could probably end up with something similar to iMUSE or the Rare style of doing music on the N64 with a little bit of legwork.
Sure there's documentation (for the file format, not sure of the replayer itself, but OpenMPT is opensource if one wants to look at how it does it, since they do work hard on compatibility settings for all formats):
ftp://ftp.modland.com/pub/documents/for ... umentation
http://fileformats.archiveteam.org/wiki/XM

Actually, with the upcoming version of löve, you don't need to do any of that sort of hackery, you can just straight-up implement yourself any kind of music synthesis or replayer code; i know, i did: https://github.com/zorggn/LoveTracker

Word of advice, don't use lua tables; either ffi yourself a part of contiguous memory by defining an array of bytes/words/doubles/whatever, or with Löve, you can nicely use a SoundData to hold the samples (if you're fine with 8 or 16 bit int formats for them), the sampling rate set for the sounddata only containing samples doesn't really matter, since you'll be feeding the data "manually" into a buffer (also a sounddata where it -does- matter).
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 5 guests