Skip to content

Commit

Permalink
Merge pull request #23 from wontem/fix-tone-duration
Browse files Browse the repository at this point in the history
align duration with wasm4 specification
  • Loading branch information
lukewilliamboswell committed Jan 29, 2024
2 parents 8246a9e + 2278c4b commit aa35e07
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/basic.roc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ init =
colors <- W4.getDrawColors |> Task.await
{} <- Inspect.toStr colors |> W4.trace |> Task.await

{} <- W4.tone { startFreq: 262, endFreq: 523, channel: Pulse1 Quarter, sustainTime: 60, releaseTime: 30 } |> Task.await
{} <- W4.tone { startFreq: 262, endFreq: 523, channel: Pulse1 Quarter, sustainTime: 60, decayTime: 30 } |> Task.await

Task.ok {}

Expand Down
6 changes: 3 additions & 3 deletions examples/rocci-bird.roc
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ flapTone = {
channel: Pulse1 Quarter,
attackTime: 10,
sustainTime: 0,
decayTime: 3,
releaseTime: 5,
decayTime: 5,
releaseTime: 3,
volume: 10,
peakVolume: 20,
}
Expand All @@ -533,7 +533,7 @@ deathTone = {
endFreq: 40,
channel: Noise,
sustainTime: 20,
releaseTime: 40,
decayTime: 40,
}

# ===== Drawing and Color =================================
Expand Down
4 changes: 2 additions & 2 deletions platform/W4.roc
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,8 @@ tone = \{ startFreq ? 0, endFreq ? 0, channel ? Pulse1 Eighth, pan ? Center, sus
duration =
Num.toU32 attackTime
|> Num.shiftLeftBy 24
|> Num.bitwiseOr (Num.toU32 releaseTime |> Num.shiftLeftBy 16)
|> Num.bitwiseOr (Num.toU32 decayTime |> Num.shiftLeftBy 8)
|> Num.bitwiseOr (Num.toU32 decayTime |> Num.shiftLeftBy 16)
|> Num.bitwiseOr (Num.toU32 releaseTime |> Num.shiftLeftBy 8)
|> Num.bitwiseOr (Num.toU32 sustainTime)

volumeBits =
Expand Down

0 comments on commit aa35e07

Please sign in to comment.