コード例 #1
0
ファイル: bach.py プロジェクト: eivindlysne/bachkov
def init_settings():
    settings = environment.UserSettings()
    environment.UserSettings()
    try:
        settings.create()
    except environment.UserSettingsException:
        pass
    settings['musicxmlPath'] = '/usr/bin/musescore'
    settings['directoryScratch'] = '/home/eivind/Repositories/bachkov/tmp'
    return settings
コード例 #2
0
    def manualCoreCorpusPath(self):
        r'''
        Set music21's core corpus to a directory, and save that information in
        the user settings.

        This is specifically for use with "no corpus" music21 packages, where
        the core corpus was not included with the rest of the package
        functionality, and had to be installed separately.

        Set it to a directory:

        >>> coreCorpus = corpus.corpora.CoreCorpus()
        >>> #_DOCS_SHOW coreCorpus.manualCoreCorpusPath = '~/Desktop'

        Unset it:

        >>> #_DOCS_SHOW coreCorpus.manualCoreCorpusPath = None
        >>> #_DOCS_SHOW coreCorpus.manualCoreCorpusPath is None
        >>> True  #_DOCS_HIDE
        True

        '''
        userSettings = environment.UserSettings()
        if 'manualCoreCorpusPath' in userSettings.keys():
            return userSettings['manualCoreCorpusPath']
        return None
コード例 #3
0
 def existsInSettings(self):
     r'''
     True if this local corpus has a corresponding entry in music21's user
     settings, otherwise false.
     '''
     if self.name == 'local':
         return True
     userSettings = environment.UserSettings()
     return self.name in userSettings['localCorporaSettings']
コード例 #4
0
ファイル: manager.py プロジェクト: hemanthk92/CaseRoutingDemo
def listLocalCorporaNames():
    '''
    List the names of all user-defined local corpora.

    The entry for None refers to the default local corpus.
    '''
    userSettings = environment.UserSettings()
    result = [None]
    result.extend(userSettings['localCorporaSettings'].keys())
    return result
コード例 #5
0
ファイル: corpora.py プロジェクト: JuanuMusic/music21
 def manualCoreCorpusPath(self, expr): # pragma: no cover
     userSettings = environment.UserSettings()
     if expr is not None:
         path = common.cleanpath(expr)
         if not os.path.isdir(path) or not os.path.exists(path):
             raise CorpusException('path needs to be a path to an existing directory')
         userSettings['manualCoreCorpusPath'] = path
     else:
         userSettings['manualCoreCorpusPath'] = None
     environment.Environment().write()
コード例 #6
0
 def delete(self):
     r'''
     Delete a non-default local corpus from the user settings.
     '''
     if self.name is None or self.name == 'local':
         return
     elif not self.existsInSettings:
         return
     userSettings = environment.UserSettings()
     del (userSettings['localCorporaSettings'][self.name])
     environment.Environment().write()
コード例 #7
0
 def save(self):
     r'''
     Save the current list of directory paths in use by a given corpus in
     the user settings.
     '''
     userSettings = environment.UserSettings()
     if self.name == 'local':
         userSettings['localCorpusSettings'] = self.directoryPaths
     else:
         userSettings['localCorporaSettings'][self.name] = self.directoryPaths
     environment.Environment().write()
コード例 #8
0
    def exportWav(self, appendName='_mod'):
        fpIn = self.exportXML(appendName)
        fpDir = fpIn[0:len(fpIn) - 4]
        fpOut = fpDir + ".wav"

        env = environment.UserSettings()
        musescorePath = env['musicxmlPath']
        musescoreRun = '"' + musescorePath + '" ' + fpIn + " -o " + fpOut + " -T 0 "

        fileLikeOpen = StringIO.StringIO()
        os.system(musescoreRun)
        fileLikeOpen.close()
        return fpOut
コード例 #9
0
def runOne(nbFile):
    us = environment.UserSettings()
    museScore = us['musescoreDirectPNGPath']
    us['musescoreDirectPNGPath'] = '/skip'
    try:
        retVal = os.system('pytest --nbval ' + nbFile + ' --sanitize-with ' +
                           common.getRootFilePath() + os.sep +
                           'documentation' + os.sep + 'docbuild' + os.sep +
                           'nbval-sanitize.cfg -q')
    except (Exception, KeyboardInterrupt):
        raise
    finally:
        us['musescoreDirectPNGPath'] = museScore

    return retVal
コード例 #10
0
ファイル: corpora.py プロジェクト: JuanuMusic/music21
    def delete(self):
        r'''
        Delete a non-default local corpus from the user settings.
        '''
        if self.name is None or self.name in ('core', 'virtual', 'local'):
            raise CorpusException('Cannot delete this corpus')
        elif not self.existsInSettings:
            return

        if os.path.exists(self.metadataBundle.filePath):
            os.remove(self.metadataBundle.filePath)

        userSettings = environment.UserSettings()
        del(userSettings['localCorporaSettings'][self.name])
        environment.Environment().write()
