MCPcopy Create free account
hub / github.com/Audio4Linux/JDSP4Linux / checkStartEnd

Function checkStartEnd

libjamesdsp/JdspImpResToolbox.c:116–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114 return 0;
115}
116void checkStartEnd(float **signal, int channels, int nsamples, float normalizedDbCutoff1, float normalizedDbCutoff2, int range[2])
117{
118 int i, j;
119 float max = fabsf(signal[0][0]);
120 for (i = 0; i < channels; i++)
121 {
122 for (j = 1; j < nsamples; j++)
123 {
124 if (fabsf(signal[i][j]) > max)
125 max = signal[i][j];
126 }
127 }
128 max = 1.0f / ((max < FLT_EPSILON) ? (max + FLT_EPSILON) : max);
129 float linGain1 = powf(10.0f, normalizedDbCutoff1 / 20.0f);
130 float linGain2 = powf(10.0f, normalizedDbCutoff2 / 20.0f);
131 int firstSmps = 0;
132 int lastSmps = 0;
133 int firstSmpsPrevious = nsamples - 1;
134 int lastSmpsPrevious = 0;
135 float normalized;
136 int found;
137 for (i = 0; i < channels; i++)
138 {
139 found = 0;
140 firstSmps = 0;
141 for (j = 0; j < nsamples; j++)
142 {
143 normalized = fabsf(signal[i][j]) * max;
144 if (!found)
145 {
146 if (normalized > linGain1)
147 {
148 if (!firstSmps)
149 {
150 firstSmps = j;
151 found = 1;
152 }
153 }
154 }
155 if (normalized > linGain2)
156 lastSmps = j;
157 }
158 firstSmpsPrevious = (firstSmpsPrevious < firstSmps) ? firstSmpsPrevious : firstSmps;
159 lastSmpsPrevious = (lastSmpsPrevious > lastSmps) ? lastSmpsPrevious : lastSmps;
160 }
161 range[0] = firstSmpsPrevious != (nsamples - 1) ? firstSmpsPrevious : 0;
162 range[1] = lastSmpsPrevious + 1;
163}
164#include "Effects/eel2/numericSys/libsamplerate/samplerate.h"
165//#define DRMP3_IMPLEMENTATION
166#include "Effects/eel2/dr_mp3.h"

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected