void Start() { Application.targetFrameRate = 60; c = Constant.CreateDefault(); ImpulseResponses.LoadAll(c); waveAudioClip = WaveAudioClip.CreateWavAudioClip("Bytes/DrumLoop2.wav"); debugButton.AddButton("Drum1", () => { waveAudioClip = WaveAudioClip.CreateWavAudioClip("Bytes/DrumLoop2.wav"); }); debugButton.AddButton("Drum2", () => { waveAudioClip = WaveAudioClip.CreateWavAudioClip("Bytes/TightFunkBreak-mono.wav"); }); debugButton.AddButton("Ochestra\nStrings", () => { waveAudioClip = WaveAudioClip.CreateWavAudioClip("Bytes/OchestraStrings-mono.wav"); }); debugButton.AddButton("Siren", () => { waveAudioClip = WaveAudioClip.CreateWavAudioClip("Bytes/PoliseCarSiren-mono.wav"); }); debugButton.AddButton("Stop", () => { isPlaying = false; audioClipStreamingPlayer.Stop(); }); positionCircle.onTouched += OnTouched; overlapAddLeft = new OverlapAdd(c); overlapAddRight = new OverlapAdd(c); bufferSample = new float[c.blockSamples]; audioClipStreamingPlayer.Initialize(c, this); }
/// <summary> /// ImpulseResponsesテスト /// </summary> private void ImpulseResponsesTest() { if (!impulseResponsesFlg) { return; } debugButton.AddButton("ImpulseResponsesTest", () => { ImpulseResponses.LoadAll(Constant.CreateDefault()); }); }
/// <summary> /// 角度に対応するサウンドデータ取得 /// WebGLでない場合はサブスレッドから実行される /// </summary> public void GetBlockBuffer(int angle, int sampleoffset, AudioClipStreamingPlayer.BlockBuffer buffer) { if (angle >= 0) { ImpulseResponses.Data data; data = ImpulseResponses.GetTransformedImpulseResponse(angle); overlapAddLeft.SetTransformedImpulseResponse(data.channelLX, data.channelLY); overlapAddRight.SetTransformedImpulseResponse(data.channelRX, data.channelRY); } else { overlapAddLeft.SetIdentifyImpulseResponse(); overlapAddRight.SetIdentifyImpulseResponse(); } waveAudioClip.GetData(bufferSample, sampleoffset, c.blockSamples); overlapAddLeft.Convolution(bufferSample); overlapAddRight.Convolution(bufferSample); float[] ret_l = overlapAddLeft.GetConvolution(); float[] ret_r = overlapAddRight.GetConvolution(); Buffer.BlockCopy(ret_l, 0, buffer.left, 0, c.blockSamples * SizeofFloat); Buffer.BlockCopy(ret_r, 0, buffer.right, 0, c.blockSamples * SizeofFloat); }