Added missing documentation to the source code in the Playdate bindings target.
This commit is contained in:
@@ -28,6 +28,7 @@ extension Sound {
|
||||
BitCrusher.api.pointee.setDepth.unsafelyUnwrapped(pointer, depth)
|
||||
}
|
||||
|
||||
/// Modulates the crush depth.
|
||||
public var depthModulator: SignalValue? {
|
||||
get { SignalValue.wrap(BitCrusher.api.pointee.getDepthModulator.unsafelyUnwrapped(pointer)) }
|
||||
set {
|
||||
@@ -41,6 +42,7 @@ extension Sound {
|
||||
BitCrusher.api.pointee.setDownsampling.unsafelyUnwrapped(pointer, downsampling)
|
||||
}
|
||||
|
||||
/// Modulates the downsampling amount.
|
||||
public var downsamplingModulator: SignalValue? {
|
||||
get { SignalValue.wrap(BitCrusher.api.pointee.getDownsamplingModulator.unsafelyUnwrapped(pointer)) }
|
||||
set {
|
||||
|
||||
@@ -24,6 +24,7 @@ extension Sound {
|
||||
DelayLineTap.api.pointee.setTapDelay.unsafelyUnwrapped(pointer, Int32(frames))
|
||||
}
|
||||
|
||||
/// Modulates the tap's delay.
|
||||
public var delayModulator: SignalValue? {
|
||||
get { SignalValue.wrap(DelayLineTap.api.pointee.getTapDelayModulator.unsafelyUnwrapped(pointer)) }
|
||||
set {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
internal import CPlaydate
|
||||
|
||||
/// The cached `playdate->sound->effect` C API table.
|
||||
private var effectAPI: UnsafePointer<playdate_sound_effect> { Playdate.effectAPI.unsafelyUnwrapped }
|
||||
|
||||
extension Sound {
|
||||
@@ -48,6 +49,7 @@ extension Sound {
|
||||
effectAPI.pointee.setMix.unsafelyUnwrapped(pointer, level)
|
||||
}
|
||||
|
||||
/// Modulates the wet/dry mix.
|
||||
public var mixModulator: SignalValue? {
|
||||
get { SignalValue.wrap(effectAPI.pointee.getMixModulator.unsafelyUnwrapped(pointer)) }
|
||||
set {
|
||||
|
||||
@@ -24,6 +24,7 @@ extension Sound {
|
||||
OnePoleFilter.api.pointee.setParameter.unsafelyUnwrapped(pointer, parameter)
|
||||
}
|
||||
|
||||
/// Modulates the filter's cutoff parameter.
|
||||
public var parameterModulator: SignalValue? {
|
||||
get { SignalValue.wrap(OnePoleFilter.api.pointee.getParameterModulator.unsafelyUnwrapped(pointer)) }
|
||||
set {
|
||||
|
||||
@@ -28,6 +28,7 @@ extension Sound {
|
||||
Overdrive.api.pointee.setLimit.unsafelyUnwrapped(pointer, limit)
|
||||
}
|
||||
|
||||
/// Modulates the clipping limit.
|
||||
public var limitModulator: SignalValue? {
|
||||
get { SignalValue.wrap(Overdrive.api.pointee.getLimitModulator.unsafelyUnwrapped(pointer)) }
|
||||
set {
|
||||
@@ -41,6 +42,7 @@ extension Sound {
|
||||
Overdrive.api.pointee.setOffset.unsafelyUnwrapped(pointer, offset)
|
||||
}
|
||||
|
||||
/// Modulates the DC offset.
|
||||
public var offsetModulator: SignalValue? {
|
||||
get { SignalValue.wrap(Overdrive.api.pointee.getOffsetModulator.unsafelyUnwrapped(pointer)) }
|
||||
set {
|
||||
|
||||
@@ -23,6 +23,7 @@ extension Sound {
|
||||
RingModulator.api.pointee.setFrequency.unsafelyUnwrapped(pointer, frequency)
|
||||
}
|
||||
|
||||
/// Modulates the modulation frequency.
|
||||
public var frequencyModulator: SignalValue? {
|
||||
get { SignalValue.wrap(RingModulator.api.pointee.getFrequencyModulator.unsafelyUnwrapped(pointer)) }
|
||||
set {
|
||||
|
||||
@@ -29,6 +29,7 @@ extension Sound {
|
||||
TwoPoleFilter.api.pointee.setFrequency.unsafelyUnwrapped(pointer, frequency)
|
||||
}
|
||||
|
||||
/// Modulates the filter's frequency.
|
||||
public var frequencyModulator: SignalValue? {
|
||||
get { SignalValue.wrap(TwoPoleFilter.api.pointee.getFrequencyModulator.unsafelyUnwrapped(pointer)) }
|
||||
set {
|
||||
@@ -46,6 +47,7 @@ extension Sound {
|
||||
TwoPoleFilter.api.pointee.setResonance.unsafelyUnwrapped(pointer, resonance)
|
||||
}
|
||||
|
||||
/// Modulates the filter's resonance.
|
||||
public var resonanceModulator: SignalValue? {
|
||||
get { SignalValue.wrap(TwoPoleFilter.api.pointee.getResonanceModulator.unsafelyUnwrapped(pointer)) }
|
||||
set {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Sound.TwoPoleFilter {
|
||||
/// The filter's response type.
|
||||
public enum Kind: UInt32, Sendable {
|
||||
case lowPass = 0
|
||||
case highPass = 1
|
||||
case bandPass = 2
|
||||
case notch = 3
|
||||
/// A parametric EQ filter.
|
||||
case peq = 4
|
||||
case lowShelf = 5
|
||||
case highShelf = 6
|
||||
|
||||
@@ -13,8 +13,11 @@ extension Sound {
|
||||
init(_ format: SoundFormat) { self = Format(rawValue: UInt32(format.rawValue)) ?? .mono16bit }
|
||||
var cValue: SoundFormat { SoundFormat(SoundFormat.RawValue(rawValue)) }
|
||||
|
||||
/// Whether the format has two channels.
|
||||
public var isStereo: Bool { rawValue & 1 != 0 }
|
||||
/// Whether samples are 16-bit (rather than 8-bit or ADPCM).
|
||||
public var is16bit: Bool { rawValue >= 2 && rawValue < 4 }
|
||||
/// The size of one sample frame, in bytes.
|
||||
public var bytesPerFrame: Int { Int(SoundFormat_bytesPerFrame(cValue)) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
extension Sound {
|
||||
/// The microphone used when recording.
|
||||
public enum MicSource: UInt32, Sendable {
|
||||
/// Use the headset microphone if one is connected, otherwise the
|
||||
/// built-in microphone.
|
||||
case autodetect = 0
|
||||
/// Always use the built-in microphone.
|
||||
case internalMic = 1
|
||||
/// Always use the headset microphone.
|
||||
case headset = 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ extension Sound {
|
||||
}
|
||||
}
|
||||
|
||||
/// Removes all events from the signal's timeline.
|
||||
public func clearEvents() {
|
||||
ControlSignal.api.pointee.clearEvents.unsafelyUnwrapped(pointer)
|
||||
}
|
||||
@@ -32,6 +33,7 @@ extension Sound {
|
||||
interpolate ? 1 : 0)
|
||||
}
|
||||
|
||||
/// Removes the event at `step`, if any.
|
||||
public func removeEvent(step: Int) {
|
||||
ControlSignal.api.pointee.removeEvent.unsafelyUnwrapped(pointer, Int32(step))
|
||||
}
|
||||
|
||||
@@ -22,18 +22,22 @@ extension Sound {
|
||||
}
|
||||
}
|
||||
|
||||
/// The attack time, in seconds.
|
||||
public func setAttack(_ attack: Float) {
|
||||
Envelope.api.pointee.setAttack.unsafelyUnwrapped(pointer, attack)
|
||||
}
|
||||
|
||||
/// The decay time, in seconds.
|
||||
public func setDecay(_ decay: Float) {
|
||||
Envelope.api.pointee.setDecay.unsafelyUnwrapped(pointer, decay)
|
||||
}
|
||||
|
||||
/// The sustain level, 0...1.
|
||||
public func setSustain(_ sustain: Float) {
|
||||
Envelope.api.pointee.setSustain.unsafelyUnwrapped(pointer, sustain)
|
||||
}
|
||||
|
||||
/// The release time, in seconds.
|
||||
public func setRelease(_ release: Float) {
|
||||
Envelope.api.pointee.setRelease.unsafelyUnwrapped(pointer, release)
|
||||
}
|
||||
@@ -66,6 +70,7 @@ extension Sound {
|
||||
Envelope.api.pointee.setRateScaling.unsafelyUnwrapped(pointer, scaling, start, end)
|
||||
}
|
||||
|
||||
/// The envelope's current value.
|
||||
public var value: Float {
|
||||
Envelope.api.pointee.getValue.unsafelyUnwrapped(pointer)
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ extension Sound {
|
||||
LFO.api.pointee.setRandomSeed.unsafelyUnwrapped(pointer, seed)
|
||||
}
|
||||
|
||||
/// The LFO's current value.
|
||||
public var value: Float {
|
||||
LFO.api.pointee.getValue.unsafelyUnwrapped(pointer)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
internal import CPlaydate
|
||||
|
||||
/// The cached `playdate->sound` C API table.
|
||||
var snd: UnsafePointer<playdate_sound> { Playdate.soundAPI.unsafelyUnwrapped }
|
||||
|
||||
/// The sound API: channels, players, synths, sequences, and effects.
|
||||
|
||||
@@ -52,10 +52,12 @@ extension Sound {
|
||||
FilePlayer.api.pointee.play.unsafelyUnwrapped(pointer, Int32(repeatCount)) != 0
|
||||
}
|
||||
|
||||
/// Pauses playback.
|
||||
public func pause() {
|
||||
FilePlayer.api.pointee.pause.unsafelyUnwrapped(pointer)
|
||||
}
|
||||
|
||||
/// Stops playback.
|
||||
public func stop() {
|
||||
FilePlayer.api.pointee.stop.unsafelyUnwrapped(pointer)
|
||||
}
|
||||
|
||||
@@ -46,10 +46,12 @@ extension Sound {
|
||||
SamplePlayer.api.pointee.play.unsafelyUnwrapped(pointer, Int32(repeatCount), rate) != 0
|
||||
}
|
||||
|
||||
/// Stops playback.
|
||||
public func stop() {
|
||||
SamplePlayer.api.pointee.stop.unsafelyUnwrapped(pointer)
|
||||
}
|
||||
|
||||
/// Pauses or resumes playback.
|
||||
public func setPaused(_ paused: Bool) {
|
||||
SamplePlayer.api.pointee.setPaused.unsafelyUnwrapped(pointer, paused ? 1 : 0)
|
||||
}
|
||||
|
||||
@@ -72,10 +72,13 @@ extension Sound {
|
||||
Instrument.api.pointee.setPitchBend.unsafelyUnwrapped(pointer, bend)
|
||||
}
|
||||
|
||||
/// The range of `setPitchBend(_:)`, in half-steps.
|
||||
public func setPitchBendRange(halfSteps: Float) {
|
||||
Instrument.api.pointee.setPitchBendRange.unsafelyUnwrapped(pointer, halfSteps)
|
||||
}
|
||||
|
||||
/// Transposes played notes by `halfSteps` (fractional values
|
||||
/// allowed).
|
||||
public func setTranspose(halfSteps: Float) {
|
||||
Instrument.api.pointee.setTranspose.unsafelyUnwrapped(pointer, halfSteps)
|
||||
}
|
||||
@@ -85,20 +88,24 @@ extension Sound {
|
||||
Instrument.api.pointee.noteOff.unsafelyUnwrapped(pointer, note, when)
|
||||
}
|
||||
|
||||
/// Releases every playing voice at time `when` (0 = now).
|
||||
public func allNotesOff(when: UInt32 = 0) {
|
||||
Instrument.api.pointee.allNotesOff.unsafelyUnwrapped(pointer, when)
|
||||
}
|
||||
|
||||
/// Sets the volume of the left and right channels, 0...1.
|
||||
public func setVolume(left: Float, right: Float) {
|
||||
Instrument.api.pointee.setVolume.unsafelyUnwrapped(pointer, left, right)
|
||||
}
|
||||
|
||||
/// The volume of the left and right channels.
|
||||
public var volume: (left: Float, right: Float) {
|
||||
var left: Float = 0, right: Float = 0
|
||||
Instrument.api.pointee.getVolume.unsafelyUnwrapped(pointer, &left, &right)
|
||||
return (left, right)
|
||||
}
|
||||
|
||||
/// The number of voices currently playing.
|
||||
public var activeVoiceCount: Int {
|
||||
Int(Instrument.api.pointee.activeVoiceCount.unsafelyUnwrapped(pointer))
|
||||
}
|
||||
|
||||
@@ -47,10 +47,12 @@ extension Sound {
|
||||
}
|
||||
}
|
||||
|
||||
/// Stops playback.
|
||||
public func stop() {
|
||||
Sequence.api.pointee.stop.unsafelyUnwrapped(pointer)
|
||||
}
|
||||
|
||||
/// Whether the sequence is playing.
|
||||
public var isPlaying: Bool {
|
||||
Sequence.api.pointee.isPlaying.unsafelyUnwrapped(pointer) != 0
|
||||
}
|
||||
|
||||
@@ -45,10 +45,12 @@ extension Sound {
|
||||
SequenceTrack.api.pointee.addNoteEvent.unsafelyUnwrapped(pointer, step, length, note, velocity)
|
||||
}
|
||||
|
||||
/// Removes the note at `step`, if any.
|
||||
public func removeNote(step: UInt32, note: MIDINote) {
|
||||
SequenceTrack.api.pointee.removeNoteEvent.unsafelyUnwrapped(pointer, step, note)
|
||||
}
|
||||
|
||||
/// Removes all notes from the track.
|
||||
public func clearNotes() {
|
||||
SequenceTrack.api.pointee.clearNotes.unsafelyUnwrapped(pointer)
|
||||
}
|
||||
@@ -94,6 +96,7 @@ extension Sound {
|
||||
return ControlSignal(pointer: signal, isOwned: false)
|
||||
}
|
||||
|
||||
/// Removes all control signal events from the track.
|
||||
public func clearControlEvents() {
|
||||
SequenceTrack.api.pointee.clearControlEvents.unsafelyUnwrapped(pointer)
|
||||
}
|
||||
@@ -103,10 +106,12 @@ extension Sound {
|
||||
Int(SequenceTrack.api.pointee.getPolyphony.unsafelyUnwrapped(pointer))
|
||||
}
|
||||
|
||||
/// The number of notes currently playing.
|
||||
public var activeVoiceCount: Int {
|
||||
Int(SequenceTrack.api.pointee.activeVoiceCount.unsafelyUnwrapped(pointer))
|
||||
}
|
||||
|
||||
/// Mutes or unmutes the track.
|
||||
public func setMuted(_ muted: Bool) {
|
||||
SequenceTrack.api.pointee.setMuted.unsafelyUnwrapped(pointer, muted ? 1 : 0)
|
||||
}
|
||||
|
||||
@@ -108,18 +108,22 @@ extension Sound {
|
||||
|
||||
// MARK: Envelope
|
||||
|
||||
/// The envelope's attack time, in seconds.
|
||||
public func setAttackTime(_ attack: Float) {
|
||||
Synth.api.pointee.setAttackTime.unsafelyUnwrapped(pointer, attack)
|
||||
}
|
||||
|
||||
/// The envelope's decay time, in seconds.
|
||||
public func setDecayTime(_ decay: Float) {
|
||||
Synth.api.pointee.setDecayTime.unsafelyUnwrapped(pointer, decay)
|
||||
}
|
||||
|
||||
/// The envelope's sustain level, 0...1.
|
||||
public func setSustainLevel(_ sustain: Float) {
|
||||
Synth.api.pointee.setSustainLevel.unsafelyUnwrapped(pointer, sustain)
|
||||
}
|
||||
|
||||
/// The envelope's release time, in seconds.
|
||||
public func setReleaseTime(_ release: Float) {
|
||||
Synth.api.pointee.setReleaseTime.unsafelyUnwrapped(pointer, release)
|
||||
}
|
||||
@@ -142,6 +146,7 @@ extension Sound {
|
||||
Synth.api.pointee.setTranspose.unsafelyUnwrapped(pointer, halfSteps)
|
||||
}
|
||||
|
||||
/// Modulates the synth's frequency.
|
||||
public var frequencyModulator: SignalValue? {
|
||||
get { SignalValue.wrap(Synth.api.pointee.getFrequencyModulator.unsafelyUnwrapped(pointer)) }
|
||||
set {
|
||||
@@ -150,6 +155,7 @@ extension Sound {
|
||||
}
|
||||
}
|
||||
|
||||
/// Modulates the synth's amplitude.
|
||||
public var amplitudeModulator: SignalValue? {
|
||||
get { SignalValue.wrap(Synth.api.pointee.getAmplitudeModulator.unsafelyUnwrapped(pointer)) }
|
||||
set {
|
||||
@@ -170,12 +176,14 @@ extension Sound {
|
||||
Synth.api.pointee.setParameter.unsafelyUnwrapped(pointer, Int32(parameter), value) != 0
|
||||
}
|
||||
|
||||
/// Modulates a generator parameter.
|
||||
public func setParameterModulator(_ parameter: Int, _ modulator: SignalValue?) {
|
||||
retain(modulator)
|
||||
Synth.api.pointee.setParameterModulator.unsafelyUnwrapped(pointer, Int32(parameter),
|
||||
modulator?.pointer)
|
||||
}
|
||||
|
||||
/// The modulator installed on a generator parameter, if any.
|
||||
public func parameterModulator(_ parameter: Int) -> SignalValue? {
|
||||
SignalValue.wrap(Synth.api.pointee.getParameterModulator.unsafelyUnwrapped(pointer, Int32(parameter)))
|
||||
}
|
||||
|
||||
@@ -8,8 +8,11 @@ extension Sound.Synth {
|
||||
case sine = 2
|
||||
case noise = 3
|
||||
case sawtooth = 4
|
||||
/// A Pocket Operator-style phase-distortion waveform.
|
||||
case poPhase = 5
|
||||
/// A Pocket Operator-style digital waveform.
|
||||
case poDigital = 6
|
||||
/// A Pocket Operator-style VOSIM (voice simulation) waveform.
|
||||
case poVosim = 7
|
||||
|
||||
var cValue: SoundWaveform { SoundWaveform(SoundWaveform.RawValue(rawValue)) }
|
||||
|
||||
Reference in New Issue
Block a user