OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 fftFrame.doInverseFFT(channel->mutableData()); | 106 fftFrame.doInverseFFT(channel->mutableData()); |
107 | 107 |
108 return channel.release(); | 108 return channel.release(); |
109 } | 109 } |
110 | 110 |
111 // Interpolates two kernels with x: 0 -> 1 and returns the result. | 111 // Interpolates two kernels with x: 0 -> 1 and returns the result. |
112 PassRefPtr<HRTFKernel> HRTFKernel::createInterpolatedKernel(HRTFKernel* kernel1,
HRTFKernel* kernel2, float x) | 112 PassRefPtr<HRTFKernel> HRTFKernel::createInterpolatedKernel(HRTFKernel* kernel1,
HRTFKernel* kernel2, float x) |
113 { | 113 { |
114 ASSERT(kernel1 && kernel2); | 114 ASSERT(kernel1 && kernel2); |
115 if (!kernel1 || !kernel2) | 115 if (!kernel1 || !kernel2) |
116 return 0; | 116 return nullptr; |
117 | 117 |
118 ASSERT(x >= 0.0 && x < 1.0); | 118 ASSERT(x >= 0.0 && x < 1.0); |
119 x = min(1.0f, max(0.0f, x)); | 119 x = min(1.0f, max(0.0f, x)); |
120 | 120 |
121 float sampleRate1 = kernel1->sampleRate(); | 121 float sampleRate1 = kernel1->sampleRate(); |
122 float sampleRate2 = kernel2->sampleRate(); | 122 float sampleRate2 = kernel2->sampleRate(); |
123 ASSERT(sampleRate1 == sampleRate2); | 123 ASSERT(sampleRate1 == sampleRate2); |
124 if (sampleRate1 != sampleRate2) | 124 if (sampleRate1 != sampleRate2) |
125 return 0; | 125 return nullptr; |
126 | 126 |
127 float frameDelay = (1 - x) * kernel1->frameDelay() + x * kernel2->frameDelay
(); | 127 float frameDelay = (1 - x) * kernel1->frameDelay() + x * kernel2->frameDelay
(); |
128 | 128 |
129 OwnPtr<FFTFrame> interpolatedFrame = FFTFrame::createInterpolatedFrame(*kern
el1->fftFrame(), *kernel2->fftFrame(), x); | 129 OwnPtr<FFTFrame> interpolatedFrame = FFTFrame::createInterpolatedFrame(*kern
el1->fftFrame(), *kernel2->fftFrame(), x); |
130 return HRTFKernel::create(interpolatedFrame.release(), frameDelay, sampleRat
e1); | 130 return HRTFKernel::create(interpolatedFrame.release(), frameDelay, sampleRat
e1); |
131 } | 131 } |
132 | 132 |
133 } // namespace WebCore | 133 } // namespace WebCore |
134 | 134 |
135 #endif // ENABLE(WEB_AUDIO) | 135 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |