• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
is kAudioUnitType_MIDIProcessor available on iOS?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

is kAudioUnitType_MIDIProcessor available on iOS?


  • Subject: is kAudioUnitType_MIDIProcessor available on iOS?
  • From: Pavel Litvinenko <email@hidden>
  • Date: Sat, 04 Oct 2014 00:45:19 +0400

Good afternoon. I'm working on a new app for iOS, this is sequencer with built-in sampler. 
Sequencer operates using MusicPlayer api. 
I've already implement a polyphonic sampler as audiounit plugin (kAudioUnitType_MusicDevice). 
Now I would like to add a few midi effects (kAudioUnitType_MIDIProcessor). 

Unfortunately I haven't found any information on how to write units with this type nor how to use it in my host code.

Naive solution not working.

//_______________________________________________________________________________________________________________

class LSQSwing : public AUBase, public AUMIDIBase
{
public:
    LSQSwing(AudioComponentInstance inInstance) : AUBase(inInstance, 1, 1),
                                                  AUMIDIBase(this)
    {
    }

    

    ~LSQSwing()
    {
    }

    

    virtual bool StreamFormatWritable(AudioUnitScope scope, AudioUnitElement element)
    {
        return false;
    }

    

    virtual bool CanScheduleParameters() const
    {
        return false;
    }

    

    virtual OSStatus MIDIEvent(UInt32 inStatus,
                               UInt32 inData1,
                               UInt32 inData2,
                               UInt32 inOffsetSampleFrame)
    {
        return AUMIDIBase::MIDIEvent (inStatus, inData1, inData2, inOffsetSampleFrame);
    }
};

//_______________________________________________________________________________________________________________

AUDIOCOMPONENT_ENTRY   (AUMIDIProcessFactory, LSQSwing);
AUDIOCOMPONENT_REGISTER(LSQSwing,
                        kLSQSwingName,
                        kLSQSwingVersion,
                        kAudioUnitType_MIDIProcessor,
                        kAudioUnitSubType_LSQMIDISwing,
                        kAudioUnitManufacturer_CasualUnderground,
                        0,
                        0);

//_______________________________________________________________________________________________________________

// Somewhere in my host program...

        _instrument = [[instrumentClass alloc] initWithComponentDescription:description
                                                            audioController:controller
                                                                      error:nil];
        LSQQueuePushHead(_mainChain, (__bridge void *)(_instrument));
        // Connect instrument to midi processor
        LSQNodeRef midiHead = LSQQueueHead(_midiFxChain);
        if (midiHead)
        {
            id<MIDIProcessorProtocol> headProc = (__bridge id<MIDIProcessorProtocol>)(LSQNodeGetContent(midiHead));
            if (AUGraphConnectNodeInput(controller.audioGraph,
                                        _instrument.audioGraphNode,
                                        0,
                                        headProc.audioGraphNode,
                                        0) != noErr)
            {
                NSLog(@"Failed to connect node: %i to node: %i", (int)headProc.audioGraphNode, (int)_instrument.audioGraphNode);
            }
        }

// ...Somewhere

            id<ComponentProtocol> midiProc = [channel midiProcessor];
            MusicTrack mTrk = MSSequencerTrackGetOutputTrack(track);
            AUNode     node = -1;
            // Check if music track already connected to aunode
            if (MusicTrackGetDestNode(mTrk, &node) == noErr && (node != midiProc.audioGraphNode || node == -1))
            {
                if (MusicTrackSetDestNode(mTrk, midiProc.audioGraphNode) != noErr)
                {
                    [NSException raise:NSStringFromSelector(_cmd)
                                format:@"Failed to set destination node of music track."];
                }
            }



Is there any examples or info about how to build it?
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: What could cause error -4 in Logic validation?
  • Next by Date: Record Speaker Output?
  • Previous by thread: Re: What could cause error -4 in Logic validation?
  • Next by thread: Record Speaker Output?
  • Index(es):
    • Date
    • Thread