├── LICENSE
├── README.md
├── audio
├── README.md
├── REC_e_post_smooth_SNR_0dB.wav
├── REC_e_post_smooth_SNR_10dB.wav
├── REC_e_post_smooth_SNR_25dB.wav
├── REC_e_post_smooth_targetSourceOnly.wav
├── REC_y_SNR_0dB.wav
├── REC_y_SNR_10dB.wav
├── REC_y_SNR_25dB.wav
├── REC_y_targetSourceOnly.wav
├── e_post_SNR_0dB.wav
├── e_post_SNR_10dB.wav
├── e_post_SNR_25dB.wav
├── e_post_smooth_SNR_0dB.wav
├── e_post_smooth_SNR_10dB.wav
├── e_post_smooth_SNR_25dB.wav
├── s1.wav
├── v_SNR_0dB.wav
├── v_SNR_10dB.wav
├── v_SNR_25dB.wav
├── x1.wav
├── x2.wav
├── y_SNR_0dB.wav
├── y_SNR_10dB.wav
└── y_SNR_25dB.wav
├── main.m
├── param
└── SQRT_PSD_RETF
│ ├── alpha_sqrtMP.mat
│ └── lap_div.mat
└── tools
├── STFT
├── calc_ISTFT.m
└── calc_STFT.m
├── estim
├── ISCLP_KF
│ ├── ISCLP.m
│ └── ISCLP.m~
└── SQRT_PSD_RETF
│ ├── corrmat
│ ├── estim_corrmat.m
│ ├── forget2tau.m
│ └── tau2forget.m
│ ├── desmooth_GEVD.m
│ ├── estim_PSD_RETF.m
│ └── minprob
│ ├── solve_RETFup.m
│ ├── solve_convMP.m
│ ├── solve_convMP_simple.m
│ └── solve_sqrtMP.m
├── plot
└── plotSpec.m
└── spatial
├── calc_diffcoherence.m
└── doa2steervec.m
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ISCLP-KF
2 | Integrated sidelobe cancellation and linear prediction Kalman filter for joint multi-microphone speech dereverberation, interfering speech cancellation, and noise reduction.
3 |
4 | See main.m for further details.
5 |
6 | See ./audio for audio examples.
7 |
--------------------------------------------------------------------------------
/audio/README.md:
--------------------------------------------------------------------------------
1 |
2 | ==== audio based on simulations, cf. Sec V ====
3 |
4 | * acoustic scenario, cf. Sec. V-C
5 |
6 | number of microphones - 5
7 | inter-microphone distance - 8cm
8 | reverberation time - 0.61s
9 | source 1 - female speech, 2m distance, 0deg rel. to broadside direction
10 | source 2 - male speech, 2m distance, 60deg rel. to broadside direction
11 | noise type - babble noise
12 |
13 |
14 | * audio files (as loaded/generated by main.m)
15 |
16 | x1.wav - reverberant speech component 1, cf. (2)
17 | x2.wav - reverberant speech component 2, cf. (2)
18 | v_SNR_#dB.wav - noise component at #dB SNR, cf. (2)
19 | y_SNR_#dB.wav - microphone signal at #dB SNR, cf. (1)
20 | s1.wav - early source image 1 (target signal), cf. (6)
21 | e_post_SNR_#dB.wav - enhanced signal, posterior, at #dB SNR cf. (42)
22 | e_post_smooth_SNR_#dB.wav - enhanced signal, posterior, smooth, at #dB SNR cf. (44)
23 |
24 |
25 |
26 | ==== audio based on recordings, cf. Sec. VI ====
27 |
28 | * acoustic scenario, cf. Sec. VI
29 |
30 | number of microphones - 5
31 | inter-microphone distance - 8cm
32 | reverberation time - 1.5s
33 | source 1 - male speech, 2m distance, 0deg rel. to broadside direction
34 | source 2 - female speech, 2m distance, 45deg rel. to broadside direction
35 | noise type - babble noise, generated by 8 loudspeakers
36 |
37 | * audio files
38 |
39 | REC_y_targetSourceOnly.wav - microphone signal, in absence of interfering noise and speech, cf. (1)
40 | REC_e_targetSourceOnly.wav - enhanced signal, posterior, smooth, in absence of interfering noise and speech, cf. (44)
41 | REC_y_SNR_#dB.wav - microphone signal at #dB SNR, cf. (1)
42 | REC_e_post_smooth_SNR_#dB.wav - enhanced signal, posterior, smooth, at #dB SNR cf. (44)
43 |
--------------------------------------------------------------------------------
/audio/REC_e_post_smooth_SNR_0dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/REC_e_post_smooth_SNR_0dB.wav
--------------------------------------------------------------------------------
/audio/REC_e_post_smooth_SNR_10dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/REC_e_post_smooth_SNR_10dB.wav
--------------------------------------------------------------------------------
/audio/REC_e_post_smooth_SNR_25dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/REC_e_post_smooth_SNR_25dB.wav
--------------------------------------------------------------------------------
/audio/REC_e_post_smooth_targetSourceOnly.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/REC_e_post_smooth_targetSourceOnly.wav
--------------------------------------------------------------------------------
/audio/REC_y_SNR_0dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/REC_y_SNR_0dB.wav
--------------------------------------------------------------------------------
/audio/REC_y_SNR_10dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/REC_y_SNR_10dB.wav
--------------------------------------------------------------------------------
/audio/REC_y_SNR_25dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/REC_y_SNR_25dB.wav
--------------------------------------------------------------------------------
/audio/REC_y_targetSourceOnly.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/REC_y_targetSourceOnly.wav
--------------------------------------------------------------------------------
/audio/e_post_SNR_0dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/e_post_SNR_0dB.wav
--------------------------------------------------------------------------------
/audio/e_post_SNR_10dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/e_post_SNR_10dB.wav
--------------------------------------------------------------------------------
/audio/e_post_SNR_25dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/e_post_SNR_25dB.wav
--------------------------------------------------------------------------------
/audio/e_post_smooth_SNR_0dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/e_post_smooth_SNR_0dB.wav
--------------------------------------------------------------------------------
/audio/e_post_smooth_SNR_10dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/e_post_smooth_SNR_10dB.wav
--------------------------------------------------------------------------------
/audio/e_post_smooth_SNR_25dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/e_post_smooth_SNR_25dB.wav
--------------------------------------------------------------------------------
/audio/s1.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/s1.wav
--------------------------------------------------------------------------------
/audio/v_SNR_0dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/v_SNR_0dB.wav
--------------------------------------------------------------------------------
/audio/v_SNR_10dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/v_SNR_10dB.wav
--------------------------------------------------------------------------------
/audio/v_SNR_25dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/v_SNR_25dB.wav
--------------------------------------------------------------------------------
/audio/x1.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/x1.wav
--------------------------------------------------------------------------------
/audio/x2.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/x2.wav
--------------------------------------------------------------------------------
/audio/y_SNR_0dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/y_SNR_0dB.wav
--------------------------------------------------------------------------------
/audio/y_SNR_10dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/y_SNR_10dB.wav
--------------------------------------------------------------------------------
/audio/y_SNR_25dB.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/audio/y_SNR_25dB.wav
--------------------------------------------------------------------------------
/main.m:
--------------------------------------------------------------------------------
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 | % Copyright 2019 Thomas Dietzen
3 | %
4 | % This software is distributed under the terms of the GNU Public License
5 | % version 3 (http://www.gnu.org/licenses/gpl.txt).
6 | %
7 | % If you find it useful, please cite:
8 | %
9 | % [1] T. Dietzen, S. Doclo, M. Moonen, and T. van Waterschoot, “Integrated
10 | % sidelobe cancellation and linear prediction Kalman filter for joint
11 | % multimicrophone dereverberation, interfering speech cancellation, and
12 | % noise reduction,” IEEE/ACM Trans. Audio, Speech, Lang. Process., vol. 28,
13 | % pp. 740 – 754, Jan. 2020.
14 | % [2] T. Dietzen, S. Doclo, M. Moonen, and T. van Waterschoot, “Square
15 | % root-based multi-source early PSD estimation and recursive RETF update
16 | % in reverberant environments by means of the orthogonal Procrustes
17 | % problem,” IEEE/ACM Trans. Audio, Speech, Lang. Process., vol. 28,
18 | % pp. 755 – 769, Jan. 2020.
19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20 |
21 | % Example of the ISCLP Kalman filter as described in [1]. The code in
22 | % contained main.m requests an SNR vaule by the user, loads microphone
23 | % signals, estimates early PSDs and updates RETFs using [2] (see also
24 | % https://github.com/tdietzen/SQRT-PSD-RETF), runs the ISCLP Kalman filter,
25 | % and plays back the enhanced signal.
26 |
27 |
28 | %% PREAMBLE
29 |
30 | clear;
31 | cd(fileparts(mfilename('fullpath')));
32 | addpath(genpath(pwd));
33 | set(0,'DefaultFigureWindowStyle','docked');
34 |
35 |
36 | %% CONFIGURATION
37 |
38 | %%% ACOUSTIC SETTINGS
39 |
40 | % speed of sound
41 | c = 340;
42 | % microphone positions
43 | micPos = [...
44 | 0, 0;...
45 | 0.08, 0;...
46 | 0.16, 0;...
47 | 0.24, 0;...
48 | 0.32, 0;...
49 | ];
50 | % number of microphones
51 | M = size(micPos,1);
52 | % source angles
53 | sourceAng = [0 60];
54 | % SNR
55 | SNR = input('which SNR/dB? ');
56 | % microphone signal components
57 | x1_TD = audioread(['.' filesep 'audio' filesep 'x1.wav']);
58 | s1_TD = audioread(['.' filesep 'audio' filesep 's1.wav']);
59 | x2_TD = audioread(['.' filesep 'audio' filesep 'x2.wav']);
60 | v_TD_SNR_0dB = audioread(['.' filesep 'audio' filesep 'v_SNR_0dB.wav']);
61 | v_TD_SNR_scaled = db2mag(-SNR)*v_TD_SNR_0dB;
62 | y_TD = x1_TD + x2_TD + v_TD_SNR_scaled;
63 |
64 | %%% ALGORITHMIC SETTINGS
65 |
66 | %%% STFT
67 | % sample rate
68 | fs = 16000;
69 | % STFT parameters
70 | N_STFT = 512;
71 | R_STFT = N_STFT/2;
72 | win = sqrt(hann(N_STFT,'periodic'));
73 | N_STFT_half = floor(N_STFT/2)+1;
74 | % frequency vector
75 | f = linspace(0,fs/2,N_STFT_half);
76 |
77 | %%% ISCLP Kalman filter [1]
78 | % prediction length
79 | L = 6;
80 | % forgetting factor alpha
81 | alpha_ISCLP_KF = 1-db2pow(-25);
82 | A = sqrt(alpha_ISCLP_KF);
83 | % LP filter variance
84 | psi_wLP = db2pow(-4);
85 | % SC filter variance
86 | psi_wSC = db2pow(linspace(0,-15,257));
87 | % build Psi_w_tilde_init and Psi_w_delta
88 | psi_LP_init = kron((psi_wLP.^(1:L-1)).', ones(M,1));
89 | Psi_w_tilde_init = cell(N_STFT_half,1);
90 | Psi_w_delta = cell(N_STFT_half,1);
91 | for k = 1:N_STFT_half
92 | Psi_w_tilde_init{k} = diag([psi_wSC(k)*ones(M-1,1); psi_LP_init]);
93 | Psi_w_delta{k} = (1-alpha_ISCLP_KF)*Psi_w_tilde_init{k};
94 | end
95 | % gain decay limitation
96 | beta_SCLP_KF = db2mag(-2);
97 |
98 | %%% PSD estimation and RETF update [2]
99 | % forgetting factor zeta
100 | zeta = tau2forget(2*M*R_STFT/fs, R_STFT, fs);
101 | % laplace coefficients of speech per frequency bin
102 | tmp = load('lap_div.mat');
103 | lap_div = tmp.lap_div;
104 | % RETF updating threshold
105 | xi_thresh = db2pow(-2);
106 | % penelty factor alpha
107 | tmp = load('alpha_sqrtMP.mat');
108 | alpha_SQRT_PSD_RETF = tmp.alpha_sqrtMP;
109 | % initial RETFs
110 | H_init_FT = doa2steervec(micPos, sourceAng, N_STFT_half, fs, c);
111 | % diffuse coherence matrix
112 | Gamma = calc_diffcoherence(micPos,N_STFT,fs,c,1e-3);
113 |
114 |
115 | %%% FIGURE SETTINGS
116 |
117 | % spectogram figure settings
118 | xTickProp = [0, R_STFT/fs, fs/R_STFT];
119 | yTickProp = [0, fs/(2000*R_STFT), R_STFT/2];
120 | cRange = [-55 5];
121 |
122 |
123 | %% STFT PROCESSING
124 |
125 | % transform
126 | y_STFT = calc_STFT(y_TD, fs, win, N_STFT, R_STFT, 'onesided');
127 | s1_STFT = calc_STFT(s1_TD, fs, win, N_STFT, R_STFT, 'onesided');
128 |
129 | % plot
130 | figure('Name',['microphone signal, SNR = ' num2str(SNR) 'dB']);
131 | plotSpec(y_STFT(:,:,1), 'mag', xTickProp, yTickProp, cRange, 0); title(['y, SNR = ' num2str(SNR) 'dB']); ylabel('f/kHz');
132 | figure('Name','target signal');
133 | plotSpec(s1_STFT(:,:,1), 'mag', xTickProp, yTickProp, cRange, 0); title('s1'); ylabel('f/kHz');
134 | drawnow;
135 |
136 |
137 | %% EARLY PSD ESTIMATION, RETF UPDATE [2]
138 |
139 | fprintf(' * estimate early PSDs, update RETFs [2]...\n');
140 |
141 | % correlation matrix of microphone signal
142 | Psi_y_STFT = estim_corrmat(y_STFT, zeta);
143 | % compute GEVD
144 | [P_STFT, lambda_STFT] = desmooth_GEVD(Psi_y_STFT, Gamma,...
145 | 'lambdaMin', 0,...
146 | 'forgetPSD', zeta);
147 |
148 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
149 | %
150 | % NOTE: instead of desmoothing eigenvalues as in the implementation above,
151 | % one might prefer to use instantaneous eigenvalues, see also [a] and the
152 | % desmooth_GEVD() function in [b].
153 | %
154 | % [a] T. Dietzen, M. Moonen, and T. van Waterschoot, 'Instantaneous PSD
155 | % estimation for speech enhancement based on generalized principal
156 | % components,' in Proc. 28th European Signal Process. Conf. (EUSIPCO 2020),
157 | % Amsterdam, Netherlands, Jan 2021, pp. 1-5.
158 | %
159 | % [b] https://github.com/tdietzen/INSTANT-PSD
160 | %
161 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
162 |
163 | [phi_s_hat,...
164 | phi_xl_hat,...
165 | H_hat_prior_STFT,...
166 | H_hat_post_STFT,...
167 | H_update_pattern]...
168 | = estim_PSD_RETF(P_STFT, lambda_STFT, Gamma, H_init_FT,...
169 | 'method', 'square-root MP',...
170 | 'itmax', 20,...
171 | 'alpha', alpha_SQRT_PSD_RETF,...
172 | 'beta', 20*lap_div.^2,...
173 | 'xiThresh', xi_thresh...
174 | );
175 |
176 | % plot
177 | figure('Name',['target PSD estimate, SNR = ' num2str(SNR) 'dB']);
178 | plotSpec(phi_s_hat(:,:,1), 'pow', xTickProp, yTickProp, cRange, 0); title(['phi s1 hat, SNR = ' num2str(SNR) 'dB']); ylabel('f/kHz');
179 | drawnow;
180 |
181 |
182 | %% ISCLP KALMAN FILTER [1]
183 |
184 | fprintf(' * run ISCLP Kalman filer [1]...\n');
185 |
186 | % number of frames
187 | numFrames = size(y_STFT,2);
188 |
189 | % init outputs
190 | q_STFT = zeros(N_STFT_half, numFrames);
191 | e_prio_STFT = zeros(N_STFT_half, numFrames);
192 | e_post_STFT = zeros(N_STFT_half, numFrames);
193 | e_post_smooth_STFT = zeros(N_STFT_half, numFrames);
194 |
195 |
196 | for k = 2:N_STFT_half
197 |
198 | % reorganize data
199 | y_stack = shiftdim(squeeze(y_STFT(k,:,:)),1); % from (1 x numFrames x M) to (M x numFrames)
200 | h_stack = shiftdim(squeeze(H_hat_post_STFT(k,:,:,1)),1); % from (1 x numFrames x M x 1) to (M x numFrames)
201 | psi_sT_stack = shiftdim(squeeze(phi_s_hat(k,:,1)),1); % from (1 x numFrames x 1) to (1 x numFrames)
202 |
203 | % run ISCLP Kalman filter and spectral post processor
204 | [ q_stack, ...
205 | e_prio_stack,...
206 | e_post_stack,...
207 | e_post_smooth_stack ] = ...
208 | ISCLP(...
209 | A, Psi_w_delta{k},...
210 | y_stack,...
211 | psi_sT_stack,...
212 | h_stack,...
213 | Psi_w_tilde_init{k},...
214 | beta_SCLP_KF );
215 |
216 | % save output
217 | q_STFT(k,:) = q_stack;
218 | e_prio_STFT(k,:) = e_prio_stack;
219 | e_post_STFT(k,:) = e_post_stack;
220 | e_post_smooth_STFT(k,:) = e_post_smooth_stack;
221 |
222 | end
223 |
224 | % plot
225 | figure('Name',['enhanced signal, beta = 0, SNR = ' num2str(SNR) 'dB']);
226 | plotSpec(e_post_STFT(:,:,1), 'mag', xTickProp, yTickProp, cRange, 0); title(['e post, beta = 0, SNR = ' num2str(SNR) 'dB']); ylabel('f/kHz');
227 | figure('Name',['enhanced signal, beta = ' num2str(round(beta_SCLP_KF,2)) ', SNR = ' num2str(SNR) 'dB']);
228 | plotSpec(e_post_smooth_STFT(:,:,1), 'mag', xTickProp, yTickProp, cRange, 0); title(['e post, beta = ' num2str(round(beta_SCLP_KF,2)) ', SNR = ' num2str(SNR) 'dB']); ylabel('f/kHz');
229 | drawnow;
230 |
231 |
232 | %% ISTFT PROCESSING
233 |
234 | e_post_TD = calc_ISTFT(e_post_STFT, win, N_STFT, R_STFT, 'onesided');
235 | e_post_smooth_TD = calc_ISTFT(e_post_smooth_STFT, win, N_STFT, R_STFT, 'onesided');
236 |
237 |
238 | %% WRITE AUDIO AND PLAY BACK
239 |
240 | audiowrite(['.' filesep 'audio' filesep 'v_SNR_' num2str(SNR) 'dB.wav'], v_TD_SNR_scaled, fs);
241 | audiowrite(['.' filesep 'audio' filesep 'y_SNR_' num2str(SNR) 'dB.wav'], y_TD, fs);
242 | audiowrite(['.' filesep 'audio' filesep 'e_post_SNR_' num2str(SNR) 'dB.wav'],e_post_TD,fs);
243 | audiowrite(['.' filesep 'audio' filesep 'e_post_smooth_SNR_' num2str(SNR) 'dB.wav'],e_post_smooth_TD,fs);
244 |
245 | fprintf(' * play microphone signal...\n');
246 | sound(y_TD(:,1), fs); pause(length(y_TD(:,1))/fs);
247 | fprintf(' * play enhanced signal...\n');
248 | sound(e_post_smooth_TD(:,1), fs);
249 |
250 | fprintf('\nDONE.\n');
251 |
--------------------------------------------------------------------------------
/param/SQRT_PSD_RETF/alpha_sqrtMP.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/param/SQRT_PSD_RETF/alpha_sqrtMP.mat
--------------------------------------------------------------------------------
/param/SQRT_PSD_RETF/lap_div.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tdietzen/ISCLP-KF/ccfb8bb92f79a1593a62ff7c512b9cc7cfcf0310/param/SQRT_PSD_RETF/lap_div.mat
--------------------------------------------------------------------------------
/tools/STFT/calc_ISTFT.m:
--------------------------------------------------------------------------------
1 | function x = calc_ISTFT(X, win, N_STFT, R_STFT, sides)
2 | % x = calc_ISTFT(X, win, N_STFT, R_STFT, sides)
3 | % performs the inverse STFT.
4 | %
5 | % IN:
6 | % X STFT tensor - freqbins x frames x channels
7 | % win window function
8 | % N_STFT frame length
9 | % R_STFT frame shift
10 | % sides {'onesided', 'twosided'}, return either onesided or twosided STFT
11 | %
12 | % OUT:
13 | % x signal - samples x channels
14 |
15 | [~, L, M] = size(X);
16 | if strcmp(sides, 'onesided')
17 | X = [X; conj(X(end-1:-1:2,:,:))];
18 | end
19 | x_frames = ifft(X, [], 1, 'symmetric');
20 |
21 | % apply synthesis window
22 | win = repmat(win, [1, L, M]);
23 | x_frames = x_frames.*win;
24 | x_frames = x_frames(1:N_STFT,:,:);
25 |
26 | % init output
27 | x = zeros(R_STFT*(L-1)+N_STFT, M);
28 |
29 | % OLA processing
30 | for l = 1:L
31 | sampIdx = (l-1)*R_STFT+1:(l-1)*R_STFT+N_STFT;
32 | x(sampIdx,:) = x(sampIdx,:) + squeeze(x_frames(:,l,:));
33 | end
--------------------------------------------------------------------------------
/tools/STFT/calc_STFT.m:
--------------------------------------------------------------------------------
1 | function [X, f] = calc_STFT(x, fs, win, N_STFT, R_STFT, sides)
2 | % [X, f] = calc_STFT(x, fs, win, N_STFT, R_STFT, sides)
3 | % performs the STFT.
4 | %
5 | % IN:
6 | % x signal - samples x channels
7 | % fs sampling frequency
8 | % win window function
9 | % N_STFT frame length
10 | % R_STFT frame shift
11 | % sides {'onesided', 'twosided'}, return either onesided or twosided STFT
12 | %
13 | % OUT:
14 | % X STFT tensor - freqbins x frames x channels
15 | % f frequency vector
16 |
17 | % use only half FFT spectrum
18 | N_STFT_half = N_STFT/2 + 1;
19 |
20 | % get frequency vector
21 | f = linspace(0,fs/2,N_STFT_half);
22 | if strcmp(sides, 'twosided')
23 | f = [f, -f(end-1:-1:2)];
24 | end
25 |
26 | % init
27 | L = floor((length(x) - N_STFT + R_STFT)/R_STFT);
28 | M = size(x,2);
29 | switch sides
30 | case 'onesided'
31 | X = zeros(N_STFT_half, L, size(x,2));
32 | case 'twosided'
33 | X = zeros(N_STFT, L, M);
34 | end
35 |
36 | for m = 1:M
37 | for l = 1:L % Frame index
38 | x_frame = x((l-1)*R_STFT+1:(l-1)*R_STFT+N_STFT, m);
39 | X_frame = fft(win.*x_frame);
40 | switch sides
41 | case 'onesided'
42 | X(:,l,m) = X_frame(1:N_STFT_half, :);
43 | case 'twosided'
44 | X(:,l,m) = X_frame;
45 | end
46 | end
47 | end
48 |
49 | end
--------------------------------------------------------------------------------
/tools/estim/ISCLP_KF/ISCLP.m:
--------------------------------------------------------------------------------
1 | function [ q_stack, e_prio_stack, e_post_stack, e_post_smooth_stack ] = ISCLP( A, Psi_w_delta, y_stack, psi_s_stack, H_stack, Psi_w_tilde_init, beta )
2 | % [ q_stack, e_prio_stack, e_post_stack, e_post_smooth_stack ] = ISCLP( A, Psi_w_delta, y_stack, psi_s_stack, H_stack, Psi_w_tilde_init, beta )
3 | % runs the ISCLP Kalman filter in one frequency bin.
4 | %
5 | % IN:
6 | % A state transition matrix - statedim x statedim
7 | % Psi_w_delta process noise correlation matrix - statedim x statedim
8 | % y_stack microphone signal - channels x frames
9 | % psi_s_stack target signal PSD - frames
10 | % H_stack RETF - channels (x sources) x frames (if more than one source)
11 | % Psi_w_tilde_init initial state estimation error correlation matrix - statedim x statedim
12 | % beta gain decay limitation
13 | %
14 | % OUT:
15 | % q_stack MF output - frames
16 | % e_prio_stack ISCLP output, prior - frames
17 | % e_post_stack ISCLP output, posterior - frames
18 | % e_post_smooth_stack ISCLP output, smooth posterior - frames
19 |
20 |
21 | % get dimensions
22 | if ismatrix(H_stack)
23 | N = 1;
24 | [M, numFrames] = size(H_stack);
25 | else
26 | [M, N, numFrames] = size(H_stack);
27 | end
28 | stateDim = size(Psi_w_tilde_init,1);
29 |
30 | % initKF
31 | %
32 | w_hat = zeros(stateDim,1);
33 | Psi_w_tile = Psi_w_tilde_init;
34 | %
35 | y_old = zeros(M,1);
36 | %
37 | u_LP = zeros(stateDim-M+1,1);
38 | %
39 | smooth_gain = 1;
40 |
41 | % init output
42 | q_stack = zeros(1, numFrames);
43 | e_prio_stack = zeros(1, numFrames);
44 | e_post_stack = zeros(1, numFrames);
45 | e_post_smooth_stack = zeros(1, numFrames);
46 |
47 |
48 | for i_frame = 1:numFrames
49 |
50 | %%% Load Data
51 | %
52 | y = y_stack(:,i_frame);
53 | psi_s = psi_s_stack(i_frame);
54 | if N == 1
55 | H = H_stack(:,i_frame);
56 | else
57 | H = H_stack(:,:,i_frame);
58 | end
59 |
60 |
61 | %%% Spatio-Temporal Pre-Processing
62 | %
63 | % compute g, B
64 | g = sum(H/(H'*H),2);
65 | Btmp = eye(M)-(H/(H'*H))*H';
66 | B = Btmp(:,1:M-N);
67 | % update q, u
68 | q = g'*y;
69 | u_SC = B'*y;
70 | u_LP = [y_old; u_LP(1:end-M)];
71 | u = [u_SC; u_LP];
72 |
73 |
74 | %%% Kalman Filter
75 | %
76 | % time update: state estimate
77 | w_hat = A*w_hat;
78 | % time update: state estimation error correlation matrix
79 | Psi_w_tile = A'*Psi_w_tile*A + Psi_w_delta;
80 | % symmetrize (just in case, avoiding accuracy issues)
81 | Psi_w_tile = 0.5*(Psi_w_tile+Psi_w_tile');
82 | % error
83 | e_prio_conj = conj(q) - u'*w_hat;
84 | % error PSD
85 | psi_e = real(u'*Psi_w_tile*u) + psi_s + eps;
86 | % Kalman gain
87 | k = Psi_w_tile*u/psi_e;
88 | % measurement update: state estimation error correlation matrix
89 | w_hat = w_hat + k*e_prio_conj;
90 | % measurement update: state estimation error correlation matrix
91 | Psi_w_tile = Psi_w_tile - k*(u'*Psi_w_tile);
92 |
93 |
94 | %%% Spectral Post Processing
95 | %
96 | % compute gains
97 | gain = psi_s/psi_e;
98 | smooth_gain = max(gain, beta*smooth_gain);
99 | %
100 | % apply gains
101 | e_post_conj = gain*e_prio_conj;
102 | e_post_smooth_conj = smooth_gain*e_prio_conj;
103 |
104 |
105 | %%% Save Data
106 | %
107 | % save
108 | q_stack(:,i_frame) = q;
109 | e_prio_stack(:,i_frame) = conj(e_prio_conj);
110 | e_post_stack(:,i_frame) = conj(e_post_conj);
111 | e_post_smooth_stack(:,i_frame) = conj(e_post_smooth_conj);
112 | % save previous mic. signal
113 | y_old = y;
114 |
115 | end
116 |
117 | end
118 |
--------------------------------------------------------------------------------
/tools/estim/ISCLP_KF/ISCLP.m~:
--------------------------------------------------------------------------------
1 | function [ q_stack, e_prio_stack, e_post_stack, e_post_smooth_stack ] = ISCLP( A, Psi_w_delta, y_stack, psi_s_stack, H_stack, Psi_w_tilde_init, beta )
2 | % [ q_stack, e_prio_stack, e_post_stack, e_post_smooth_stack ] = ISCLP( A, Psi_w_delta, y_stack, psi_s_stack, H_stack, Psi_w_tilde_init, beta )
3 | % runs the ISCLP Kalman filter in one frequency bin
4 | %
5 | % IN:
6 | % A state transition matrix
7 | % Psi_w_delta process noise correlation matrix
8 | % y_stack microphone signal - channels x frames
9 | % psi_s_stack target signal PSD - frames
10 | % H_stack RETF - channels (x sources) x frames (if more than one source)
11 | % Psi_w_tilde_init initial state estimation error correlation matrix
12 | % beta gain decay limitation
13 | %
14 | % OUT:
15 | % q_stack square root PSD estimate - sources x 1
16 | % Omega_hat estimate of unitary matrix - sources x sources
17 | % eps_phi_s_rel estimation error
18 | % eps_phi_s_rel_it estimation error per iteration
19 |
20 | % get dimensions
21 | if ismatrix(H_stack)
22 | N = 1;
23 | [M, numFrames] = size(H_stack);
24 | else
25 | [M, N, numFrames] = size(H_stack);
26 | end
27 | stateDim = size(Psi_w_tilde_init,1);
28 |
29 | % initKF
30 | %
31 | w_hat = zeros(stateDim,1);
32 | Psi_w_tile = Psi_w_tilde_init;
33 | %
34 | y_old = zeros(M,1);
35 | %
36 | u_LP = zeros(stateDim-M+1,1);
37 | %
38 | smooth_gain = 1;
39 |
40 | % init output
41 | q_stack = zeros(1, numFrames);
42 | e_prio_stack = zeros(1, numFrames);
43 | e_post_stack = zeros(1, numFrames);
44 | e_post_smooth_stack = zeros(1, numFrames);
45 |
46 |
47 | for i_frame = 1:numFrames
48 |
49 | %%% Load Data
50 | %
51 | y = y_stack(:,i_frame);
52 | psi_s = psi_s_stack(i_frame);
53 | if N == 1
54 | H = H_stack(:,i_frame);
55 | else
56 | H = H_stack(:,:,i_frame);
57 | end
58 |
59 |
60 | %%% Spatio-Temporal Pre-Processing
61 | %
62 | % compute g, B
63 | g = sum(H/(H'*H),2);
64 | Btmp = eye(M)-(H/(H'*H))*H';
65 | B = Btmp(:,1:M-N);
66 | % update q, u
67 | q = g'*y;
68 | u_SC = B'*y;
69 | u_LP = [y_old; u_LP(1:end-M)];
70 | u = [u_SC; u_LP];
71 |
72 |
73 | %%% Kalman Filter
74 | %
75 | % time update: state estimate
76 | w_hat = A*w_hat;
77 | % time update: state estimation error correlation matrix
78 | Psi_w_tile = A'*Psi_w_tile*A + Psi_w_delta;
79 | % symmetrize (just in case, avoiding accuracy issues)
80 | Psi_w_tile = 0.5*(Psi_w_tile+Psi_w_tile');
81 | % error
82 | e_prio_conj = conj(q) - u'*w_hat;
83 | % error PSD
84 | psi_e = real(u'*Psi_w_tile*u) + psi_s + eps;
85 | % Kalman gain
86 | k = Psi_w_tile*u/psi_e;
87 | % measurement update: state estimation error correlation matrix
88 | w_hat = w_hat + k*e_prio_conj;
89 | % measurement update: state estimation error correlation matrix
90 | Psi_w_tile = Psi_w_tile - k*(u'*Psi_w_tile);
91 |
92 |
93 | %%% Spectral Post Processing
94 | %
95 | % compute gains
96 | gain = psi_s/psi_e;
97 | smooth_gain = max(gain, beta*smooth_gain);
98 | %
99 | % apply gains
100 | e_post_conj = gain*e_prio_conj;
101 | e_post_smooth_conj = smooth_gain*e_prio_conj;
102 |
103 |
104 | %%% Save Data
105 | %
106 | % save
107 | q_stack(:,i_frame) = q;
108 | e_prio_stack(:,i_frame) = conj(e_prio_conj);
109 | e_post_stack(:,i_frame) = conj(e_post_conj);
110 | e_post_smooth_stack(:,i_frame) = conj(e_post_smooth_conj);
111 | % save previous mic. signal
112 | y_old = y;
113 |
114 | end
115 |
116 | end
117 |
--------------------------------------------------------------------------------
/tools/estim/SQRT_PSD_RETF/corrmat/estim_corrmat.m:
--------------------------------------------------------------------------------
1 | function [Psi_x_smth, Psi_x_mean] = estim_corrmat(X, alpha)
2 | % [Psi_x_smth, Psi_x_mean] = estim_corrmat(X, alpha)
3 | % estimates correlation matrix.
4 | %
5 | % IN:
6 | % X STFT data - freqbins x frames x channels
7 | % alpha forgetting factor
8 | %
9 | % OUT
10 | % Psi_x_smth smooth correlation matrix estimate - freqbins x frames x channels x channels
11 | % Psi_x_mean mean correlation matrix estimate - freqbins x 1 x channels x channels
12 |
13 | % dimensions
14 | [N_half, L, M, ~] = size(X);
15 |
16 | %%% compute average PSD matrix
17 | if alpha ~= 1
18 | R_inst = zeros(N_half, L, M, M);
19 | for l = 1:L
20 | for k = 1:N_half
21 | x = squeeze(X(k,l,:));
22 | R_inst(k,l,:,:) = shiftdim(x*x', -2);
23 | end
24 | end
25 | Psi_x_mean = sum(R_inst, 2)/L;
26 | else
27 | Psi_x_mean = zeros(N_half, 1, M, M);
28 | for l = 1:L
29 | for k = 1:N_half
30 | x = squeeze(X(k,l,:));
31 | Psi_x_mean(k,1,:,:) = Psi_x_mean(k,1,:,:) + shiftdim(x*x', -2);
32 | end
33 | end
34 | Psi_x_mean = Psi_x_mean/L;
35 | end
36 |
37 | %%% compute smooth PSD matrix
38 |
39 | R_smth_tmp = eps*ones(N_half, 1, M, M);
40 | if alpha ~= 1
41 | Psi_x_smth = zeros(N_half, L, M, M);
42 | for l = 1:L
43 | R_smth_tmp = alpha*R_smth_tmp + (1-alpha)*R_inst(:,l,:,:);
44 | Psi_x_smth(:,l,:,:) = R_smth_tmp;
45 | end
46 | else
47 | Psi_x_smth = Psi_x_mean;
48 | end
49 |
--------------------------------------------------------------------------------
/tools/estim/SQRT_PSD_RETF/corrmat/forget2tau.m:
--------------------------------------------------------------------------------
1 | function [ tau ] = forget2tau( forget, R_STFT, fs )
2 | % [ tau ] = forget2tau( forget, R_STFT, fs )
3 | % converts forgeting factor to time constant.
4 | %
5 | % IN:
6 | % forget forgetting factor
7 | % R_STFT frame shift
8 | % fs sampling frequency
9 | %
10 | % OUT:
11 | % tau time constant
12 |
13 | tau = -R_STFT./(fs*log(forget));
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/tools/estim/SQRT_PSD_RETF/corrmat/tau2forget.m:
--------------------------------------------------------------------------------
1 | function [ forget ] = tau2forget( tau, R_STFT, fs )
2 | % [ forget ] = tau2forget( tau, R_STFT, fs )
3 | % converts forgeting factor to time constant.
4 | %
5 | % IN:
6 | % tau time constant
7 | % R_STFT frame shift
8 | % fs sampling frequency
9 | %
10 | % OUT:
11 | % forget forgetting factor
12 |
13 | forget = exp(-R_STFT./(fs*tau));
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/tools/estim/SQRT_PSD_RETF/desmooth_GEVD.m:
--------------------------------------------------------------------------------
1 | function [P_STFT, lambda_STFT, lambda_LP_STFT] = desmooth_GEVD(Psi_x_STFT, Gamma_FT, varargin)
2 | % [P_STFT, lambda_STFT, lambda_LP_STFT] = desmooth_GEVD(Psi_x_STFT, Gamma_FT, varargin)
3 | % performs GEVD and subspace-based desmoothing.
4 | %
5 | % IN:
6 | % Psi_x_STFT correlation matrix - freqbins x frames x channels x channels
7 | % Gamma_FT diffuse coherence matrix - freqbins x 1 x channels x channels
8 | % 'lambdaMin', lambdaMin eigenvalue threshold
9 | % 'forgetPSD', forgetPSD forgetting factor for desmoothing
10 | %
11 | % OUT:
12 | % P_STFT eingevectors - freqbins x frames x channels x channels
13 | % lambda_STFT desmoothed eigenvalues - freqbins x frames x channels
14 | % lambda_LP_STFT smooth eigenvalues - freqbins x frames x channels
15 |
16 |
17 | % dimensions
18 | [N_FT_half, L, M, ~] = size(Psi_x_STFT); % number of frequency bins, frames, microphones
19 |
20 | % default options
21 | forgetPSD = 0; % PSD forgetting factor
22 | lambdaMin = 0; % minimum power
23 |
24 | % read options from input
25 | for i = 1:2:length(varargin)
26 | if ischar(varargin{i})
27 | switch varargin{i}
28 | case 'forgetPSD'
29 | forgetPSD = varargin{i+1};
30 | case 'lambdaMin'
31 | lambdaMin = varargin{i+1};
32 | end
33 | end
34 | end
35 |
36 | % init
37 | P_STFT = zeros(N_FT_half,L,M,M);
38 | lambda_STFT = zeros(N_FT_half,L,M);
39 | lambda_LP_STFT = zeros(N_FT_half,L,M);
40 |
41 | for k=2:N_FT_half
42 | R_v = 0;
43 |
44 | % apply regularization
45 | Gamma = squeeze(Gamma_FT(k,1,:,:));
46 | for l = 1:L
47 |
48 | %%% GEVD %%%
49 | %
50 | Psi_x = squeeze(Psi_x_STFT(k,l,:,:));
51 | % generalized eigenvalue decomposition
52 | [P, Lambda_LP] = eig(Psi_x, Gamma);
53 | % ignore residual imaginary component and set negative values to zero
54 | lambda_LP = real(diag(Lambda_LP));
55 | % rescaling W such that P'*Rv_k*P = I and P'*Ry_kp*P = Lambda
56 | P = P/diag(sqrt(real(diag(P'*Gamma*P))));
57 |
58 |
59 | %%% Sorting eigenvalues/eigenvectors %%%
60 | %
61 | if l > 1
62 | % map current eigenvector order to previous one, start with principal eigenvector
63 | [~, maxIdx] = sort(lambda_LP, 'descend');
64 | % if ordered correctly, Q approximates I
65 | Q = abs(P_old'*Gamma*P);
66 | % temporary variables
67 | P_tmp = P;
68 | lambda_LP_tmp = lambda_LP;
69 | % order such that Q approximates I
70 | for m = transpose(maxIdx)
71 | % find index
72 | [~, maxIdx] = max(Q(:,m));
73 | % set corresponding row to zero (guarantees that maxIdx is unique in each iteration)
74 | Q(maxIdx,:) = 0;
75 | % sort P and Lambda
76 | P(:, maxIdx) = P_tmp(:,m);
77 | lambda_LP(maxIdx) = lambda_LP_tmp(m);
78 | end
79 | end
80 | P_old = P;
81 | %
82 | % save
83 | P_STFT(k,l,:,:) = shiftdim(P, -2);
84 | lambda_LP_STFT(k,l,:) = shiftdim(lambda_LP, -2);
85 |
86 |
87 | %%% Filter eigenvalues to compensate for recursive avaeraging %%%
88 | %
89 | if l > 1
90 | % apply HP to Lambda
91 | lambda_LP_old = squeeze(lambda_LP_STFT(k,l-1,:));
92 | lambda = 1/(1-forgetPSD)*lambda_LP - forgetPSD/(1-forgetPSD)*lambda_LP_old;
93 | lambda(lambda < lambdaMin) = lambdaMin;
94 | else
95 | % use LP version
96 | lambda = lambda_LP;
97 | lambda(lambda < lambdaMin) = lambdaMin;
98 | end
99 | %
100 | % save
101 | lambda_STFT(k,l,:) = shiftdim(lambda, -2);
102 |
103 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 | %
105 | % NOTE: instead of desmoothing eigenvalues as in the implementation
106 | % above, one might prefer to use instantaneous eigenvalues, see
107 | % also [a] and the desmooth_GEVD() function in [b].
108 | %
109 | % [a] T. Dietzen, M. Moonen, and T. van Waterschoot, 'Instantaneous
110 | % PSD estimation for speech enhancement based on generalized
111 | % principal components,' in Proc. 28th European Signal Process.
112 | % Conf. (EUSIPCO 2020), Amsterdam, Netherlands, Jan 2021, pp. 1-5.
113 | %
114 | % [b] https://github.com/tdietzen/INSTANT-PSD
115 | %
116 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117 |
118 | end
119 | end
120 |
121 | end
122 |
--------------------------------------------------------------------------------
/tools/estim/SQRT_PSD_RETF/estim_PSD_RETF.m:
--------------------------------------------------------------------------------
1 | function [phi_s_hat_STFT, phi_d_STFT, H_hat_prior_STFT, H_hat_post_STFT, update_RETF] = estim_PSD_RETF(P_STFT, lambda_STFT, Gamma_FT, H_init_FT, varargin)
2 | % function [phi_s_hat_STFT, phi_d_STFT, H_hat_prior_STFT, H_hat_post_STFT, update_RETF] = estim_PSD_RETF(P_STFT, lambda_STFT, Gamma_FT, H_init_FT, varargin)
3 | % estimates PSDs and updates RETFs.
4 | %
5 | % IN:
6 | % P_STFT eigenvectors - freqbins x frames x channels x channels
7 | % lambda_STFT eigenvalues - freqbins x frames x channels
8 | % Gamma_FT diffuse coherence matrix - freqbins x 1 x frames x channels
9 | % H_init_FT initial RETF estimate - freqbins x frames x channels x sources
10 | % 'itmax', itmax maximum number of iterations
11 | % 'phiMin', phiMin power threshold
12 | % 'method', method {'conventional MP', 'square-root MP'}, defines estimation method
13 | % 'alpha', alpha penalty factor conventional and square-root MP
14 | % 'beta', beta penalty factor in RETF update MP
15 | % 'xiThresh', xi_thresh threshold for RETF update
16 | %
17 | % OUT:
18 | % phi_s_hat_STFT early PSD estimates - freqbins x frames x sources
19 | % phi_d_STFT diffuse PSD estimate - freqbins x frames
20 | % H_hat_prior_STFT prior RETF estimate - freqbins x frames x channels x sources
21 | % H_hat_post_STFT posterior RETF estimate - freqbins x frames x channels x sources
22 | % update_RETF RETF update pattern - freqbins x frames x sources
23 |
24 | % dimensions
25 | [N_FT_half, L, M] = size(lambda_STFT); % number of frequency bins, frames, microphones
26 | N = size(H_init_FT, 4); % number of sources
27 |
28 | % default values
29 | method = 'square-root MP';
30 | itmax = 20; % max iterations
31 | phiMin = db2pow(-80); % minimum power threshold
32 | beta = 1e3*ones(N_FT_half,1); % beta
33 | alpha = 1e3*ones(N_FT_half,1); % alpha
34 |
35 | % parse name-value pairs
36 | for i = 1:2:length(varargin)
37 | if ischar(varargin{i})
38 | switch varargin{i}
39 | case 'itmax'
40 | itmax = varargin{i+1};
41 | case 'phiMin'
42 | phiMin = varargin{i+1};
43 | case 'method'
44 | method = varargin{i+1};
45 | case 'alpha'
46 | alpha = varargin{i+1};
47 | case 'beta'
48 | beta = varargin{i+1};
49 | case 'xiThresh'
50 | xi_thresh = varargin{i+1};
51 | end
52 | end
53 | end
54 |
55 | % init
56 | phi_s_hat_STFT = zeros(N_FT_half,L,N);
57 | phi_d_STFT = zeros(N_FT_half,L);
58 |
59 | if strcmp('method','square-root MP')
60 | H_hat_prior_STFT = zeros(N_FT_half,L,M,N);
61 | H_hat_post_STFT = zeros(N_FT_half,L,M,N);
62 | update_RETF = zeros(N_FT_half,L,N);
63 | else
64 | H_hat_prior_STFT = [];
65 | H_hat_post_STFT = [];
66 | update_RETF = [];
67 | end
68 |
69 |
70 | for k=2:N_FT_half
71 |
72 | % get H
73 | H_hat = squeeze(H_init_FT(k,1,:,:));
74 | H_hat_post = H_hat;
75 |
76 | % get Gamma
77 | Gamma = squeeze(Gamma_FT(k,1,:,:));
78 |
79 | for l = 1:L
80 |
81 | % get P and lambda
82 | P = squeeze(P_STFT(k,l,:,:));
83 | lambda = squeeze(lambda_STFT(k,l,:));
84 |
85 | %%% Decompose into early and late part %%%
86 | %
87 | % find index of maximum eigenvalues and principal eigenvectors
88 | [~, maxIdx] = sort(lambda, 'descend');
89 | Pmax = P(:,maxIdx(1:N));
90 | lambdaMax = lambda(maxIdx(1:N));
91 | lambdaMin = lambda(maxIdx(N+1:end));
92 | %
93 | % compute late reverberant PSD
94 | phi_d = mean(lambdaMin); % using min or mean doesn't make much of a difference
95 | %
96 | % save
97 | phi_d_STFT(k,l) = phi_d;
98 | %
99 | % compute lambda_xe
100 | lambda_xe = lambdaMax - phi_d;
101 | lambda_xe(lambda_xe < phiMin) = phiMin;
102 |
103 |
104 | %%% early correlation matrix %%%
105 | %
106 | sqrtlambda_xe = sqrt(lambda_xe);
107 | sqrtPsi_xe = Gamma*Pmax*diag(sqrtlambda_xe);
108 | Psi_xe = sqrtPsi_xe*sqrtPsi_xe';
109 |
110 |
111 | switch method
112 |
113 | case 'conventional MP'
114 |
115 | % solve
116 | phi_s_hat = solve_convMP(H_hat, Psi_xe, phiMin, alpha(k), itmax);
117 |
118 | case 'square-root MP'
119 |
120 | % propagate H_hat_post
121 | H_hat_prior = H_hat_post;
122 |
123 | % initial value
124 | sqrtphi_s_init = sqrt(solve_convMP_simple(H_hat_prior, Psi_xe, phiMin));
125 |
126 | % solve
127 | [sqrtphi_s_hat, Omega_hat] = solve_sqrtMP(sqrtPsi_xe, H_hat_prior, sqrtphi_s_init, alpha(k), itmax);
128 | phi_s_hat = sqrtphi_s_hat.*conj(sqrtphi_s_hat);
129 |
130 | %%% update RETF H %%%
131 | if l > 16
132 | % update H
133 | phi_reg = phi_d + 1e-3;
134 | [H_hat_post, up] = solve_RETFup(sqrtPsi_xe, sqrtphi_s_hat, Omega_hat, xi_thresh, phi_reg, beta(k), H_hat_prior);
135 |
136 | else
137 | H_hat_post = H_hat_prior;
138 | up = zeros(N,1);
139 | end
140 |
141 | % save
142 | H_hat_prior_STFT(k,l,:,:) = shiftdim(H_hat_prior, -2);
143 | H_hat_post_STFT(k,l,:,:) = shiftdim(H_hat_post, -2);
144 | update_RETF(k,l,:) = up;
145 | end
146 |
147 | % save
148 | phi_s_hat_STFT(k,l,:) = phi_s_hat;
149 |
150 | end
151 | end
152 |
153 |
154 | end
--------------------------------------------------------------------------------
/tools/estim/SQRT_PSD_RETF/minprob/solve_RETFup.m:
--------------------------------------------------------------------------------
1 | function [H_hat_post, up, rho_H_prior_rel, rho_H_post_rel] = solve_RETFup( sqrtPsi_xe, sqrtphi_s_hat, Omega_hat, xiThresh, reg, beta, H_hat_prior, H)
2 | % [H_hat_post, up, rho_H_prior_rel, rho_H_post_rel] = solve_RETFup( sqrtPsi_xe, sqrtphi_s_hat, Omega_hat, xiThresh, reg, beta, H_hat_prior, H)
3 | % solves RETF update MP.
4 | %
5 | % IN:
6 | % sqrtPsi_xe square root of correlation matrix - channels x sources
7 | % sqrtphi_s_hat square root PSD estimate - sources x 1
8 | % Omega_hat estimate of unitary matrix - sources x sources
9 | % xiThresh update threshold
10 | % reg threshold regularization
11 | % beta penalty factor
12 | % H_hat_prior prior RETFs - channels x sources
13 | % H ground truth RETF (optional)
14 | %
15 | % OUT:
16 | % H_hat_post posterior RETFs - channels x sources
17 | % up RETF update pattern - channels x sources
18 | % rho_H_prior_rel prior estimation error
19 | % rho_H_post_rel posterior estimation error
20 |
21 | [M, N] = size(H_hat_prior);
22 |
23 | % init
24 | H_hat_post = ones(M,N);
25 |
26 | % update
27 | phi_s_hat = real(diag(sqrtphi_s_hat')*sqrtphi_s_hat);
28 | xi = phi_s_hat/(sum(phi_s_hat) + reg);
29 |
30 | up = zeros(N,1);
31 | for n = 1:N
32 | if xi(n) > xiThresh
33 | up(n) = 1;
34 | H_hat_post(2:M,n) = (sqrtPsi_xe(2:M,:)*Omega_hat(:,n)*conj(sqrtphi_s_hat(n)) + beta*H_hat_prior(2:M,n))/(phi_s_hat(n) + beta);
35 | else
36 | up(n) = 0;
37 | H_hat_post(2:M,n) = H_hat_prior(2:M,n);
38 | end
39 | end
40 |
41 |
42 |
43 |
44 |
45 | %if nargin < 6
46 | if nargin < 8
47 | rho_H_prior_rel = [];
48 | rho_H_post_rel = [];
49 | else
50 | % relative error
51 | H_e_prior = H - H_hat_prior;
52 | H_e_post = H - H_hat_post;
53 |
54 | rho_H_prior_rel = trace(H_e_prior'*H_e_prior)/trace(H(2:M,:)'*H(2:M,:));
55 | rho_H_post_rel = trace(H_e_post'*H_e_post)/trace(H(2:M,:)'*H(2:M,:));
56 | end
57 |
58 | end
59 |
--------------------------------------------------------------------------------
/tools/estim/SQRT_PSD_RETF/minprob/solve_convMP.m:
--------------------------------------------------------------------------------
1 | function [phi_s_hat, eps_phi_s_rel] = solve_convMP(H_hat, Psi_xe, phiMin, alpha, itMax, phi_s)
2 | % function [phi_s_hat, eps_phi_s_rel] = solve_convMP(H_hat, Psi_xe, phiMin, alpha, itMax, phi_s)
3 | % solves conventional MP.
4 | %
5 | % IN:
6 | % H_hat RETFs - channels x sources
7 | % Psi_xe correlation matrix - channels x channels
8 | % phiMin PSD threshold
9 | % alpha penalty factor
10 | % itMax max number of iterations
11 | % phi_s ground truth PSD estimates (optional) - sources x 1
12 | %
13 | % OUT:
14 | % phi_s_hat PSD estimate - sources x 1
15 | % eps_phi_s_rel estimation error
16 |
17 |
18 | N = size(H_hat,2);
19 |
20 | % cost function terms
21 | A1 = abs(H_hat'*H_hat).^2;
22 | A2 = alpha*ones(N);
23 | A = A1 + A2;
24 | b = -real(diag(H_hat'*Psi_xe*H_hat) + alpha*Psi_xe(1,1)*ones(N,1));
25 |
26 | % initial value
27 | R = 1e-8*(trace(A1)/N)*eye(N);
28 | x0 = -(A + R)\b;
29 |
30 | % gradient
31 | G = @(x) (x'*A)'+b;
32 |
33 | % step size
34 | mu = 1/norm(A);
35 |
36 | for it = 1:itMax
37 |
38 | xOld = x0;
39 | % compute gradient
40 | Gtemp = G(x0);
41 | % take gradient step
42 | xstep = x0-mu*Gtemp;
43 | % apply proximal opetor
44 | xProj = max(xstep,phiMin);
45 | % overwrite
46 | x0 = xProj;
47 |
48 | if norm(x0-xOld)/norm(xOld)<1e-6
49 | break;
50 | end
51 |
52 | end
53 |
54 | phi_s_hat = x0;
55 |
56 |
57 | if nargin < 6
58 | eps_phi_s_rel = [];
59 | else
60 | % error
61 | e_phi_s = sqrt(phi_s) - sqrt(phi_s_hat);
62 | eps_phi_s_rel = e_phi_s'*e_phi_s/sum(phi_s);
63 | end
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | end
--------------------------------------------------------------------------------
/tools/estim/SQRT_PSD_RETF/minprob/solve_convMP_simple.m:
--------------------------------------------------------------------------------
1 | function [phi_s_hat, eps_phi_s_rel] = solve_convMP_simple(H_hat, Psi_xe, phiMin, phi_s)
2 | % function [phi_s_hat, eps_phi_s_rel] = solve_convMP_simple(H_hat, Psi_xe, phiMin, phi_s)
3 | % solves simple conventional MP.
4 | %
5 | % IN:
6 | % H_hat RETFs - channels x sources
7 | % Psi_xe correlation matrix - channels x channels
8 | % phiMin PSD threshold
9 | % phi_s ground truth PSD estimates (optional) - sources x 1
10 | %
11 | % OUT:
12 | % phi_s_hat PSD estimate - sources x 1
13 | % eps_phi_s_rel estimation error
14 |
15 | N = size(H_hat, 2);
16 |
17 | % cost function terms
18 | A = abs(H_hat'*H_hat).^2;
19 | b = -real(diag(H_hat'*Psi_xe*H_hat));
20 |
21 | R = 1e-8*(trace(A)/N)*eye(N);
22 | phi_s_hat = max(-(A + R)\b, phiMin);
23 |
24 | if nargin < 4
25 | eps_phi_s_rel = [];
26 | else
27 | % error
28 | e_phi_s = sqrt(phi_s) - sqrt(phi_s_hat);
29 | eps_phi_s_rel = e_phi_s'*e_phi_s/sum(phi_s);
30 | end
31 |
32 | end
33 |
34 |
--------------------------------------------------------------------------------
/tools/estim/SQRT_PSD_RETF/minprob/solve_sqrtMP.m:
--------------------------------------------------------------------------------
1 | function [sqrtphi_s_hat, Omega_hat, eps_phi_s_rel, eps_phi_s_rel_it] = solve_sqrtMP(sqrtPsi_xe, H_hat, sqrtphi_s_init, alpha, itMax, phi_s)
2 | % [sqrtphi_s_hat, Omega_hat, eps_phi_s_rel, eps_phi_s_rel_it] = solve_sqrtMP(sqrtPsi_xe, H_hat, sqrtphi_s_init, alpha, itMax, phi_s)
3 | % solves square-root MP.
4 | %
5 | % IN:
6 | % sqrtPsi_xe square root of correlation matrix - channels x sources
7 | % H_hat RETFs - channels x sources
8 | % sqrtphi_s_init intital square root PSD estimate - sources x 1
9 | % alpha penalty factor
10 | % itMax max number of iterations
11 | % phi_s ground truth PSD estimates (optional) - sources x 1
12 | %
13 | % OUT:
14 | % phi_s_hat square root PSD estimate - sources x 1
15 | % Omega_hat estimate of unitary matrix - sources x sources
16 | % eps_phi_s_rel estimation error
17 | % eps_phi_s_rel_it estimation error per iteration
18 |
19 | % initial value
20 | sqrtphi_s_hat = sqrtphi_s_init;
21 |
22 | % number of sources
23 | [M, N] = size(H_hat);
24 |
25 |
26 | if nargin < 6
27 | compute_eps = 0;
28 | else
29 | compute_eps = 1;
30 | end
31 |
32 | if compute_eps
33 | eps_phi_s_rel_it = zeros(itMax, 1);
34 | else
35 | eps_phi_s_rel_it = [];
36 | eps_phi_s_rel = [];
37 | end
38 |
39 | for i_it = 1:itMax
40 |
41 | % save convergence plot
42 | if compute_eps
43 | e_phi_s = sqrt(phi_s) - abs(sqrtphi_s_hat);
44 | eps_phi_s_rel_it(i_it) = e_phi_s'*e_phi_s/sum(phi_s);
45 | end
46 |
47 | % get Sigma
48 | [U, ~, V] = svd(sqrtPsi_xe'*H_hat*diag(sqrtphi_s_hat));
49 |
50 | Omega_hat = U*V';
51 |
52 | % get sqrtphi_xe_hat
53 | sqrtphi_s_hat_old = sqrtphi_s_hat;
54 |
55 | sqrtphi_s_hat = (diag(H_hat'*sqrtPsi_xe*Omega_hat) + alpha*Omega_hat'*sqrtPsi_xe(1,:)')./...
56 | (diag((H_hat'*H_hat)) + alpha*ones(N,1));
57 |
58 | % break condition
59 | delta_sqrtphi_s_hat = abs(sqrtphi_s_hat) - abs(sqrtphi_s_hat_old);
60 | if delta_sqrtphi_s_hat'*delta_sqrtphi_s_hat/(sqrtphi_s_hat_old'*sqrtphi_s_hat_old) < 1e-6
61 | % save convergence plot and break
62 | if compute_eps
63 | eps_phi_s_rel_it(i_it+1:end) = eps_phi_s_rel_it(i_it);
64 | end
65 | break;
66 | end
67 | end
68 |
69 | if compute_eps
70 | eps_phi_s_rel = eps_phi_s_rel_it(end);
71 | end
72 |
73 | end
74 |
75 |
--------------------------------------------------------------------------------
/tools/plot/plotSpec.m:
--------------------------------------------------------------------------------
1 | function plotSpec(spec, magPowLin, xTickProp, yTickProp, cRange, plotColorbar)
2 | % plotSpec(spec, magPowLin, xTickProp, yTickProp, cRange, plotColorbar)
3 | % plots spectrogram.
4 | %
5 | % IN:
6 | % spec spectrogram data - freqbins x frames
7 | % magPowLin {'mag', 'pow', 'lin'}, scaling option, plot logarithmic magnitudes, logarithmic powers, or linear
8 | % xTickProp [xTick start, xTick resolution, xTick distance]
9 | % xTickProp [yTick start, yTick resolution, yTick distance]
10 | % cRange range of colorbar
11 | % plotColorbar plot colorbar if 1
12 |
13 | % plot spectrogram
14 | switch magPowLin
15 | case 'mag'
16 | imagesc(mag2db(abs(spec)), cRange);
17 | case 'pow'
18 | imagesc(pow2db(abs(spec)), cRange);
19 | case 'lin'
20 | imagesc(spec, cRange);
21 | otherwise
22 | error('undefined scaling option.')
23 | end
24 | set(gca,'Ydir','normal');
25 | set(gca,'TickLength',[0 0]);
26 |
27 | % add colorbar
28 | if plotColorbar
29 | colorbar;
30 | end
31 |
32 | % add ticks
33 | if ~isempty(xTickProp)
34 | xStartValue = xTickProp(1);
35 | xRes = xTickProp(2);
36 | xTickDist = xTickProp(3);
37 | xTicks = 1:xTickDist:size(spec,2);
38 | xTickLabels = cellstr(num2str((xStartValue + (xTicks-1)*xRes).'));
39 | set(gca,'xTick',xTicks)
40 | set(gca,'xTickLabel',xTickLabels);
41 | else
42 | set(gca,'xTick',[])
43 | end
44 |
45 | if ~isempty(yTickProp)
46 | yStartValue = yTickProp(1);
47 | yRes = yTickProp(2);
48 | ytickDist = yTickProp(3);
49 | yTicks = 1:ytickDist:size(spec,1);
50 | yTickLabels = cellstr(num2str((yStartValue + (yTicks-1)*yRes).'));
51 | set(gca,'yTick',yTicks);
52 | set(gca,'yTickLabel',yTickLabels);
53 | else
54 | set(gca,'yTick',[]);
55 | end
56 |
57 | end
--------------------------------------------------------------------------------
/tools/spatial/calc_diffcoherence.m:
--------------------------------------------------------------------------------
1 | function Gamma = calc_diffcoherence(micPos,N_STFT,fs,c,reg,type)
2 | % Gamma = calc_diffcoherence(micPos,N_STFT,fs,c,reg,type)
3 | % calculates diffuse coherence matrix.
4 | %
5 | % IN:
6 | % micPos microphone positions - channels x coordinates
7 | % N_STFT STFT frame length
8 | % fs sampling rate
9 | % c speed of sound
10 | % reg regularization (avoids ill-conditioned matrices at very low frequencies)
11 | % type {'spherical', 'cylindrical'}, coherence type
12 | %
13 | % OUT:
14 | % Gamma diffuse coherence matrix - freqbins x 1 x channels x channels
15 |
16 | if nargin<6
17 | type = 'spherical';
18 | end
19 |
20 | N_STFT_half = N_STFT/2 + 1;
21 | f = linspace(0,fs/2,N_STFT_half);
22 |
23 | M = size(micPos,1);
24 | Gamma = (1+reg)*ones(N_STFT_half,1,M,M);
25 |
26 | for m_out = 1:M-1
27 | for m_in = m_out+1:M
28 | d = norm(micPos(m_out,:)-micPos(m_in,:));
29 | switch type
30 | case 'spherical'
31 | Gamma(:,1,m_out,m_in) = sinc(2*f*d/c);
32 | case 'cylindrical'
33 | Gamma(:,1,m_out,m_in) = besselj(0, 2*pi*f*d/c);
34 | end
35 | Gamma(:,1,m_in,m_out) = Gamma(:,1,m_out,m_in);
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/tools/spatial/doa2steervec.m:
--------------------------------------------------------------------------------
1 | function H = doa2steervec(micPos, sourceAng, N_FT_half, fs, c)
2 | % H = doa2steervec(micPos, sourceAng, N_FT_half, fs, c)
3 | % converts DoAs in steering vectors.
4 | %
5 | % IN:
6 | % micPos microphone positions - channels x coordinates
7 | % sourceAng DoA angles of sources
8 | % fs sampling frequency
9 | % c speed of sound
10 | %
11 | % OUT:
12 | % H steering vectors - freqbins x 1 x channels x sources
13 |
14 |
15 | M = size(micPos, 1);
16 | N_src = length(sourceAng);
17 |
18 | H = zeros(N_FT_half, 1, M, N_src);
19 | f = (0:N_FT_half-1)*fs/(2*(N_FT_half-1));
20 |
21 | d = sqrt(sum((micPos-repmat(micPos(1,:), [M, 1])).^2, 2));
22 |
23 |
24 | for n = 1:N_src
25 | for k = 1:N_FT_half
26 | delay = sin(deg2rad(sourceAng(n)))*d/c;
27 | % h(k,1,:,n) = exp(1i*2*pi*f(k)*delay);
28 | H(k,1,:,n) = exp(-1i*2*pi*f(k)*delay);
29 | end
30 | end
--------------------------------------------------------------------------------