Ejemplo n.º 1
0
from ftis.analyser.descriptor import FluidMFCC
from ftis.analyser.stats import Stats
from ftis.analyser.clustering import AgglomerativeClustering
from ftis.analyser.audio import CollapseAudio
from ftis.world import World
from ftis.corpus import Corpus
from ftis.common.io import get_sr, get_duration
from pathlib import Path

# instantiate
sink = "~/reaperising-ftis-2"
c = Corpus("~/Documents/Max 8/Packages/TB2-Alpha06-MacOS-Max/media")
clustering = AgglomerativeClustering(numclusters=3)

# script connection
c >> CollapseAudio() >> FluidMFCC() >> Stats() >> clustering
w = World(sink=sink)
w.build(c)
if __name__ == "__main__":
    w.run()

    # #---------- Data for render_tracks would look something like this ----------#
    # # data = {
    # #    "track1" : [
    # #        {"file" : None, "length": 1.0, "start": 0.0, "position": 0.0}
    # #    ],
    # #    "track2" : [
    # #        {"file" : None, "length": 1.0, "start": 0.0, "position": 0.0}
    # #    ]
    # # }
    # #---------------------------------------------------------------------------#
Ejemplo n.º 2
0
    .duration(min_duration=0.1, max_duration=10)
)

point = Corpus("~/Cloud/Projects/ElectroMagnetic/reaper/Interruptions/media/06-Kindle Off-200513_1547-glued-04.wav")

output = "../outputs/isolate_static"

analysis = Chain(
    source = (point+corpus),
    folder = output
)

kdtree = KDTree()
dr = UMAP(components=10, cache=1)
analysis.add(
    CollapseAudio(),
    FluidMFCC(discard=True, numcoeffs=20, fftsettings=[2048, -1, -1], cache=1),
    Stats(numderivs=1, flatten=True, cache=1),
    Standardise(cache=1),
    dr,
    kdtree
)

if __name__ == "__main__":
    analysis.run()
    pinpoint = point.items[0] # single item
    x = dr.output["/Users/james/Cloud/Projects/ElectroMagnetic/MultiCorpus/outputs/isolate_static/0_CollapseAudio/06-Kindle Off-200513_1547-glued-04.wav"]
    dist, ind = kdtree.model.query([x], k=40)
    keys = [x for x in dr.output.keys()]
    names = [keys[x] for x in ind[0]]
    d = {"1" : names}
Ejemplo n.º 3
0
    default="~/corpus-folder/fluid-dataset",
    type=str,
    help="Folder for output. This will be made if it doesnt exist.",
)
args = parser.parse_args()
"""
Using the python-flucoma package analyser outputs can be turned into datasets.
To do this we have to specifically create an instance of the analyser we are interested in.
After the FTISProcess has run we then extract the output from that instance.
"""

src = Corpus(args.input)
out = args.output

world = World(sink=out)

stats = Stats(numderivs=2,
              spec=["stddev", "mean"])  # create an instance of the stats class
src >> CollapseAudio() >> FluidMFCC() >> stats
world.build(src)

if __name__ == "__main__":
    world.run()

    # Now that ftis has completed lets pack the data into a fluid dataset
    dataset = dataset.pack(
        stats.output
    )  # use the pack function to marshall it to the right format
    dataset_path = Path(out) / "dataset.json"  # create an output path
    write_json(dataset_path.expanduser(), dataset)  # write to disk
Ejemplo n.º 4
0
from ftis.corpus import Corpus
from ftis.world import World
from ftis.world import World
from ftis.analyser.audio import CollapseAudio
from ftis.analyser.descriptor import (FluidLoudness, FluidPitch, FluidMFCC)
from ftis.analyser.stats import Stats
from pathlib import Path

corpus = Corpus("~/corpus-folder/corpus1")
collapse = CollapseAudio()
pitch = FluidPitch(fftsettings=[1024, 512, 1024])
pitch_stats = Stats(spec=["median"])
loudness = FluidLoudness(windowsize=1024, hopsize=512)
loudness_stats = Stats(spec=["mean"])


def mask_with_loudness(self):
    for k, v in loudness_stats.output.items():
        mean = v[0]
        for i, (x, y) in enumerate(loudness.output.items()):
            dbfs = y[0]
            if sum(dbfs) / len(dbfs) < mean:
                del self.output[k][0][i]
                del self.output[k][1][i]


pitch.post = mask_with_loudness

# script the connections
corpus >> collapse
collapse >> loudness >> loudness_stats
Ejemplo n.º 5
0
from ftis.corpus import Corpus
import argparse

parser = argparse.ArgumentParser(
    description="Process input and output location")
parser.add_argument(
    "-i",
    "--input",
    default="~/corpus-folder/corpus1",
    type=str,
    help="Folder for input. This should contain some audio files.",
)
parser.add_argument(
    "-o",
    "--output",
    default="~/corpus-folder/flux",
    type=str,
    help="Folder for output. This will be made if it doesnt exist.",
)
args = parser.parse_args()

src = Corpus(args.input)
out = args.output

process = World(source=src, sink=out)

process.add(CollapseAudio(), Flux())

if __name__ == "__main__":
    process.run()
Ejemplo n.º 6
0
from ftis.analyser.audio import CollapseAudio
from ftis.corpus import Corpus
from ftis.world import World
import argparse

parser = argparse.ArgumentParser(
    description="Process input and output location")
parser.add_argument(
    "-i",
    "--input",
    default="~/corpus-folder/corpus1",
    type=str,
    help="Folder for input. This should contain some audio files.",
)
parser.add_argument(
    "-o",
    "--output",
    default="~/corpus-folder/collapse",
    type=str,
    help="Folder for output. This will be made if it doesnt exist.",
)
args = parser.parse_args()

process = World(source=Corpus(args.input), sink=args.output)

process.add(CollapseAudio())

if __name__ == "__main__":
    process.run()
Ejemplo n.º 7
0
from ftis.corpus import Corpus
import argparse

parser = argparse.ArgumentParser(
    description="Process input and output location")
parser.add_argument(
    "-i",
    "--input",
    default="~/corpus-folder/corpus1",
    type=str,
    help="Folder for input. This should contain some audio files.",
)
parser.add_argument(
    "-o",
    "--output",
    default="~/corpus-folder/chroma",
    type=str,
    help="Folder for output. This will be made if it doesnt exist.",
)
args = parser.parse_args()

src = Corpus(args.input)
out = args.output

process = World(source=src, sink=out)

process.add(CollapseAudio(), Chroma())

if __name__ == "__main__":
    process.run()
Ejemplo n.º 8
0
    '--input',
    default="~/corpus-folder/corpus1",
    type=str,
    help="Folder for input. This should contain some audio files.")
parser.add_argument(
    '-o',
    '--output',
    default="~/corpus-folder/lambdas",
    type=str,
    help='Folder for output. This will be made if it doesnt exist.')
args = parser.parse_args()
"""
We can pre and process data in place, rather than having to create new analysers to process input and output data.
This functionality is inherited from the base analyser class, so everything can do it, you just need to implement what you want to do.
In this example, I simply reset the values in the output of the FluidLoudness() class after processing
"""

out = args.output
world = World(sink=out)


def remove_truepeak(self):
    self.output = {k: v[0] for k, v in self.output.items()}


corpus = Corpus(args.input)
corpus >> CollapseAudio() >> FluidLoudness(post=remove_truepeak)
world.build(corpus)

if __name__ == "__main__":
    world.run()