# Python FluCoMa

**URL:** https://discourse.flucoma.org/t/python-flucoma/1863
**Category:** Code Sharing
**Created:** [March 29, 2023, 1:14am UTC](https://discourse.flucoma.org/t/python-flucoma/1863 "2023-03-29T01:14:03Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jamesbradbury](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/jamesbradbury/32/1252_2.png) [@jamesbradbury](https://discourse.flucoma.org/u/jamesbradbury)
#### Post date: [March 29, 2023, 1:14am UTC](https://discourse.flucoma.org/t/python-flucoma/1863/1 "2023-03-29T01:14:03Z")

</div>

Hi all,

I took to making a new major version, 2.0.0, of the [Python/FluCOMa CLI Bindings](https://pypi.org/project/python-flucoma/2.0.0/). The major motivation was to learn how dataclasses can be leveraged to make very simple object representations of the returns from the algorithms. As a result, I’ve come up with something that feels far more native (to me at least).

For example:

```py
from pathlib import Path
from flucoma import fluid

source = Path("stereo_test.wav")
mfcc = fluid.mfcc(source, numcoeffs=5, numbands=20)

stats = fluid.stats(mfcc, numderivs=0)

# Let's see the data
for i, band in enumerate(stats):
    printout = f"Stats for MFCC band number {i}: {band}"

```

is perhaps the most basic example. All the outputs are iterable with patterns and idioms that _feel_ pythonic and you get a lot of flexibility in how you treat the objects as a result. Here is a more complicated example:

```py
from pathlib import Path
from flucoma import fluid

source = Path("Nicol-LoopE-M.wav")

# Run HPSS on the source and return a custom DataClass
hpss = fluid.hpss(source)

# Retrieve the outputs by name
harmonic = hpss.harmonic
percussive = hpss.percussive
residual = hpss.residual

# This allows you to work programatically on the outputs

for x in hpss:
    # As it stands these bindings return a path for everything, even if it wasnt made
    # HPSS can return either 2 or 3 things depending on the mode its in
    # So its worth checking that in this case the residual was made
    # If it wasn't it would be a blank string so we just don't process these
    print(x)
    if x != "":
        sines = fluid.sines(
            x
        ) # The path printed here can be passed to something else for processing
    print(sines.sines)
    print(sines.residual)

```

Anyway. I’m not sure anyone but me was using this, but its out there for anyone to play with freely.

---

<div class="post-metadata">

### Author: ![tremblap](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/tremblap/32/5_2.png) [@tremblap](https://discourse.flucoma.org/u/tremblap)
#### Post date: [March 29, 2023, 8:08am UTC](https://discourse.flucoma.org/t/python-flucoma/1863/2 "2023-03-29T08:08:52Z")

</div>

This is fantastic. You should advertise it on python and dsp groups, as there are people there that might be interested. Maybe there is a PYO bridge in the making?

---

<div class="post-metadata">

### Author: ![balintlaczko](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/balintlaczko/32/1184_2.png) [@balintlaczko](https://discourse.flucoma.org/u/balintlaczko)
#### Post date: [April 1, 2023, 1:10pm UTC](https://discourse.flucoma.org/t/python-flucoma/1863/3 "2023-04-01T13:10:25Z")

</div>

Yes, I am particularly fond of James’s genius for making this, and I am planning to use it (and advertise it:) in research!

---

<div class="post-metadata">

### Author: ![agustinissidoro](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/agustinissidoro/32/1782_2.png) [@agustinissidoro](https://discourse.flucoma.org/u/agustinissidoro)
#### Post date: [April 2, 2023, 4:06pm UTC](https://discourse.flucoma.org/t/python-flucoma/1863/4 "2023-04-02T16:06:24Z")

</div>

James, this is fantastic. Thank you so much. I came here to post a question that was inspired by your work and this has helped a lot!

---

<div class="post-metadata">

### Author: ![jarm](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/jarm/32/2205_2.png) [@jarm](https://discourse.flucoma.org/u/jarm)
#### Post date: [April 3, 2023, 9:20am UTC](https://discourse.flucoma.org/t/python-flucoma/1863/5 "2023-04-03T09:20:13Z")

</div>

Great! Thanks so much @jamesbradbury!

---

<div class="post-metadata">

### Author: ![olsgo](https://discourse.flucoma.org/letter_avatar_proxy/v4/letter/o/779978/32.png) [@olsgo](https://discourse.flucoma.org/u/olsgo)
#### Post date: [July 16, 2024, 10:57am UTC](https://discourse.flucoma.org/t/python-flucoma/1863/6 "2024-07-16T10:57:29Z")

</div>

So useful for me right now. Thank you sm for this, James 😃
