{"size": 1824, "ext": "js", "max_stars_repo_path": "test/instrument/MetalSynth.js", "max_stars_repo_name": "jacobclarke92/Tone.js", "max_stars_repo_stars_event_min_datetime": "2019-10-14T22:32:22.000Z", "max_stars_repo_stars_event_max_datetime": "2019-11-29T06:21:20.000Z", "max_issues_repo_path": "test/instrument/MetalSynth.js", "max_issues_repo_name": "jacobclarke92/Tone.js", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/instrument/MetalSynth.js", "max_forks_repo_name": "jacobclarke92/Tone.js", "max_forks_repo_forks_event_min_datetime": "2019-07-12T22:46:49.000Z", "max_forks_repo_forks_event_max_datetime": "2019-07-12T22:46:49.000Z"}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 27.223880597, "max_line_length": 73, "alphanum_fraction": 0.6743421053}
import MetalSynth from "Tone/instrument/MetalSynth";
import Basic from "helper/Basic";
import InstrumentTest from "helper/InstrumentTests";
import CompareToFile from "helper/CompareToFile";
import Supports from "helper/Supports";

describe("MetalSynth", function(){

	Basic(MetalSynth);
	InstrumentTest(MetalSynth);

	if (Supports.CHROME_AUDIO_RENDERING){
		it("matches a file", function(){
			return CompareToFile(function(){
				var synth = new MetalSynth().toMaster();
				synth.triggerAttackRelease(0.1, 0.05);
			}, "metalSynth.wav", 7.4);
		});
	}

	context("API", function(){

		it("can be constructed with octave and harmonicity values", function(){
			var cymbal = new MetalSynth({
				"octaves" : 0.4,
				"resonance" : 2300,
				"harmonicity" : 3.1
			});
			expect(cymbal.harmonicity).to.be.closeTo(3.1, 0.01);
			expect(cymbal.resonance).to.be.closeTo(2300, 0.01);
			expect(cymbal.octaves).to.be.closeTo(0.4, 0.01);
			cymbal.dispose();
		});

		it("can get and set envelope attributes", function(){
			var cymbal = new MetalSynth();
			cymbal.envelope.attack = 0.024;
			cymbal.envelope.decay = 0.9;
			expect(cymbal.envelope.attack).to.equal(0.024);
			expect(cymbal.envelope.decay).to.equal(0.9);
			cymbal.dispose();
		});

		it("can set the modulationIndex", function(){
			var cymbal = new MetalSynth();
			cymbal.modulationIndex = 82;
			expect(cymbal.modulationIndex).to.be.closeTo(82, 0.01);
			cymbal.dispose();
		});

		it("can get/set attributes", function(){
			var cymbal = new MetalSynth();
			cymbal.set({
				"frequency" : 120
			});
			expect(cymbal.get().frequency).to.be.closeTo(120, 0.01);
			cymbal.harmonicity = 2;
			expect(cymbal.harmonicity).to.be.closeTo(2, 0.01);
			cymbal.resonance = 2222;
			expect(cymbal.resonance).to.be.closeTo(2222, 1);
			cymbal.dispose();
		});

	});
});