コード例 #11
0
    def save(self):
        r'''
        Save the current list of directory paths in use by a given corpus in
        the user settings.  And reindex.
        '''
        userSettings = environment.UserSettings()
        lcs = environment.LocalCorpusSettings(self.directoryPaths)
        if self.name != 'local':
            lcs.name = self.name
        lcs.cacheFilePath = self.cacheFilePath

        if self.name == 'local':
            userSettings['localCorpusSettings'] = lcs
        else:
            userSettings['localCorporaSettings'][self.name] = lcs
        environment.Environment().write()
        self.cacheMetadata()
コード例 #12
0
ファイル: nbvalNotebook.py プロジェクト: wilsonify/music21
def runOne(nbFile):
    us = environment.UserSettings()
    museScore = us['musescoreDirectPNGPath']
    us['musescoreDirectPNGPath'] = '/skip' + str(museScore)

    # this config file changes 0x39f3a0 to 0xADDRESS.
    sanitize_fn = str(common.getRootFilePath() / 'documentation' / 'docbuild' /
                      'nbval-sanitize.cfg')
    try:
        retVal = subprocess.run([
            'pytest', '--disable-pytest-warnings', '--nbval',
            str(nbFile), '--sanitize-with', sanitize_fn, '-q'
        ])
    except (Exception, KeyboardInterrupt):
        raise

    finally:
        us['musescoreDirectPNGPath'] = museScore

    return retVal
コード例 #13
0
 def _getSettings(self):
     userSettings = environment.UserSettings()
     if self.name == 'local':
         return userSettings['localCorpusSettings']
     return userSettings['localCorporaSettings'].get(self.name, None)
コード例 #14
0
from music21 import environment
config = environment.UserSettings()
config['lilypondPath'] = r'C:\Program Files (x86)\LilyPond\usr\bin\lilypond.exe'
config["musicxmlPath"] = r'C:\Program Files\MuseScore 3\bin\MuseScore3.exe'
config["musescoreDirectPNGPath"] = config["musicxmlPath"]
コード例 #15
0
def cli():
    us = environment.UserSettings()
    # ~/.music21rc should be edited to support using musescore for score.show()
    # us.create()
    pass
コード例 #16
0
def get_music21_user_settings_path():
    user_settings = environment.UserSettings()
    return user_settings.getSettingsPath()
コード例 #17
0
        , grad_weight = 10
        , z_dim = 32
        , batch_size = BATCH_SIZE
        , n_tracks = n_tracks
        , n_bars = n_bars
        , n_steps_per_bar = n_steps_per_bar
        , n_pitches = n_pitches
        )

gan.load_weights(RUN_FOLDER, None)
gan.generator.summary()
gan.critic.summary()

# 샘플 악보보기
from music21 import environment
us = environment.UserSettings()
us['musicxmlPath'] = 'C:/MuseScore/bin/MuseScore3.exe'
us['musescoreDirectPNGPath'] = 'C:/MuseScore/bin/MuseScore3.exe'

chords_noise = np.random.normal(0, 1, (1, gan.z_dim))
style_noise = np.random.normal(0, 1, (1, gan.z_dim))
melody_noise = np.random.normal(0, 1, (1, gan.n_tracks, gan.z_dim))
groove_noise = np.random.normal(0, 1, (1, gan.n_tracks, gan.z_dim))

gen_scores = gan.generator.predict([chords_noise, style_noise, melody_noise, groove_noise])

np.argmax(gen_scores[0,0,0:4,:,3], axis = 1)

gen_scores[0,0,0:4,60,3] = 0.02347812

filename = 'example'
コード例 #18
0
ファイル: utils.py プロジェクト: discordance/torchb
from music21 import midi, environment
import base64
import numpy as np
from tqdm import tqdm

environment.UserSettings()['warnings'] = 0

BEAT_DIV = 32
TICKS_PER_Q = 192
PERC_MAP = {
    # KICK GROUP
    0: 36,
    # SNARE AND RIMS
    1: 40,
    2: 37,
    # TOMS
    3: 41,  # low
    4: 47,  # mid
    5: 50,  # high
    # WORLD
    6: 64,  # low percs african
    7: 63,  # high percs african
    8: 68,  # latin a
    9: 77,  # latin b
    10: 56,  # unusual, unique
    # HH / CYMB
    11: 42,  # muted hh
    12: 46,  # open hat / splash
    13: 49,  # crash and chinese
    14: 51  # rides
}