Skip to content

Commit

Permalink
ADD SamplePlayer.setOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
ninovanhooff committed Mar 29, 2024
1 parent 8ac527c commit e38bcc7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/playdate/bindings/sound.nim
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ type PlaydateSoundSampleplayer {.importc: "const struct playdate_sound_samplepla
# setLoopCallback* {.importc: "setLoopCallback".}: proc (player: ptr SamplePlayer;
# callback: SndCallbackProc) {.cdecl.}
getOffset* {.importc: "getOffset".}: proc (player: SamplePlayerPtr): cfloat {.cdecl , raises: [].}
setOffset {.importc: "setOffset".}: proc (player: SamplePlayerPtr; offset: cfloat) {.
cdecl, raises: [].}
setPaused {.importc: "setPaused".}: proc (player: SamplePlayerPtr; flag: cint) {.
cdecl, raises: [].}
# type PlaydateSoundSampleplayer* = ptr PlaydateSoundSampleplayerRaw
Expand Down
5 changes: 5 additions & 0 deletions src/playdate/sound.nim
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ proc setVolume*(this: SamplePlayer, left: float32, right: float32) =
privateAccess(PlaydateSoundSampleplayer)
playdate.sound.sampleplayer.setVolume(this.resource, left.cfloat, right.cfloat)

proc `offset=`*(this: SamplePlayer, offset: float32) =
privateAccess(PlaydateSound)
privateAccess(PlaydateSoundSampleplayer)
playdate.sound.sampleplayer.setOffset(this.resource, offset.cfloat)

proc offset*(this: SamplePlayer): float32 =
privateAccess(PlaydateSound)
privateAccess(PlaydateSoundSamplePlayer)
Expand Down

0 comments on commit e38bcc7

Please sign in to comment.