Latest 0.8.0
Homepage https://github.com/hirohitokato/HKLSynthesizer
License New BSD
Platforms ios 8.0, requires ARC
Frameworks Foundation, AVFoundation, AudioToolbox

Platform iOS

Swift 2 compatible
CocoaPods compatible
Carthage compatible
License: New BSD

Audio synthesizer & sequencer engine for iOS. It enables you to create a rhythmbox/drum-machine app easily.

Features

  • M tracks & N steps sequencer.(depends on your iOS device spec)
  • gain & pan parameters for each track
  • supports 44100Hz/16bits linearPCM audio data
  • suports over 1000bpm(actually, there is no limit)
  • supports both Swift & Objective-C

How to use

  • import HKLSynthesizer (if you use Objective-C, import AudioEngineIF.h)
  • Instantiate a AudioEngineIF object and use it.
let engine_ = AudioEngineIF()

Methods

  • start() starts synthesizer
  • stop() stops running
  • tempo property sets its bpm
  • numSteps property decides the total steps of sequencer
  • sounds property sets the sound file for each track.
  • setStepSequence() sets a note on/off sequence for the specified track.
  • setAmpGain() sets an amp gain for the specified track.
  • setPanPosition() sets a panning position for the specified track.

The class API is as follows:

@protocol AudioEngineIFProtocol;

@interface AudioEngineIF : NSObject

/**
*  bpm
*/
@property (nonatomic, assign) double tempo;

/**
*  number of steps in a track
*/
@property (nonatomic, assign) NSInteger numSteps;

/**
*  Sound files. The number of sounds must be equal to the number of tracks
*/
@property (nonatomic, copy) NSArray<NSString*>* _Nullable sounds;

/**
*  Set sequence for the specified track.
*
*  The sequence contains NSNumber<bool> values. The size must be equal to numSteps property.
*
*  @param sequence array of bool values. true means note on.
*  @param trackNo  track number
*/
- (void)setStepSequence:(NSArray<NSNumber *>* _Nonnull)sequence ofTrack:(NSInteger)trackNo;

/**
*  Set amplifier gain(0.0-2.0) for the specified track
*
*  @param ampGain 0.0(mute)…1.0(original)…2.0(x2.0)
*  @param trackNo track number
*/
- (void)setAmpGain:(double)ampGain ofTrack:(NSInteger)trackNo;

/**
*  Set pan position(-1.0…1.0) for the specified track.
*
*  @param position -1.0(left)…0.0(center)…1.0(right)
*  @param trackNo  track number
*/
- (void)setPanPosition:(double)position ofTrack:(NSInteger)trackNo;

/**
*  Start a sequencer
*/
- (void)start;

/**
*  Stop a sequencer
*/
- (void)stop;

/**
*  Delegate object conforms to AudioEngineIFProtocol
*/
@property (nonatomic, weak) id<AudioEngineIFProtocol> delegate;
@end

@protocol AudioEngineIFProtocol <NSObject>
@required
/**
*  Tells the delegate that the sequencer has triggered at the step(time)
*
*  @param engine       the audio engine that the tracks are triggered
*  @param tracks       tracks that the note is ON
*  @param stepNo       step number
*  @param absoluteTime time for triggered
*/
- (void)audioEngine:(AudioEngineIF * _Nonnull)engine didTriggeredTracks:(NSArray<NSNumber *>* _Nonnull) tracks step:(int)stepNo atTime:(uint64_t)absoluteTime;
@end

Screenshot of sample project

The sample shows 4 track & N steps sequencer.

screenshot

License

New BSD License

Reference

This library uses the sample program of KORG WIST SDK as audio engine.

Latest podspec

{
    "name": "HKLSynthesizer",
    "version": "0.8.0",
    "summary": "Audio Synthesizer & Sequencer engine for iOS.",
    "description": "HKLSynthesizer is a simple but precise audio synthesizer/sequencer engine for iOS.n**This library uses a sample program contained in KORG WIST SDK.**",
    "homepage": "https://github.com/hirohitokato/HKLSynthesizer",
    "screenshots": "https://raw.githubusercontent.com/hirohitokato/HKLSynthesizer/master/images/screenshot_0.png",
    "source": {
        "git": "https://github.com/hirohitokato/HKLSynthesizer.git",
        "tag": "v0.8.0"
    },
    "license": "New BSD",
    "authors": "Hirohito Kato",
    "social_media_url": "http://twitter.com/hkato193",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "frameworks": [
        "Foundation",
        "AVFoundation",
        "AudioToolbox"
    ],
    "module_name": "HKLSynthesizer",
    "source_files": "HKLSynthesizer/**/*.{h,cpp,mm,swift}",
    "public_header_files": [
        "HKLSynthesizer/HKLSynthesizer.h",
        "HKLSynthesizer/AudioEngine/AudioEngineIF.h"
    ]
}

Pin It on Pinterest

Share This