-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 22f1efe
Showing
15 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## Sound from Sequence | ||
|
||
|
||
## Tabs for Tin whistle from sequence | ||
|
||
| _ | _ | _ | | ||
| :--- | :--- | :--- | | ||
| '3760642169' | --> | ![img1](img1.jpg) | |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import math | ||
import pyaudio | ||
PyAudio = pyaudio.PyAudio | ||
|
||
#See http://en.wikipedia.org/wiki/Bit_rate#Audio | ||
BITRATE = 16000 #number of frames per second/frameset. | ||
|
||
#See http://www.phy.mtu.edu/~suits/notefreqs.html | ||
LENGTH = 0.3 #seconds to play sound | ||
|
||
NUMBEROFFRAMES = int(BITRATE * LENGTH) | ||
# RESTFRAMES = NUMBEROFFRAMES % BITRATE | ||
WAVEDATA = '' | ||
|
||
##fill remainder of frameset with silence | ||
# for x in xrange(RESTFRAMES): | ||
# WAVEDATA = WAVEDATA+chr(128) | ||
|
||
#14159265358979323846264338327950288419716939937510582 | ||
|
||
def READ_SEQ(path): | ||
res = [] | ||
with open(path, 'r') as f: | ||
for line in f: | ||
res.append(int(line)) | ||
return res | ||
|
||
|
||
def MY_FREQ(digit): | ||
return { | ||
0: 1174.66, | ||
1: 1318.51, | ||
2: 1479.98, | ||
3: 1567.98, | ||
4: 1760.00, | ||
5: 1975.53}.get(digit, -1) | ||
|
||
|
||
def ADD_SOUND(digit): | ||
global WAVEDATA | ||
for x in xrange(NUMBEROFFRAMES): | ||
WAVEDATA = WAVEDATA+chr(int(math.sin(x/((BITRATE/MY_FREQ(digit))/math.pi))*127+128)) | ||
return | ||
|
||
if __name__ == "__main__": | ||
seq = READ_SEQ('seq/02.txt') | ||
for i in seq: | ||
sound = int(i)%6 | ||
print(sound) | ||
ADD_SOUND(sound) | ||
|
||
p = PyAudio() | ||
stream = p.open(format = p.get_format_from_width(1), | ||
channels = 1, | ||
rate = BITRATE, | ||
output = True) | ||
stream.write(WAVEDATA) | ||
stream.stop_stream() | ||
stream.close() | ||
p.terminate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
42 | ||
13 | ||
67 | ||
89 | ||
2 | ||
5 | ||
2 | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
0 | ||
1 | ||
1 | ||
2 | ||
3 | ||
5 | ||
8 | ||
13 | ||
21 | ||
34 | ||
55 | ||
89 | ||
144 | ||
233 | ||
377 | ||
610 | ||
987 | ||
1597 | ||
2584 | ||
4181 | ||
6765 | ||
10946 | ||
17711 | ||
28657 | ||
46368 | ||
75025 | ||
121393 | ||
196418 | ||
317811 | ||
514229 | ||
832040 | ||
1346269 | ||
2178309 | ||
3524578 | ||
5702887 | ||
9227465 | ||
14930352 | ||
24157817 | ||
39088169 | ||
63245986 | ||
102334155 | ||
165580141 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
0 | ||
1 | ||
1 | ||
2 | ||
3 | ||
5 | ||
8 | ||
13 | ||
21 | ||
34 | ||
55 | ||
89 | ||
144 | ||
233 | ||
377 | ||
610 | ||
987 | ||
1597 | ||
2584 | ||
4181 | ||
6765 | ||
10946 | ||
17711 | ||
28657 | ||
46368 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python | ||
|
||
from reportlab.pdfgen import canvas | ||
from reportlab.lib.units import inch, cm | ||
|
||
|
||
def MY_FREQ(digit): | ||
return {0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6}.get(digit, -1) | ||
|
||
|
||
c = canvas.Canvas('ex.pdf') | ||
|
||
# 14159265358979323846264338327950288419716939937510582 | ||
|
||
# count = 0 | ||
c_x = 0 | ||
c_y = 0 | ||
|
||
# new line after every 26 tabs | ||
|
||
for i in '3760642169': | ||
# print(int(i)%6) | ||
c.drawImage('whistle_tabs/0{}.png'.format(MY_FREQ(int(i) % 6)), 13+23*c_x, | ||
730 - 105*c_y, 22, 95) | ||
# count += 1 | ||
c_x += 1 | ||
|
||
if c_x == 20: | ||
c_y += 1 | ||
c_x = 0 | ||
|
||
c.showPage() | ||
c.save() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.