Would you like this to be developed further (because it does subvert the core internals of the alda player), or do you think there's a better way to do it? If you think it's good approach, I'll clean it up (eventually.) and make a PR with proper integration in the client/server as well (but this will probably take a while). I couldn't find any way to write jsyn out to a file, so I don't know how much luck we'll have with that. I really despise listening to audio out (since recording much be done in realtime, and it feels really hacky), so I think that midi export should be a feature in alda even if jsyn features are added (for pure midi tracks). I don't know if there's another way to do this 'cleanly'. However, I think this should be pretty easy to add with a bit more playing around.Īlso because I was super crunched on time, it encodes midi's whenever it plays, to a hardcoded file, but that's not really the point of this :P. One of the problems with this method is that (because I didn't understand how instruments work) all the events are played with the piano. Finally, I tell the sequencer to record what I'm transmitting, and it builds a midi sequence for me! Writing it out to a file then is fairly easy, and converting it to a wav is just one more step which should be easy (I didn't do it for now, since I was able to just launch another java process to do that for me). This web page was incredibly helpful during this process, I probably couldn't have done anything without it.Įssentially all I'm doing is looping through all the events in a score, and sending corresponding notestart and noteend events (instead of registering callbacks) into a sequencer. Isn't this fragile (and can lead to timing problems?) From what I can tell, java highly recommends building a sequence if timing is important. It seems to be scheduling every note start and note end via a callback (via jsyn), and using those callbacks to call functions on the midi Synthesizer. I'm actually a little bit confused at the design for this system.
#Wotja export to wav file how to
While I haven't looked at the source, the 'getMaxTransmitters' function returns 0 on a Synthesizer, leading me to believe this is route is impossible (if someone knows how to do this, please let me know).īecause of that, I decided to go the second route, which is building Midi Sequences from alda scores manually, then writing those scores to disk. However, when you try to do this, you get a MidiUnavailableException, which lead me to a dead end (no one seems to have overcome this, there are several SO posts with no answers with the same problem as me). The Midi Wave exports mentioned before all work with sequences (they read midi files from disk into a Sequence) so I wanted to re-direct the Synthesizer to 'transmit' into a Sequencer 'receiver'. The second is the Synthesizer, which is capable of producing sounds when written to or when commanded manually via function calls. Two relevant subclasses of MidiDevice are Sequencer, which is able to write and read from a sequence, the "official" method of storing midi "scores" in java. Any "MidiDevice" has support for both 'receiving' and transmitting' audio, if set up correctly. It's a little tough to understand, but it's better than the API (although still not great). Very basic googling will quickly center to this page, which describes the method java uses for midi recording and export.
![wotja export to wav file wotja export to wav file](https://is2-ssl.mzstatic.com/image/thumb/Purple115/v4/8c/7a/00/8c7a00be-6f43-e62a-00f7-49e7121dc834/source/576x768bb.jpg)
I'll try to encode everything that I learned here, since resources on java midi export are incredibly rare (?!?!?)
![wotja export to wav file wotja export to wav file](https://intermorphic.com/archive/wotja/20/guide/img/crops/-wotja-mix-music-editor-generator-network@0.5x.png)
Right now it's terrible quality (which is why it's not in a PR) and not even close to completion, but it does work, somewhat. I really think it's rediculous that alda dosen't have any form of export, and a bunch of my friends needed alda to have an export feature for a hackathon project, so I spent a bunch of time messing with this.