| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 232 } |
| 233 | 233 |
| 234 // We must access m_periodicWave only inside the lock. | 234 // We must access m_periodicWave only inside the lock. |
| 235 if (!m_periodicWave.get()) { | 235 if (!m_periodicWave.get()) { |
| 236 outputBus->zero(); | 236 outputBus->zero(); |
| 237 return; | 237 return; |
| 238 } | 238 } |
| 239 | 239 |
| 240 size_t quantumFrameOffset; | 240 size_t quantumFrameOffset; |
| 241 size_t nonSilentFramesToProcess; | 241 size_t nonSilentFramesToProcess; |
| 242 double startFrameOffset; |
| 242 | 243 |
| 243 updateSchedulingInfo(framesToProcess, outputBus, quantumFrameOffset, | 244 updateSchedulingInfo(framesToProcess, outputBus, quantumFrameOffset, |
| 244 nonSilentFramesToProcess); | 245 nonSilentFramesToProcess, startFrameOffset); |
| 245 | 246 |
| 246 if (!nonSilentFramesToProcess) { | 247 if (!nonSilentFramesToProcess) { |
| 247 outputBus->zero(); | 248 outputBus->zero(); |
| 248 return; | 249 return; |
| 249 } | 250 } |
| 250 | 251 |
| 251 unsigned periodicWaveSize = m_periodicWave->periodicWaveSize(); | 252 unsigned periodicWaveSize = m_periodicWave->periodicWaveSize(); |
| 252 double invPeriodicWaveSize = 1.0 / periodicWaveSize; | 253 double invPeriodicWaveSize = 1.0 / periodicWaveSize; |
| 253 | 254 |
| 254 float* destP = outputBus->channel(0)->mutableData(); | 255 float* destP = outputBus->channel(0)->mutableData(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 279 | 280 |
| 280 float incr = frequency * rateScale; | 281 float incr = frequency * rateScale; |
| 281 float* phaseIncrements = m_phaseIncrements.data(); | 282 float* phaseIncrements = m_phaseIncrements.data(); |
| 282 | 283 |
| 283 unsigned readIndexMask = periodicWaveSize - 1; | 284 unsigned readIndexMask = periodicWaveSize - 1; |
| 284 | 285 |
| 285 // Start rendering at the correct offset. | 286 // Start rendering at the correct offset. |
| 286 destP += quantumFrameOffset; | 287 destP += quantumFrameOffset; |
| 287 int n = nonSilentFramesToProcess; | 288 int n = nonSilentFramesToProcess; |
| 288 | 289 |
| 290 // If startFrameOffset is not 0, that means the oscillator doesn't actually |
| 291 // start at quantumFrameOffset, but just past that time. Adjust destP and n |
| 292 // to reflect that, and adjust virtualReadIndex to start the value at |
| 293 // startFrameOffset. |
| 294 if (startFrameOffset > 0) { |
| 295 ++destP; |
| 296 --n; |
| 297 virtualReadIndex += (1 - startFrameOffset) * frequency * rateScale; |
| 298 DCHECK(virtualReadIndex < periodicWaveSize); |
| 299 } else if (startFrameOffset < 0) { |
| 300 virtualReadIndex = -startFrameOffset * frequency * rateScale; |
| 301 } |
| 302 |
| 289 while (n--) { | 303 while (n--) { |
| 290 unsigned readIndex = static_cast<unsigned>(virtualReadIndex); | 304 unsigned readIndex = static_cast<unsigned>(virtualReadIndex); |
| 291 unsigned readIndex2 = readIndex + 1; | 305 unsigned readIndex2 = readIndex + 1; |
| 292 | 306 |
| 293 // Contain within valid range. | 307 // Contain within valid range. |
| 294 readIndex = readIndex & readIndexMask; | 308 readIndex = readIndex & readIndexMask; |
| 295 readIndex2 = readIndex2 & readIndexMask; | 309 readIndex2 = readIndex2 & readIndexMask; |
| 296 | 310 |
| 297 if (hasSampleAccurateValues) { | 311 if (hasSampleAccurateValues) { |
| 298 incr = *phaseIncrements++; | 312 incr = *phaseIncrements++; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 | 458 |
| 445 AudioParam* OscillatorNode::detune() { | 459 AudioParam* OscillatorNode::detune() { |
| 446 return m_detune; | 460 return m_detune; |
| 447 } | 461 } |
| 448 | 462 |
| 449 void OscillatorNode::setPeriodicWave(PeriodicWave* wave) { | 463 void OscillatorNode::setPeriodicWave(PeriodicWave* wave) { |
| 450 oscillatorHandler().setPeriodicWave(wave); | 464 oscillatorHandler().setPeriodicWave(wave); |
| 451 } | 465 } |
| 452 | 466 |
| 453 } // namespace blink | 467 } // namespace blink |
| OLD | NEW |