Exemplo n.º 1
0
def do_calc(LATLIMS_AM, LONLIMS_AM, indir, outdir):
    land_checker = Basemap()
    if land_checker.is_land(LATLIMS_AM, LONLIMS_AM):
        print "SOS! Sorry you have selected a land pixel!"
        pygame.mixer.music.load("SOS.midi")
        pygame.mixer.music.play()
        while pygame.mixer.music.get_busy():
            # plot animado?
            time.sleep(1)
    else:
        dataAM = extract_series(LATLIMS_AM, LONLIMS_AM, indir)
        data_am = np.double(dataAM["Series"])
        if all(np.isnan(a) for a in data_am):
            print "THE SOUND OF SILENCE. Also, BATMAN. Everything is Rest and NaN"
            pygame.mixer.music.load("Batman_song.midi")
            pygame.mixer.music.play()
            while pygame.mixer.music.get_busy():
                # Anim plot? See Matplotlib.Animation
                time.sleep(1)
        else:
            am = get_music(data_am)

            music = pygame.mixer.Sound("Oc.midi")
            pygame.mixer.music.load("Oc.midi")
            pygame.mixer.music.play()
            anim = plot_animation(
                data_am,
                (u"Music from Lat = %.2f Lon = %.2f" % (dataAM["Lat"], dataAM["Lon"])),
                "serie.png",
                t_max=36000,
            )  # music.get_length())
Exemplo n.º 2
0
def do_calc(LATLIMS_AM, LONLIMS_AM, indir, outdir):
    land_checker = Basemap()
    if land_checker.is_land(LATLIMS_AM, LONLIMS_AM):
        print('SOS! Sorry you have selected a land pixel!')
        pygame.mixer.music.load('SOS.midi')
        pygame.mixer.music.play()
        while pygame.mixer.music.get_busy():
            #plot animado?
            time.sleep(1)
    else:
        dataAM = extract_series(LATLIMS_AM, LONLIMS_AM, indir)
        data_am = np.double(dataAM['Series'])
        if all(np.isnan(a) for a in data_am):
            print(
                'THE SOUND OF SILENCE. Also, BATMAN. Everything is Rest and NaN'
            )
            pygame.mixer.music.load('Batman_song.midi')
            pygame.mixer.music.play()
            while pygame.mixer.music.get_busy():
                # Anim plot? See Matplotlib.Animation
                time.sleep(1)
        else:
            am = get_music(data_am)

            music = pygame.mixer.Sound('Oc.midi')
            pygame.mixer.music.load('Oc.midi')
            pygame.mixer.music.play()
            anim = plot_animation(data_am,
                                  ('Music from Lat = %.2f Lon = %.2f' %
                                   (dataAM['Lat'], dataAM['Lon'])),
                                  'serie.png',
                                  t_max=36000)  #music.get_length())
Exemplo n.º 3
0
def change_instrumentation(theme):
    music = get_music(theme,
                      key="C",
                      mode="pentatonic",
                      octaves=OCTAVES,
                      instruments=[43],
                      period=1)
    return music
Exemplo n.º 4
0
def minor_mode(theme):
    music = get_music(theme,
                      key="C",
                      mode="minor",
                      octaves=OCTAVES,
                      instruments=[49],
                      period=1)
    return music
Exemplo n.º 5
0
def theme_restatement(theme):
    music = get_music(theme,
                      key="C",
                      mode="pentatonic",
                      octaves=OCTAVES,
                      instruments=[49],
                      period=1)
    return music
Exemplo n.º 6
0
def test_get_music():
    series = [np.random.rand(24).reshape(2, 12), np.random.rand(30)]
    inst = [[0,23], [0]]
    testMuz = []
    for i, item in enumerate(series):
        testMuz.append(get_music(item, key='D', mode='pentatonic',
                  octaves=2, instruments=inst[i]))
    assert len(testMuz[0].getvalue()) == 281
    assert len(testMuz[1].getvalue()) == 314
Exemplo n.º 7
0
def reverse_theme(theme):
    reversed_theme = theme[::-1]
    music = get_music(reversed_theme,
                      key="C",
                      mode="major",
                      octaves=OCTAVES,
                      instruments=[1],
                      period=1)
    return music
Exemplo n.º 8
0
def modulate_theme(theme):
    music = get_music(theme,
                      key="F",
                      mode="pentatonic",
                      octaves=OCTAVES,
                      instruments=[41],
                      period=1)
    # print "this is a {0}".format(music)
    return music
Exemplo n.º 9
0
def theme_initial_statement(theme):
    music = get_music(theme,
                      key="C",
                      mode="pentatonic",
                      octaves=1,
                      instruments=[1],
                      period=1)
    # print("music is of type {0}".format(music))
    return music
Exemplo n.º 10
0
def test_get_music():
    series = [np.random.rand(24).reshape(2, 12), np.random.rand(30)]
    inst = [[0, 23], [0]]
    testMuz = []
    for i, item in enumerate(series):
        testMuz.append(
            get_music(item,
                      key='D',
                      mode='pentatonic',
                      octaves=2,
                      instruments=inst[i]))
    assert len(testMuz[0].getvalue()) == 281
    assert len(testMuz[1].getvalue()) == 314
Exemplo n.º 11
0
def music():
    if request.method == 'GET':
        mode = request.args.get('mode', 'MODIS')

        if mode == 'MODIS':
            lat = float(request.args['lat'])
            lon = float(request.args['lon'])
            music, series, new_lat, new_lon = (
                gen_music(lat, lon, current_app.config['DATADIR']))
            return json.dumps({
                              'lat': new_lat,
                              'lon': new_lon,
                              'series': replace_nan(series.tolist()),
                              'music': base64.b64encode(music.getvalue()),
                              }, allow_nan=False)
        elif mode == 'series':
            series = np.array(request.args.getlist('series[]'), dtype='f8')
            return json.dumps({
                'series': replace_nan(series.tolist()),
                'music': base64.b64encode(get_music(series).getvalue())
            }, allow_nan=False)
    else:
        return Response("", status=415)
Exemplo n.º 12
0
def gen_music(lat, lon, datadir):
    data_am = extract_series(lat, lon, datadir)
    am = get_music(data_am['Series'])

    return am, data_am['Series'], data_am['Lat'], data_am['Lon']