<commit_before># -*- coding: utf-8 -*-
"""
Created on Fri Nov 13 15:17:27 2020

@author: wantysal
"""
# Standard library import
import numpy as np
from scipy.io.wavfile import write



def signal_test(fc, fmod, mdepth, fs, d, dB):
    """ Creation of stationary amplitude modulated signals for the roughness 
    validation procedure (signal created according to equation 1 in 
    "Psychoacoustical roughness:implementation of an optimized model" 
    by <NAME> in 1997.
    
    Parameters
    ----------
    fc: integer
        carrier frequency
    fmod: integer
        modulation frequency
    mdepth: float
        modulation depth
    fs: integer
        sampling frequency
    d: float
        signal duration [s]
    dB: integer
        SPL dB level of the carrier signal
    """
    
    # time axis definition
    dt = 1/fs    
    time = np.arange(0,d,dt)
    
    signal = 0.5 * (1 + mdepth * (np.sin(2 * np.pi * fmod * time))) * np.sin( 2 * np.pi * fc * time)    
    rms = np.sqrt(np.mean(np.power(signal,2)))
    ampl = 1.42 * np.power(10,0.05*dB) / rms
    signal = signal * ampl
        
    return signal
    
def wav_test(fc, fmod, mdepth, fs, d, dB, folder):
    """ Creation of .wav file of stationary amplitude modulated signals for the roughness 
    validation procedure (signal created according to equation 1 in <commit_msg>[CC] correction of 2**0.5 for the signal to be in Pa<commit_after># -*- coding: utf-8 -*-
"""
Created on Fri Nov 13 15:17:27 2020

@author: wantysal
"""
# Standard library import
import numpy as np
from scipy.io.wavfile import write



def signal_test(fc, fmod, mdepth, fs, d, dB):
    """ Creation of stationary amplitude modulated signals for the roughness 
    validation procedure (signal created according to equation 1 in 
    "Psychoacoustical roughness:implementation of an optimized model" 
    by <NAME> Weber in 1997.
    
    Parameters
    ----------
    fc: integer
        carrier frequency
    fmod: integer
        modulation frequency
    mdepth: float
        modulation depth
    fs: integer
        sampling frequency
    d: float
        signal duration [s]
    dB: integer
        SPL dB level of the carrier signal
    """
    
    # time axis definition
    dt = 1/fs    
    time = np.arange(0,d,dt)
    
    signal = 0.5 * (1 + mdepth * (np.sin(2 * np.pi * fmod * time))) * np.sin( 2 * np.pi * fc * time)    
    rms = np.sqrt(np.mean(np.power(signal,2)))
    ampl = 0.00002 * np.power(10,dB/20) / rms
    signal = signal * ampl
        
    return signal
    
def wav_test(fc, fmod, mdepth, fs, d, dB, folder):
    """ Creation of .wav file of stationary amplitude modulated signals for the roughness 
    validation procedure (signal created according to equation 1 in 
{'fraction_non_alphanumeric': 0.0989090909090909, 'fraction_numerical': 0.02727272727272727, 'mean_word_length': 2.417391304347826, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2268610', 'n_tokens_mistral': 922, 'n_tokens_neox': 822, 'n_words': 309}