| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 84 } |
| 85 | 85 |
| 86 float DynamicsCompressor::parameterValue(unsigned parameterID) { | 86 float DynamicsCompressor::parameterValue(unsigned parameterID) { |
| 87 ASSERT(parameterID < ParamLast); | 87 ASSERT(parameterID < ParamLast); |
| 88 return m_parameters[parameterID]; | 88 return m_parameters[parameterID]; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void DynamicsCompressor::process(const AudioBus* sourceBus, | 91 void DynamicsCompressor::process(const AudioBus* sourceBus, |
| 92 AudioBus* destinationBus, | 92 AudioBus* destinationBus, |
| 93 unsigned framesToProcess) { | 93 unsigned framesToProcess) { |
| 94 // Though numberOfChannels is retrived from destinationBus, we still name it n
umberOfChannels instead of numberOfDestinationChannels. | 94 // Though numberOfChannels is retrived from destinationBus, we still name it |
| 95 // It's because we internally match sourceChannels's size to destinationBus by
channel up/down mix. Thus we need numberOfChannels | 95 // numberOfChannels instead of numberOfDestinationChannels. It's because we |
| 96 // internally match sourceChannels's size to destinationBus by channel |
| 97 // up/down mix. Thus we need numberOfChannels |
| 96 // to do the loop work for both m_sourceChannels and m_destinationChannels. | 98 // to do the loop work for both m_sourceChannels and m_destinationChannels. |
| 97 | 99 |
| 98 unsigned numberOfChannels = destinationBus->numberOfChannels(); | 100 unsigned numberOfChannels = destinationBus->numberOfChannels(); |
| 99 unsigned numberOfSourceChannels = sourceBus->numberOfChannels(); | 101 unsigned numberOfSourceChannels = sourceBus->numberOfChannels(); |
| 100 | 102 |
| 101 ASSERT(numberOfChannels == m_numberOfChannels && numberOfSourceChannels); | 103 ASSERT(numberOfChannels == m_numberOfChannels && numberOfSourceChannels); |
| 102 | 104 |
| 103 if (numberOfChannels != m_numberOfChannels || !numberOfSourceChannels) { | 105 if (numberOfChannels != m_numberOfChannels || !numberOfSourceChannels) { |
| 104 destinationBus->zero(); | 106 destinationBus->zero(); |
| 105 return; | 107 return; |
| 106 } | 108 } |
| 107 | 109 |
| 108 switch (numberOfChannels) { | 110 switch (numberOfChannels) { |
| 109 case 2: // stereo | 111 case 2: // stereo |
| 110 m_sourceChannels[0] = sourceBus->channel(0)->data(); | 112 m_sourceChannels[0] = sourceBus->channel(0)->data(); |
| 111 | 113 |
| 112 if (numberOfSourceChannels > 1) | 114 if (numberOfSourceChannels > 1) |
| 113 m_sourceChannels[1] = sourceBus->channel(1)->data(); | 115 m_sourceChannels[1] = sourceBus->channel(1)->data(); |
| 114 else | 116 else |
| 115 // Simply duplicate mono channel input data to right channel for stereo
processing. | 117 // Simply duplicate mono channel input data to right channel for stereo |
| 118 // processing. |
| 116 m_sourceChannels[1] = m_sourceChannels[0]; | 119 m_sourceChannels[1] = m_sourceChannels[0]; |
| 117 | 120 |
| 118 break; | 121 break; |
| 119 default: | 122 default: |
| 120 // FIXME : support other number of channels. | 123 // FIXME : support other number of channels. |
| 121 ASSERT_NOT_REACHED(); | 124 ASSERT_NOT_REACHED(); |
| 122 destinationBus->zero(); | 125 destinationBus->zero(); |
| 123 return; | 126 return; |
| 124 } | 127 } |
| 125 | 128 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 137 m_lastAnchor = anchor; | 140 m_lastAnchor = anchor; |
| 138 } | 141 } |
| 139 | 142 |
| 140 float dbThreshold = parameterValue(ParamThreshold); | 143 float dbThreshold = parameterValue(ParamThreshold); |
| 141 float dbKnee = parameterValue(ParamKnee); | 144 float dbKnee = parameterValue(ParamKnee); |
| 142 float ratio = parameterValue(ParamRatio); | 145 float ratio = parameterValue(ParamRatio); |
| 143 float attackTime = parameterValue(ParamAttack); | 146 float attackTime = parameterValue(ParamAttack); |
| 144 float releaseTime = parameterValue(ParamRelease); | 147 float releaseTime = parameterValue(ParamRelease); |
| 145 float preDelayTime = parameterValue(ParamPreDelay); | 148 float preDelayTime = parameterValue(ParamPreDelay); |
| 146 | 149 |
| 147 // This is effectively a master volume on the compressed signal (pre-blending)
. | 150 // This is effectively a master volume on the compressed signal |
| 151 // (pre-blending). |
| 148 float dbPostGain = parameterValue(ParamPostGain); | 152 float dbPostGain = parameterValue(ParamPostGain); |
| 149 | 153 |
| 150 // Linear blending value from dry to completely processed (0 -> 1) | 154 // Linear blending value from dry to completely processed (0 -> 1) |
| 151 // 0 means the signal is completely unprocessed. | 155 // 0 means the signal is completely unprocessed. |
| 152 // 1 mixes in only the compressed signal. | 156 // 1 mixes in only the compressed signal. |
| 153 float effectBlend = parameterValue(ParamEffectBlend); | 157 float effectBlend = parameterValue(ParamEffectBlend); |
| 154 | 158 |
| 155 float releaseZone1 = parameterValue(ParamReleaseZone1); | 159 float releaseZone1 = parameterValue(ParamReleaseZone1); |
| 156 float releaseZone2 = parameterValue(ParamReleaseZone2); | 160 float releaseZone2 = parameterValue(ParamReleaseZone2); |
| 157 float releaseZone3 = parameterValue(ParamReleaseZone3); | 161 float releaseZone3 = parameterValue(ParamReleaseZone3); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 180 | 184 |
| 181 void DynamicsCompressor::setNumberOfChannels(unsigned numberOfChannels) { | 185 void DynamicsCompressor::setNumberOfChannels(unsigned numberOfChannels) { |
| 182 m_sourceChannels = wrapArrayUnique(new const float*[numberOfChannels]); | 186 m_sourceChannels = wrapArrayUnique(new const float*[numberOfChannels]); |
| 183 m_destinationChannels = wrapArrayUnique(new float*[numberOfChannels]); | 187 m_destinationChannels = wrapArrayUnique(new float*[numberOfChannels]); |
| 184 | 188 |
| 185 m_compressor.setNumberOfChannels(numberOfChannels); | 189 m_compressor.setNumberOfChannels(numberOfChannels); |
| 186 m_numberOfChannels = numberOfChannels; | 190 m_numberOfChannels = numberOfChannels; |
| 187 } | 191 } |
| 188 | 192 |
| 189 } // namespace blink | 193 } // namespace blink |
| OLD | NEW |