Created
February 10, 2015 18:05
-
-
Save lukas2511/3049e60d42d7861f7dfa to your computer and use it in GitHub Desktop.
Stupid SIP analog phone adapter melody fun
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
#!/usr/bin/env python | |
from tones import tones | |
import math | |
# format: | |
# | |
# freq@-attn, | |
# freq@-attn, | |
# freq@-attn | |
# ; | |
# 20( | |
# len/delay/1, | |
# len/delay/2, | |
# len/delay/3 | |
# ) | |
def gen_melody(tones): | |
melody = "" | |
length = 0.0 | |
for tone in tones: | |
melody += "%d@-16," % tone[0] | |
length += float(tone[1]) | |
melody = melody[:-1] | |
melody += ";" | |
length = math.ceil(length/1000) | |
melody += "%d(" % length | |
i=1 | |
for tone in tones: | |
melody += ".%.3d/0/%d," % (tone[1], i) | |
i+=1 | |
melody = melody[:-1] | |
melody += ")" | |
return melody | |
print("Dial tone:") | |
print(gen_melody(tones[:6])) | |
print("Reorder tone:") | |
print(gen_melody(tones[6:12])) |
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
# Example (AxelF): | |
tones = [ [659,460,], [784,340,], [659,230,], [659,110,], [880,230,], [659,230,], [587,230,], [659,460,], [988,340,], [659,230,], [659,110,], [1047,230,],] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment