Welcome to the Parallax Discussion Forums, sign-up to participate.
var
long p_music
long nmillis
dat
BPM long 60
Charge long N_G3, T_8TH, N_C4, T_8TH, N_E4, T_8TH
long N_G4, T_8TH * 3 / 2, N_E4, T_8TH, N_G4, T_DHALF
long -1, -1
OneNote long 0, 0, -1, -1 ' for tone_on
pri play_music | nfreq
if (p_music =< 0) ' manual stop invoked?
io.freq_out(0, SPKR, 0)
return
if (--nmillis > 0) ' is note playing now?
return
nfreq := long[p_music] ' get note
p_music += 4 ' advance to timing
if (nfreq < 0) ' if end
longfill(@p_music, 0, 2)
return
nmillis := long[p_music] * 60 / BPM ' adjust timing for bpm
p_music += 4
io.freq_out(0, SPKR, nfreq) ' start the note
Comments
Though if you compile your program as COG only is it not possible to just index from a pointer passed in PAR?
dgately
What is the link to the spin2cpp programs?
Thanks
Tom
The source code is at https://github.com/totalspectrum/spin2cpp/.
There are binary releases here.
21st Century C
For instance to initialize a structure :
MY_TYPE a = { .flag = true, .value = 123, .stuff = 0.456 }; (from a stack overflow answer but the book describes this more accurately)
Other members are initialized as zero
That's new syntax for me! Thanks for sharing
I really need to see about C on the Propeller, seeing some of the examples there would be very little change between C code for WiringPi on the Raspberry Pi and code for the Propeller in many cases, this could definitely make for some interesting possibilities.
E.g Javascript:
let a = {flag : true, value : 123, stuff : 0.456};
Or Python:
a = {'flag': True, 'value': 123, 'stuff': 0.456}
What language does it more concisely ?