gsapi.GSIO module¶
-
gsapi.GSIO.
fromMidi
(midiPath, NoteToTagsMap='pitchNames', tracksToGet=None, TagsFromTrackNameEvents=False, filterOutNotMapped=True, checkForOverlapped=False)[source]¶ Loads a midi file as a pattern.
Parameters: - midiPath – midi filePath
- NoteToTagsMap –
dictionary converting pitches to tags if only interested in pitch, you can set this to “pitchNames”, or optionally set the value to the list of string for pitches from C noteMapping maps classes to a list of possible mappings, a mapping can be either:
- a tuple of (note, channel):
- if one of those doesnt matter it canbe replaced by ‘*’ character
- an integer:
- if only pitch matters
for simplicity, one can pass only one integer (i.e not a list) for one to one mappings if midi track contains the name of one element of mapping, it’ll be choosed without anyother consideration
- TagsFromTrackNameEvents – use only track names to resolve mapping, useful for midi containing named tracks
- filterOutNotMapped – if set to true, don’t add event not represented by NoteToTagsMap
- tracksToGet – if not empty, specifies Midi tracks wanted either by name or index
- checkForOverlapped – if true will check that two consecutiveEvents with exactly same MidiNote are not overlapping
-
gsapi.GSIO.
fromMidiCollection
(midiGlobPath, NoteToTagsMap=['C', 'C#', 'D', 'Eb', 'E', 'F', 'F#', 'G', 'Ab', 'A', 'Bb', 'B'], tracksToGet=None, TagsFromTrackNameEvents=False, filterOutNotMapped=True, desiredLength=0)[source]¶ Loads a midi collection.
Parameters: - midiGlobPath – midi filePath in glob naming convention (e.g. ‘/folder/To/Crawl/*.mid’)
- NoteToTagsMap –
- tracksToGet –
- TagsFromTrackNameEvents –
- filterOutNotMapped –
- desiredLength – optionally cut patterns in equal length
Returns: a list of GSPattern build from Midi folder
-
gsapi.GSIO.
fromJSONFile
(filePath, conserveTuple=False)[source]¶ Load a pattern to internal JSON Format.
Parameters: filePath – filePath where to load it
-
gsapi.GSIO.
toJSONFile
(pattern, folderPath, useTagIndexing=True, nameSuffix=None, conserveTuple=False)[source]¶ Save a pattern to internal JSON Format.
Parameters: - pattern – a GSPattern
- folderPath – folder where to save it, fileName will be pattern.name+nameSuffix+”.json”
- nameSuffix – string to append to name of the file
- useTagIndexing – if true, tags are stored as indexes from a list of all tags (reduce size of json files)
- ConserveTuple – useful if some tags can be tuple but much slower
-
gsapi.GSIO.
fromPickleFile
(filePath)[source]¶ Load a pattern from pickle Format.
Parameters: filePath – filePath where to load it