NickCulbertson / AUv3-Instrument

This is a minimal AUv3 instrument app example using AudioKit 5.
MIT License
34 stars 4 forks source link

Some nice updates! An oscillator edition would be appreciated. #3

Closed 01GOD closed 1 year ago

01GOD commented 1 year ago

That new keyboard is WAY nicer. Thanks for adding that! Today tried for hours to get a recipe from the Cookbook to function with this project. Previously did the AU, but today was going for the AU and the app also (partially to avoid the App Store Connect hassles and partially because thought it would be MUCH easier than it was). An oscillator (not an EXS sampler) edition of this project template would certainly be a nice and appreciated addition. I imagine that is likely pretty easy when somebody is very comfy with how AudioKit 5 does things and how the MIDI system of that framework is built. If there is an easy way to slap an oscillator into that, certainly would like to know how. Basically there weren't compatible noteOn methods seemingly. I switched it from MIDISamplerInstrument to MIDIInstrument with the VocalTract and thought that should do it, but without a compatible noteOn it was a bigger challenge than anticipated. Anyway, thanks in advance for posting a short how-to on converting that to oscillator compatibility or for posting an oscillator example!

PS: "Modular, modular, modular" is a nice software architecture CHANT for such a framework. Modular architecture is easier to use and maintain. I am way into modular product design though.

NickCulbertson commented 1 year ago

Hmmm, yeah that's a good idea. I'll look into it in the future. You would still setup your oscillator in allocateResources then to play the sound you would have to do something like func noteOn(pitch: Pitch, point _: CGPoint) { isPlaying = true osc.frequency = AUValue(pitch.midiNoteNumber).midiNoteToFrequency() } in https://github.com/AudioKit/Cookbook/blob/main/Cookbook/CookbookCommon/Sources/CookbookCommon/Recipes/Oscillators/Oscillator.swift

01GOD commented 1 year ago

Thanks! Saw now. Actually thankfully found a way to edit the DynamicOscillator in the cookbook and brought that over into this project. So now I have 2 projects...one with a functioning app...and one with a functioning AU from before... Thankfully both sound the same and hopefully will integrate those projects together tomorrow (wish I knew of an easy way to ship them separately, so that wouldn't be necessary).

I should get to bed and work on that later though, because it's almost 1am here. Thankfully that keyboard looks 1337 enough to ship a standalone app. (It's calling for a step sequencer, but I am like...maybe another day!)

By the way, not sure if it's the best place to ask, but is there a way to make the XY pad and so on in Controls update while touching? Currently those various controls in that package only update position after touchUp. If that is unexpected, I can post that as an issue on that repo.

01GOD commented 1 year ago

PS: I was using "conductor.noteOn(note: noteNumber)" in the AU. Seems that kinda weird "CGPoints" param is a new thing maybe in the AudioKit MIDI, so the compiler complained and commenting out the noteOn functionality obviously wasn't the best solution. Basically it's saying that part of the AU that I ported over from the AU that I made with a past iteration of this repo maybe isn't as compatible as it could be.

NickCulbertson commented 1 year ago

The XYPad appears to be working when I just tried it. Make sure the value you are updating is @Published. point: CGPoint returns the vertical position of a key press in case you want it for velocity control.

01GOD commented 1 year ago

Ah, alright. Thanks! Had thought it was maybe for something like that, but it seemed to be in the MIDI portion also, so that seemed odd.

Thankfully finished both after 2am…I am admittedly a little relentless sometimes. Brought in the cookbook keyboard to make the integration of the oscillator recipe function and something odd happened on the keyboard in the app with the AudioKit keyboard. When multiple keys are pressed and then any of them are released , all the note offs happen instead of only that specific key only

This World simulation is MY LINEAR DREAM inside of OMNIPRESENT ME, so it’s good and beneficial for the entire population of the World to protect Me from having too much stress (MY AVATAR was residing in china when the pandemic started there, as an example of why). So thanks in advance for notifying of a solution to that keyboard issue. I can post an “issue” on the AudioKit keyboard repo if that’s not only because of merging those projects.

Update: Confirmed that happens with the piano keyboards in oscillator examples in the cookbook also. So maybe it is an issue with Keyboard.

01GOD commented 1 year ago

PS: Built on macOS also. Also the AU built successfully on macOS, but haven't figured out where it is in Garageband. Would certainly like to run the AU in Ableton and so on. By the way, there is an AudioKit IRC chat or discord chat or similar?

NickCulbertson commented 1 year ago

The Oscillators are monophonic and Keyboard doesn't have a monophonic, legato mode. To have the notes return to a previously pressed key you would have to put the currently held notes into an array and re-trigger noteOn manually from your noteOff method. There is an AudioKit Discord: https://discord.gg/fzx7HNPV7y

01GOD commented 1 year ago

Ah, that's not why, but thanks for posting a possible solution. Basically it's polyphonic, but when letting up any key, ALL the note offs happen. So when pressing 3 keys, all 3 notes play, but if any of those are lifted, ALL the notes turn off (although keys are still pressed).

The cookbook keyboard has a more simplified noteOn and noteOff seemingly. By the way, been working on getting that .appex AUV3 to run on macOS. JUCE community forum makes the process seem as though it's one of the least documented things Apple has ever made. Here are some tips though: https://forum.juce.com/t/osx-10-15-debug-auv3-in-logic/40453/3

I don't have Logic Pro installed right now. So maybe try it with that later sometime. Supposedly it should install from Mac App Store though.