| Copyright | (c) Hans Hoglund 2012-2014 | 
|---|---|
| License | BSD-style | 
| Maintainer | hans@hanshoglund.se | 
| Stability | experimental | 
| Portability | non-portable (TF,GNTD) | 
| Safe Haskell | None | 
| Language | Haskell2010 | 
Music.Score.Export.Backend
Description
- type HasOrdPart a = (HasPart' a, Ord (Part a))
- type HasDynamic3 a a' a'' = (HasDynamic' a, HasDynamic' a'', HasDynamic a a', HasDynamic a' a'', HasDynamic a a'')
- type HasDynamicNotation a b c = (HasDynamic3 a b c, Dynamic b ~ Ctxt (Dynamic a), Dynamic c ~ DynamicNotation, Real (Dynamic a), Part (SetDynamic (Dynamic a) a) ~ Part (SetDynamic DynamicNotation b))
- type HasArticulation3 c d e = (HasArticulation' c, HasArticulation c d, HasArticulation d e, HasArticulation c e)
- type HasArticulationNotation a b c = (HasArticulation3 a b c, Articulation b ~ Ctxt (Articulation a), Articulation c ~ ArticulationNotation, Articulation a ~ (Average Double, Average Double))
- class Functor (BackendScore b) => HasBackend b where- type BackendMusic b :: *
- type BackendNote b :: *
- type BackendScore b :: * -> *
- type BackendContext b :: * -> *
- finalizeExport :: b -> BackendScore b (BackendNote b) -> BackendMusic b
 
- class HasBackend b => HasBackendScore b s where- type BackendScoreEvent b s :: *
- exportScore :: b -> s -> BackendScore b (BackendContext b (BackendScoreEvent b s))
 
- class HasBackend b => HasBackendNote b a where- exportNote :: b -> BackendContext b a -> BackendNote b
- exportChord :: b -> BackendContext b [a] -> BackendNote b
 
- export :: (HasBackendScore b s, HasBackendNote b (BackendScoreEvent b s)) => b -> s -> BackendMusic b
Documentation
type HasOrdPart a = (HasPart' a, Ord (Part a)) Source
type HasDynamic3 a a' a'' = (HasDynamic' a, HasDynamic' a'', HasDynamic a a', HasDynamic a' a'', HasDynamic a a'') Source
type HasDynamicNotation a b c = (HasDynamic3 a b c, Dynamic b ~ Ctxt (Dynamic a), Dynamic c ~ DynamicNotation, Real (Dynamic a), Part (SetDynamic (Dynamic a) a) ~ Part (SetDynamic DynamicNotation b)) Source
type HasArticulation3 c d e = (HasArticulation' c, HasArticulation c d, HasArticulation d e, HasArticulation c e) Source
type HasArticulationNotation a b c = (HasArticulation3 a b c, Articulation b ~ Ctxt (Articulation a), Articulation c ~ ArticulationNotation, Articulation a ~ (Average Double, Average Double)) Source
class Functor (BackendScore b) => HasBackend b where Source
This class defines types and functions for exporting music. It provides the
 primitive types and methods used to implement export.
The backend type b is just a type level tag to identify a specific backend.
 It is typically defined as an empty data declaration.
The actual conversion is handled by the subclasses HasBackendScore and
 HasBackendNote, which converts the time structure, and the contained music
 respectively. Thus structure and content are handled separately.
It is often necessary to alter the events based on their surrounding context: for
 examples the beginning and end of spanners and beams depend on surrounding notes.
 The BackendContext type allow HasBackendScore instances to provide context for
 HasBackendNote instances.
@ data NoteList
instance HasBackend NoteList where type BackendScore NoteList = [] type BackendContext NoteList = Identity type BackendNote NoteList = [(Sum Int, Int)] type BackendMusic NoteList = [(Sum Int, Int)] finalizeExport _ = concat
instance HasBackendScore NoteList [a] a where exportScore _ = fmap Identity
instance HasBackendNote NoteList a => HasBackendNote NoteList [a] where exportNote b ps = mconcat $ map (exportNote b) $ sequenceA ps
instance HasBackendNote NoteList Int where exportNote _ (Identity p) = [(mempty ,p)]
instance HasBackendNote NoteList a => HasBackendNote NoteList (DynamicT (Sum Int) a) where exportNote b (Identity (DynamicT (d,ps))) = set (mapped._1) d $ exportNote b (Identity ps) -- @
Associated Types
type BackendMusic b :: * Source
External music representation
type BackendNote b :: * Source
Notes, chords and rests, with output handled by HasBackendNote
type BackendScore b :: * -> * Source
Score, voice and time structure, with output handled by HasBackendScore
type BackendContext b :: * -> * Source
This type may be used to pass context from exportScore to exportNote.
   If the note export is not context-sensitive, Identity can be used.
Methods
finalizeExport :: b -> BackendScore b (BackendNote b) -> BackendMusic b Source
class HasBackend b => HasBackendScore b s where Source
A class for musical container types with an external representation.
The first type parameter is simply a token representing the external format,
 and the second parameter is the type being represented. In a sense, the first
 parameter saves us from defining a separate class for each external representation,
 so rather than having HasMidiScore, HasMusicXmlScore and so on, we have 
 HasBackendScore Midi, HasBackendScore MusicXml and so on.
Associated Types
type BackendScoreEvent b s :: * Source
Type of events in this score type. This is generally just the parameterized type in a container, so we have
BackendScoreEvent (Score a) ~ a BackendScoreEvent (Voice a) ~ a
and so on.
It is defined as a type function so that instances can put constraints on the saturated type, rather than being parametric over all note types.
Methods
exportScore :: b -> s -> BackendScore b (BackendContext b (BackendScoreEvent b s)) Source
Instances
| HasBackendScore NoteList [a] | |
| HasBackendScore NoteList (Score a) | |
| (HasPart' a, HasMidiProgram (Part a)) => HasBackendScore Midi (Voice a) | |
| (HasPart' a, Ord (Part a), HasMidiProgram (Part a)) => HasBackendScore Midi (Score a) | |
| HasBackendScore SuperCollider (Voice (Maybe a)) | |
| (HasPart' a, Ord (Part a)) => HasBackendScore SuperCollider (Score a) | |
| (HasDynamicNotation a b c, HasArticulationNotation c d e, (~) * (Part e) (Part c), HasOrdPart a, Transformable a, Semigroup a, Tiable e, HasOrdPart c, Show (Part c), HasLilypondInstrument (Part c), Satisfied) => HasBackendScore Lilypond (Score a) | |
| (HasDynamicNotation a b c, HasOrdPart a, Transformable a, Semigroup a, HasOrdPart c, Tiable c, Show (Part a), HasMusicXmlInstrument (Part a)) => HasBackendScore MusicXml (Score a) | 
class HasBackend b => HasBackendNote b a where Source
A class for musical event types with an external representation.
The first type parameter is simply a token representing the external format,
 and the second parameter is the type being represented. In a sense, the first
 parameter saves us from defining a separate class for each external representation,
 so rather than having HasMidiNote, HasMusicXmlNote and so on, we have 
 HasBackendNote Midi, HasBackendNote MusicXml and so on.
Minimal complete definition
Methods
exportNote :: b -> BackendContext b a -> BackendNote b Source
exportChord :: b -> BackendContext b [a] -> BackendNote b Source
Instances
export :: (HasBackendScore b s, HasBackendNote b (BackendScoreEvent b s)) => b -> s -> BackendMusic b Source
This is the primitive music export function.
Backend developers are encouraged to provide wrappers on the form toX, writeX etc.