Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

A simpler example? #6

Open
pistacchio opened this issue Mar 21, 2021 · 5 comments
Open

A simpler example? #6

pistacchio opened this issue Mar 21, 2021 · 5 comments

Comments

@pistacchio
Copy link

pistacchio commented Mar 21, 2021

Not complaining about your incredible work that you put out for free, but I just want to point out that this project is a wonderful app but a terrible example. A good example would contain the minimum amount of code lines able to compile a AUv3 plugin that prints "Hello world" in a hosting application and maybe plays a single "beep sound" or outputs a single MIDI note just to show how integration works.

I'm just trying to understand how to convert my app into a AUv3 plugin and I'm utterly lost in the hundreds of files of this project and it's frustrating because I know that what I need is lost somewhere deep down the pile of code, files, assets, functionalities that have nothing to do an "Example app".

Also, this "example" is obviously so pointlessly complicated that, I guess, porting it to v5 of AudioKit is a huge amount of work nobody would ever do, effectively making this project useless and obsolete. A proper, minimal example app with just the amount of code to show how to setup a AUv3 plugin would be actually way manageable and maintainable.

@emurray2
Copy link
Member

emurray2 commented Aug 6, 2021

Not complaining about your incredible work that you put out for free, but I just want to point out that this project is a wonderful app but a terrible example. A good example would contain the minimum amount of code lines able to compile a AUv3 plugin that prints "Hello world" in a hosting application and maybe plays a single "beep sound" or outputs a single MIDI note just to show how integration works.

I'm just trying to understand how to convert my app into a AUv3 plugin and I'm utterly lost in the hundreds of files of this project and it's frustrating because I know that what I need is lost somewhere deep down the pile of code, files, assets, functionalities that have nothing to do an "Example app".

Also, this "example" is obviously so pointlessly complicated that, I guess, porting it to v5 of AudioKit is a huge amount of work nobody would ever do, effectively making this project useless and obsolete. A proper, minimal example app with just the amount of code to show how to setup a AUv3 plugin would be actually way manageable and maintainable.

I hear you, and I was in your shoes looking at this project back in December. From what I understand, this project is meant to be an example of what a fully-fledged AUv3 might look like. If you're looking for the simplest answer to creating an AUv3, all you need is an existing AudioComponent to instantiate (whether in a host or in your app). Conveniently, all of the AudioKit v5 nodes already have underlying Audio Components you can use. They're also very similar to AudioKit v4. Here's a migration guide with all the changes described: https://audiokit.io/MigrationGuide/ .

I'll see if I can create a minimal example of an AUv3 with AudioKit. I've already somewhat done this, but there were still some things I was fixing up to make everything work.

@emurray2
Copy link
Member

emurray2 commented Aug 7, 2021

Here's an example I just made: emurray2/AUv3HelloWorld. It takes a huge shortcut and is still a work-in-progress, but I'll keep updating it as I learn more. I'm open to feedback others have as well.

@aehlke
Copy link

aehlke commented Jun 5, 2022

Anything you've learned since that you would've liked to have added to your helpful hello world?

@emurray2
Copy link
Member

emurray2 commented Jun 5, 2022

Anything you've learned since that you would've liked to have added to your helpful hello world?

Absolutely.

AUv3 is very different from AUv2. Why?

AUv3 is built off of Apple's App Extensions System. This is important because most stuff you can do in an app you can also do in an AUv3--they're not much different.

What is the minimal thing you actually need to compile an AUv3?

Well, think about it like a musician. If you're building an Instrument AUv3, you need to have only an audio output (output bus) and MIDI handling. For an Effect AUv3, you need to have an audio input and an audio output. And also, what is the plugin going to do to the sound? That's what the internalRenderBlock is for. You can either use your own signal processing code and specify the render block, or you can use AVAudioEngine to render the audio--which is what this example does. And don't forget, you need to allocate (gather the resources) to do all of that stuff, which is what allocateRenderResources() is for. Finally, you need a description and name for your plugin which are all contained in Info.plist. Then, this info is called upon by the host in the audio unit's init method, which is called by the factoryFunction. Then, when it's time for the audio unit to be removed, you need to specify deallocateRenderResources(). That's it, those are all the things you need. You don't even need to specify parameters--hosts will look for all the parameters you have and return none if there aren't any.

Can AUv3 be used in Mac Catalyst?

Yes, in fact you don't even need that when using Apple Silicon (M1). This is because Apple now supports Universal Build Architecture. In other words, Apple is trying to move towards making it easier to port a MacOS app to iPad, whether you have an Intel chip or M1 chip.

Resources?

You can check out a new AUv3 I'm working on right now which utilizes all of these tips at emurray2/MusicalWeather. Also, checking out this guide by Apple is a neccesity: App Extension Programming Guide. Finally, this one is a big go to: Creating Custom Audio Effects. There are also a ton of other people in the AudioKit community who have been contributing videos/examples on this topic: Nick Culbertson, Gene De Lisa, Eric George. And more I'm probably forgetting.

As far as adding anything to that example, I don't think I would. In fact, it may be too simple. What I was doing was getting away with using an audio unit instantiated by AudioKit in the factoryFunction, which is what the host uses to get the audio unit. I don't know if you're supposed to do this, and it certainly creates some issues auval isn't too happy about. I'd much rather go with the approach in this app actually, just with only the simple "Hello World" UI.

@VielfaltSoftware
Copy link

I found a simple AUv3 iOS plugin example that uses AudioKit 5 (after trying and failing to update this project to AudioKit 5):
https://github.com/NickCulbertson/AUv3-Instrument

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants