• 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
AUSampler Parameters modified with Midi Messages (???)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AUSampler Parameters modified with Midi Messages (???)


  • Subject: AUSampler Parameters modified with Midi Messages (???)
  • From: Pascal Do <email@hidden>
  • Date: Tue, 09 Jul 2013 04:37:45 -0700 (PDT)

Hi everyone,

I have a AUSampler audiounit in my graph. It loads a preset (with a looped external audio file) that was created in AU Lab. The AUSampler loads well and it plays correctly plays notes on and off when I call the following :

void playNote(AESynthChannel* THIS,int note,UInt32 startFrameIndex){
    //------------------------
    //     note on
    //------------------------
    UInt32 velocity = 127;
    UInt32 __block noteCommand = kMIDIMessage_NoteOn << 4 | 0;
    log_if_err(MusicDeviceMIDIEvent (myAudioUnit,
                noteCommand,
                note,
                velocity,
                startFrameIndex),@"Unable to play note On");
    //------------------------
    //    note off
    //------------------------
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW,timePerStepInSec * NSEC_PER_SEC),
                   dispatch_get_current_queue(),^(void){
                       log_if_err(MusicDeviceMIDIEvent (myAudioUnit,
                                                        noteCommand,
                                                        note,
                                                        velocity,
                                                        startFrameIndex),@"Unable to play note Off");
}

This works just fine. BTW is it okay to use a dispatch_after to send a note off message ? Any reliable way ?

Then in AU Lab, I have added some intrument connections. For instance :

Ctrl#2 > Envelope Release Time
Ctrl#3 > Envelope Attack Time
Ctrl#12 > Filter Cutoff Freq (the Filter is activated in the layer panel)
Ctrl#13 > Filter Resonance

All connections use the assigned default values. For instance, Ctrl#2 has a scale from -10 to +10. All connections have the default Bipolar curves

Here is my MusicDeviceMIDIEvent call for the controllers:

-(void) setParam:(int)paramId withVal:(float)val{
    UInt32 noteCommand = 0;
    switch (paramId){
        ...
        case OSC_VOLUME_A:        noteCommand = 0x01;  break;
        case OSC_VOLUME_R:        noteCommand = 0x02;  break;
        case OSC_FILTER_A:        noteCommand = 0x04;  break;
        case OSC_FILTER_R:        noteCommand = 0x07;  break;
        case OSC_CUTOFF:        noteCommand = 0x0B;      break;
        case OSC_RESONANCE_:    noteCommand = 0x0C; break;
        default:break;
    }
    if (noteCommand!=0){
        int inData2 = round(val)*127;
        noteCommand = noteCommand << 4 | 0; // is this correct ?
        log_if_err(MusicDeviceMIDIEvent (self.audioUnit,
                                        0x0B,
                                        noteCommand,
                                        inData2,
                                        0),@"Couldn't set a controller value";
    }
}

Nothing happens. I have tried using the following post (https://groups.google.com/forum/#!searchin/coreaudio-api/MusicDeviceMIDIEvent|sort:relevance/coreaudio-api/JhLzfZqX_Z8/NhtBbiVjQzAJ) and but no luck.

My questions :

- Anyone any idea what's wrong with my code ?

- What is the value range to use with MusicDEviceMIDIEvent? Is it always 0 to 127 ? Then the connection settings in AU Lab makes the conversion to another range of values, it that correct ?

- Is it okay to control the Tuning, the Pan midi MIDI Messages ?

- At last, any examples anyone of how to take advantage that the "Performance Parameters can be automated using Parameter Events"? It sounds great but rather daunting to implement too.

I am kind of lost here. Any help will be more than welcome. Many thanks,

Pascal
 _______________________________________________
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: Why is this audio unit producing a distorted sound
  • Next by Date: Re: AVAudioRecorder questions (iOS) about ".aac" vs ".m4a" formatting
  • Previous by thread: Re: Why is this audio unit producing a distorted sound
  • Next by thread: Is it possible to programmatically change the shape of an LFO in an AUSampler?
  • Index(es):
    • Date
    • Thread