Skip to content

Commit 076a4c0

Browse files
init
0 parents  commit 076a4c0

16 files changed

+1305
-0
lines changed

.paket/Paket.Restore.targets

Lines changed: 442 additions & 0 deletions
Large diffs are not rendered by default.

.paket/paket.bootstrapper.exe

62.8 KB
Binary file not shown.

.paket/paket.exe

8.26 MB
Binary file not shown.

.paket/paket.targets

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<PropertyGroup>
5+
<!-- Enable the restore command to run before builds -->
6+
<RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages>
7+
<PaketToolsPath>$(MSBuildThisFileDirectory)</PaketToolsPath>
8+
<PaketRootPath>$(MSBuildThisFileDirectory)..\</PaketRootPath>
9+
<PaketLockFilePath>$(PaketRootPath)paket.lock</PaketLockFilePath>
10+
<PaketRestoreCacheFile>$(PaketRootPath)paket-files\paket.restore.cached</PaketRestoreCacheFile>
11+
<MonoPath Condition="'$(MonoPath)' == '' And Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
12+
<MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath>
13+
</PropertyGroup>
14+
15+
<PropertyGroup>
16+
<!-- Paket command -->
17+
<PaketExePath Condition=" '$(PaketExePath)' == '' AND Exists('$(PaketRootPath)paket.exe')">$(PaketRootPath)paket.exe</PaketExePath>
18+
<PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)paket.exe</PaketExePath>
19+
<PaketCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand>
20+
<PaketCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</PaketCommand>
21+
</PropertyGroup>
22+
23+
<Choose> <!-- MyProject.fsproj.paket.references has the highest precedence -->
24+
<When Condition="Exists('$(MSBuildProjectFullPath).paket.references')">
25+
<PropertyGroup>
26+
<PaketReferences>$(MSBuildProjectFullPath).paket.references</PaketReferences>
27+
</PropertyGroup>
28+
</When> <!-- MyProject.paket.references -->
29+
<When Condition="Exists('$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references')">
30+
<PropertyGroup>
31+
<PaketReferences>$(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references</PaketReferences>
32+
</PropertyGroup>
33+
</When> <!-- paket.references -->
34+
<When Condition="Exists('$(MSBuildProjectDirectory)\paket.references')">
35+
<PropertyGroup>
36+
<PaketReferences>$(MSBuildProjectDirectory)\paket.references</PaketReferences>
37+
</PropertyGroup>
38+
</When> <!-- Set to empty if a reference file isn't found matching one of the 3 format options -->
39+
<Otherwise>
40+
<PropertyGroup>
41+
<PaketReferences></PaketReferences>
42+
</PropertyGroup>
43+
</Otherwise>
44+
</Choose>
45+
46+
<PropertyGroup>
47+
<!-- Commands -->
48+
<RestoreCommand>$(PaketCommand) restore --references-file "$(PaketReferences)"</RestoreCommand>
49+
<!-- We need to ensure packages are restored prior to assembly resolve -->
50+
<BuildDependsOn Condition="$(RestorePackages) == 'true'">RestorePackages; $(BuildDependsOn);</BuildDependsOn>
51+
</PropertyGroup>
52+
<Target Name="RestorePackages">
53+
<PropertyGroup>
54+
<PaketRestoreRequired>true</PaketRestoreRequired>
55+
</PropertyGroup>
56+
57+
<PropertyGroup Condition="Exists('$(PaketRestoreCacheFile)') ">
58+
<PaketRestoreCachedHash>$([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))</PaketRestoreCachedHash>
59+
<PaketRestoreLockFileHash>$([System.IO.File]::ReadAllText('$(PaketLockFilePath)'))</PaketRestoreLockFileHash>
60+
<PaketRestoreRequired>true</PaketRestoreRequired>
61+
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '$(PaketRestoreCachedHash)' ">false</PaketRestoreRequired>
62+
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired>
63+
</PropertyGroup>
64+
65+
<Exec Command="$(RestoreCommand)"
66+
IgnoreStandardErrorWarningFormat="true"
67+
WorkingDirectory="$(PaketRootPath)"
68+
ContinueOnError="false"
69+
Condition=" '$(PaketRestoreRequired)' == 'true' AND Exists('$(PaketReferences)') AND '$(PaketReferences)' != '' "
70+
/>
71+
</Target>
72+
</Project>

CHANGES

Whitespace-only changes.

LICENSE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright (c) 2008 Stephen Peter Tetley
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions
7+
are met:
8+
9+
1. Redistributions of source code must retain the above copyright
10+
notice, this list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright
13+
notice, this list of conditions and the following disclaimer in the
14+
documentation and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the author nor the names of his contributors
17+
may be used to endorse or promote products derived from this software
18+
without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
21+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
24+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28+
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30+
POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
zmidi-core-fs
2+
=============
3+
4+
Minimalist F# library to read and write MIDI files based on original Haskell library http://hackage.haskell.org/package/zmidi-core.

demo/MidiCopy.hs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{-# OPTIONS -Wall #-}
2+
3+
-- Read a MIDI file, build a syntax tree and encode it again.
4+
-- Are the files the same?
5+
6+
7+
module Main where
8+
9+
import ZMidi.Core
10+
11+
import System.Environment
12+
13+
14+
main :: IO ()
15+
main = do
16+
args <- getArgs
17+
case args of
18+
[path] -> process path
19+
_ -> mapM_ putStrLn $
20+
[ "Usage: MidiCopy <filename>"
21+
, "--"
22+
, "Read the file, building a syntax tree, generate binary output"
23+
, "from the syntax tree."
24+
, ""
25+
, "Tests that read and write are isomorphic."
26+
, ""
27+
]
28+
29+
30+
process :: FilePath -> IO ()
31+
process filename = do
32+
ans <- readMidi filename
33+
case ans of
34+
Left err -> print err
35+
Right mfile -> let outfile = filename ++ ".001"
36+
in do { mapM_ putStrLn $ printMidiHeader mfile
37+
; putStrLn ""
38+
; writeMidi outfile mfile
39+
; putStrLn $ "Wrote file: " ++ outfile
40+
}
41+
42+

demo/MidiPrint.hs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{-# OPTIONS -Wall #-}
2+
3+
-- Dump the contents of a MIDI file
4+
5+
-- Note - GHC (Windows at least) appears to throw an error if
6+
-- the copyright symbol is used a Text meta-event.
7+
8+
9+
10+
module Main where
11+
12+
import ZMidi.Core
13+
14+
import System.Console.GetOpt
15+
import System.Environment
16+
import System.Exit
17+
18+
19+
20+
header :: String
21+
header = unlines $
22+
[ "Usage: MidiPrint --format=... <filename>"
23+
, ""
24+
, "Formats are 'csv', 'ascii', 'original'."
25+
]
26+
27+
help_message :: String
28+
help_message = unlines $
29+
[ "Decode binary MIDI files." ]
30+
31+
32+
data Flag = Usage
33+
| OutFormat String
34+
deriving (Eq, Show)
35+
36+
37+
options :: [OptDescr Flag]
38+
options =
39+
[ Option ['h'] ["help"] (NoArg Usage) help_message
40+
, Option ['f'] ["format"] (ReqArg OutFormat "original") "output format"
41+
]
42+
43+
main :: IO ()
44+
main = do
45+
args <- getArgs
46+
let (opts, nonopts, errs) = getOpt Permute options args
47+
main2 opts nonopts errs
48+
49+
50+
main2 :: [Flag] -> [FilePath] -> [String] -> IO ()
51+
main2 opts _ _
52+
| Usage `elem` opts = midiPrintExit $ usageInfo header options
53+
main2 [OutFormat ss] [infile] [] = process ss infile
54+
main2 [] [infile] [] = process "original" infile
55+
main2 _ _ errs =
56+
midiPrintExitFail 1 (concat errs ++ usageInfo header options)
57+
58+
59+
midiPrintExit :: String -> IO ()
60+
midiPrintExit s = putStrLn s >> exitWith ExitSuccess
61+
62+
midiPrintExitFail :: Int -> String -> IO ()
63+
midiPrintExitFail i s = putStrLn s >> exitWith (ExitFailure i)
64+
65+
66+
process :: String -> FilePath -> IO ()
67+
process fmt filename = do
68+
ans <- readMidi filename
69+
case ans of
70+
Left (ParseErr n msg) ->
71+
midiPrintExitFail 1 $ "Parse failure at " ++ show n ++ ": " ++ msg
72+
Right m -> outputMidi fmt m
73+
74+
75+
outputMidi :: String -> (MidiFile -> IO ())
76+
outputMidi "csv" = putCsv
77+
outputMidi "ascii" = putAscii
78+
outputMidi "original" = putMidi
79+
outputMidi _ = const $ putStrLn "Unrecognized output format."

demo/MidiTune.hs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{-# OPTIONS -Wall #-}
2+
3+
--
4+
-- Write a MIDI \"tune\".
5+
--
6+
-- The MIDI AST should be considered too low level to work with
7+
-- directly...
8+
--
9+
10+
module Main where
11+
12+
import ZMidi.Core
13+
14+
import System.Directory
15+
16+
17+
18+
main :: IO ()
19+
main = do
20+
createDirectoryIfMissing True "./out/"
21+
writeMidi "./out/midi_tune.mid" midi_tune01
22+
putStrLn "Wrote file: ./out/midi_tune.mid"
23+
24+
25+
midi_tune01 :: MidiFile
26+
midi_tune01 = MidiFile
27+
{ mf_header = MidiHeader { hdr_format = MF1
28+
, num_tracks = 2
29+
, time_division = TPB 480
30+
}
31+
, mf_tracks = [ meta_track, sound_track ]
32+
}
33+
where
34+
meta_track = MidiTrack [ (0, MetaEvent $ TextEvent SEQUENCE_NAME "Track 0")
35+
, (0, MetaEvent $ EndOfTrack)
36+
]
37+
38+
sound_track = MidiTrack [ (0, MetaEvent $ TextEvent SEQUENCE_NAME "Track 1")
39+
, (0, MetaEvent $ SetTempo 500000)
40+
, (0, VoiceEvent RS_OFF $ NoteOn 0 60 127)
41+
, (480, VoiceEvent RS_OFF $ NoteOff 0 60 15)
42+
, (0, VoiceEvent RS_OFF $ NoteOn 0 62 127)
43+
, (480, VoiceEvent RS_OFF $ NoteOff 0 62 15)
44+
, (0, VoiceEvent RS_OFF $ NoteOn 0 64 127)
45+
, (480, VoiceEvent RS_OFF $ NoteOff 0 64 15)
46+
, (0, VoiceEvent RS_OFF $ NoteOn 0 66 127)
47+
, (480, VoiceEvent RS_OFF $ NoteOff 0 66 15)
48+
, (0, MetaEvent $ EndOfTrack)
49+
]
50+
51+

0 commit comments

Comments
 (0)