Skip to content

Commit

Permalink
Clean up. Add README
Browse files Browse the repository at this point in the history
  • Loading branch information
akarazeev committed Apr 10, 2017
0 parents commit 22f1efe
Show file tree
Hide file tree
Showing 15 changed files with 176 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
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 added ex.pdf
Binary file not shown.
Binary file added img1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions mus.py
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()
8 changes: 8 additions & 0 deletions seq/01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
42
13
67
89
2
5
2
1
42 changes: 42 additions & 0 deletions seq/02.txt
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
25 changes: 25 additions & 0 deletions seq/03.txt
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
33 changes: 33 additions & 0 deletions tabs.py
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()
Binary file added whistle_tabs/01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added whistle_tabs/02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added whistle_tabs/03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added whistle_tabs/04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added whistle_tabs/05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added whistle_tabs/06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added whistle_tabs/07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 22f1efe

Please sign in to comment.