Skip to content

Commit

Permalink
Correct last commit
Browse files Browse the repository at this point in the history
(We needed to add the offset of 12 to shift the octave in the right direction rather than to subtract it!)
  • Loading branch information
newlandsvalley committed Oct 27, 2017
1 parent aeec081 commit 5c3f1f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Audio/SoundFont/Gleitz.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Audio.SoundFont.Gleitz (
) where


import Prelude (class Show, (<>), ($), (+), (-), (*), map, negate, show)
import Prelude (class Show, (<>), ($), (+), (*), map, negate, show)
import Data.String.Regex as Regex
import Data.String.Regex.Flags (noFlags)
import Data.String (toUpper)
Expand Down Expand Up @@ -95,7 +95,7 @@ midiPitch1 s =
-- | The MIDI standard does not standardise on a particular middle C
toMidiPitch :: Int -> Int -> Int -> Int
toMidiPitch octave pitch accidental =
(12 * octave) + pitch + accidental - 12
(12 * octave) + pitch + accidental + 12

lookupPitch :: Pitch -> Maybe Int
lookupPitch p =
Expand Down
10 changes: 5 additions & 5 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ gleitzSuite :: forall t. Free (TestF t) Unit
gleitzSuite =
suite "gleitz" do
test "midi pitch C4" do
Assert.equal 36 (midiPitch "C4")
Assert.equal 60 (midiPitch "C4")
test "midi pitch Bb1" do
Assert.equal 10 (midiPitch "Bb1")
Assert.equal 34 (midiPitch "Bb1")
test "midi pitch A#1" do
Assert.equal 10 (midiPitch "A#1")
Assert.equal 34 (midiPitch "A#1")
test "midi pitch A4" do
Assert.equal 45 (midiPitch "A4")
Assert.equal 69 (midiPitch "A4")
test "midi pitch C8" do
Assert.equal 84 (midiPitch "C8")
Assert.equal 108 (midiPitch "C8")

main :: forall t.
Eff
Expand Down

0 comments on commit 5c3f1f1

Please sign in to comment.