Ejemplo n.º 1
0
    def __init__(self, folder, piece_name):
        """Initialize the Score.

        :param folder: The directory in which the score should be initialized.
            The name of the Score is derived from the name of this directory.

        :param piece_name: Name of the Piece to which the Score belongs.
        """
        super(Score, self).__init__()

        if not os.path.isdir(folder):
            raise MSMDDBError('Score initialized with'
                              ' non-existent directory: {0}'.format(folder))
        self.folder = folder
        name = path2name(folder)
        self.name = name
        self.piece_name = piece_name

        self.pdf_file = self.discover_pdf()

        self.metadata = self.load_metadata()

        # Shortcut to standard views: img and coords
        self.img_dir = os.path.join(self.folder, 'img')
        self.coords_dir = os.path.join(self.folder, 'coords')
        self._ensure_directory_structure()

        self.views = self.collect_views()
Ejemplo n.º 2
0
    def __init__(self,
                 folder,
                 piece_name,
                 audio_fmt='flac',
                 require_audio=True,
                 require_midi=True):
        """Initialize Performance.

        :param audio_fmt: The audio of the performance is expected
            to have this format.
        """
        super(Performance, self).__init__()

        if not os.path.isdir(folder):
            raise MSMDDBError('Performance initialized with'
                              ' non-existent directory: {0}'
                              ''.format(folder))
        self.folder = folder
        name = path2name(folder)
        self.name = name
        self.piece_name = piece_name

        self.metadata = self.load_metadata()

        if audio_fmt.startswith('.'):
            audio_fmt = audio_fmt[1:]
        self.audio_fmt = audio_fmt

        self.audio = self.discover_audio(required=require_audio)
        self.audio_name = None
        if self.audio:
            self.audio_name = path2name(self.audio)

        self.midi = self.discover_midi(required=require_midi)

        self.features_dir = os.path.join(self.folder, 'features')
        self._ensure_features_dir()

        self.features = self.collect_features()
Ejemplo n.º 3
0
 def update(self):
     self.audio = self.discover_audio()
     self.audio_name = path2name(self.audio)
     self.midi = self.discover_midi()
     self.update_features()