Skip to content

Commit

Permalink
Add another misaligned audio hack
Browse files Browse the repository at this point in the history
Part of #10
  • Loading branch information
mtolly committed Feb 24, 2018
1 parent acd1d7b commit 634ae38
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/Sound/Jammit/Export.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Control.Monad (forM, forever)
import Data.Char (toLower)
import Data.Int (Int16, Int32)
import Data.List (isInfixOf, sort, isPrefixOf)
import Data.Maybe (catMaybes)
import Data.Maybe (catMaybes, fromMaybe)

import System.Directory (getDirectoryContents)
import System.FilePath ((</>), splitFileName, takeFileName)
Expand Down Expand Up @@ -81,15 +81,18 @@ getSheetParts lib = do
_ -> []

audioSource :: (MonadResource m) => FilePath -> IO (A.AudioSource m Int16)
audioSource fp = if takeFileName fp `elem` [tttDrums, tttDrumsBack]
then fmap (A.padStart $ A.Frames 38) $ readIMA fp
else readIMA fp
-- I've only found one audio file where the instruments are not aligned:
-- the drums and drums backing track for Take the Time are 38 samples ahead
-- of the other instruments. So as a hack, we pad the front of them by 38
-- samples to line things up.
where tttDrums = "793EAAE0-6761-44D7-9A9A-1FB451A2A438_jcfx"
tttDrumsBack = "37EE5AA5-4049-4CED-844A-D34F6B165F67_jcfx"
audioSource fp = let
-- These are hacks that make one instrument line up with the rest of a song.
timingHacks =
-- Take the Time (Dream Theater)
[ ("793EAAE0-6761-44D7-9A9A-1FB451A2A438_jcfx", A.padStart $ A.Frames 38) -- Drums
, ("37EE5AA5-4049-4CED-844A-D34F6B165F67_jcfx", A.padStart $ A.Frames 38) -- Drums backing
-- Rockstar (Nickelback)
, ("FB9A99DB-C70C-47CB-B63F-A78F11AC05D5_jcfx", A.dropStart $ A.Frames 11) -- Vocal
, ("7998F9B7-8A97-49D0-A3A9-C001FDD1C1DC_jcfx", A.dropStart $ A.Frames 11) -- B Vocals
, ("C4C543A0-EB1F-4628-A401-C5860D675FA4_jcfx", A.dropStart $ A.Frames 11) -- Vocal backing
]
in fromMaybe id (lookup (takeFileName fp) timingHacks) <$> readIMA fp

runAudio
:: [FilePath] -- ^ AIFCs to mix in normally
Expand Down

0 comments on commit 634ae38

Please sign in to comment.