Search Unity

Maestro Midi Player Tool Kit - Good news for your rhythm game !

Discussion in 'Made With Unity' started by BachmannT, Apr 14, 2018.

  1. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    And it'is available with the free version :)
     
  2. JWerner

    JWerner

    Joined:
    Dec 18, 2016
    Posts:
    5
    After reading about the new OnAudioFrameStart callback, I bought MPTK Pro to use in a rhythm / music creation game I'm designing. But I have found a couple of issues.

    I bought a soundfont from EdgeSounds I was hoping to use. Although Polyphone can read it, MPTK fails to add it in the Unity editor. The soundfont contains 24-bit samples, and the reported error is an sdta chunk size mismatch. Just a guess, but maybe the sm24 sub-chunk is causing an issue? The soundfont is available for download here: http://www.edgesounds.com/Products/SoundLibraries/GeneralMIDI/GenevoiceGM64Pro24.aspx
    But more importantly, there is a link on that page to a free 24-bit vibraphone soundfont that could be used for testing.

    The other issue is more of a nit. The editor code has dependencies on two classes in the demo scripts, SceneHandler and MainMenu. Not a big deal, but it breaks the build if you don't import the demo with the rest of the MPTK package.
     
    Alvare32 likes this.
  3. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    Hello
    I can confirm, Unity default is 16 bits for sample but it can also plays 24 bits. MPTK is design for playing 16 bits only, I will have a look to evaluate the possibility for playing 24 bits samples.
    For the other issue (dependence with demo) I will look ASAP. Thank for this information.
    All my best
    Thierry
     
  4. JWerner

    JWerner

    Joined:
    Dec 18, 2016
    Posts:
    5
    24-bit sample support would be great.

    But a quick way to support 24-bit soundfonts would be to ignore the sm24 sub-chunk and just read the smpl sub-chunk as normal 16-bit data. That would allow supporting 24-bit soundfonts, although the samples used would be 16-bit.
     
    Last edited: May 6, 2021
  5. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    whaoo, are you sure of that ? transform a 24 bits sample to a 16 bits just by truncating ?
     
  6. JWerner

    JWerner

    Joined:
    Dec 18, 2016
    Posts:
    5
    Made a quick change to the ProcessSDta method of the SFLoad class to skip the sm24 sub-chunk and now the soundfont is being imported without issue. Sounds great! MPTK is exceeding my expectations so far.
     
  7. JWerner

    JWerner

    Joined:
    Dec 18, 2016
    Posts:
    5
    This works by design. The sm24 sub-chunk contains the least significant byte of each 24-bit sample, and can be combined with the 16-bit sample in the smpl sub-chunk to form the 24-bit value. That allows the sm24 sub-chunk to be ignored if necessary, to provide easy backward-compatibility with 16-bit soundcards.
     
    Last edited: May 6, 2021
  8. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    You are a soundfont expert, this format is quite complex. I will be happy if you send me your change, I will update MPTK. You can send on my email thierry.bachmann@gmail.com if you prefer. Thank.
     
  9. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    Hello John, now MPTK is able to read 24 bits SoundFont, next step playing 24 bits samples with Unity ;-)
    Also, I corrected "breaks the build if you don't import the demo".

    Thank to help me make MPTK better.

    Thierry
     
  10. Wailander

    Wailander

    Joined:
    May 2, 2017
    Posts:
    10
    Hi, don't know if that's the right place, I get plenty of errors in the editor (2021.1.0f1) when I add the MidiPlayerList.

    The first is this :

    MPTK Error Object reference not set to an instance of an object
    UnityEngine.Debug:LogWarning (object)
    MidiPlayerTK.MidiPlayerGlobal:ErrorDetail (System.Exception) (at Assets/MidiPlayer/Scripts/MPTKGameObject/MidiPlayerGlobal.cs:934)
    MidiPlayerTK.MidiListPlayerEditor:OnInspectorGUI () (at Assets/MidiPlayer/Scripts/Editor/Pro/MidiListPlayerEditor.cs:377)
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)
     
  11. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    Hello
    Yes it's the good place, you can also send me an email.
    For sure it's strange.
    Which version of MPTK ? and PC/Mac ? It's an initial instal ? or an update from the Package Manager ?
    Have you added a soundfont and some midi files ?
    Have you also an error when adding a prefab MidiFIlePlayer ?

    Sorry to harass you with all these questions !
     
    Last edited: May 11, 2021
  12. Wailander

    Wailander

    Joined:
    May 2, 2017
    Posts:
    10
    Hey, I did manage to fix it by reimporting the whole MidiPlayer folder.
    I must have done something very wrong as reimporting resulted on lots of diffs. Probably as I switched from free to pro.

    I'm all good, but if you want to investigate here's a diff of a file that changed while reimporting
     

    Attached Files:

  13. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    I will try doing the same : install a free then a pro. Perhaps I will be able to reproduce ... but tomorrow !
     
  14. HEATH3N

    HEATH3N

    Joined:
    Jul 19, 2014
    Posts:
    16
    Hi; thanks for this awesome asset. I am wondering -- is there a way I can have a MIDI file in my game NOT in the Resources folder? I'm loading them later so they don't bloat startup time. Or maybe I have to pay for this feature?
     
  15. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    Hello, thank for your interest! Yes you can use the prefab MidiExternalPlay to load and play a midi file anywhere from your device or from a website. And yes, this function is available with the pro version of Maestro.
    Demo MidiExternalPlay in the pro version :

    upload_2021-6-9_6-55-5.png

    Thierry
     
  16. HEATH3N

    HEATH3N

    Joined:
    Jul 19, 2014
    Posts:
    16
    Did something with the MidiFilePlayer change recently? According to the documentation there should be a "Release Same Note" option but I don't have it in mine. I'm having an issue where if a note is played twice in a row, it doesn't register that those are two separate events (I am using the NoteOff setting because I need to read those events).

    I set the boolean manually (and it appears to default to True anyway) but I'm still seeing keys get held down through two of the same note instead of going up and back down. Is there something I can do to fix this?

    My app so far is basically just a virtual piano where keys should go up and down with the MIDI file.
     
    Last edited: Jun 10, 2021
  17. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    Hi, nothing has changed for the "Release Same Note" function recently. But the algo for reading/generating noteoff has been updated (depending midi file there is not notefoff but noteon with velocity=0).
    So, I think it's more an issue withe the midi reader than the synth player.
    Could you send me your midi file ?
     
  18. Alvare32

    Alvare32

    Joined:
    May 26, 2020
    Posts:
    40
  19. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    Hello
    You are right, this Midi is using the pitch sensitivity change event. Luckily, this event is managed with the next version of MPTK.
    upload_2021-6-13_7-8-26.png

    I hope to publish it soon. In the meantime, I send you an audio of what I get :
    https://1drv.ms/u/s!Ao-u2_LaRuYilMVBhVWvoxUuKUzZnA?e=aUmHPp
     
    Last edited: Jun 13, 2021
    Alvare32 likes this.
  20. Alvare32

    Alvare32

    Joined:
    May 26, 2020
    Posts:
    40
    I'm very excited about this asset and the future updates.

    Also, I was wondering f.e. let's say; if two different soundfonts use the same sounds, I now have duplicate resources of that same sound in the seperate wav folders.. would it be possible to optimize that?
     
  21. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    What you mean it's a kind of merge between soundfonts with removing of duplicated sound ... humm, let me say, soundfont is a very complex format, this kind of operation will be a full app. I encourage you to look at this freeware : viena. It's a soundfont editor. You could use it to make your own soundfont ... but even with an app as viena that could be tricky !
     
    Alvare32 likes this.
  22. Alvare32

    Alvare32

    Joined:
    May 26, 2020
    Posts:
    40
    Yeah, basically there are a few soundfonts that have similar sounds included and a few changed around to get it right. I thought it was possible for a soundfont to get these sounds universally from one source folder. I guess I should look into the software you mentioned.
     
  23. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    Where have you found the soundfont Main_orchestra ? very good in a small size.
     
    Alvare32 likes this.
  24. Gaffe

    Gaffe

    Joined:
    Jul 13, 2017
    Posts:
    4
    Hello, I recently purchased this asset and I'm very happy with how well it works and how thorough it is. Opens up a lot of creative ideas.

    I only have one issue: The MIDI reader stops working when I build the project, stops outputting any logs. Any advice?
     
  25. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    Hello, thank for your comment. If your are happy I'm happy :)
    For your issue, I confirm, you can't run something when Unity is rebuilding the project. It's not an issue with MPTK, it's a general case with Unity. It is better to stop running when rebuillding. Why Unity don't block this behavior ? it's mysterious !
     
  26. Gaffe

    Gaffe

    Joined:
    Jul 13, 2017
    Posts:
    4
    Thank you for the incredibly quick reply. I closed down the Unity editor, and opened up the build, and the MIDI worked! Hurray
     
  27. Alvare32

    Alvare32

    Joined:
    May 26, 2020
    Posts:
    40

    I know, it's absolutely awesome. "DezZival But Faster" posted a link of his work on his channel.
    Tried them all and grouped the songs in the right folders with the correct soundfont.
     
  28. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    I read your review, thank a lot for that. It's vital to have a good rate.
    I was not aware that you are using the midi output function. Which OS are you using Windows or MacOS ?
    I have experimented with Windows some issues when rebuilding after playing with the midi output plugins. It's a DLL, and the DLL remains loaded even after stopped the unity app.Sometime the DLL freeze the unity editor, you need to close down and open up. Don't forget to save very often your scene! For now, i did'nt find a solution. For now, I go to sleep !
     
  29. Gaffe

    Gaffe

    Joined:
    Jul 13, 2017
    Posts:
    4
    I'm using Windows 10 x64. And it turns out after some tests, actually it works completely fine now? I must have caused some kind of weird error when I was coding, but after restarting my computer I no longer have the issue that the Build version MIDI stops reading while the Editor was open. I'm using it for more than MIDI out, but even the MIDI in when I had this bug wasn't registering. Not sure what it was, but I've been modifying a lot of things in my project. Regardless, seems fine, and I know if that happens again just to restart some things.
     
    Last edited: Jun 14, 2021
  30. clagrens

    clagrens

    Joined:
    May 19, 2017
    Posts:
    93
    Hi, I am planning to create a music generation program
    This may require different instruments to be used at the same time.
    This will require reading multiple soundfonts at the same time

    I would like to ask if MPTK supports multiple players with different soundfonts
     
  31. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    Hello
    No, only one soundfont can be active at a time. But there is hundreds instruments in one soundfont, why do you want using multiple soundfonts at a time ? OF course, multiple instrument from one soundfont can be played at the same time (see video).
    All my best
     
  32. Alvare32

    Alvare32

    Joined:
    May 26, 2020
    Posts:
    40
    You were right BachmannT. Creating your own soundfont in Vienna is really difficult. Been trying to recreate that simple earth temple song from Windwaker now for 3 times in a row and each time I get stuck on getting the values right.
     
  33. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    Yes, soundfont is an incredible and rich format!
     
    Alvare32 likes this.
  34. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    but you can switch between soundfonts when running but this action will restart the MidiPlayer and can take one second depending the size of the soundfont.
     
    Last edited: Jun 19, 2021
  35. clagrens

    clagrens

    Joined:
    May 19, 2017
    Posts:
    93
    Yes I know.

    I want the user to be able to import their own library, so they can use their own library and the library provided by the program at the same time.

    OK, I will try to merge a large library package as much as possible
    Thanks for your help!
     
  36. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    You want also merging in run mode? Ambitious! Your are not alone with this demand (read Alvare32 post). I will have a look of what it's possible ... but without guarantee!
     
  37. Alvare32

    Alvare32

    Joined:
    May 26, 2020
    Posts:
    40
    Thanks for the update. The pitch scaling works perfect now. Especially the Spirit Temple song sounds exceptional.
    Two things I'd still like to ask:

    - The sample rate of the samples is 32000 hz. The rate synth output is set to 24000 hz right now for better performance. And 36000 hz seemed way too high. Could you please add the 32000 hz option to the dropdown menu?

    - When switching between any midi track in the inspector during playmode, the very first note of one instrument never sounds correct, ever. It picks the flute instrument for half a sec and then cancels it out. It seems the first note is played before the correct soundfont is applied or something. When I have 'Loop On Midi' on, and it goes back from the end to end it works like it should. Very strange. Do you know what's causing that? xD

    https://www.mediafire.com/file/tiecl64vc88u6la/Ganondorf_Theme.mid/file
    Here's the file. The Ganondorf theme is also played by 'Main Orchestra' soundfont and you'll probably notice the wrong flute at the start as well.
     
    Last edited: Jun 22, 2021
  38. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    Hello
    For sure, pitch scaling was a good enhancement. You were several to ask me at the same time!
    For the sample rate: I can't change the list of frequency without impacted others developers. I will add a dedicated and free field.

    For the switch, I can't reproduce. That could happen when application start, depending of the size of soundfont, 10ms to 1000ms can be necessary. But not when switching between MIDI file.

    Is start play from first note is enabled ?
    upload_2021-6-22_8-6-56.png

    Could you send me MIDI files ?
     
    Alvare32 likes this.
  39. Alvare32

    Alvare32

    Joined:
    May 26, 2020
    Posts:
    40
    Ah, will try to look into that more.
    Application start is what's causing that most likely. Will make a few tests.

    Edit -
    Correct, 'start play from first note' has always been checked.
    I wrote down a script to play the midi delayed with an IEnumerator, but the issue still happens.
    Is there some way I must preload the soundfont or midi before starting to play it?
     
    Last edited: Jun 22, 2021
  40. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    It's better to wait the soundfont is ready at start. You could use something like that:

    void Update()
    {
    // Check that SoundFont is loaded and add
    // a little wait (0.5 s by default) because Unity AudioSource
    // need some time to be started. Could be also set to 0.
    if (!MidiPlayerGlobal.MPTK_IsReady())
    return;
    ...
    }
     
  41. Alvare32

    Alvare32

    Joined:
    May 26, 2020
    Posts:
    40
    Code (CSharp):
    1.     private IEnumerator Music_Play(float Seconds, string MidiName)
    2.     {
    3.         yield return new WaitForSeconds(Seconds);
    4.         MusicPlayer.MPTK_SearchMidiToPlay(MidiName);
    5.         while (!MidiPlayerGlobal.MPTK_IsReady()) yield return new WaitForSeconds(.1f);
    6.             MusicPlayer.MPTK_Play();
    7.     }
    I tried this. But the issue still persists.
     
  42. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    Yes that could help only at the start of app.
    Could you send me yours MIDIs by email ?
    Is it a new issue since the last version ?
     
  43. Alvare32

    Alvare32

    Joined:
    May 26, 2020
    Posts:
    40
    Sure, will pack all the files and send them over.
    No, this issue was ever since I got your asset. Funny thing is, the fluidsynth midi plugin for Foobar performs worse in regards to this issue. Here are the files:
    https://www.mediafire.com/file/krtg6uvtobgpkw7/Ocarina_Of_Time_Midi%27s.zip/file

    Like I said before, most of the songs are ordered in folders with the corresponding soundfont file.
     
    Last edited: Jun 22, 2021
  44. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    Hi, you are changing of soundfont dynamically when the app is running ? I see in your zip a lot of soundfont, you have loaded all the soundfont in the soundfont setup window and you switch of soundfont when you need ?
     
  45. Alvare32

    Alvare32

    Joined:
    May 26, 2020
    Posts:
    40
    Yes. Well for now, I'm not exactly sure how to switch dynamically in a script, so I just run the game with the midi player and switch the soundfonts from Unity's window tab above.
     
  46. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    Could you say me wich midi and soundfont to test ? there is a lot!
    I'm available until this evening, then I will not able to make test during one week.
     
  47. Alvare32

    Alvare32

    Joined:
    May 26, 2020
    Posts:
    40
    Pretty much all of the main orchestra hyrule field have this first note problem. And ganondorf theme.
     
  48. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    No I can't reproduce. Please, say me exactly with which soundfonts (2 soundfonts) to switch with which MIDI (one MIDI) to experiment your issue.
     
  49. Alvare32

    Alvare32

    Joined:
    May 26, 2020
    Posts:
    40
    Hm.. strange. I will make a recording of it and show you later. Im not in a hurry with solving this. Im at my work right now so I dont have time.
     
  50. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    273
    This method could help :
    http://autogam.free.fr/MPTK/html/d9...player.html#aa4df6af985832015bcd50caf00dc2a56

    When a Soundfont is switched, the MIDI Synth need to be reload.

    MPTK_LeanSynthStarting
    A lean startup of the volume of the synth is useful to avoid weird sound at the beginning of the application (in some cases).
    This parameter define the speed of the increase of the volume of the audio source.
    Set to 1 for an immediate full volume at start.
     
    Last edited: Jun 23, 2021
unityunity