Ejemplo n.º 1
0
    def _makePdf(cls, processingPhase, targetFileNamePrefix, voiceNameList):
        """Processes lilypond file and generates extract or score PDF
           file."""

        Logging.trace(">>: targetFilePrefix = %r, voiceNameList=%r",
                      targetFileNamePrefix, voiceNameList)

        configData = cls._configData
        tempLilypondFilePath = configData.tempLilypondFilePath
        lilypondFile = LilypondFile(tempLilypondFilePath)
        lilypondFile.generate(
            configData.includeFilePath, configData.lilypondVersion,
            processingPhase, voiceNameList, configData.title,
            configData.songComposerText, configData.voiceNameToChordsMap,
            configData.voiceNameToLyricsMap,
            configData.voiceNameToScoreNameMap, configData.measureToTempoMap,
            configData.phaseAndVoiceNameToClefMap,
            configData.phaseAndVoiceNameToStaffListMap)
        cls._processLilypond(tempLilypondFilePath, targetFileNamePrefix)
        OperatingSystem.moveFile(targetFileNamePrefix + ".pdf",
                                 configData.targetDirectoryPath)
        OperatingSystem.removeFile(tempLilypondFilePath,
                                   configData.intermediateFilesAreKept)

        Logging.trace("<<")
Ejemplo n.º 2
0
    def processMidi(cls):
        """Generates midi file from lilypond file."""

        Logging.trace(">>")

        configData = cls._configData
        intermediateFilesAreKept = configData.intermediateFilesAreKept
        tempLilypondFilePath = configData.tempLilypondFilePath
        lilypondFile = LilypondFile(tempLilypondFilePath)
        lilypondFile.generate(
            configData.includeFilePath, configData.lilypondVersion, "midi",
            configData.midiVoiceNameList, configData.title,
            configData.songComposerText, configData.voiceNameToChordsMap,
            configData.voiceNameToLyricsMap,
            configData.voiceNameToScoreNameMap, configData.measureToTempoMap,
            configData.phaseAndVoiceNameToClefMap,
            configData.phaseAndVoiceNameToStaffListMap)

        tempMidiFileNamePrefix = (configData.intermediateFileDirectoryPath +
                                  cls._pathSeparator +
                                  configData.fileNamePrefix + "-temp")
        tempMidiFileName = tempMidiFileNamePrefix + ".mid"
        targetMidiFileName = (cls._midiFileNameTemplate %
                              configData.fileNamePrefix)

        cls._processLilypond(tempLilypondFilePath, tempMidiFileNamePrefix)

        # postprocess MIDI file
        OperatingSystem.showMessageOnConsole("== adapting MIDI into " +
                                             targetMidiFileName)
        trackToSettingsMap = cls._calculateTrackToSettingsMap()

        midiTransformer = MidiTransformer(tempMidiFileName,
                                          intermediateFilesAreKept)
        midiTransformer.addMissingTrackNames()
        midiTransformer.humanizeTracks(
            configData.countInMeasureCount,
            configData.measureToHumanizationStyleNameMap)
        midiTransformer.positionInstruments(trackToSettingsMap)
        midiTransformer.addProcessingDateToTracks(trackToSettingsMap.keys())
        midiTransformer.save(targetMidiFileName)

        OperatingSystem.moveFile(targetMidiFileName,
                                 configData.targetDirectoryPath)
        OperatingSystem.removeFile(tempMidiFileName, intermediateFilesAreKept)
        OperatingSystem.removeFile(tempLilypondFilePath,
                                   intermediateFilesAreKept)

        Logging.trace("<<")