Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

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

  1. rmacgillis

    rmacgillis

    Joined:
    Feb 5, 2014
    Posts:
    15
    Update,

    Very odd:

    I'd only tested on my tablet which has Android 8.1.0. Never could get the sound from just cutting out within minutes.

    Decided, what the heck, tested it on my cheap phone which also has 8.1.0 , and the Streamer never cut out, and I thoroughly tested it!

    So could a midi issue like this just be related to hardware? Or maybe some program on the tablet it conflicts with?
     
  2. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Hard question you have!
    Normally, Unit is able to play on every hardware and Maestro use only standard Unity functions. So, the difference could be when compiling your project for Android. Have you the correct app bundle ? It's often an issue on this side.

    Regards
    Thierry
     
  3. rmacgillis

    rmacgillis

    Joined:
    Feb 5, 2014
    Posts:
    15
    Yeah. I suppose I will experiment with different build options and let you know. Thnks. BTW, on the tablet, it's not just midi audio that cuts out, ALL audiosources, non-midi, produce no sound when the cut out happens, yet, there are no debug.log error messages in the build (which I can read using a plug-in).

    It's a Samsung Tablet, maybe that's the problem....
     
    Last edited: Apr 24, 2022
  4. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    151
    Hey there Bachmann, I've updated my project to the latest version and it's still all working flawlessly.
    I also revamped the music system of Ocarina Of Time and make it so it only has to read from a single soundfont instead of multiple smaller ones. I can now use streamplayer to make the player input keys on the ocarina. However, I don't know how I can make it so that...
    Code (CSharp):
    1. Stream.MPTK_ChannelForcedPresetSet(43,-1);
    2. Stream.MPTK_PlayEvent(NotePlaying);
    play's a different instrument on the soundfont. It's index 43 that is of the ocarina. I tried multiple things but it seems to remain on index 0 accordion. Am I doing something wrong?
     
  5. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Good news!
    For your issue, look here the API documentation for this method: https://mptkapi.paxstellar.com/d3/d..._synth.html#aa028db91cbec41e3bbe9e27e52d9a99e
    Change your code with:
    Stream.MPTK_ChannelForcedPresetSet(0, 43);
    (if the channel of your MIDI event is 0)
    Regards
    Thierry
     
    Alvarezmd90 likes this.
  6. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    151
    Thanks, yes, that does the trick!
    However, for some unknown reason I ran into a new issue now that when this note is played, it cancels the current song being played, instead of overlapping with the current song. I use midistreamplayer alongside midifileplayer. I tried changing the id session or channel but it keeps cutting out when I play a note. Should there be a special value set somewhere to bypass this behavior?
     
  7. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Have you two separate prefab like this ? (see the demo CatchMusic)
    upload_2022-4-28_7-27-6.png
     
    Alvarezmd90 likes this.
  8. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    151
    Works like a charm. Thanks! :D
     
  9. niux001

    niux001

    Joined:
    Jul 20, 2021
    Posts:
    6
    Hi Bachmann,
    I'm your MPTKpro user. When I using MPTKpro with the OBOE plugin together the sound output become different(Frequency changed).

    OS Platform:Android 12
    Unity 2019.4.28
    OBOE plugin 1.6.2
    MPTKpro plugin 2.89.2

    Could you please help me to deal with this problem?

    Chris.
     
    Last edited: May 19, 2022
  10. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Hello Chris.
    Thank for your interest with Maestro.
    Sure, I will help you. Some questions to start:
    Have you this issue also when running in Editor mode ?
    On which desktop, MacOS, Windows ?
    Which SoundFont ?

    Regards
    Thierry
     
  11. niux001

    niux001

    Joined:
    Jul 20, 2021
    Posts:
    6
    Hello Thierry,
    Thank you very much for your support.
    Let me explain the situation, everything works fine on Windows Editor mode, IOS and Android without using OBOE plugin. And Oboe plugin works fine when playback Wav or Mp3.
    This is the soundfont link we are using:
    1. GeneralUser GS v1.471
    2. Nice-Steinway-Lite-v3.0 https://drive.google.com/file/d/1e5nPbx7_yPY6mNr3H1pInUgTKmGM6cHo/view?usp=sharing

    Maybe there is some problems between Maestro and Oboe communication. We have tried to modify system sample rate to 48000 and wav assets sample rate to 48000, nothing changed and sounds also weird.

    Waiting for suggestion.
    Regards
    Chris

     
  12. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Thank for all these information.
    I'm not really inspired.
    Oboe is useful only to get a better latency. I'm not sure that is absolutely need with the last Unity version.
    Have you tried without Oboe ?
    See here "Second Option: Modify Unity Audio properties"
    https://paxstellar.fr/oboe-fight-android-latency/

    Regards
     
  13. niux001

    niux001

    Joined:
    Jul 20, 2021
    Posts:
    6
    Thank you Thierry, I will try the Second Option.

    Regards
     
  14. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    I encourage you also to use the last version of Unity, I found the integration with Android better.
     
  15. niux001

    niux001

    Joined:
    Jul 20, 2021
    Posts:
    6
    Do you mean Unity 2021.3.x or later?

    Regards
     
  16. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    I'm testing the last version of Oboe (1.6.2) , last version of Maestro Pro (2.89.2) and Unity 2021.3 for an Android device.
    Bad news ... this version of oboe is not compatible with Maestro. I will provide a new version of Maestro as soon as possible.
    regards
     
  17. niux001

    niux001

    Joined:
    Jul 20, 2021
    Posts:
    6
    That's very kind of you to do this update. Waiting for your progress.

    Regards!
     
  18. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Good news, that's ok now. I need to make some tests and I will publish a new version before the end of this week.
    Regards
    Thierry
     
  19. niux001

    niux001

    Joined:
    Jul 20, 2021
    Posts:
    6
    Great news! Thanks for your work.

    Regards
    Chris
     
  20. Dregal

    Dregal

    Joined:
    May 8, 2020
    Posts:
    1
    Hello,
    I am using the MidiSpatializer by tracks, but I need to load midis from an external folder like with MidiExternalPlay, is it possible?
    No matter how hard I try, I can't use MidiExternalPlay's track spatializer.
     
  21. CDAfonsoCl

    CDAfonsoCl

    Joined:
    May 18, 2021
    Posts:
    17
    Hello Thierry!

    Any developments regarding this issue?
     
  22. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Hello,
    From my point of view, it's not an issue from Maestro but from this MIDI file!
     
    CDAfonsoCl likes this.
  23. CDAfonsoCl

    CDAfonsoCl

    Joined:
    May 18, 2021
    Posts:
    17
    You're right! Thank you anyway.

    Just one last question :)
    Is there any method to get the associated channel with one specific track?

    Thank for all your support, you're a great guy!!
     
  24. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Hello, thanks for your appreciation!
    Fo your question, no, because track and channel are not related.
    Channel is useful to group notes by instrument.
    Track is more a way to display notes for example on a sequencer. Track has no effect on the music itself.
    But each MIDI events (like note) belong to a channel and a track, you can find this information for each MIDI events with the structure MPTKEvent.

    Regards
    Thierry
     
    CDAfonsoCl likes this.
  25. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Oups, Sorry I miss your message. Sometimes I did'nt get notification.
    Have you find a solution to your issue ?
     
  26. kirkokuev

    kirkokuev

    Joined:
    Aug 9, 2014
    Posts:
    15
    Hello, why when I turn on spatialization on MidiFilePlayer I can't pause the damn thing? Sorry , I am so frustrated after spending 4 hours trying to debug why pause don't work and finally found out that spatialization settings breaks it. Is this part bugged? I have commented out this whole section, at least pause is working and Unity spatializer too.
     
  27. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Hello
    Sorry, low Access to internet for now, I'm in hollidays.
    Normally Pause works well, I will test when I will come back.
    Regards
     
  28. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
     
  29. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Hello, tested on Android Lenovo Tab M10 without any issues detected.
    How can I help you?
    Which version of Unity are you using?
     
    Last edited: Jul 22, 2022
  30. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Hello
    I just come back from holiday, sorry for the delay.
    I tested with the demo ... and yes there is an issue with the pause.
    Give me some hours to find a solution and I will answer you.
     
  31. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Ok, I found the origin of this issue.
    I need to make some changes in MPTK, but in the meantime, you could comment these lines in MidiFilePlayer.cs
    In consequence, the MIDI player will not be paused when distance withe the listener is greater than MPTK_MaxDistance but I will find and publish a better approach (the decrease of sound volume with distance will continue to be processed correctly)
    upload_2022-7-22_10-22-53.png

    Sorry for this error.
    Regards
    Thierry
     

    Attached Files:

  32. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Hi
    Really sorry for the delay, I missed your question.
    That will be possible with the next version, MPTK_Play(byte[] data) has been moved from MidiExternal to the base class MidiFilePlayer. So it will be available for each classes which inherits from MidiFilePlayer like MidiSpatializer.

    Example of use:
    Code (CSharp):
    1.  
    2. midiSpatializer.MPTK_PlayOnStart = false;
    3. using (Stream fsMidi = new FileStream(pathToMidiFile, FileMode.Open, FileAccess.Read))
    4. {
    5.       byte[] data = new byte[fsMidi.Length];
    6.       fsMidi.Read(data, 0, (int)fsMidi.Length);
    7.       midiSpatializer.MPTK_Play(data);
    8. }
    9.  
    This demo has been updated to check this new function:
    upload_2022-7-24_11-4-21.png

    upload_2022-7-24_11-4-57.png

    Regards
    Thierry
     
    Last edited: Jul 24, 2022
  33. rmacgillis

    rmacgillis

    Joined:
    Feb 5, 2014
    Posts:
    15
    ver 2019.4.33

    Hi,

    I gave up after awhile, but have actually tried the streamer again recently.

    I've since tested on several android devices and I think there's something in my main scene interfering with the streamer, causing issues. Because, in a stripped-down scene with just the streamer playing a sequence, with soundfont changing, I haven't had issues on any device.
     
    Last edited: Jul 25, 2022
  34. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Hi
    If possible, try also with a recent Unity version, that could help.
     
  35. rmacgillis

    rmacgillis

    Joined:
    Feb 5, 2014
    Posts:
    15
    Tried newest version, but still same. I think I've narrowed the problem down to switching soundfonts. On my tablet (android 8), using Streamer, if I change soundfonts (even without doing anything else) with MPTK_SelectSoundFont() , at around 10 switches, app freezes a few seconds, then resumes, but with no audio output for any audiosources.

    If I then continue to switch between soundfonts the app eventually crashes. Once, I saw a Maestro "out of memory" console warning prior to crash.

    So maybe I'm not using this method correctly?
     
    Last edited: Jul 28, 2022
  36. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Hi
    MPTK_SelectSoundFont is heavy for CPU. Not a good way for light device. If possible, it's better to keep one SoundFontFont where you have merged all the presets you need. Look a t the app viena here: http://www.synthfont.com/Viena_news.html
    Also, don't forget that this method reinitialize all internal synths.
    What do you mean with "at around 10 switches" ?
     
  37. chetan51

    chetan51

    Joined:
    Apr 5, 2015
    Posts:
    3
    Hello,

    Thank you for this great asset! I'm having some trouble with the MidiKeyboard plugin that I was hoping you could help me with. When I run the TestMidiKeyboard scene, I get the following warnings/errors:

    MPTK MidiKeyboard PlugIns version is not correct
    Look here to get the last version https://paxstellar.fr/class-midikeyboard
    MidiKeyboard Plugin not found, please see here to setup https://paxstellar.fr/class-midikeyboard/
    MidiKeyboard assembly:<unknown assembly> type:<unknown type> member:(null)

    Here are more details on my setup:

    MacBook Pro (14in, 2021 with M1 Pro chip)
    Maestro - Midi Player Tool Kit - Pro: Version 2.89.4 (latest)
    MidiKeyboard plugin: Version 1.2 (latest) - I tried choosing "Intel 64-bit" and "Apple silicon" for the MidiKeyboard.bundle platform settings, both result in the same errors.
    Unity Editor: Version 2021.3.7f1

    Any help to get this working would be very appreciated!

    Thank you,
    Chetan

    -----
    Update: On my Intel x64 MacBook Pro 2017, the same project seems to work correctly. But it doesn't on my M1 Pro MacBook Pro 2021. Is the MidiKeyboard plugin confirmed to work on the M1 Pro chip?
     
    Last edited: Jul 29, 2022
  38. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,409
    Hi, is there a scene or demo that shows how I send out-going midi notes?
    (midi out of Unity to a standalone midi synth on the same computer)

    From the docs I think it should be part of MidiKeyboard. (I own Pro.)
    (I can see that MidiKeyboard works, and is receiving signals from a usb keyboard automagically)

    Thank you.!
     
  39. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Hello
    Yes!

    Display the demo's list:
    upload_2022-7-29_14-4-3.png

    Select the last one, Read/Write ...
    upload_2022-7-29_13-55-12.png

    upload_2022-7-29_13-55-59.png

    Warning: it seems that MidiKeyboard plugins is not working on MacOS M2.
    Only on device with Intel/AMD processors.
    Regards
    Thierry
     
    Last edited: Jul 29, 2022
    wetcircuit likes this.
  40. rmacgillis

    rmacgillis

    Joined:
    Feb 5, 2014
    Posts:
    15
    By 10 switches I just mean selecting back and forth between SFs. I'll try to find a single SF that has what I need.
     
  41. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Don,'t forget also Viena, it's easy to copy/past preset between Soundfonts.
     
  42. Telperion1991

    Telperion1991

    Joined:
    Nov 16, 2019
    Posts:
    4
    Hey Buddy!
    Thanks for the asset, it works great!

    But I want to record the sound played by MPTK at runtime, especially through that Oboe asset, is there any API for that?
     
  43. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Hello
    Thanks for your appreciation!
    For your question, not with MPTK.
    But,The music is generated with standard Unity components (AudioSource, AudioListener). I'm sure that you will found something in the store .. or by script!
    I suppose it's for Android ? I will be interesting if you find a solution ... perhaps an enhancement in the future for MPTK!
    Regards
    Thierry
     
  44. BangingRocks

    BangingRocks

    Joined:
    Jun 19, 2018
    Posts:
    4
    Loving MPTK - ignorant question:

    We're using the NAudio MidiFileInspector.cs in a project and trying to switch build to android - we get:

    error CS0246: The type or namespace name 'MidiFile' could not be found (are you missing a using directive or an assembly reference?)

    error CS0246: The type or namespace name 'NAudio' could not be found (are you missing a using directive or an assembly reference?)

    Project runs fine, builds fine on PC, but throws this when we try our Android Build. I know I'm missing something obvious, but am not sure what it is.
     
  45. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Hello lover !
    Sorry that will be hard to help you. Could you create a light version of your project but with this issue, I will try to find the problem. You can contact me by email. See here or here to find my email.
    regards
    Thierry
     
  46. zhaojiangjiang

    zhaojiangjiang

    Joined:
    Aug 31, 2019
    Posts:
    5
    Hi,I'm trying to make midi keyboard of Android plugins, I want to know how can I generate the data of type is ulong for MidiMsgCB? the data of type in Android is byte[].
     
  47. a4505ab

    a4505ab

    Joined:
    Sep 25, 2022
    Posts:
    4
    Hello,
    I want to make a MIDI visualization project, but I met a problem.
    I want two MidiFilePlayers, one volume of which is adjusted to 0, which is responsible for the generation of MIDI visualization.
    Another one need delay a few millisecond before starting to play.

    I add two MidiFilePlayers, it will play at the same time.

    I notice a demo project call "TestMidiFilePlayerMulti", that project maybe can help me.
    Can you share how to trigger different MidiFilePlayer with distance?
    Or another way can play MidiFilePlayers at different time.
     
  48. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Hello
    Sorry for the delay. I didn't have a good internet connection this week end.
    Your question is more related to C#, isn't it ?
    So you will easy find answer like c# ulong to array string.
    Regards
    Thierry
     
  49. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385
    Sorry for the delay. I didn't have a good internet connection this week end.
    Not easy to answer with a short. Could I contact you Monday or Tuesday ?
    In the mean time, you could also have a look to the demo CatchMusic.
    One midi player to get the MIDI events and on stream MIDI player to play the note with a time shift.
    upload_2022-10-15_19-34-7.png
    Regards
    Thierry
     
  50. BachmannT

    BachmannT

    Joined:
    Nov 20, 2016
    Posts:
    385