Last active
May 14, 2021 22:23
-
-
Save coleww/939bc606645c57dd1b29 to your computer and use it in GitHub Desktop.
overtone/freesound get ids for samples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `npm install --save request cheerio` | |
var request = require("request") | |
var cheerio = require("cheerio") | |
function getSampleIDs(query, min, max){ | |
var url = "https://www.freesound.org/search/?q="+query+"&f=duration%3A%5B"+(min || 0)+"+TO+"+(max || 1)+"%5D&s=duration+asc&advanced=1&a_tag=1&a_filename=1&a_description=1&g=" | |
request(url, function (error, response, html) { | |
if (!error && response.statusCode == 200) { | |
var $ = cheerio.load(html); | |
$(".sound_filename a").each(function(i, element){ | |
var id = $(element).attr("href").split("/").filter(function(x){return x.length}).reverse()[0] // wow what is wrong with me | |
var name = $(element).text().replace(/\W/g, "-") | |
console.log(":"+name+" (freesound "+id+")") | |
}); | |
} | |
}) | |
} | |
getSampleIDs("boop") | |
// => | |
// :8-bit-Blip-aif (freesound 170143) | |
// :8-bit-Blip1-aif (freesound 170142) | |
// :pup_fat-mp3 (freesound 167338) | |
// :menuInc-wav (freesound 87033) | |
// :menuDec-wav (freesound 87032) | |
// :Computer-Boop (freesound 186669) | |
// :Appliance-Microwave-Butt--- (freesound 144227) | |
// :beep-beep (freesound 258193) | |
// :melody-Sound-15-wav (freesound 59473) | |
// :menuSel-wav (freesound 87035) | |
// :beat-wav (freesound 99218) | |
// :boop2-wav (freesound 99219) | |
// :DeeDoot-mp3 (freesound 92066) | |
// :oot-wav (freesound 85205) | |
// :Error-wav (freesound 188013) | |
// get factory sounds that are at least 30 seconds long | |
getSampleIDs("factory", 30, "*") | |
// => | |
// :cardboard_factory_machin--- (freesound 232873) | |
// :SYnth_NoisesAT-flac (freesound 170127) | |
// :SYnth_NoisesAS-flac (freesound 170128) | |
// :whirr-WAV (freesound 252791) | |
// :industrial22 (freesound 136868) | |
// :Machine-X-02-aif (freesound 17498) | |
// :Metal_pipe_pieces_proces--- (freesound 262192) | |
// :Factory-Sounds---Lens-Ma--- (freesound 21761) | |
// :Machinery-Inside-Top-Of---- (freesound 148292) | |
// :FactoryFusionator-flac (freesound 169237) | |
// :DoubleSteamWhistle-wav (freesound 30628) | |
// :dubstep-preview (freesound 237342) | |
// :Pinning-Machine-02-wav (freesound 157677) | |
// :F-brica---Ambiente---M-q--- (freesound 237584) | |
// :080908okrzeja-mp3 (freesound 79580) | |
// copy the output into a clojure map, then play the sounds like | |
// ;; ((:key-to-the-sample yrMapOfSamples)) | |
// loop/control playback rate of samples | |
// ;; (def wat (freesound 11111111)) | |
// ;; (wat :rate 0.5 :loop? true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment