Page 1 of 5

Music like in Nintendo games

Posted: Mon Apr 25, 2016 9:48 am
by Nutte
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.

Re: Music like in Nintendo games

Posted: Mon Apr 25, 2016 10:36 am
by ivan
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.

Re: Music like in Nintendo games

Posted: Mon Apr 25, 2016 11:15 am
by zorg
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)

Re: Music like in Nintendo games

Posted: Mon Apr 25, 2016 12:23 pm
by Nutte
Thank you, have somebody create music with Love 2D using SoundData? Can you uplode a program to show me? Please.

Re: Music like in Nintendo games

Posted: Mon Apr 25, 2016 1:12 pm
by zorg
Sadly i can only show you the harder route. Maybe someone else can.

Re: Music like in Nintendo games

Posted: Mon Apr 25, 2016 1:34 pm
by Nutte
zorg wrote:Sadly i can only show you the harder route. Maybe someone else can.
Thank you anyway.

Re: Music like in Nintendo games

Posted: Mon Apr 25, 2016 1:40 pm
by Nixola
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 218 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 188 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.

Re: Music like in Nintendo games

Posted: Mon Apr 25, 2016 2:34 pm
by Nutte
Thank you, Nixola.

Re: Music like in Nintendo games

Posted: Mon Apr 25, 2016 3:28 pm
by Nutte
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

Re: Music like in Nintendo games

Posted: Mon Apr 25, 2016 5:51 pm
by zorg
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.