Dynamic reading and writing build problems #264
Replies: 4 comments 2 replies
-
Hi, Show the code please. Also clarify what do you mean "it gets stuck"? Is Unity hanging? |
Beta Was this translation helpful? Give feedback.
-
Hi Max. Ok, here's the code. I've tried to remove anything irrelevant so it's not miles of code. Please forgive messy code, this is my first project. I hope that all makes sense. Thanks |
Beta Was this translation helpful? Give feedback.
-
Hi Max. Ok, apologies for my bad use of terminology. I'm still learning. I see what you mean, reading is not the same as playback, yes. I hope you don't mind me asking a question unrelated to DryWetMidi, but I don't really have anyone else to get advice from that understand both music and coding. But am I using the wrong platform or language? I learned C#, but it seems impossible to do what I need. Unity seems designed to do good graphics, but it can't hold time for music. And yet, there are all these apps like iReal that do hold good time, so it must be possible. Do I need to learn swift and Kotlin? What would you recommend for making something that can sequence music, either straight from a tick Generator or via dynamic MidiFile? As always, thanks for your time. |
Beta Was this translation helpful? Give feedback.
-
Oh that's interesting. Thanks Max. Actually since I wrote that last comment, I've had a bit more luck creating a tick generator by doing it based on the audio rate and using OnAudioFilterRead. This seems to hold time pretty well although the processor struggles depending on what I'm doing with the ticks. I've been finding ways to reduce that by putting events in dictionaries with the tick as the key so it doesn't have to iterate through the whole list every tick. It also helps if I only have a single event publisher. I think the bit that I was missing is the threading. If you want to create accurate pulses it has to be off the main thread. Because I notice that in your gen you are just using stopwatch, and I previously tried that on the main thread and it was really wobbly. I'll give your generator a proper try, maybe it will create accurate ticks without hammering the processor as much as the OnAudioFilterRead method does. As always. Thanks for your advice and help. I can't stress how helpful it is to ask questions to someone that understands audio/Midi. Most unity devs think using sound means audioSource.play() ;-) |
Beta Was this translation helpful? Give feedback.
-
Hi Max.
As you may remember, my project is dynamically writing and then reading a single midiFile.
It works great in unity, but when I build for Android, it gets stuck and I think the problem is at the point where it either writes or reads the midiFile. I've tried using Application.persistentDataPath and Application.temporaryCachePath and both still get stuck. Should I be using a different file path to make this work?
Any thoughts on what might be happening?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions