HKLSynthesizer 0.8.0

HKLSynthesizer 0.8.0

测试已测试
语言语言 Objective C++Objective C++
许可证 BSD 3.0
发布最后发布2016年6月

Hirohito Kato 维护。




适用于 iOS 的音频合成器和序列器引擎。它使您能够轻松地创建节奏盒/鼓电脑应用程序。

功能

  • M 个轨道和 N 个步骤序列器。(取决于您的 iOS 设备规格)
  • 每个轨道的增益和平坦参数
  • 支持 44100Hz/16位线性PCM音频数据
  • 支持超过 1000bpm(实际上没有限制)
  • 支持 Swift 和 Objective-C

使用方法

  • import HKLSynthesizer (如果您使用 Objective-C,请导入 AudioEngineIF.h)
  • 实例化一个 AudioEngineIF 对象并使用它。
let engine_ = AudioEngineIF()

方法

  • start() 开始合成器
  • stop() 停止运行
  • tempo 属性设置其 bpm
  • numSteps 属性决定序列器的总步数
  • sounds 属性为每个轨道设置声音文件。
  • setStepSequence() 为指定轨道设置音符开启/关闭序列。
  • setAmpGain() 为指定轨道设置增益。
  • setPanPosition() 为指定轨道设置音量平衡。

类 API 如下

@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

示例项目的截图

示例展示了 4 个轨道和 N 个步骤序列器。

screenshot

许可证

新 BSD 许可证

参考

该库使用 KORG WIST SDK 的示例程序 作为音频引擎。