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.
Nutte
Prole
Posts: 32
Joined: Sat Feb 27, 2016 1:08 pm

Music like in Nintendo games

Post by Nutte » Mon Apr 25, 2016 9:48 am

Hi!

Are it posible to make music in Love 2D Engine, like in Super Mario bros? [youtube]https://www.youtube.com/watch?v=NTa6Xbzfq1U[/youtube] ?
I want to program music not use a file, can i do that with Love?
Or can i make PCspeker music, you know that speker that make beep, beep sound?

Sorry for my bad english.

User avatar
ivan
Party member
Posts: 1188
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Music like in Nintendo games

Post by ivan » Mon Apr 25, 2016 10:36 am

Hello.
Sure, take a look at the sound data object:
https://love2d.org/wiki/SoundData
You have to study waveforms if you plan on using SoundData.
It may be possible to use the PC speaker via os.execute but that's not
really cross-platform and Love2D really isn't the best tool for that kind of stuff.

Most of the time you can get better results by simply:
1.mixing different tracks
2.playing samples with modified pitch.

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

Re: Music like in Nintendo games

Post by zorg » Mon Apr 25, 2016 11:15 am

This is actually something i've been working on, with a little help.
It is most certainly possible, though it won't be easy if you want to tackle it yourself, since you'd need to write a -optimally, threaded- playback routine for it, and a few wave generators that can generate one samplepoint per function call, and other similar things.

That said, it can be achieved easier with Sources and audio files loaded into them, like ivan said. For the SMB theme song, you'd need 4 Sources, two with square wave sounds, one with an imperfect triangle wave sound, and one with noise for the percussions; though this way has limitations not inherent with the song of choice. (it has no pitch bends in it, for one, or any other special effects)
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 » Mon Apr 25, 2016 12:23 pm

Thank you, have somebody create music with Love 2D using SoundData? Can you uplode a program to show me? Please.

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

Re: Music like in Nintendo games

Post by zorg » Mon Apr 25, 2016 1:12 pm

Sadly i can only show you the harder route. Maybe someone else can.
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 » Mon Apr 25, 2016 1:34 pm

zorg wrote:Sadly i can only show you the harder route. Maybe someone else can.
Thank you anyway.

User avatar
Nixola
Inner party member
Posts: 1888
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Music like in Nintendo games

Post by Nixola » Mon Apr 25, 2016 1:40 pm

I've been doing stuff like that since LÖVE 0.8.0, even though I never actually did anything serious. This is one of the two projects I'm working on.
compose.love
(14.14 KiB) Downloaded 67 times
Some notes about it: I've had no regards about code quality. The main generation is in notes.lua (please only look at sine[beat], square, organ[beat], guitar; I haven't needed the others, so they're most likely just quick and wrong drafts), you'll probably find what you need there (if you can figure it out... There's not a single comment in there and that code is years old). You can save with ctrl+s, load with ctrl+l (will automatically load the most recent save) or by dragging and dropping a file onto LÖVE when open and loaded.
Here's the beginning of a song (which is Black Diamond by Stratovarius, I'm writing a little piece every time I need to test something):
1453470573.txt
Actual extension is usually .nixm but I can't upload nixm files here.
(581 Bytes) Downloaded 48 times
EDIT: As I said, I never did anything serious. While this is basically working, I don't consider it finished or polished enough.
Some more instructions if somebody wants to test it:
Left click on a square to add/edit/delete a note. A circle is a single note, a "<" is the beginning of a long note, a ">" is its end, while an empty square is nothing. Right click to delete a note.
Up and down change the tempo, which isn't actually written anywhere in the screen, so this love file is better used from a terminal (where the tempo is printed). Please don't change it while playing.
Space starts and pauses playback (please don't change tempo while paused either), while escape will stop (pause and rewind) it.
You can scroll vertically with the mousewheel (or shift + horizontal wheel, or other secondary buttons I guess), horizontally with horizontal wheel (or shift + vertical wheel).
I think that pretty much covers it.
Last edited by Nixola on Mon Apr 25, 2016 8:12 pm, edited 1 time in total.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics

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

Re: Music like in Nintendo games

Post by Nutte » Mon Apr 25, 2016 2:34 pm

Thank you, Nixola.

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

Re: Music like in Nintendo games

Post by Nutte » Mon Apr 25, 2016 3:28 pm

Thank you for all help But i looking for somting like this: https://www.youtube.com/watch?v=1IOL4q5tDDQ or: https://www.youtube.com/watch?v=YdxnVITVXx4

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

Re: Music like in Nintendo games

Post by zorg » Mon Apr 25, 2016 5:51 pm

Nixola: Any reason why your .love file gives me a no-game screen? EDIT: It may be a false alarm, on my end.

Nutte: Thing is, i'm not sure how much work you're willing to actually do to get music like what you show.
The second video could be done easily with two methods. Either get a scorewriter that can export .midi files, and open them in löve, since it plays without instrumetns, it will sound like beeps. The second method would be to get a beep sound as wav or mp3 or something, load it into a source, and in your code, call it with specific pitches and timings for it to make music.
The monkey island one is harder because even though sources can be pitched, you'd need a hell of a timing to actually accomplish such arpeggios and stuff that that song does.

Audio creation is sadly a no hands held business, and there's no simple way of doing 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.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests