overtone/overtone — pull request #146 by rogerallen (2012-09-03 23:23:52+00:00)
Title: potential fix (or at least starting point) for Issue 111

I've modified the code in src/overtone/helpers/file.clj to be a bit less verbose. Let me know if you think this is a reasonable change to resolve Issue 111.

It changes the output from this:

user> (freesound-path 704)
--> Asset not cached - starting download...
--> Downloading file - http://www.freesound.org/api/sounds/704?api_key=47efd585321048819a2328721507ee23
--> Download successful
--> Asset not cached - starting download...
--> Downloading file (9 KB) - http://www.freesound.org/api/sounds/704/serve?api_key=47efd585321048819a2328721507ee23
1% (0 B) completed
15% (1 KB) completed
29% (2 KB) completed
50% (4 KB) completed
72% (6 KB) completed
93% (8 KB) completed
--> Download successful
"/Users/rallen/.overtone/assets/www.freesound.org-api-sounds-704-serveapi_key47efd585321048819a2328721507ee23---1237048159/bwoop2.wav--744037877"

To this:

user> (freesound-path 704)
--> Asset not cached - starting download...
--> Downloading file - http://www.freesound.org/api/sounds/704?api_key=47efd585321048819a2328721507ee23
--> Download successful
--> Asset not cached - starting download...
--> Downloading file (9 KB) - http://www.freesound.org/api/sounds/704/serve?api_key=47efd585321048819a2328721507ee23
[======]
--> Download successful
"/Users/rallen/.overtone/assets/www.freesound.org-api-sounds-704-serveapi_key47efd585321048819a2328721507ee23---1237048159/bwoop2.wav--744037877"

For a file that is a bit more reasonable in size, instead of 100 lines of status, I changed the limit to be 50 chars, so it looks like this:

user> (freesound-path 28138)
--> Asset not cached - starting download...
--> Downloading file - http://www.freesound.org/api/sounds/28138?api_key=47efd585321048819a2328721507ee23
--> Download successful
--> Asset not cached - starting download...
--> Downloading file (4 MB) - http://www.freesound.org/api/sounds/28138/serve?api_key=47efd585321048819a2328721507ee23
[=================================================]
--> Download successful
"/Users/rallen/.overtone/assets/www.freesound.org-api-sounds-28138-serveapi_key47efd585321048819a2328721507ee23--508896364/Valladolidstation2_kort.wav--191421259"

In the code, I chose to modify the routine print-if-verbose to be println-if-verbose since that was closer to waht it was actually doing. I added new version called print-if-verbose for the new functionality. I didn't see the println-if-verbose used outside this file.

[This is my first pull request, so let me know if I'm doing this right]