def main():
    print("Começou...")
    Hearing = True
    SM = st.signalMeu()
    sd.default.samplerate = 44100
    freq_dict = {
        '0': [941, 1336],
        '1': [697, 1209],
        '2': [697, 1336],
        '3': [697, 1477],
        '4': [770, 1209],
        '5': [770, 1336],
        '6': [770, 1477],
        '7': [852, 1209],
        '8': [852, 1336],
        '9': [852, 1447],
        'A': [697, 1633],
        'B': [770, 1633],
        'C': [852, 1633],
        'D': [941, 1633],
        'X': [941, 1209],
        '#': [941, 1477],
    }
    while Hearing:
        letra = input("Digite o simbolo desejado: ")
        for k in freq_dict.keys():  #Lendo cada chave do dicionário
            if k == letra.capitalize(
            ):  #Se uma chave do freq_dict for pressionada no telcado
                print('You Pressed A Key!')
                x = freq_dict[letra.capitalize(
                )]  #Deixa a letra pressionada em maiuscula
                x1, s1 = SM.generateSin(x[0], 10, 2, 44100)
                x1, s2 = SM.generateSin(x[1], 10, 2, 44100)
                s = s1 + s2
                sd.play(s)  #Tocar as duas frequencias juntas
                sd.wait()
                #plt.plot(s)
                #plt.xlim(0,500)
                #SM.plotFFT(s,44100)
                break
            if letra == "/":  #Para sair do loop usa-se "/"
                Hearing = False
                break
            else:
                pass
Beispiel #2
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sounddevice as sd
import matplotlib.pyplot as plt
import json
import numpy as np
import time
from scipy import signal
from signalTeste import signalMeu

fs = 44100
duration = 10
freq = 12000
sinal = signalMeu()


def record(duration, fs):
    print("iniciando a gravação")
    myrecording = sd.rec(int(duration * fs), samplerate=fs, channels=2)
    sd.wait()

    print(len(myrecording))
    print(myrecording)
    return myrecording[:, 0]  #return só de um canal do recording


def demodulate(recording, base_freq, fs, duration):
    s, portadora = generateSin(base_freq, 1, duration, fs)
    demodulate = np.multiply(portadora, recording)
    return demodulate
Beispiel #3
0
import sounddevice as sd
import signalTeste as st
import soundfile as sf
import matplotlib.pyplot as plt
import numpy as np
import scipy as sp

chama = st.signalMeu()

timer = 1
fs = 44100
timeParser = 1000
sd.default.samplerate = fs
sd.default.channels = 2
duration = 5  #segundos


def grava_e_salva():
    myrecording = sd.rec(int(duration * fs), channels=2)
    sd.wait()
    sf.write("myrecording.wav", myrecording, fs)
    chama.plotFFT(myrecording.T[0], fs)
    plt.show()
    print("Teste")
    sd.play(myrecording, fs)
    sd.wait()
    print("Done")
    plt.plot(myrecording.T[0])
    plt.show()
    print(myrecording.T[0] / np.argmax(myrecording.T[0]))
Beispiel #4
0
    9: [852, 1447],
    0: [941, 1336]
}


def check(x):
    x = sum(x)
    for i in freq:
        a = sum(freq[i])
        if abs(a - x) <= 10:
            z = i
            return z
    return "a"


sgn = sgn.signalMeu()

num = []

fs = 44100
sd.default.samplerate = fs
sd.default.channels = 1
counter = 0
duration = 1
print('Gravando')
t = np.linspace(0, duration, fs)
while counter < 10:

    myrecording = sd.rec(int(duration * fs))
    # print(myrecording)
    plt.plot(t, myrecording[:, 0])
Beispiel #5
0
import signalTeste as st
import sounddevice as sd
import math
import numpy
import peakutils
from peakutils.plot import plot as pplot
from matplotlib import pyplot as plt

if __name__ == "__main__":
    SM = st.signalMeu()
    freq_dict = {'0':[941, 1336],
                '1':[697,1209],
                '2':[697, 1336],
                '3':[697, 1477],
                '4':[770, 1209],
                '5':[770, 1336],
                '6':[770, 1477],
                '7':[852, 1209],
                '8':[852, 1336],
                '9':[852, 1447],
                'A':[697, 1633],
                'B':[770, 1633],
                'C':[852, 1633],
                'D':[941, 1633],
                'X':[941, 1209],
                '#':[941, 1477],}
    duration = 1  # seconds
    fs = 44100
    sd.default.samplerate = fs
    sd.default.channels = 1
    myarray = int(duration * fs)