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: 2733
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Music like in Nintendo games

Post by zorg » Tue Apr 26, 2016 4:39 pm

Ivan only said that
- It might be possible to send data to the pc speaker via os.execute, depending on what os you run it on, and that
- Nowadays it's easier to -render-, that is, simulate the sounds, and play it back as a wav file on your actual speakers or headphones.

But to answer your question, sound = love.audio.newSource("music.wav" , os.PCspeaker) will not work, since löve can't handle that second parameter.

Also, read this. The most important parts:
- Eventually because of the lack of hardware to communicate with, support for Beep was dropped in Windows Vista and Windows XP 64-Bit Edition.
- In Windows 7, Beep was rewritten to pass the beep to the default sound device for the session. This is normally the sound card, except when run under Terminal Services, in which case the beep is rendered on the client.

So whatever you do, the beep will happen on the normal speakers, or it won't happen at all, on windows at least.

It's sad really, my first synthesizer program was written in turbopascal in DOS, and it used the beep function, and it was "polyphonic"... with some cheating.
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
Davidobot
Party member
Posts: 1149
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

Re: Music like in Nintendo games

Post by Davidobot » Tue Apr 26, 2016 4:50 pm

This seems awfully complicated and as others said, not a lot of mobos even have a speaker nowadays, mostly IBM ones.
This could help: http://superuser.com/questions/227939/h ... and-prompt

Also, if you run

Code: Select all

print("\7")
it plays the bell sound, but there is no way to pitch that.
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

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

Re: Music like in Nintendo games

Post by zorg » Tue Apr 26, 2016 5:48 pm

Davidobot wrote:This seems awfully complicated and as others said, not a lot of mobos even have a speaker nowadays, mostly IBM ones.
This could help: http://superuser.com/questions/227939/h ... and-prompt
Also, if you run

Code: Select all

print("\7")
it plays the bell sound, but there is no way to pitch that.
(I tested that, win7 x64 did not do anything, that's why i didn't mention it.)
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
Davidobot
Party member
Posts: 1149
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

Re: Music like in Nintendo games

Post by Davidobot » Wed Apr 27, 2016 6:12 am

zorg wrote:(I tested that, win7 x64 did not do anything, that's why i didn't mention it.)
(You need to have the console window open for it to work - t.console = true)
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

User avatar
DekuJuice
Prole
Posts: 14
Joined: Mon Nov 24, 2014 9:31 pm

Re: Music like in Nintendo games

Post by DekuJuice » Sun May 01, 2016 9:21 pm

As master both said, you can use a music tracker to compose your songs.

Since you brought up SMB as an example, I recommend http://famitracker.com/

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

Re: Music like in Nintendo games

Post by zorg » Sun May 01, 2016 10:00 pm

Except:
Nutte wrote:I want to program music not use a file, can i do that with Love?
Not with löve... yet : 3
One can render an mp3 or something from Famitracker, sure, or even use a more sampling oriented one, and load the module files themselves for less hdd space, but that's not what the OP wanted to do.
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.

Nutte
Prole
Posts: 32
Joined: Sat Feb 27, 2016 1:08 pm

Re: Music like in Nintendo games

Post by Nutte » Tue May 03, 2016 2:24 pm

Thank you for all the answer.

therektafire
Prole
Posts: 12
Joined: Mon May 22, 2017 3:45 am

Re: Music like in Nintendo games

Post by therektafire » Fri Jun 02, 2017 9:19 pm

I was actually thinking about doing this too recently :) I think by far the biggest issue with making a software based chiptune/music-in-general player in Love is timing issues. There are no events that get triggered at a predictable periodic rate afaik. Love.update and love.draw get called once per *rendered frame* i think meaning the quality of the music would heavily depend on the framerate. Retro console programmers had it easy when it comes to this kind of thing because they had hardware timers that always fired at the same rate every frame (on the NES you get an event fired every time a frame is finished rendering for example). This made music programming very easy since all you had to do is write the sound engine code then provide a pointer to it in the interrupt vector table (which is at the very end of the program since the CPU looks for interrupt handler pointers at the very last few bytes of RAM, at least on the 6502 which is what the NES uses). Of course in real life applications the music code would be sharing valuable CPU time with other things like controller input, physics/sprite updates etc, but thats beside the point :D

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

Re: Music like in Nintendo games

Post by zorg » Fri Jun 02, 2017 9:53 pm

I already made a player that needs perfect timing, mr. necropost-by-googling-and-old-thread. :3

https://github.com/zorggn/LoveTracker
therektafire wrote:
Fri Jun 02, 2017 9:19 pm
I think by far the biggest issue with making a software based chiptune/music-in-general player in Love is timing issues.
There are no events that get triggered at a predictable periodic rate afaik. Love.update and love.draw get called once per *rendered frame* i think meaning the quality of the music would heavily depend on the framerate.
False, you can edit love.run or have vsync turned off, or you can use a separate thread for generatin audio alltogether.
Also, you're rendering into a buffer, the quality won't depend on anything; if you use a buffer smaller than how much you can render at once, it will underrun, that's all there is to it.
therektafire wrote:
Fri Jun 02, 2017 9:19 pm
Retro console programmers had it easy when it comes to this kind of thing because they had hardware timers that always fired at the same rate every frame (on the NES you get an event fired every time a frame is finished rendering for example). This made music programming very easy since all you had to do is write the sound engine code then provide a pointer to it in the interrupt vector table (which is at the very end of the program since the CPU looks for interrupt handler pointers at the very last few bytes of RAM, at least on the 6502 which is what the NES uses).
Nothing was very easy back then, and if this was a C app, you probably could access the 3 hardware timers that pc-s still have... but the question is why, computers are fast enough for you to just rely on the os scheduler to run your code as fast as it does...
therektafire wrote:
Fri Jun 02, 2017 9:19 pm
Of course in real life applications the music code would be sharing valuable CPU time with other things like controller input, physics/sprite updates etc, but thats beside the point :D
As you said, if i had threaded my thing, that would give it even more guarantees, in that other processing wouldn't block the audio generation thread. Everything's on the main thread, renders into a tiny buffer for the least amount of delay, and it works without any hitches still.

Hell, someone implemented a game boy emulator with löve (without sound for now, iirc he's waiting for 0.11 to come out because better generative sound API stuff, just like in my project), that also works besides the fact that löve doesn't give you access to hardware timer interrupts on the pc... not like you need them; just edit the default love.run or set vsync to false if you don't want it to run as fast as your screen's refresh rate.
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.

therektafire
Prole
Posts: 12
Joined: Mon May 22, 2017 3:45 am

Re: Music like in Nintendo games

Post by therektafire » 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?

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 7 guests