<commit_before>// Copyright AudioKit. All Rights Reserved. Revision History at http://github.com/AudioKit/AudioKit/

import AudioKit
import XCTest
import CAudioKit
import AVFoundation

class AKOscillatorTests: AKTestCase {
    func testAmpitude() {
        input = AKOscillator(waveform: AKTable(.square), amplitude: 0.5)
        engine.output = input
        XCTAssertEqual(input.amplitude, 0.5)
        input.start()
        AKTest()
    }

    func testDefault() {
        engine.output = input
        input.start()
        AKTest()
    }

    func testDetuningMultiplier() {
        input = AKOscillator(waveform: AKTable(.square), detuningMultiplier: 0.9)
        engine.output = input
        XCTAssertEqual(input.detuningMultiplier, 0.9)
        input.start()
        AKTest()
    }

    func testDetuningOffset() {
        input = AKOscillator(waveform: AKTable(.square), detuningOffset: 11)
        engine.output = input
        XCTAssertEqual(input.detuningOffset, 11)
        input.start()
        AKTest()
    }

    func testFrequency() {
        input = AKOscillator(waveform: AKTable(.square), frequency: 400)
        engine.output = input
        XCTAssertEqual(input.frequency, 400)
        input.start()
        AKTest()
    }

    func testParametersSetAfterInit() {
        input = AKOscillator(waveform: AKTable(.square))
        input.rampDuration = 0.0
        input.frequency = 400
        input.amplitude = 0.5
        XCTAssertEqual(input.rampDuration, 0.0)
        XCTAssertEqual(input.frequency, 400)
        XCTAssertEqual(input.amplitude, 0.5)
        engine.output = input
        input.start()
        AKTest()
    }

    func testParameters() {
        input = AKOscillator(waveform: AKTable(.square), frequency: 400, amplitude: 0.5)
        engine.output = input
        input.start()
        AKTest()
    }

    func testAutomationFrequency() {
        input = AKOscillator(waveform: AKTable(.square), frequency: 400, amplitude: 0.5)
        input.parameterAutomation?.add(point: AKParameterAutomationPoint(targetValue: 880,
                                                                         startTime: 0,
                                                                         rampDuration: duration),
                                       to: input.$frequency)
        engine.output = input

        afterStart = {
            self.input.parameterAutomation?.startPlayback()
        }

        input.start()

        AKTest()
    }

    func testAutomationAmplitude() {
        input = AKOscillator(waveform: AKTable(.square), frequency: 400, amplitude: 0.0)
        input.parameterAutomation?.add(point: AKParameterAutomationPoint(targetValue: 1.0,
                                                                         startTime: 0,
                                                                         rampDuration: duration),
                                       to: input.$amplitude)
        engine.output = input

        afterStart = {
            self.input.parameterAutomation?.startPlayback()
        }

        input.start()

        AKTest()
    }

    func testAutomationMultiple() {
        input = AKOscillator(waveform: AKTable(.square), frequency: 400, amplitude: 0.0)
        input.parameterAutomation?.add(point: AKParameterAutomationPoint(targetValue: 880,
                                                                         startTime: 0,
                                                                         rampDuration: duration),
                                       to: input.$frequency)
        input.parameterAutomation?.add(point: AKParameterAutomationPoint(targetValue: 1.0,
                                                                         startTime: 0,
                                                                         rampDuration: duration),
                                       to: input.$amplitude)
        engine.output = input

        afterStart = {
            self.input.parameterAutomation?.startPlayback()
        }

        input.start()

        AKTest()
    }

    func testNewAutomationFrequency() {
        input = AKOscillator(waveform: AKTable(.square), frequency: 400, amplitude: 0.5)
        engine.output = input

        afterStart = {
            self.input.$frequency.automate(events: [AKAutomationEvent(targetValue: 880,
                                                                      startTime: 0,
                                                                      rampDuration: self.duration)])
        }

        input.start()

        AKTest()<commit_msg>Remove old parameter automation tests.<commit_after>// Copyright AudioKit. All Rights Reserved. Revision History at http://github.com/AudioKit/AudioKit/

import AudioKit
import XCTest
import CAudioKit
import AVFoundation

class AKOscillatorTests: AKTestCase {
    func testAmpitude() {
        input = AKOscillator(waveform: AKTable(.square), amplitude: 0.5)
        engine.output = input
        XCTAssertEqual(input.amplitude, 0.5)
        input.start()
        AKTest()
    }

    func testDefault() {
        engine.output = input
        input.start()
        AKTest()
    }

    func testDetuningMultiplier() {
        input = AKOscillator(waveform: AKTable(.square), detuningMultiplier: 0.9)
        engine.output = input
        XCTAssertEqual(input.detuningMultiplier, 0.9)
        input.start()
        AKTest()
    }

    func testDetuningOffset() {
        input = AKOscillator(waveform: AKTable(.square), detuningOffset: 11)
        engine.output = input
        XCTAssertEqual(input.detuningOffset, 11)
        input.start()
        AKTest()
    }

    func testFrequency() {
        input = AKOscillator(waveform: AKTable(.square), frequency: 400)
        engine.output = input
        XCTAssertEqual(input.frequency, 400)
        input.start()
        AKTest()
    }

    func testParametersSetAfterInit() {
        input = AKOscillator(waveform: AKTable(.square))
        input.rampDuration = 0.0
        input.frequency = 400
        input.amplitude = 0.5
        XCTAssertEqual(input.rampDuration, 0.0)
        XCTAssertEqual(input.frequency, 400)
        XCTAssertEqual(input.amplitude, 0.5)
        engine.output = input
        input.start()
        AKTest()
    }

    func testParameters() {
        input = AKOscillator(waveform: AKTable(.square), frequency: 400, amplitude: 0.5)
        engine.output = input
        input.start()
        AKTest()
    }

    func testNewAutomationFrequency() {
        input = AKOscillator(waveform: AKTable(.square), frequency: 400, amplitude: 0.5)
        engine.output = input

        afterStart = {
            self.input.$frequency.automate(events: [AKAutomationEvent(targetValue: 880,
                                                                      startTime: 0,
                                                                      rampDuration: self.duration)])
        }

        input.start()

        AKTest()
{'fraction_non_alphanumeric': 0.09027181688125895, 'fraction_numerical': 0.017310443490701002, 'mean_word_length': 1.5692760014700478, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 44, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4928373', 'n_tokens_mistral': 1964, 'n_tokens_neox': 1732, 'n_words': 352}