#
# (C) Oriol Boix 2018
# Based on CircuitPython Audio Out by Adafruit
# https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-audio-out
#
import math
import audiocore
import audioio
import array
def nota(Freq, Vol):
    Vol = 32767 * math.fabs(Vol)
    if Vol > 32767:
        Vol = 32767
    Mostreig = 8000
    NumValors = Mostreig//Freq
    ona = array.array("H", [0] * NumValors)
    for k in range(NumValors):
        ona[k] = int((1 + math.sin(2 * math.pi * k / NumValors)) * Vol)
    return audiocore.RawSample(ona)
