AKOutputWaveformPlot of AKNode in a different class?

57 views
Skip to first unread message

Michael Samuels

unread,
Apr 3, 2018, 5:30:21 PM4/3/18
to AudioKit Announcements
Hi folks,

I'm having some trouble with AKOutputWaveformPlot. 

I have a project with an AudioKit synthesizer built in a class called Synthesizer.swift, and a UI controlled by SynthesizerViewController.swift. SynthesizerViewController.swift creates an instance of Synthesizer.swift. 

I'm trying to include an AKOutputWaveformPlot of the output from Synthesizer.swift in my View Controller. I am able to create the AKOutputWaveformPlot view, add it as a subview, etc., all no problem. However the WaveformPlot does not seem to register any input (i.e. from the instance of Synthesizer.swift). It remains blank/lifeless. My guess after trying a few things is that this is because Synthesizer.swift is a different class (by the way, Synthesizer.swift is declared with type AKNode).

I'm wondering if there's an additional step I need to take (like passing my "synthesizer" instance to AKOutputWaveform Plot as a parameter... except it doesn't take a parameter besides frame... I could also change over to AKNodeOutputPlot?)

My best guess is that I'm supposed to declare another instance of AKOutputWaveformPlot inside of Synthesizer.swift, and then assign wavetable = synthesizer.waveform in my ViewController, but this presents a different problem: I have to pass the Synthesizer.swift instance of AKOutputWaveform a frame, but the frame is only defined in the ViewController.

Any help would be much appreciated...

Michael 

class SynthetizerViewController : UIViewController, VerticalTabBarControllerEmbedded, AKKeyboardDelegate {

...
   
var synthesizer = Synthesizer()


    var wavetable: AKOutputWaveformPlot!

   
...

override func loadView() {

       

       super.loadView()


     
let wavetable = AKOutputWaveformPlot()


        wavetable.plotType = .buffer


        wavetable.backgroundColor = .red


        wavetable.color = .blue


        wavetable.shouldCenterYAxis = true


        view.addSubview(wavetable)


        wavetable.snp.makeConstraints { make in


            make.top.equalTo(device1View.snp.top)


            make.left.equalTo(device1View.snp.right).offset(5)


            make.right.equalTo(device2View.snp.left).offset(5)


            make.bottom.equalTo(device1View.snp.bottom)


        }


        //self.wavetable = synthesizer.waveform


        self.wavetable = wavetable


...


override func viewDidLoad() {

       super.viewDidLoad()



   // wavetable = self.synthesizer.waveform   (My best guess? but declaring another instance of AKOutputWaveform in the synthesizer class presents its own problem: I need to pass a frame, which is only specified in SynthesizerViewController.swift)










Aurelius Prochazka

unread,
Apr 3, 2018, 5:35:49 PM4/3/18
to AudioKit Announcements
Oops, I actually mean to reject this message but accepted by accident... but it allows me remind everyone of a few things:

This list is not meant for support anymore.  Michael should really post this message to Stack Overflow and then more people can respond, get credit on StackOverflow for their answers, and have the answers available to others who might be having similar problems in the future.

This list is for announcing new apps, AudioKit updates, etc.

If however, you post to StackOverflow and you get ignored for a few days, then you can "announce" your StackOverflow link on this mailing list to get some attention.  But, please don't do that until people on StackOverflow have had a chance to answer your question.

Aure
Reply all
Reply to author
Forward
0 new messages