Example #1
0
        if not os.path.exists(CONFIG_FILE_PATH):
            CONFIG_FILE_PATH = "./config.ini"
            print '>>>> CONFIG: looking for config.ini in /SamplerBox/'
            # try:
            #     file = open(CONFIG_FILE_PATH, 'r') # test if exists
            # except:
            #     file = open(CONFIG_FILE_PATH,'w')
            #     config_exists = False
            #     print 'Creating empty config.ini'
            # file.close()
        print '>>>> CONFIG used: %s' % CONFIG_FILE_PATH
else:
    CONFIG_FILE_PATH = "../config.ini"
    print '>>>> CONFIG: using config.ini in ../'

cp = configparser_samplerbox.Setup(config_file_path=CONFIG_FILE_PATH)
# If the main config doesn't exist, or if it's empty, build it with default values
if os.path.isfile(CONFIG_FILE_PATH) == False or os.stat(CONFIG_FILE_PATH).st_size == 0:
    cp.build_config_from_defaults()

SYSTEM_MODE = int(cp.get_option_by_name('SYSTEM_MODE'))
MAX_POLYPHONY = int(cp.get_option_by_name('MAX_POLYPHONY'))
MIDI_CHANNEL = int(cp.get_option_by_name('MIDI_CHANNEL'))
BUFFERSIZE = int(cp.get_option_by_name('BUFFERSIZE'))
SAMPLERATE = int(cp.get_option_by_name('SAMPLERATE'))
BOXRELEASE = int(cp.get_option_by_name('BOXRELEASE'))
RAM_LIMIT_PERCENTAGE = int(cp.get_option_by_name('RAM_LIMIT_PERCENTAGE'))
# global_volume = int(cp.get_option_by_name('GLOBAL_VOLUME'))
global_volume = 100  # ignore config.ini value and set to max
global_volume_percent = int((float(global_volume) / 100.0) * 100)
global_volume = 0 if global_volume < 0 else 100 if global_volume > 100 else global_volume
Example #2
0
        'default': 16,
        'section': 'GPIO LCD HD44780 PIN SETUP'
    },
    'GPIO_LCD_D6': {
        'type': 'int',
        'default': 13,
        'section': 'GPIO LCD HD44780 PIN SETUP'
    },
    'GPIO_LCD_D7': {
        'type': 'int',
        'default': 12,
        'section': 'GPIO LCD HD44780 PIN SETUP'
    },
    'GPIO_7SEG': {
        'type': 'int',
        'default': 1,
        'section': 'GPIO FOR A 7 SEGMENT DISPLAY'
    }
}

if __name__ == "__main__":
    import configparser_samplerbox

    cp = configparser_samplerbox.Setup('../config.ini')

    for c in configdefaults.iteritems():

        cp.update_config(section=c[1].get('section'),
                         option=c[0],
                         value=c[1].get('default'))