Giter VIP home page Giter VIP logo

freesound.js's Introduction

freesound.js's People

Contributors

lemonzi avatar g-roma avatar ffont avatar 749 avatar xavierfav avatar

Stargazers

Grant Fullen Jr. avatar David avatar  avatar EILSEQ avatar John C avatar Fábio avatar Morgan Kobeissi avatar Devansh Gulhane avatar Dave avatar Naoto Hieda avatar Anthony Hoss avatar Paolo Gastaldi avatar Eric Lu avatar Ethan Davidson avatar Roman Hofmann avatar Michael Chadwick avatar Jorge Gomez avatar dvc avatar Luke KB avatar Foxx avatar Diogo Cocharro avatar Federico Visi avatar aarón montoya-moraga avatar  avatar Nikita Simakov avatar Ajay Aswal avatar  avatar Prentice Bjerkeseth avatar Eric Kramer avatar Arelthia Phillips avatar Emiliano Mastragostino avatar nadir B. avatar Akito van Troyer avatar  avatar  avatar Kreig Durham avatar Eric Rosenbaum avatar  avatar Joel Robert Justiawan avatar andy 801 avatar Shaun Wakashige avatar Alessio Felicioni avatar  avatar Andrej Hronco avatar Michael Anthony avatar Martin Piffault avatar Li Song avatar Martin Dahlgren avatar Vijay Rudraraju avatar Art2code avatar Sergei Nikitin avatar  avatar Xoan Sampaiño avatar Antonello Pasella avatar

Watchers

 avatar James Cloos avatar Michael Anthony avatar John Johnston avatar thelastrider avatar

freesound.js's Issues

lack of CORS headers breaks MediaElementAudioSource

I wanted to extend your test.html to use MediaElementAudioSource with Web Audio API instead of just using AudioElement, something like this:

myAudioElement = new Audio(sound.previews['preview-hq-mp3']);
mySource = gAudioContext.createMediaElementSource(myAudioElement);
mySource.connect(gAudioContext.destination);

But no sound is heard, neither in Firefox nor in Chrome. Chrome gives this error message:

client-test.html:1 MediaElementAudioSource outputs zeroes due to CORS access restrictions for https://www.freesound.org/data/previews/96/96541_7037-hq.mp3

Spaces in search query result in TypeError

It is possible to have spaces in the search query. When run in a Node environment, at least, this results in a TypeError in makeRequest. It appears as though the makeUri method does not properly URIEncode the space character.

The same problem actually plagues an empty search query as well (e.g. searching tags only). This is because the empty string is replaced with a single space character (" "), which hits the same problem mentioned above.

I was able to bypass the empty search query issue locally by simply removing that space character and leaving it as the empty string (""). I am not sure if this works as expected or if it breaks something else that is expected.

Consider using JSON.parse instead of eval

From freesound.js#L84-87...

if (xhr.readyState === 4 && [200,201,202].indexOf(xhr.status)>=0){
    var data = eval("(" + xhr.responseText + ")");
    if(success) success(wrapper?wrapper(data):data);
}

I believe xhr.responseText is a JSON string, in which case JSON.parse can be used to safely parse the data. Is there a reason eval is used instead?

CORS errors

I'm having trouble using the API at all, due to CORS restrictions. All I tried to do was clone the repo, add my API key, and open the test.html page. But the result is just a bunch of errors like

XMLHttpRequest cannot load https://freesound.org/apiv2/search/text/?&page=1&filter=tag:tenuto%20durati…%2015.0]&sort=rating_desc&fields=id,name,url&query=violoncello&format=json. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

I am however able to use the api if I build a request using Postman, for what it's worth.

Example get descriptors value from text search

The example test.html shows how to retrieve sound from a text query. Moreover, it provides a way to then get the analysis of the retrieved sounds by performing another request.
However, the example does not show how to get analysis descriptors from text search request directly.

To make people more aware of the API good uses, it would be useful to have an example of how to perform a text query and specify some descriptors to be retrieved.

I plan to add a descriptors parameter in the example 2 of the test.html.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.