question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Playback produces unexpected results in Unity

See original GitHub issue

I’ve integrated DWM into my Unity project (2019.1.0f2) for MIDI file playback and parsing. I’ve called playback.Start() and the MIDI file will not play. I have tried several MIDI files and nothing will play.

// Use the first available OutputDevice (Microsoft GS Wavetable Synth)
var outputDevice = OutputDevice.GetAll().ToArray()[0];
// The MIDI file is copied to this location earlier
var playback = MidiFile.Read(Application.dataPath + @"/Scripts/in.mid").GetPlayback(outputDevice);

Later, in a coroutine (so the MIDI file starts playing at a specific time):

playback.Start();

Playback doesn’t want to start, even on the main thread.

Also, playback.Play() works, but it freezes the thread which I don’t want, and it also drops a lot of notes, even on really simple MIDI files.

No exceptions are thrown.

What am I missing? And is there some fix to the dropped notes?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:43 (26 by maintainers)

github_iconTop GitHub Comments

1reaction
melanchallcommented, Sep 26, 2019

@Teafuu Right now there are no workarounds.

BUT I’m going to implement kind of ticking mode for playback/clock to choose between:

  • high-precision timer (current approach which fails on Unity/Mono)
  • regular .NET timer (can cause latency of about 15 ms or higher)
  • manual ticking (useful for coroutines in Unity, you need to call “tick” method in coroutine body to play next portion of data).

I’ll implement this API as soon as possible.

1reaction
melanchallcommented, Aug 14, 2019

Problem with using winmm timers in Unity/Mono. Unity team is working on a solution. Waiting for news from them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unity freezes on second play after objects disposing
I have the issue with playback on Unity: Playback produces unexpected results in Unity. User who reported the issue created a simple Unity ......
Read more >
Common problems | DryWetMIDI
Playback doesn't produce sound or events logs. Make sure an instance of Playback ... Playback produces unexpected results in Unity · Visualization of...
Read more >
10 Common Unity Mistakes
Before you use Unity's straightforward and intuitive tool for multi-platform development, acquaint yourself with and avoid these common Unity mistakes.
Read more >
Troubleshooting - Unity's Package Manager
Failed to resolve packages: The file [<project-path>/Packages/manifest.json] is not valid JSON: Unexpected token '}' at 44:1 }.
Read more >
Known issues and limitations | Recorder | 4.0.1
Known issue: When you build a project that includes Recorder tracks in Timeline, Unity throws an error in the Console. Recorder tracks are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found