# Audio Query in SuperCollider Demo

**URL:** https://discourse.flucoma.org/t/audio-query-in-supercollider-demo/1149
**Category:** Code Sharing
**Created:** [December 8, 2021, 6:22pm UTC](https://discourse.flucoma.org/t/audio-query-in-supercollider-demo/1149 "2021-12-08T18:22:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![tedmoore](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/tedmoore/32/439_2.png) [@tedmoore](https://discourse.flucoma.org/u/tedmoore)
#### Post date: [December 8, 2021, 6:22pm UTC](https://discourse.flucoma.org/t/audio-query-in-supercollider-demo/1149/1 "2021-12-08T18:22:20Z")

</div>

Here’s a script that chops up a drum loop (the Nicol drum loop that comes with the FluCoMa package) and replaces all the drums sounds with other sounds from a corpus.

[audio\_query\_with\_scaler.scd](https://discourse.flucoma.org/uploads/short-url/1KjdLmQp3oObFhUhmcIFy0EgXtk.scd) (11.3 KB)

This came out of one of our workshops last week! Thoughts, questions, additions, suggestions requested!

Video Demo:

[![](https://img.youtube.com/vi/xV1z782Ay-U/maxresdefault.jpg "Audio Query in SuperCollider (Drum Replacement by Nearest Neighbour)") ](https://www.youtube.com/watch?v=xV1z782Ay-U)

---

<div class="post-metadata">

### Author: ![Andres](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/andres/32/1840_2.png) [@Andres](https://discourse.flucoma.org/u/Andres)
#### Post date: [November 24, 2022, 5:29pm UTC](https://discourse.flucoma.org/t/audio-query-in-supercollider-demo/1149/2 "2022-11-24T17:29:44Z")

</div>

I was trying out the code and I wasn’t getting any sound out of the code until I added the neighbour variable (k) or explicitly prompted " action: " while skipping the neighbour variable in step 11.

~kdtree.kNearest(scaled\_buf, action: {  
arg nearest…

or

~kdtree.kNearest(scaled\_buf, k, {  
arg nearest…

where k is nunNeighbours.

I don’t know if this is an issue for anyone else but this solution worked for me to get actual sound from the patch in step 11. I wonder if someone else ran into the same issue. Both the scd code of the demo posted and the guide in the Flucoma release omit the numNeighbours variable when instantiating the function.

---

<div class="post-metadata">

### Author: ![weefuzzy](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/weefuzzy/32/362_2.png) [@weefuzzy](https://discourse.flucoma.org/u/weefuzzy)
#### Post date: [November 24, 2022, 5:32pm UTC](https://discourse.flucoma.org/t/audio-query-in-supercollider-demo/1149/3 "2022-11-24T17:32:41Z")

</div>

Thanks for the catch: the signature for `kNearest` changed, so we should definitely update the code with the release
