Asset - Extension Chiptune Player (game_music_emu) *Free*

Discussion in 'Marketplace' started by Mick, Apr 21, 2017.

  1. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    [​IMG]

    Description
    Chiptune Player is an extension that uses game_music_emu and audio buffers in GMS to play chiptune music in several formats including NSF (NES, Nintendo Entertainment System), GBS (Nintendo Game Boy) and SPC (Super Nintendo). Chiptune Player currently supports Windows, Linux, Mac OS X (built on 10.9) and Android. Individual voices can be muted and tempo can be changed in real time. An example of usage is included in the asset, should be very easy to use.

    game_music_emu is released under LGPL (GNU Lesser General Public License), so you are allowed to use it in commercial games since the library is dynamically linked to your project. To comply with LGPL, the source code for the shared library need to be included in your game project (the source code I used to build the library is included with this asset and is only 154KB, the archive also includes instructions for building the library on the different platforms). You should also mention in your game credits that you are using the game_music_emu library. The game_music_emu project can be found here: https://bitbucket.org/mpyne/game-music-emu/wiki/Home

    Because of the hassle with licenses I'm releasing this for free, if you want to support my work then you can get the MOD Player available from me on the Gamemaker Marketplace.

    Documentation
    http://gamephase.net/files/linked/chiptune-player-documentation.pdf

    Marketplace link
    https://marketplace.yoyogames.com/assets/5319/chiptune-player

    Supported formats
    Code:
    AY       ZX Spectrum/Amstrad CPC
    GBS      Nintendo Game Boy
    GYM      Sega Genesis/Mega Drive
    HES      NEC TurboGrafx-16/PC Engine
    KSS      MSX Home Computer/other Z80 systems (doesn't support FM sound)
    NSF/NSFE Nintendo NES/Famicom (with VRC 6, Namco 106, and FME-7 sound)
    SAP      Atari systems using POKEY sound chip
    SPC      Super Nintendo/Super Famicom
    VGM/VGZ  Sega Master System/Mark III, Sega Genesis/Mega Drive,BBC Micro
     
    Last edited: Aug 1, 2017
  2. RujiK

    RujiK Member

    Joined:
    Jun 21, 2016
    Posts:
    165
    Does anyone know if these kind of chiptunes can be used in commercial projects?

    Meaning if I used a .GBS chiptune is nintendo going to get mad that I used their gameboy music format or whatever?

    Sweet project BTW.
     
  3. nesrocks

    nesrocks Member

    Joined:
    Nov 6, 2016
    Posts:
    304
    This is so sweeeeet! I'm going to test it today, even though I'm dead beat from a long day of work. Can I like it twice?

    @RujiK Most certainly you can't use third-party music without their consent in a commercial product.

    edit: already working, very plug and play demo object. I got my music in the game. Thanks for the morale boost in my project :D I'll make sure to support you.
     
    Last edited: Apr 22, 2017
    Mick likes this.
  4. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    @nesrocks : Rujik is talking about using the actual music format. This is an interesting question, I tried googling around but could not find anything about it. This can't be a problem, can it? Successful games already use nsf music, even if it's been previously converted to wav or mp3.

    EDIT: At least the NSF file format is created at a later date by Kevin Horton, so Nintendo has no copyright ground for this.
     
    Last edited: Apr 22, 2017
    Blackened and RujiK like this.
  5. nesrocks

    nesrocks Member

    Joined:
    Nov 6, 2016
    Posts:
    304
    I see, my mistake.

    Yeah, I think that nsf from commercial NES games contain code from such game's sound engine. It wouldn't be the case with newly created nsf, but it still emulates part of the NES. And since emulators are as far as I know legally ok, it seems that at least NSF are fair to use, so long as the music is original. I can't say for sure if the other formats are the same.

    edit: there is a vgm file format that encompasses many systems, such as arcades, etc. Certainly that wouldn't be the same
     
    Last edited: Apr 22, 2017
  6. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    True, but the sound chip in the NES is created by Ricoh. Damn, i really hate the license jungle, it's all very confusing and there's rarely any clear answers to anything.
     
  7. nesrocks

    nesrocks Member

    Joined:
    Nov 6, 2016
    Posts:
    304
    I think it is extremely unlikely that anyone would ever have trouble with it. Just remember that microsoft sells NES battletoads on xbox (obviously emulated), and nintendo didn't sue.
     
  8. Shadowblitz16

    Shadowblitz16 Member

    Joined:
    Jun 23, 2016
    Posts:
    596
    this is awesome
    can you make music with it?
     
  9. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    You can't make music with this extension, but you can play back chip tunes made with music trackers like Famitracker and Little Sound DJ. The advantages is that your game will be considerably smaller in size (good for mobile) and you can mute individual channels and speed up or slow down the music.
     
    Blackened likes this.
  10. Shadowblitz16

    Shadowblitz16 Member

    Joined:
    Jun 23, 2016
    Posts:
    596
    aww ok I might get this later
     
  11. nesrocks

    nesrocks Member

    Joined:
    Nov 6, 2016
    Posts:
    304
    Not to mention perfect looping with no noticeable hiccups.
     
  12. WreckingPrograms

    WreckingPrograms Member

    Joined:
    Jan 24, 2017
    Posts:
    14
    For some reason, this extension works perfectly in a new project but whenever I try to implement it in my current project, it plays no music at all. I even loaded it in a completely blank room (as the first room in the game) with the exact same code, and it just didn't play anything. Do you happen to know what could have caused this?
     
  13. nesrocks

    nesrocks Member

    Joined:
    Nov 6, 2016
    Posts:
    304
    I simply create the gme object on the first room and then play songs normally whenever I want. Admitedly, I trimmed the gme object a bit when I put it on my project, but I remember it being simple changes. I didn't move the code to another object though, there is the dedicated persistent gme object. Emphasis on persistent.
     
    Last edited: Jul 16, 2017
  14. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    Hmm, I can't say what the problem might be without seeing the code. If you are willing to share the project with me I could have a look. You can also trim a copy of the project to the bare minimum with the problem still present,
    if you are not willing to share your entire project (which you probably should not anyway).
     
    Last edited: Jul 17, 2017
  15. WreckingPrograms

    WreckingPrograms Member

    Joined:
    Jan 24, 2017
    Posts:
    14
    That would be great, thanks! How do you want me to contact you? The forums don't seem to have some kind of PM system, at least I couldn't find it.
     
  16. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    You can click on my profile name and there you should see a gray link that says "Start a conversation".
     
  17. Carnivius

    Carnivius Member

    Joined:
    Jun 20, 2016
    Posts:
    171
    How the heck have I not seen this before? This is almost exactly what I've been wanting from a GMS extension for the past few years cos i mostly make retro style game and have actual chiptune musicians to make my games and having to convert to bulky mp3s bloats the filesizes ridiculously when I could have the original format tunes all nice and compact and played with this?

    Just had a quick test. It's very cool. Love that you can control tempo and channels. My only disappointment is that it doesn't seem to support YM files which is the main format the Amstrad CPC (the retro system I most enjoy developing for) uses. I know it says Amstrad under AY but that's not often used on the system. Is there any way to add YM support? I am currently looking to see if it's possible to convert YM to AY but not sure. Just found a forum link I shall ask at too though seems a bit dead. https://groups.google.com/forum/#!forum/blargg-sound-libs :)
    The other format I tend to simulate with game making is NES and so glad to see NSF support here. :)
     
    Last edited: Jul 18, 2017
    Blackened likes this.
  18. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    I found out why you are having problems with your current project. You need to use the new audio engine for this extension to work. You can change this in Global Game Settings (General / Use New Audio Engine).

    As far as I know, the game_music_emu library I used for this extension does not support YM files I'm afraid. Another extension using some AY/YM replayer library is needed for this (should not be too hard to do but I don't have the time to do it at the moment).
     
  19. PageWizard

    PageWizard Member

    Joined:
    Jul 20, 2017
    Posts:
    1
    First, this is especially cool! I love the control you have over the channels and tempo. Do you have any plans of incorporating FDS for NSF? I noticed that when I tried feeding it some of my songs that include the FDS channel, it just plays nothing.

    I may consider for a future project using this (my current project uses FDS pretty closely, using S-Winamp at the moment with Game Maker Studio). I was trying to see if it would work with my current project (I made a new project to try it out) and I got this error. All I did was put the main object in the first room, then made the next room the demo object. I made sure to check off to use the New Sound Engine. I don't know if you would have any suggestions for what to do if I get the below error when I attempt to run it.

    Code:
    ___________________________________________
    ############################################################################################
    ERROR in
    action number 1
    of Create Event
    for object obj_gme_demo:
    
    Cannot load buffer file
     at gml_Script_GME_LoadSong (line 41) -   buffer_gme = buffer_load(_filename);
    ############################################################################################
    --------------------------------------------------------------------------------------------
    stack frame is
    gml_Script_GME_LoadSong (line 41)
    called from - gml_Object_obj_gme_demo_CreateEvent_1 (line 31) - sound_index = GME_LoadSong(filename);
    
     
  20. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    Hmm, I have to do some research about this. There are several versions of game_music_emu available on github etc. and fds seems to be implemented in some version. Can you send a link to an nsf song that includes fds so I can test it?

    Can't directly say what the problem is. Did you also add the test.nsf song? The main object doesn't need to be added manually by the way. It is created by GME_Init() (called from obj_gme_demo)
     
  21. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
  22. Tronco

    Tronco Member

    Joined:
    Jul 8, 2016
    Posts:
    18
    This extension is incredible, thank you!

    Just one question. I've tried playing VGM files generated with Deflemask in the YM2151 + Sega PCM configuration and they don't seem to work (Megadrive YM2612 vgms work fine).

    Is there any chance for a support for this format?
     
  23. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    Glad you like the extension! There are versions of game_music_emu that probably support YM2151. Problem is that those versions use source code under GPL which means they can't be used in game projects other than those licensed under GPL. I want to only use LGPL code in this extension so there is not much I can do, sorry.
     
  24. KhMaIBQ

    KhMaIBQ Member

    Joined:
    Jun 22, 2016
    Posts:
    38
    Hey Mick. Thank you so much for making this extension. It makes a HUUUUUGE difference in the game I am working on. I was able to decrease my game's file size by 14 MBs because of this extension.

    I did run into an issue after converting my game to use your extension. When I pause my game, the music will either stutter or pause. If it pauses, it will resume after unpausing the game. Here is my current code:

    Code:
    audio_pause_all();
    audio_resume_sound( bgm_index );
    I also tried replacing audio_resume_sound with GME_Play but it made it worse. The only solution I can think of is to pause all the sound effects in my game separately.
     
  25. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    Try this:

    Pause:
    Code:
    GME_Pause(true);
    audio_pause_all();
    Resume:
    Code:
    GME_Play();
    audio_resume_all();
     
  26. KhMaIBQ

    KhMaIBQ Member

    Joined:
    Jun 22, 2016
    Posts:
    38
    What about if I want to use audio_pause_all but not pause the music? This is when I run into the stuttering issues. It only seems to occur during the first few instances.
     
  27. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    Sorry, I misunderstood. I will do some testing and get back to you!
     
  28. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    I'm not sure if your variable bgm_index contains the index returned by GME_LoadSong(...) but anyway this seems to work for me:

    Create:
    Code:
    sound_index = GME_LoadSong(filename);
    GME_StartTrack(0);
    GME_Play();
    
    Pause:
    Code:
    audio_pause_all();
    audio_resume_sound( sound_index );
    
     
  29. KhMaIBQ

    KhMaIBQ Member

    Joined:
    Jun 22, 2016
    Posts:
    38
    That is what I am also doing. I tried out some more things and solved my issue. It was screen_save_part's fault and not GME's. I was calling screen_save_part and then pausing the audio after it, so I moved the audio code before screen_save_part and now everything sounds great.

    Causes stutter:
    Code:
    screen_save_part( "pause.png", 0, 0, inner_width, inner_height );
    audio_pause_all();
    audio_resume_sound( bgm_index );
    Doesn't cause stutter:
    Code:
    audio_pause_all();
    audio_resume_sound( bgm_index );
    screen_save_part( "pause.png", 0, 0, inner_width, inner_height );
    Thank you for looking into it and sorry for the false alarm. Also, thank you again for such an amazing extension.
     
    Mick likes this.
  30. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    This extension has now been updated with a few useful functions:
    • GME_GetTrackLength
    • GME_GetPosition
    • GME_SetPosition
    • GME_GetName
    • GME_GetAuthor
    • GME_GetComment
    • GME_GetCopyright
    All of these functions are now available for all music formats. The documentaion has been updated to reflect the additions.
     
    KhMaIBQ and nesrocks like this.
  31. KhMaIBQ

    KhMaIBQ Member

    Joined:
    Jun 22, 2016
    Posts:
    38
    Hey @Mick. I think I found an issue with GME. I left my game running on the same stage for over 9 hours and the music stopped playing when I came back. I was doing a soak test of my game. Here are the details...

    - It was an NSF track
    - The song is only around a minute long

    Once my game plays a song again, the music returns just fine, so this isn't a permanent issue that requires restarting the game.
     
  32. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    Thanks for letting me know. Was this on Windows PC or some other format? Also, did the music stop exactly when you came back (when you started interacting with the game) or had the music stopped some unspecific time during the test?
     
  33. KhMaIBQ

    KhMaIBQ Member

    Joined:
    Jun 22, 2016
    Posts:
    38
    This was on Windows 7. The music stopped at some unspecific time. I was sleeping while running the soak test. lol
     
  34. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    Ok, thanks. :) I forgot to ask, GMS1.4 or 2.x?
     
  35. KhMaIBQ

    KhMaIBQ Member

    Joined:
    Jun 22, 2016
    Posts:
    38
    GMS1.4
     
  36. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    Thanks, I will look into it!
     
  37. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    I updated this extension so it should now work for Ubuntu 64bit and maybe for Mac OS X 64bit.
     
    KhMaIBQ and nesrocks like this.
  38. KhMaIBQ

    KhMaIBQ Member

    Joined:
    Jun 22, 2016
    Posts:
    38
    Hello again @Mick. I installed GMS 1.4.9999 and my game started experiencing random audio corruption. I didn't have any audio corruption on GMS 1.4.1772 which I have reverted back to. Just letting you know that the GMS 1.4.9999 update may be causing problems for your extension.
     
  39. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    Hi, yeah, YoYo replaced the audio engine after .1772 and it was left in a non-perfect state when end of life happened. Not much I can do about it really.
     
  40. KhMaIBQ

    KhMaIBQ Member

    Joined:
    Jun 22, 2016
    Posts:
    38
    Oh. My game relies heavily on your extension, so I guess I'll be stuck on .1772 then.
     
  41. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    I installed 1.4.9999 myself to try it out, I get no stuttering. Have you tried increasing the number of buffers? The variable buffer_count can be found in obj_gme / create. Try increasing the number of buffers to 40 or something. I might try to increase the buffer size also, this needs to be done in the dll however.
     
  42. KhMaIBQ

    KhMaIBQ Member

    Joined:
    Jun 22, 2016
    Posts:
    38
    I tried installing 1.4.9999 and increasing the buffer_count to 40, but I'm still experiencing audio corruption and other issues. I can send you a build of my game over PM if you'd like to hear for yourself.
     
  43. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    Yes, please do. I have built a dll with increased buffer size that you could try also, we can talk about it privately, and then I will update this thread with a possible solution.
     
  44. nesrocks

    nesrocks Member

    Joined:
    Nov 6, 2016
    Posts:
    304
    I may be missing something, but is there a way to use this extension for sound effects while the music is playing?
     
  45. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    Sorry, no, that's not possible I'm afraid.
     
    nesrocks likes this.
  46. Tony Long

    Tony Long Member

    Joined:
    Dec 7, 2018
    Posts:
    6
    I have made a music app with game maker. It is great! If the game maker can create many applications out of the game then it's a great thing. For example reading newspapers, listening to music, or studying. There will definitely be more users. A very special programming language.

    Great! Thanks for your contributions to the community.
     
    Last edited by a moderator: May 7, 2019
    Mick likes this.
  47. Trianull

    Trianull Member

    Joined:
    May 18, 2019
    Posts:
    1
    For some reason when I mute both pulse channels on the same frame, the entire song cuts out. When I unmute it, it takes about the same time it went muted to resume the music. Do you know why it's doing this, and is there a fix? Thanks.
     
  48. FabianLC

    FabianLC Member

    Joined:
    May 26, 2019
    Posts:
    1
    Hello @Mick, we've been using this extension in our projects and the music stops some times, most in the team and a lot of players have experienced this issue, our code is pretty much the same as the demo code but with a little workaround for another issue that only runs when the music starts playing.
     
    Last edited: May 26, 2019
    nesrocks likes this.
  49. nesrocks

    nesrocks Member

    Joined:
    Nov 6, 2016
    Posts:
    304
    I'm not sure if this is the same bug I'm getting. I've just started implementing sound effects. There's a bug in my project that causes obj_gme to enter a bugged state, where songs will never play any sound again, and only restarting the game fixes it.

    I'm not using buffers or emitters for sound effects yet, I'm simply playing them with "audio_play_sound()". I'll try to see if doing it another way fixes the problem.

    Situation examples and results:
    - no bug: start with music on, mute the music and start it again.
    - no bug: start with the music off, play some sfx and then start the music.
    - bug: start with music on, mute the music, play a sfx and then start the music.

    So the bug only happens if you have music playing, then use GME_Stop(), then play some sfx using audio_play_sound(), and then try to play using GME_Play().
     
    Last edited: May 27, 2019
  50. Mick

    Mick Member

    Joined:
    Jun 30, 2016
    Posts:
    725
    I'm sorry, but I currently don't have any time to troubleshoot this free extension, but if any of you find the solution/reason please let me know and I will update the extension. The source code for the shared library is included with the extension if you want to have a look. The problem could be something in the shared library but also a script or object code (obj_gme).
     
    nesrocks likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice