Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Midi Player Tool Kit V2.5 Available! Better sound, better accuracy

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

  1. maidilakbar

    maidilakbar

    Joined:
    Mar 9, 2015
    Posts:
    2
    Hello BachmannT,

    Thanks for your libs. so much easy to understand and well documented.
    But, i still have problem with the libs sound. There are no balance with distortion guitar sound and the drum sound.
    The drum sound too soft compared with guitar sound, is it because of GM Bank sound.?

    Can i set the GM Bank to original MIDI sound.?

    Best Regards,
    Aidil
     
  2. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello Aidil
    Thank for your encouragement, I'm happy that you like this product.
    For your question, yes the sound quality is depending on the Soundfont selected. There is a lot of Soundfont with differents goals..
    But it's possible also to adapt the volume of the midi on each notes. You need a Midi editor and a lot of patience !

    Best Regards
    Thierry
     
  3. maidilakbar

    maidilakbar

    Joined:
    Mar 9, 2015
    Posts:
    2
    Hello BachmannT,

    Thanks for the fast response.
    I tried playing a music midi file and I thought it got the wrong tempo when playing compared to using the mac midi player (GarageBand).
    Is my file not support for this libs.?

    (I attached the midi file to test)

    Best Regards,
    Aidil
     

    Attached Files:

  4. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Strange, on my PC, the speed is the same that others sequencers.
    What version of MPTK are you using ?
    Have you check the parameters "Speed" in the inspector ? a normal value must be 1.
     
    Last edited: Mar 27, 2019
  5. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello
    I have checked with a test midi file on MacOS: the speed is ok. Please, try on your desktop with the midi file Test 4-4. The length must be 6 seconds.
    Best Regards
    Thierry MacMidiPlayerTest.png
     

    Attached Files:

  6. PsiloCybian

    PsiloCybian

    Joined:
    May 14, 2015
    Posts:
    4
    Does it support sf3 ?
     
  7. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello
    No it doesn't. But don't be worry, Unity transform wave to vorbis (compressed wave). See snapshot bellow.
    Also, with the Pro version, MPTK analyses your Midi files and removes waves not used.
    BR.
    upload_2019-4-6_12-23-28.png
     
    Last edited: Apr 6, 2019
  8. kylerobertbradley

    kylerobertbradley

    Joined:
    Aug 5, 2018
    Posts:
    1
    Hello, I have been looking at your tool kit for a few months now and I think it is right for me, but I am not sure.

    Is there a seperate email I can send more information about my application, so that you can help me gage if what I need is in range of what this asset could do?

    Thank you so much!

    Kyle
     
  9. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello Kyle
    I answered to your mail. yes, send me more information, i will see what it's possible.
     
  10. AStoryBoardZ

    AStoryBoardZ

    Joined:
    Feb 10, 2016
    Posts:
    2
    Hi! Could you please tell will it work with iOS? I found post on your blog that it supports Android but no word about iOS.
     
  11. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello
    MPTK support Android but partially. See here
    I have never checked with iOS, only with MacOS. Some users say me that it's ok but without a full check ... I encourage you to verify with the free version and I will offer you a Pro version for a full check on iOS ;-)
    Best Regards
    Thierry
     
    Last edited: Apr 9, 2019
  12. robinspots

    robinspots

    Joined:
    May 10, 2018
    Posts:
    10
    Hi,

    Firstly, great tool, thanks for your hard work!

    I can't seem to get the noteOff events to fire. I've set the MPTK_KeepNoteOff value to 'true' and have turned 'Log Midi events' on but I'm not seeing any noteOff events. Am I missing something?

    Ultimately, I need to add a noteoff subscriber. I've successfully done this using
    Code (CSharp):
    1. midiExternalPlayer.OnEventNotesMidi.AddListener(NotesToPlay);
    for noteOn events, but again, this doesn't seem to work for noteOff.

    Any tips would be very much appreciated. Thanks!
     
  13. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hi robinspots
    Thank for your encouragement !
    You are right, there is a bug. I search for a workaround and take you inform.
    Best Regards
    Thierry

    [EDIT] I'm sorry, but there is no simple workaround. I need to publish an update. I will do that as soon as possible, but publishing a new version need serious testing phase. I hope to be ready for the next week.
    I apologize for that.
    Best Regards
    Thierry
     
    Last edited: Apr 11, 2019
  14. robinspots

    robinspots

    Joined:
    May 10, 2018
    Posts:
    10
    Bonjour Thierry,

    That's no problem. Please let me know when the update is ready.

    Merci :)
     
  15. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Version 2.03 has been sent to the store. I hope that will be available for the beginning of the week. Je vois que mon origine géographique a été démasqué ;-)
     
  16. robinspots

    robinspots

    Joined:
    May 10, 2018
    Posts:
    10
    The new update seems to be working great. Thanks Thierry!
     
    BachmannT likes this.
  17. Mihaylevskiy

    Mihaylevskiy

    Joined:
    Aug 30, 2017
    Posts:
    4
    Hello. I want to use this plugin to play on WEB, but in the Unity Editor (or Windows app.) and WEBGL midi sounds different. How to fix it? Thanks.
     
  18. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello
    MPTK doesn't support playing sound with a good quality on WebGL. See here.
    The reason is the WebGL doesn't support CoRoutine, I'm sorry for that.
    It's possible to load a Midi file to read and process Midi Events.
    Best Regards
    Thierry
     
  19. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Good to know, and thank for your test.
     
  20. Mihaylevskiy

    Mihaylevskiy

    Joined:
    Aug 30, 2017
    Posts:
    4
    Unity 2018.3 support CoRoutine and MIDI file is played.
    for example: https://qa3.elpcorp.com/test_web_midi/test_pro/
    (using MIDI lib.), but not played well.
    Original midi file in attach.
     

    Attached Files:

  21. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    My explanations was a little short: here some info from Unity
    You are right, CoRoutine run correctly with WebGL. The issue is Threading. The impact on sound is much more on how a sound loop on a wave. The wave loop with WebGL (and also with Android) is done on the full wave, not on a sustain section:
    When a piano key is hit, the wave is playing from start: first the attack+decay phase (a very short phase), then the wave is playing the sustain phase until the key is released, then wave is playing the release phase (a short phase) and the sound is stopped.
    With WebGL and Android, the wave is plays from start to end in a loop until the key is released: attack/decay/sustain/release. Here information how a synthesizer runs (in particular with envelope).

    I have the idea for a future version of MPTK to cut each waves in each steps; then let MPTK runs each sub wave according the current phase. It's a lot of work and ... with no guarantee to get a good sound (i'm afraid to have some glitch sound between each phase ...)
     
    Last edited: Apr 17, 2019
  22. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Thank for your comment on the pro store. It help me to continue trying doing the best !
     
  23. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hi All
    V2.04 waiting for review.
    Some little enhancements or corrections:
    • Calculate Midi duration after loading a Midi
    • Corrected calculated Duration which was wrong in some cases
    • Class MidiLoad: Add MPTK_InitialTempo attribute
    • Prefab MidiListPlayer: Add MPTK_Load() method. Useful to get information about the Midi before play it.
    • Add two new reasons for stop midi: next and previous
    • Demo TestMidiFilePlayerScripting: Add display of Midi information
    • Demo TestMidiFileLoad: Add display of attributes
    • Demo TestMidiListPlayer: Add play previous button and events trigger by script.
    Have Fun !
    Thierry
     
  24. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hi
    The V2.04 is available since 10 days. A V2.05 is quite ready with a little enhancement for playing midi with a time overlap between two midi.
    Now I would like build a 2.1 with great new functions.
    I have some ideas like: a midi filter track+channel to play only a part of the midi, a modifier to change some instrument, ...
    Have you some idea ?
    Have your say !
     
  25. sakura_cube

    sakura_cube

    Joined:
    Dec 3, 2015
    Posts:
    8
    Hello. I bought pro-version and found it is very nice. Thanks for sharing your great assets with all.

    I am in trouble with the following.
    I just want to read an external MiDi File(xx.mid) and add MPTK by not unity editor's "Add Midi File" but application's function.
    However, I could not find a way to load external MIDI files directly from the application in your document.
    My final goal is to create an iOS application that can read and play midi files written by the user on iOS with the file sharing function of itunes.
    Thanks.
    sakura.
     
  26. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello Sakura
    Thank to bought the pro version,
    Yes this function exists with MPTK (pro version). See the prefab MidiExternalPlay and the demo TestExternalMidiPlay.
    Have a nice day.
    Thierry
     
  27. sakura_cube

    sakura_cube

    Joined:
    Dec 3, 2015
    Posts:
    8
    Hello BachmannT,
    Thanks for your information. I tried MidiExternalPlay and TestExternalMidiPlay.
    And I found the Midi file on WEB is OK, but File-pass + File name is not OK.
    I Type the full path on my destroy is "file://Users/name/Desktop/xxxx.midi".
    I found TheadLoadDataAndPlay() in MidiExternalPlayer.cs is started and Timing.RunCoroutine(ThreadPlay(www.bytes).CancelWith(gameObject)); is also started.
    However, as a result, Midi play is not started.
    Midi-file on WEB is ok, Midi-file in my mac is not OK. I used "Amanda.mid" file for both tests.
    I can't understand how the code can handle files on both WEB and mac.
    Since I cannot trace your code anymore, happy if you let me know some hint.

    What I want to do is only to play a midi-file(xxx.mid) on my mac with your MidiExternalPlay & TestExternalMidiPlay.

    Regards,
    sakura.
     
  28. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello Sakura, i will make a test on Mac asap. BR
     
  29. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello Sakura
    No problem on my side, but add a / to your path like this:
    file:///Users/thierry/Desktop/Nirvana - Smells Like Teen Spirit.mid

    Or, use the browser in the inspector to select your midi file on your Mac.

    I have updated the MPTK documentation, see here.

    upload_2019-5-16_21-16-38.png

    BR
    Thierry
     
    Last edited: May 17, 2019
  30. sakura_cube

    sakura_cube

    Joined:
    Dec 3, 2015
    Posts:
    8
    Hello Bachmann,
    Thanks for your kind supports.
    "files:///" is OK for your Midi file Amanda.mid. I understood "///" is vital to set the full path of the midi-file.
    However my Midi file is not still played.
    I checked both Midi files in Window's Media Player and found that both works well.
    After some tests, finally I found the cause. File name.
    My fine name is "2343_3_#814.mid". Maybe this file name was rejected in your code without any error message. (trim() function?)
    I changed my file name to "Amanda123.midi" and found that my midi file is playing successfully.
    So I will change all my midi file's name and believe they will go well.
    Thanks for your kind support.
    Regards,
    sakura, tokyo, japan.
     
  31. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Thank for these information.
    I checked on my PC and on a Mac, I can't reproduce the issue with a # in the file name. Which version of Unity are you using ?
    BR
    Thierry, lyon, france
     
  32. sakura_cube

    sakura_cube

    Joined:
    Dec 3, 2015
    Posts:
    8
    Hello Bachmann,
    Unity Version is 2019.1.0f2 Personal.
    Additional information, my mac uses Japanese Language. This might cause some phenomena.
    sakura.
     
  33. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello
    Sorry, I can't reproduce your issue.
    Have you find a solution ?
     
  34. tencnivel

    tencnivel

    Joined:
    Sep 26, 2017
    Posts:
    13
    Hello Bachmann,
    Congratulations on your V2!

    I have a few questions if you allow me:
    • Is Michelle (attached) supposed to sound like this ?
    • Has the library been tested on Android and iOS ?
    • Is it possible to mute a channel of the midi file while playing ?
     

    Attached Files:

  35. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello
    See above my answers.
    BR
     
  36. robinspots

    robinspots

    Joined:
    May 10, 2018
    Posts:
    10
    Hi Thierry,

    I've encountered what could be a problem with the MIDI timing in the sequencer. When I load up this file in Midi External player: http://www.yamahaden.com/midi-files...a-6314-4c8d-a8c7-164439488b1f&method=download it starts playing but the timing is slightly incorrect.

    I've tried it on two different machines, both times using the TestExternalMidiPlay scene so that I can be sure it's not my own code causing the problem.

    I've tested the same midi file and soundfont in SynthFont2 (another windows midi soundfont sequencer) and it plays correctly.

    Do you know what might be causing this? Are you able to hear the problem?

    Thanks,

    Robin
     
  37. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello robin.
    Thank for the exchange by mail and the tests you did. I changed the attributes of the CoRoutine which read and play Midi events and get a better result ... but not perfect. It can happen when the tempo is high with a lot of note where a good timing is mandatory. For example as with your Midi: the Turkish Marsh from Mozart. Accordingly, I have updated the post here with more details. Thank a lot for your help.
     
  38. Ghant

    Ghant

    Joined:
    Aug 22, 2019
    Posts:
    5
    This asset has some nice features, and I was able to get it up and running quite easily, despite having little Unity experience. However, most of the midi files I tried sounded off due to timing issues. I suspect this is due to running everything off the main thread. Would it be possible to provide a version that generates and plays midi events on a background thread?
     
  39. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello Ghant, Yes you are right, currently all is running in the Unity main thread. The benefits is that midi events triggered can access to the Unity gameObject and create animation in relation with the music. The counterpart is a lack of accuracy (for 1% of the midi events).
    Yes, a new version is in progress to propose also a midi player based on a background thread (thank to OnAudioFilterRead!)
    Best regards
     
  40. Ghant

    Ghant

    Joined:
    Aug 22, 2019
    Posts:
    5
    Great! I would suggest processing the midi events on a background thread and posting separate animation events to the main thread, since having the animation slightly off is preferable to the music sounding off. For my needs, I can synchronize based on the duration of the midi file played instead of individual events, so it would be good to have an option to skip generating animation events based on notes and instead get events based on time. I will gladly pay for the pro version if you add these features. Thanks and great work!
     
  41. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello. Don't be worried! MPTK don't generate animation. What i would say is: you can subscribe to the MPTK event OnEventNotesMidi to trigger actions on gameobject in your own script (which could be Unity animation, of course).
    In all cases, if the event is triggered in a thread which is not the main thread, this process can't work. GameObject can't be modified outside the main Unity thread.
    Thierry
     
  42. unfungmz

    unfungmz

    Joined:
    Jul 29, 2017
    Posts:
    158
    This thing is great, but I have a couple of questions.

    I am using the TestMidiStream scene to script events rather than play midi files. I'm wondering where the GUI is coming from since it doesn't seem to be in the canvas or anywhere in the game objects. I'd like to completely disable it.

    Also, when it comes to playing a note via scripting, I'm not sure how to stop a specific note...

    NotePlaying = new MPTKEvent()
    {

    Command = MPTKCommand.NoteOn,
    Value = 22,
    Channel = StreamChannel,
    Duration = 9999999, // 9999 seconds but stop by the new note. See before.
    Velocity = Velocity // Sound can vary depending on the velocity
    };


    Now, doing midiStreamPlayer.MPTK_StopEvent(NotePlaying); will stop the note, but how can I stop a specific note based on value (the pitch of the note)?

    I've tried putting a new NewPlaying with the above info before stopping the note, but it's not working.
     
    Last edited: Sep 11, 2019
  43. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello
    Thank to appreciate MPTK!
    No canvas are used for this demo. All the GUI is scripted in TestMidiStream.cs with the OnGUI() method. Have a look, it's simpler for this kind of UI.
    For your second question: you have to keep a list of all the MPTKEvent you created, for example with a List<MPTKEvent>, then search in the list the note you want to stop. Of course if you have a lot of events you could use a Dictionary to get a faster process with the note as a key.
    Best Regards
    Thierry
     
  44. unfungmz

    unfungmz

    Joined:
    Jul 29, 2017
    Posts:
    158
    Thanks for the reply! One more question: How many channels are there?
     
  45. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Midi channels ? 16 it's the default value with the Midi norm. But with MPTK you can create more channel, but it's experimental !
     
  46. URGr8

    URGr8

    Joined:
    Sep 10, 2012
    Posts:
    14
    Hi Thierry,
    I have been using MPTk for awhile and it works great. I am using Version 1.96.
    I was trying to play a midi file at a specific position, but it doesn't seem to be working right.
    In my code I am calling:
    midiFilePlayer.MPTK_Position = isMidiPosition; //(float values in miliseconds)
    midiFilePlayer.MPTK_Play();

    but it seem to keep setting it back to 0 and starting from there.
    in MidiFilePlayer.cs in MPTK_Position it keeps complaining that the value is not valid, i.e, not between if (value >= 0f) && value <= (float)MPTK_Duration.TotalMilliseconds)
    I check it and the MPTK_Duration.TotalMilliseconds always seems to be 0.

    Do you have an example of this working, or what am I missing?
    Thanks
     
  47. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    86
    Hello
    Right, MPTK_Position is designed to be used when the Midi is playing. The call to MPTK_Play reset the position to 0.
    First solution:calling Position after Play but with a short delay because Play is running in a coroutine. Not a robust solution, but ... easy!
    Second solution: change the position at the first note with theOnEventNotesMidi.
    Code (CSharp):
    1.  midiFilePlayer.OnEventNotesMidi.AddListener(NotesToPlay);
    Third solution: wait for the next version, a MPTK_Play(from, to) will be added !

    I encourage you to download the last version of MPTK (v 2.5), the sound quality is much better!

    Thank to using MPTK!

    Best Regards
    Thierry