Created
June 8, 2021 15:00
-
-
Save frozenoak/a4ee6cec57aa35414c45a4c27aa6053c to your computer and use it in GitHub Desktop.
Create a Callsign in a panadapter waterfall burte force method
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
from scipy.io.wavfile import write | |
import numpy as np | |
samplerate = 44100 | |
def get_piano_notes(): | |
''' | |
Returns a dict object for all the piano | |
note's frequencies | |
''' | |
# White keys are in Uppercase and black keys (sharps) are in lowercase | |
octave = ['C', 'c', 'D', 'd', 'E', 'F', 'f', 'G', 'g', 'A', 'a', 'B'] | |
base_freq = 1046.502 #Frequency of Note C4 | |
note_freqs = {octave[i]: base_freq * pow(2,(i/12)) for i in range(len(octave))} | |
note_freqs[''] = 0.0 | |
return note_freqs | |
def get_wave(freq, duration=0.5): | |
amplitude = 4096 | |
t = np.linspace(0, duration, int(samplerate * duration)) | |
wave = amplitude * np.sin(2 * np.pi * freq * t) | |
return wave | |
def get_chord_data(chords): | |
chords = chords.split('-') | |
note_freqs = get_piano_notes() | |
chord_data = [] | |
for chord in chords: | |
data = sum([get_wave(note_freqs[note]) for note in list(chord)]) | |
chord_data.append(data) | |
chord_data = np.concatenate(chord_data, axis=0) | |
return chord_data.astype(np.int16) | |
def main(): | |
#Playing chords | |
chords = 'Eg-EG-Ef-EF-Ef-EG-Eg-FfG-E-E-EFfG-Eg-Eg-FfG-f-FG-Eg-Eg-EFfGg-Eg-Eg-FfG-Eg-Eg-Eg-Eg-EG-Ffg-Eg-Eg-Eg-FG-FG-f-f' | |
data = get_chord_data(chords) | |
data = data * (16300/np.max(data)) | |
data = np.resize(data, (len(data)*5,)) | |
write('DM57_Call_Sign.wav', samplerate, data.astype(np.int16)) | |
if __name__=='__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment