A Code Example/Tutorial on Dragging Audio and MIDI to the DAW [UPDATED WITH VIDEO]
-
EDIT: All works now, thanks to the tireless efforts of @Christoph-Hart. Thanks, man!
This code example demonstrates how to:
- Load a MIDI file.
- Draw a map of the MIDI file in a Panel to check if it loaded properly.
- Play back the loaded MIDI sequence, synched to the DAW.
- Create a panel allowing the MIDI file to be dragged to a DAW.
- Render the MIDI file to audio (with the currently-loaded Sample Map).
- Create a panel for dragging the file to a DAW.
The code is straight from my plugin. I've commented it to explain what's happening at each line. Comments/feedback/corrections encouraged/appreciated. [EDIT: @Christoph-Hart improved my code, and added it to the Snippets library — use that code.]
EDIT: Here's the usage case, including a simple progress bar:
Raw code for the dragging and related part (not a project):
HiseSnippet 3952.3oc0a0uaajbjmzqUvIc2Ej.bO.cz+XJDZFoMa9.1vHgRjxlI5CFRpcSvhEBMmoIYGMbZdS2TzDAF3dZt2l7RbOA2avc+pp6Y3PpurT1rqWBCayo6pqpqt93WU8vtYlHk0ZxpTc6AKmopT8eaq9KScSNZhTmVoSqJU+wacjIVIZ+d4zYIpJGtblzZUwUpV8ydKMmpa+7J7m+2e2gxDYZjZ0ipT4KM5H0I5oZ2pm182+G0IIGKiUCzSKM6u322IxjdjIwLGxyms09UlIitRNVcljl1y1pR0eT6Xsyj02IcJakpO+PS7x9SLKR8y+K0V8PHj3KGToOVH+iO1jDSRL8zJGMQmD2MeeaqfUo6Jsvm40B+GacpNVW77UZieBOfXEEk0GUe15h2msl3cvcId2hHUsjH8buH8S2peTldla0Hj77utUmTmJajLZ8iF+bq7r+9K25W7c9mcdRTI52df3hthuCY4+X6RvSwaUNwPXkpSGKlISUIhL0HUlBtA1F6.yYqSbsLyO1kGc9ocOue6dW1RM5nTWh8xt3r6TS5k8U+myIh9RsZwku8hNh2HNxfS1TWiwJ2QloyLo3K018wtP6t2qebhAQ3g9czkM6M3eDAYikhDkbcVbl7iQg09riNuEs5X5cM5T2ocZ04iP+bmzcapiaL4lyi0lmBWJHLeq1LNV3lnDD6E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8wZuQ6Tt8TTA8xx+hCdDuw86euuw8erh3OcqtDD6aWFe1sHiPS8OCYL76T3eeq1.EQjak.97sN9O+T+QI7.r22gmwmJcY52Wo5VmMeZefAJREZ+JV7sp9LxZw+88ouSZf9HYE+k+O7IL3Az2qFF7f7AqLUFkYtLx6EP+RH9W3m.YJk+Qfr8VmReWbPE1ynrdlBkcYTz5K0MH7yepD9KepD9EOUB+UOUB+0OUB+MOUB+sOLgzq.Zyv6JBbapT4zts4PIUq5KUisVq7+CgstiXA
-
Cheers to you man, snippet?
-
This post is deleted! -
@clevername27 God Bless man, Amazing Work :victory_hand_light_skin_tone:
-
Why is that
Most likely a file permission issue - I see you're writing it to a location inside the app data directory, this might cause some issues.
But it's a nice example of a heavily underdocument feature so I'm refactoring it a bit and will add this to the HISE snippet browser.
-
@Christoph-Hart Thank you for the kind words. I thought so, as well about the permission – I tried the Documents and Downloads folder – on both cases, the OS asked permission and I granted it. Same result, tho. I'll try some other permutations. I've also amended my original post to see if someone can try this under Windows or GNU/Linux, where I suspect it might work fine.
-
@Christoph-Hart said in A Code Example/Tutorial on Dragging Audio and MIDI to the DAW*:
I'm refactoring it a bit and will add this to the HISE snippet browser
I just saw the snippet browser link in the help menu. Clicking on it crashes HISE here.
-
@d-healey can you check if it only happens on Linux?
There‘s a lot going on there, it creates another HISE instance in a new window that you can use next to your currently loaded project but it might be a bit funky on Linux as I haven‘t tested this yet.
-
@Christoph-Hart it works on Mac
-
Works on Windows here.
It works on Linux in a debug build but not a release build. And it takes ages to open the snippet browser.
I'm wondering, does the snippet browser thing respect the
USE_LINUX_FONT_HANDLER
flag? I remember if I have this enabled then it takes ages to open HISE so I always disable this in my release build but I have to enable it in the debug build otherwise it won't open. -
@d-healey Does it take longer than the initial startup of HISE?
-
@Christoph-Hart The debug build of HISE takes about 6 seconds to open, from within there the snippet browser takes about 12 seconds. So roughly twice as long.
-
@Christoph-Hart Thanks for the suggestion - I notice that the MIDI file was getting written OK (to the App Data folder), so I tried the same with audio - same thing. I know you're busy - if you have a chance, do you have any further thoughts? Thank you.