예제 #1
0
 def get(self, page=None, walk_id=None):
     log.info("Home.get %s" % page)
     if not len(page):
         return self.render("home.html")
     if page == "walk":
         if len(walk_id) and walk_id == "c":
             walks = model.fetch_walks()
             if len(walks):
                 walk_id = random.choice(walks)['id']
             else:
                 walk_id = None
         elif not type(walk_id) == int and not len(walk_id):
             walk_id = None
         return self.render("walk.html",
                            sequence=json.dumps(
                                model.fetch_sequence(walk_id)),
                            ref_id=walk_id)
     if page == "walks":
         return self.render("walks.html",
                            walks=model.fetch_walks(hidden=True))
     if page == "choose":
         return self.render("choose.html", walks=model.fetch_walks())
     if page in [
             "prepare", "route", "map", "thanks", "orientation",
             "background"
     ]:
         return self.render("%s.html" % page)
     return self.not_found()
예제 #2
0
 def get(self, page=None, walk_id=None):
     log.info("Home.get %s" % page)
     if not len(page):
         return self.render("home.html")        
     if page == "walk":
         return self.render("walk.html", sequence=json.dumps(model.fetch_sequence(walk_id)), ref_id=walk_id if len(walk_id) else 0) 
     if page == "choose":
         return self.render("choose.html", walks=model.fetch_walks()) 
     if page in ["prepare", "route", "map", "thanks"]:
         return self.render("%s.html" % page)
     return self.not_found()
예제 #3
0
 def get(self, page=None, walk_id=None):
     log.info("Home.get %s" % page)
     if not len(page):
         return self.render("home.html")        
     if page == "walk":            
         if len(walk_id) and walk_id == "c":
             walks = model.fetch_walks()
             if len(walks):
                 walk_id = random.choice(walks)['id']
             else:
                 walk_id = None
         elif not type(walk_id) == int and not len(walk_id):
             walk_id = None
         return self.render("walk.html", sequence=json.dumps(model.fetch_sequence(walk_id)), ref_id=walk_id) 
     if page == "walks":
         return self.render("walks.html", walks=model.fetch_walks(hidden=True))
     if page == "choose":
         return self.render("choose.html", walks=model.fetch_walks()) 
     if page in ["prepare", "route", "map", "thanks", "orientation", "background"]:
         return self.render("%s.html" % page)
     return self.not_found()
예제 #4
0
def get_data(hidden=False):

    log.debug("HIDDEN %s" % hidden)

    data = {}

    try:

        walks = model.fetch_walks(hidden=hidden)

        notes = []
        v = 0
        ids = []
        for walk in walks:
            sequence = model.fetch_sequence(walk['id'])
            if len(sequence) < config['min_steps']:
                continue
            for step in sequence:  #[:config['max_steps']]:
                notes.append((step[0], v, 0 if step[1] == 'left' else 1))
            v += 1
            ids.append(walk['id'])

        # sort and normalize onsets
        notes.sort(key=lambda x: x[0])
        onsets = [note[0] for note in notes]
        onsets = sp.normalize(onsets)
        notes = [(onsets[i], note[1], note[2])
                 for (i, note) in enumerate(notes)]

        log.info("NOTES %s" % len(notes))

        data['notes'] = notes
        data['walk_ids'] = ids

    except Exception as e:
        log.error(log.exc(e))
        return {}

    return json.dumps(data)
예제 #5
0
def get_data(hidden=False):

    log.debug("HIDDEN %s" % hidden)

    data = {}

    try:

        walks = model.fetch_walks(hidden=hidden)

        notes = []
        v = 0
        ids = []
        for walk in walks:
            sequence = model.fetch_sequence(walk['id'])
            if len(sequence) < config['min_steps']:
                continue
            for step in sequence:#[:config['max_steps']]:
                notes.append((step[0], v, 0 if step[1] == 'left' else 1))
            v += 1
            ids.append(walk['id'])

        # sort and normalize onsets
        notes.sort(key=lambda x: x[0])
        onsets = [note[0] for note in notes]
        onsets = sp.normalize(onsets)
        notes = [(onsets[i], note[1], note[2]) for (i, note) in enumerate(notes)]

        log.info("NOTES %s" % len(notes))

        data['notes'] = notes
        data['walk_ids'] = ids

    except Exception as e:
        log.error(log.exc(e))
        return {}

    return json.dumps(data)
예제 #6
0
#!/usr/bin/env python3

