aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorunknown <dm2515@eews303a-003.ic.ac.uk>2018-03-08 15:47:51 +0000
committerunknown <dm2515@eews303a-003.ic.ac.uk>2018-03-08 15:47:51 +0000
commitf6589be8581dfc9b967777bca05c60d478feb796 (patch)
tree59bd4494d99819cfbdf48270fbb2599d8c6197d6
parentcfbb5c75a314b78bd45ca87506d8513f26ff09e9 (diff)
parentf511b9c433e0ff7bf71b0213473555818bacc85e (diff)
downloadNoiseSilencer-f6589be8581dfc9b967777bca05c60d478feb796.tar.gz
NoiseSilencer-f6589be8581dfc9b967777bca05c60d478feb796.zip
[merging]
-rw-r--r--Project/RTDSP/.launches/RTDSP.launch8
-rw-r--r--Project/RTDSP/enhance.c55
2 files changed, 26 insertions, 37 deletions
diff --git a/Project/RTDSP/.launches/RTDSP.launch b/Project/RTDSP/.launches/RTDSP.launch
index 4e7c341..5a533d8 100644
--- a/Project/RTDSP/.launches/RTDSP.launch
+++ b/Project/RTDSP/.launches/RTDSP.launch
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="com.ti.ccstudio.debug.core.CCELaunchType">
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;sourceLookupDirector&gt;&#13;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;default/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#13;&#10;&lt;/sourceContainers&gt;&#13;&#10;&lt;/sourceLookupDirector&gt;&#13;&#10;"/>
-<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<booleanAttribute key="com.ti.ccstudio.debug.core.MRU_PROGRAM_S_ONLY" value="false"/>
+<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="com.ti.ccstudio.debug.core.CCEDebugger"/>
<stringAttribute key="CCEDebugOptions.CPU_RESOLVE_OPTION" value="exact"/>
<stringAttribute key="org.eclipse.debug.ui.DISPLAY_NAME" value="RTDSP [Debug] - Spectrum Digital DSK-EVM-eZdsp onboard USB Emulator_0/TMS320C671X"/>
@@ -12,8 +12,8 @@
<stringAttribute key="com.ti.ccstudio.debug.core.DISPLAY_NAME_FORMAT" value="RTDSP [Debug] - {0}"/>
<stringAttribute key="CCEDebugOptions.TARGET_CONFIGURATION_OPTION" value="full"/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList/&gt;&#13;&#10;"/>
-<stringAttribute key="com.ti.ccstudio.debug.core.MRU_PROGRAM_NAME" value="C:\GIT\RTDSP\Project\RTDSP\Debug\RTDSP.out"/>
-<stringAttribute key="com.ti.ccstudio.debug.core.MRU_MODULES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;modules&gt;&#13;&#10;&lt;module name=&quot;C:\GIT\RTDSP\lab3\RTDSP\Debug\RTDSP.out&quot; time=&quot;Fri Jan 19 14:07:28 GMT 2018&quot; time_long=&quot;1516370848357&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\Github\RTDSP\lab3\RTDSP\Debug\RTDSP.out&quot; time=&quot;Tue Jan 23 11:15:11 GMT 2018&quot; time_long=&quot;1516706111426&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\GIT\RTDSP\lab4\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Feb 01 11:44:21 GMT 2018&quot; time_long=&quot;1517485461898&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\github\RTDSP\lab4\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Feb 15 13:55:55 GMT 2018&quot; time_long=&quot;1518702955359&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\Github\RTDSP\lab5\RTDSP\Debug\RTDSP.out&quot; time=&quot;Tue Feb 27 12:18:55 GMT 2018&quot; time_long=&quot;1519733935329&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\github\RTDSP\lab5\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Mar 01 13:36:20 GMT 2018&quot; time_long=&quot;1519911380476&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\github\RTDSP\Project\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Mar 08 12:40:39 GMT 2018&quot; time_long=&quot;1520512839256&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\GIT\RTDSP\Project\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Mar 08 14:26:22 GMT 2018&quot; time_long=&quot;1520519182099&quot;/&gt;&#13;&#10;&lt;/modules&gt;&#13;&#10;"/>
+<stringAttribute key="com.ti.ccstudio.debug.core.MRU_PROGRAM_NAME" value="C:\github\RTDSP\Project\RTDSP\Debug\RTDSP.out"/>
+<stringAttribute key="com.ti.ccstudio.debug.core.MRU_MODULES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;modules&gt;&#13;&#10;&lt;module name=&quot;C:\GIT\RTDSP\lab3\RTDSP\Debug\RTDSP.out&quot; time=&quot;Fri Jan 19 14:07:28 GMT 2018&quot; time_long=&quot;1516370848357&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\Github\RTDSP\lab3\RTDSP\Debug\RTDSP.out&quot; time=&quot;Tue Jan 23 11:15:11 GMT 2018&quot; time_long=&quot;1516706111426&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\GIT\RTDSP\lab4\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Feb 01 11:44:21 GMT 2018&quot; time_long=&quot;1517485461898&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\github\RTDSP\lab4\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Feb 15 13:55:55 GMT 2018&quot; time_long=&quot;1518702955359&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\Github\RTDSP\lab5\RTDSP\Debug\RTDSP.out&quot; time=&quot;Tue Feb 27 12:18:55 GMT 2018&quot; time_long=&quot;1519733935329&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\github\RTDSP\lab5\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Mar 01 13:36:20 GMT 2018&quot; time_long=&quot;1519911380476&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\github\RTDSP\Project\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Mar 08 15:31:06 GMT 2018&quot; time_long=&quot;1520523066763&quot;/&gt;&#13;&#10;&lt;module name=&quot;C:\GIT\RTDSP\Project\RTDSP\Debug\RTDSP.out&quot; time=&quot;Thu Mar 08 15:45:03 GMT 2018&quot; time_long=&quot;1520523903840&quot;/&gt;&#13;&#10;&lt;/modules&gt;&#13;&#10;"/>
<stringAttribute key="CCEDebugOptions.CPU_NAME" value="Spectrum Digital DSK-EVM-eZdsp onboard USB Emulator_0/TMS320C671X"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="RTDSP"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;globalVariableList/&gt;&#13;&#10;"/>
@@ -21,6 +21,6 @@
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/RTDSP.out"/>
<stringAttribute key="CCEDebugOptions.CPU_ISA" value="TMS320C671X"/>
<stringAttribute key="com.ti.ccstudio.debug.core.BUILD_CONFIGURATION" value="Debug"/>
-<stringAttribute key="CCEDebugOptions.TARGET_CONFIGURATION_FILE" value="C:\GIT\RTDSP\Project\RTDSP\NewTargetConfiguration.ccxml"/>
+<stringAttribute key="CCEDebugOptions.TARGET_CONFIGURATION_FILE" value="C:\github\RTDSP\Project\RTDSP\NewTargetConfiguration.ccxml"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="com.ti.ccstudio.debug.core.sourceLocator"/>
</launchConfiguration>
diff --git a/Project/RTDSP/enhance.c b/Project/RTDSP/enhance.c
index 5422bcd..45a0060 100644
--- a/Project/RTDSP/enhance.c
+++ b/Project/RTDSP/enhance.c
@@ -80,11 +80,6 @@ DSK6713_AIC23_Config Config = { \
/**********************************************************************/
};
-typedef struct {
- float *pow;
- float sum;
-} MVal;
-
// Codec handle:- a variable used to identify audio interface
DSK6713_AIC23_CodecHandle H_Codec;
@@ -105,7 +100,8 @@ volatile int m_ptr = 0;
float lambda = 0.05;
float alpha = 100;
double avg = 0;
-MVal M[NUM_M];
+float *M[NUM_M];
+float mag_N_X;
float K;
static float time_constant = 40e-3; /* Time constant in ms */
int started = 0;
@@ -133,8 +129,10 @@ void main()
outwin = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */
fft_out = (complex *) calloc(FFTLEN, sizeof(complex)); /* FFT Output */
power_in = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */
- mag_in = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */
lpf = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */
+ mag_in = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */
+ noise = (float *) calloc(FFTLEN, sizeof(float)); /* Output window */
+
/* initialize board and the audio port */
init_hardware();
@@ -152,12 +150,7 @@ void main()
outgain=OUTGAIN;
for (k = 0; k < NUM_M; ++k) {
- int i;
- M[k].pow = (float *) calloc(FFTLEN, sizeof(float));
- for(i = 0; i < FFTLEN; ++i) {
- M[k].pow[i] = MAX_FLOAT;
- }
- M[k].sum = MAX_FLOAT;
+ M[k] = (float *) calloc(FFTLEN, sizeof(float));
}
K = exp(-TFRAME/time_constant);
@@ -204,30 +197,29 @@ void init_HWI(void)
// Spectrum calculations for the new values
void write_spectrum(void) {
unsigned int k;
- M[m_ptr].sum = 0;
for(k = 0; k < FFTLEN; ++k) {
- if(power_in[k] < M[m_ptr].pow[k] && power_in[k] != 0) {
- M[m_ptr].pow[k] = power_in[k];
- M[m_ptr].sum += power_in[k];
- } else {
- M[m_ptr].sum += M[m_ptr].pow[k];
+ if(power_in[k] < M[m_ptr][k] || M[m_ptr][k] == 0) {
+ M[m_ptr][k] = power_in[k];
}
}
}
// Noise estimataion
void get_noise(void) {
- float min_sum = M[0].sum;
- int min_index = 0, k;
+ int k, i, min_i;
+ float min_val;
- for(k = 1; k < NUM_M; ++k) {
- if (M[k].sum < min_sum) {
- min_sum = M[k].sum;
- min_index = k;
+ for(k = 0; k < FFTLEN; ++k) {
+ min_i = 0;
+ min_val = M[0][k];
+ for(i = 1; i < NUM_M; ++i) {
+ if (M[i][k] < min_val && M[i][k]!= 0) {
+ min_val = M[i][k];
+ min_i = i;
+ }
}
+ noise[k] = alpha * M[min_i][k];
}
-
- noise = M[min_index].pow;
}
@@ -247,7 +239,6 @@ void process_frame(void)
{
int k, m;
int io_ptr0;
- float mag_N_X;
/* work out fraction of available CPU time used by algorithm */
cpufrac = ((float) (io_ptr & (FRAMEINC - 1)))/FRAMEINC;
@@ -282,7 +273,7 @@ void process_frame(void)
// calculate the power spectrum
for (k = 0; k < FFTLEN; ++k) {
- power_in[k] = pow(fft_out[k].r, 2) + pow(fft_out[k].i, 2);
+ power_in[k] = sqrt(fft_out[k].r * fft_out[k].r + fft_out[k].i * fft_out[k].i);
}
//low_pass_filter();
@@ -297,17 +288,15 @@ void process_frame(void)
int i;
frame_ctr = 0;
if(++m_ptr == NUM_M) m_ptr = 0;
- M[m_ptr].sum = 0;
for(i = 0; i < FFTLEN; ++i) {
- M[m_ptr].pow[i] = power_in[i];
- M[m_ptr].sum += power_in[i];
+ M[m_ptr][i] = power_in[i];
}
}
// max(lambda, |N(w)/g(w)|
for (k = 0; k < FFTLEN; ++k) {
float g;
- mag_N_X = sqrt(1 - alpha * noise[k]/power_in[k]);
+ mag_N_X = 1 - noise[k]/power_in[k];
g = mag_N_X > lambda ? mag_N_X : lambda;
fft_out[k] = rmul(g, fft_out[k]);
}