stevelloyd / Learn-sonification-with-Sonic-Pi

Listen to the weather using Sonic Pi and data from Mathematica
Other
11 stars 8 forks source link

Copy and tech edit #1

Closed LizUpton closed 2 years ago

LizUpton commented 10 years ago

@lauraclay Could you please apply Pi house style to this, and turn it into a standard resource in our usual template, keeping @stevelloyd visible as the author (and crediting him in a nice visible fashion)? @stevelloyd, do you have a website you'd like us to link to?

It'd be good to break the data collection and Sonic Pi parts into two separate worksheets (says @clivebeale) so they both have reuse value as individual tutorials. If you've any Sonic Pi technical queries, please ask @missphilbin - thanks!

IBPublishing commented 10 years ago

You could link to http://stevelloyd.net - thanks

stevelloyd commented 10 years ago

Whoops! I was logged in on my work account, I should have been @stevelloyd

lauraclay commented 10 years ago

@LizUpton I've forked a local copy and applied Pi house style and some edits, but the code is being a bit of a pain.

It looks like the temperature.txt file is formatted incorrectly when the data are extracted- instead of 'Quantity[15., "DegreesCelsius"]' my entries look like '{{2014, 10, 1, 1, 50, 0}, 17.}'. Sonic Pi merrily displays this in the Output menu but doesn't play any sounds. If I manually create a temperature.txt formatted the first way, Sonic Pi plays sounds as expected, so perhaps there's something amiss in the Mathematica command to extract the data? @stevelloyd any thoughts?

stevelloyd commented 10 years ago

@lauraclay it may be a Mathematica versions thing - can you check the Help>About Wolfram Mathematica menu item. I get version 10.0.0.0 reported-see image. The previous version's values did look like the format you're seeing. screen shot 2014-10-14 at 15 03 54

lauraclay commented 10 years ago

Hmm, that's the version I have, and the latest Sonic Pi. I've run apt-get update and apt-get upgrade, and the only difference in the command I'm typing is the quote marks are straight (pasting the command as-is produces an error over the curly quotes). Here are the contents of the file- I've tried it two or three times now, but I'll keep at it...

values

stevelloyd commented 10 years ago

@lauraclay hmm interesting, I'll take a look in case I've got some global setting which causes the difference. Sorry this is being a pain!

stevelloyd commented 10 years ago

@lauraclay I've discovered there's more to the Mathematica version than meets the eye. If you look at the About Mathematica menu item and access 'System Information' in the dialog, you'll see a Version with a date. I duplicated the difference between what we're seeing on two systems which had the revisions as below. I updated the older system to the Aug4, 2014 version, and it now behaves the same. If you can duplicate this, it may mean a warning in the README about updating Mathematica (I've put this into my copy).

I did think whether there is a way of making older Mathematica versions produce the new format, but it makes the code a bit less clear.

Thanks for the quote mark info - I've fixed in my version (my Markdown editor being over helpful!)

screen shot 2014-10-14 at 20 13 01

lauraclay commented 10 years ago

@stevelloyd aha! Well spotted! Have run all the upgrades again, and the text file is now in the correct format. For some reason apt-get upgrade was holding back the Mathematica update I thought it had installed. Ah well, all working now :)

stevelloyd commented 10 years ago

Great! There's something in the back of my mind about Mathematica being a little finicky when upgrading, but I can't track down any reference online. I guess the advantage of doing a full update will be that people get the latest and greatest Sonic Pi too...

I did update a bit of the ruby code for scaling, to make sure something plays even if the temperature is minus (its been getting old in Wales) - but this is just a frill.

# scale(t)
# multiply t by a scaling factor to get a playable note
# and limit to a lower minimum
def scale(t)
    scaling_factor = 3
    lower_limit = 30
    scaled_note =  t.to_i * scaling_factor
    return (scaled_note < lower_limit) ? lower_limit : scaled_note
end
stevelloyd commented 10 years ago

Haha! for old read cold