import os, sys, time
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import model
import numpy as np
from housepy import config, log, drawing, geo, util

MIN_STEPS = 50

walk_data = model.fetch_walks(desc=False)
# walk_data = [walk for walk in walks if walk['id'] >= config['walk_id']]

walks = []
for walk in walk_data:
    sequence = model.fetch_sequence(walk['id'])
    if len(sequence) < MIN_STEPS:
        continue
    walks.append(walk)


LON = 0
LAT = 1
X = 2
Y = 3

all_points = []
for walk in walks:
    points = model.fetch_geo(walk['id'])
    points = np.array([(point['lng'], point['lat'], None, None) for point in points])
    for point in points:
예제 #7
0
    ctx.line([(float(i) / total_samples, y) for (i, y) in enumerate(ys)],
             stroke=(0., 1., 0., 1.0))  #, thickness=3.0)
    ctx.line([(float(i) / total_samples, z) for (i, z) in enumerate(zs)],
             stroke=(0., 0., 1., 1.0))  #, thickness=3.0)
    ctx.line([(float(i) / total_samples, d) for (i, d) in enumerate(ds)],
             stroke=(0., 0., 0.),
             thickness=3.0)
    ctx.line([(float(i) / total_samples, f) for (i, f) in enumerate(fs)],
             stroke=(1., 0., 1.),
             thickness=5.0)
    for peak in peaks:
        x, y = peak
        x = float(x) / total_samples
        ctx.arc(x,
                y, (10.0 / ctx.width), (10.0 / ctx.height),
                fill=(1., 0., 0.),
                thickness=0.0)
    ctx.output("charts/steps_%s_%s.png" % (walk_id, int(time.time())))


if __name__ == "__main__":
    walk_id = sys.argv[1]
    force = True if len(sys.argv) > 2 and sys.argv[2][0] == "f" else False
    if walk_id == "all":
        walks = model.fetch_walks()
        log.info("Total walks: %s" % len(walks))
        for walk in walks:
            process_walk(walk['id'], force)
    else:
        process_walk(walk_id, force)
예제 #8
0
import signal_processing as sp
from braid import *
from braid.voice.swerve import Swerve

MIN_STEPS = 50


steps = [   (C3, D3),
            (G3, A3),
            (D4, E4),
            (A4, B4),
            (E5, F5),
            (G5, A5)
            ]    

walks = model.fetch_walks(desc=False)

# collect notes
notes = []
v = 0
voices = []
for walk in walks:
    sequence = model.fetch_sequence(walk['id'])
    if len(sequence) < MIN_STEPS:
        continue    
    voices.append(Swerve(v + 1))
    for step in sequence:
        notes.append((step[0], v, 0 if step[1] == 'left' else 1))
    v += 1   
    if v == len(steps):
        break
예제 #9
0
        log.error("Can't draw")
        return

    # plot
    ctx = drawing.Context(5000, 600, relative=True, flip=True)
    ctx.line(200.0 / total_samples, 0.5, 350.0 / total_samples, 0.5, thickness=10.0)
    ctx.line([(float(i) / total_samples, x) for (i, x) in enumerate(xs)], stroke=(1., 0., 0., 1.0))# thickness=3.0)
    ctx.line([(float(i) / total_samples, y) for (i, y) in enumerate(ys)], stroke=(0., 1., 0., 1.0))#, thickness=3.0)
    ctx.line([(float(i) / total_samples, z) for (i, z) in enumerate(zs)], stroke=(0., 0., 1., 1.0))#, thickness=3.0)
    ctx.line([(float(i) / total_samples, d) for (i, d) in enumerate(ds)], stroke=(0., 0., 0.), thickness=3.0)
    ctx.line([(float(i) / total_samples, f) for (i, f) in enumerate(fs)], stroke=(1., 0., 1.), thickness=5.0)
    for peak in peaks:
        x, y = peak
        x = float(x) / total_samples
        ctx.arc(x, y, (10.0 / ctx.width), (10.0 / ctx.height), fill=(1., 0., 0.), thickness=0.0)
    ctx.output("charts/steps_%s_%s.png" % (walk_id, int(time.time())))


if __name__ == "__main__":
    walk_id = sys.argv[1]
    force = True if len(sys.argv) > 2 and sys.argv[2][0] == "f" else False
    if walk_id == "all":
        walks = model.fetch_walks()
        log.info("Total walks: %s" % len(walks))
        for walk in walks:
            process_walk(walk['id'], force)
    else:
        process_walk(walk_id, force)