Skip to content

Accessing data for the amplitudes. #2

@saolsen

Description

@saolsen

Hey,

One of the reasons I'm interested in this library is because I want to play around with some machine listening ideas. To do some of these things I think It'll be necessary to run the samples through various algorithms like an fft that are typically written to take arrays of samples and not a sampling function.

I was looking through sampled-sound.clj and see that you have a protocol that has an amplitudes function that returns the raw sample data of the sound which I think is what I'm looking for. I see it's built using a function f that takes a channel and a time so I'm wondering why this is a separate namespace and a separate protocol when the amplitude function on ISound is so similar to this function f.

Couldn't amplitudes just be a function in the sound namespace that looks something like this?

(defn amplitudes [s sample-rate]
  (let [d (duration s)
        c (channels s)]
    (for [chan (range c)]
      (hiphip.double/amake [i (* d sample-rate)]
        (sample s (double (/ i sample-rate)) chan)))))

I'm guessing there are performance reasons as to why you have a whole other namespace since that naive function above takes a really long time to run. I also probably want a way to get a lazy sequence of the samples and not load the whole thing into memory. Then again maybe I could write an fft and other processing code that works with samples and pulls the data as it needs it.

Have you thought about this much?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions