Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #import <AudioToolbox/AudioToolbox.h>
  2. #include "Stk.h"
  3. #include "HevyMetl.h"
  4. #include "Voicer.h"
  5.  
  6. #define VOICES 4
  7.  
  8. using namespace stk;
  9. struct AudioData{
  10. Voicer *voicer;
  11. HevyMetl *instrument[VOICES];
  12. };
  13.  
  14. @interface SoundManager : NSObject {
  15. struct AudioData audioData;
  16. }
  17.  
  18. audioData.voicer = new Voicer();
  19. for (int i = 0; i < VOICES; i++) {
  20. HevyMetl *heavyMetal = new HevyMetl();
  21. audioData.instrument[i] = heavyMetal;
  22. audioData.voicer->addInstrument(heavyMetal);
  23. }
  24.  
  25. float note = arc4random() % 88; // a random midi note
  26. long noteTag = audioData.voicer->noteOn(note, 128.0);
  27.  
  28. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
  29. audioData.voicer->noteOff(noteTag, 64.0);
  30. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement