Skip to content

Commit

Permalink
Added more examples and test results
Browse files Browse the repository at this point in the history
  • Loading branch information
szarvas committed Nov 12, 2016
1 parent 6322f2c commit 70ee7d7
Show file tree
Hide file tree
Showing 14 changed files with 32,719 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#About

![Sound pressure in a room](examples/nice.png)
![Sound pressure in a room](examples/test_results/nice.png)

**anc-field** is a collection of utilities for simulating active noise cancelling in room acoustic environments. All original content is released under the GNU GPL v3 license. Contents of the `anc-field` directory describe a high-performance core written in C++11 and OpenCL 1.1. The binary program can be used through a command line interface, but it is recommended to use the high-level Python wrapper instead.

Expand Down
4 changes: 1 addition & 3 deletions anc_field_py/ancutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
import numpy as np
from scipy import signal

def EstimateIr(input, output, N, mu):
def EstimateIr(input, output, N, mu=1e-4):
W = np.zeros(N)

for m in range(0,16):
steps = min(np.size(input, 0), np.size(output, 0))
# mu = 1e-4

x_buf = np.zeros(N)

for k in range(0, steps):
Expand Down
8 changes: 7 additions & 1 deletion examples/dsp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import division

import numpy as np
Expand All @@ -15,7 +16,7 @@
# this folder will contain a Kerkythea model named `model.xml`
# and the `material_a.dat`, `material_b.dat` files pertaining
# to the materials referenced in it.
anc = AncField('cpu', 'models/dsp')
anc = AncField('gpu', 'models/dsp')

# Place a microphone at position x=3, y=1, z=1 in meters.
# The acoustic pressure at this point will be recorder, and
Expand Down Expand Up @@ -48,3 +49,8 @@

# Let's save the impulse response so that we can use it later
np.savetxt('dsp_ir.dat', h)

# Let's take a look at the IR
# It should look something like `dsp_ir_plot.png`
plt.plot(h)
plt.show()
47 changes: 37 additions & 10 deletions examples/ie224.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,46 @@
import matplotlib.pyplot as plt
from scipy import signal, stats

from ancfield import *
from ancutil import *
import sys
sys.path.append('..')

anc = AncField('cpu', 'models/ie224')
from anc_field_py.ancfield import *
from anc_field_py.ancutil import *

def add_microphones(ancObject):
# error_mic
ancObject.AddMic([4,1.6,5.3])

# reference_front
ancObject.AddMic([4,1.6,4.5])

# reference_back
ancObject.AddMic([4,1.6,6.5])

# reference_left
ancObject.AddMic([3,1.6,5.5])

# reference_right
ancObject.AddMic([5,1.6,5.5])

# reference_bottom
ancObject.AddMic([4,0.6,5.5])

# reference top
ancObject.AddMic([4,2.6,5.5])

return ancObject

# We create a simulation and immeatealy add microphones to it
anc = add_microphones(AncField('cpu', 'models/ie224'))

# noise_source
anc.AddSource([4,1.6,1.0], bandnoise([100,2000], 11*32000, 32000))
anc.AddMic([4,1.6,5.3])
anc.AddMic([4,1.6,4.5])
anc.AddMic([4,1.6,6.5])
anc.AddMic([3,1.6,5.5])
anc.AddMic([5,1.6,5.5])
anc.AddMic([4,0.6,5.5])
anc.AddMic([4,2.6,5.5])

anc.Visualize(1.6)
(x,y) = anc.Run(10)

#h = EstimateIr(x[0,:], y, anc.fs)
#np.savetxt('h_'+sim+'.dat', h)
#h = EstimateIr(x[0::4], y[6,0::4], 3*8e3, 1e-4)
#savetxt('noise_to_reference_bottom.dat', h)
Binary file added examples/models/dsp/dsp.wings
Binary file not shown.
Binary file added examples/models/ie224/ie224.wings
Binary file not shown.
Loading

0 comments on commit 70ee7d7

Please sign in to comment.