Skip to content

Commit

Permalink
In the process of adding a 'sound class'
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander James Wallar committed Feb 7, 2014
1 parent 5fc4bfd commit c6e436e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
22 changes: 19 additions & 3 deletions locaudio/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
SAMPLE_R_REF = 1
SAMPLE_L_REF = 65
SAMPLE_NAME = "Cock"
SAMPLE_CLASS = "Chicken"


# Table Names
Expand All @@ -42,6 +43,10 @@
FINGERPRINT_PRIMARY_KEY = "name"


# Secondary Keys
FINGERPRINT_SECONDARY_KEY = "class"


def create(conn):
"""
Expand All @@ -59,6 +64,10 @@ def create(conn):
primary_key=FINGERPRINT_PRIMARY_KEY
).run(conn)

r.db(DB).table(FINGERPRINT_TABLE).index_create(
FINGERPRINT_SECONDARY_KEY
).run(conn)


def init():
"""
Expand All @@ -73,7 +82,13 @@ def init():
if not DB in r.db_list().run(conn):
create(conn)
f_print = fingerprint.get_fingerprint(SAMPLE_PATH)
insert_reference(SAMPLE_NAME, f_print, SAMPLE_R_REF, SAMPLE_L_REF)
insert_reference(
SAMPLE_NAME,
f_print,
SAMPLE_R_REF,
SAMPLE_L_REF,
SAMPLE_CLASS
)
return True
else:
return False
Expand Down Expand Up @@ -144,7 +159,7 @@ def get_list_of_names():
return list(names)


def insert_reference(name, f_ref, r_ref, l_ref):
def insert_reference(name, f_ref, r_ref, l_ref, class_ref):
"""
Inserts a reference into the database
Expand All @@ -166,7 +181,8 @@ def insert_reference(name, f_ref, r_ref, l_ref):
"name": name,
"fingerprint": f_ref,
"distance": r_ref,
"spl": l_ref
"spl": l_ref,
"class": class_ref
}
).run(conn)

Expand Down
3 changes: 2 additions & 1 deletion locaudio/detectionserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ def get_post_upload():
request.form["sound_name"],
fingerprint.get_fingerprint(file_path),
float(request.form["r_ref"]),
float(request.form["l_ref"])
float(request.form["l_ref"]),
request.form["class"]
)
return render_template("upload.html")

Expand Down
1 change: 0 additions & 1 deletion locaudio/localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

from point import Point
from location import Location
from functools import partial
from collections import namedtuple

import math
Expand Down
4 changes: 4 additions & 0 deletions locaudio/templates/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ <h2 class="brand">Upload</h2>
<td>Sound name:</td>
<td><input type="text" name="sound_name"/></td>
</tr>
<tr>
<td>Sound class:</td>
<td><input type="text" name="class"></td>
</tr>
<tr>
<td>Reference distance:</td>
<td><input type="text" name="r_ref"></td>
Expand Down

0 comments on commit c6e436e

Please sign in to comment.