Sending System Output Sounds to TAAE

Please forgive me but i am extremely new to Obj c , I did get TAAE and AudioBus to Work sending Audio Out using my test wav file below. However, how do i send all system audio sounds(main OutPut coming from the App) and add them to _audioController :(

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"HotSound1" ofType:@"wav"];

NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];

self.senderfile = [AEAudioFilePlayer audioFilePlayerWithURL:fileURL error:NULL];

_senderfile.volume = 1.0;
_senderfile.channelIsMuted = NO;
_senderfile.loop = YES;







// Create the combined system output group.

_sendersOutputGroup = [_audioController createChannelGroup];


// Combined system output, containing the kick, snare, and hi-hat loops.
[_audioController addChannels:@[_senderfile] toChannelGroup:_sendersOutputGroup];


[_audioController setAudiobusSenderPort:_sender forChannelGroup:_sendersOutputGroup];

Comments

  • Quick Update i am using OpenAL and was really trying to figure out anyway of tapping the sounds out

  • (Posting here too just to save people trouble: this is what TAAE itself does, no need to reinvent the wheel =))

  • @CreateLex, My original app started with OpenAL, too. It was a long and arduous process to migrate its engine to TAAE, because I couldn't find any code examples that showed how to properly implement AUSamplers. Luckily, I discovered the following GitHub project whichhelped immensely:

    https://github.com/rzil/TAAETest

    This example demonstrates how to implement a AUSampler component that references .caf, .wav, or .aif files from your Sounds directory, without relying on AULab software to create presets for you:

    https://github.com/rzil/TAAETest/blob/master/TAAETest/TAAETViewController.m

    Once you set up your tapped UI sound effects using AUSamplers, you will be able to set their individual volume, left/right panning, and pitch to a specific note in the range from 0-127. Of course, MIDI note number = #60, being middle C (original pitch of the audio file). If you want to play the audio sample at a one octave higher, then set the MIDI note number to #72 (60 + 12). For one octave lower, set it to #48 (60 - 12). Here's a MIDI note number chart for reference:

    http://newt.phys.unsw.edu.au/jw/notes.html

    Lastly, by having your sound effects played via AUSamplers, you will be able to trigger them via MIDI, and capture their audio output into Audiobus. Sweet!

    I hope this helps.

    Take care,

    Mark

  • @Michael @markjeschke you guys rock. I am certainly going to do this. and yes this saves so much people. thank you so much again.

  • Wow the ability to adjust pitch is neat, didn't know about that!

  • @warpling, Yes, being able to change the pitch can allow you to expand your sound effect sound set, without adding a large collection of audio files to your build. For example, if you had a single explosion sound effect, you could randomize its playback timing, pitch, volume, and pan, mixed with randomized amounts of parametric eq, high/low-pass, distortion, and reverb, etc. You could also limit the sound's pitch range to a particular key or octave. The possibilities are endless. :)

  • @markjeschke @Michael so after weeks of learning. do i have to still create a AUSAmpler.aupresets file? all my wav sounds are in the bundle resources. i can't it play out to TAAE :(

    • (void)loadSamples {
      // NSString *samplesPath = [[NSBundle mainBundle] [[NSBundle mainBundle] resourcePath] ofType:nil];

      NSArray *filenames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[[NSBundle mainBundle] resourcePath] error: nil];

      NSLog(@%@", filenames);

      NSString *samplesPath = [[NSBundle mainBundle]resourcePath];

      NSLog(@%@", samplesPath);

      NSError *error;

      // NSArray *filenames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:samplesPath error:&error];
      if (error) {
      NSLog(@%@", error.localizedDescription);
      return;
      }
      NSArray *filesArray = [filenames filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@SELF endswith %@", @.wav]];
      NSMutableArray *urls = [NSMutableArray arrayWithCapacity:filesArray.count];
      for (NSString *name in filesArray) {
      [urls addObject:[NSURL fileURLWithPath:[samplesPath stringByAppendingPathComponent:name]]];

      }
      CFArrayRef urlArrayRef = (__bridge CFArrayRef)urls;

      {
      OSStatus status = AudioUnitSetProperty(self.sampler.audioUnit,
      kAUSamplerProperty_LoadAudioFiles,
      kAudioUnitScope_Global,
      0,
      &urlArrayRef,
      sizeof(urlArrayRef));
      if (status != noErr) {
      NSLog(@Failed to load samples. OSStatus was %ld, (long)status);
      return;
      }
      }
      }

Sign In or Register to comment.