rbnpi / test Goto Github PK
View Code? Open in Web Editor NEWtesting use of github. Nothing of interest here!
testing use of github. Nothing of interest here!
OK. Read up the markdown stuff now and will try and use in future. Also sorry about duplicating the help rather than just reference. Still a lot to learn about using github -:)
Tried another test
define :testing do
p=play 60,amp: 0.01, sustain: 2
control p, amp: 1
sleep 2
q=play 72,amp: 1,sustain: 2
control q,amp: 0.01
sleep 2
end
loop{testing}
#I would expect the first note to switch to amp: 1 and the second to amp: 0.01
#but control statement has no effect
#In the second example below the note: change happens exactly as I would expect.
#The first note switched up an octave immediately and the second down an octave.
define :testing do
p=play 60,amp: 0.01, sustain: 2
control p, note: 72
sleep 2
q=play 72,amp: 1,sustain: 2
control q,note: 60
sleep 2
end
loop{testing} ```
#scaleupdown is a function which plays a scale of a defined type starting on a defined note
#for a given number of octaves, first ascending then descending.
#an interesting feature is that it incorporates a crescendo an decrescendo as the scale plays
#It is also a good example for illustrating how Ruby operations on a one dimensional list or array
#can be carried out. eg use of .reverse, [1..-1] (to select all bu first element of an array)
#and linking arrays with the .zip method, so that they can be traversed together
define :scaleupdown do |n,type,octaves,v1,v2,dur|
nt=scale(n,type,num_octaves: octaves)
inc= (v2-v1).to_f/nt.length #calculate volume increment per note
vt = [v1] #starting note volume
nt.length.times do #build the volume array
vt = vt + [vt[-1]+inc] #next element is last element + increment
end
dt = [dur]*nt.length #build note duration array: all elements identical
nt.zip(dt,vt).each do |x,y,z| #zip three arrays so that they can be traversed together: current elements referred to as x,y and z
play x,amp: z,attack: y/50,sustain: 0.9*y-y/50,release: 0.1*y
sleep y
end
#now reverse the arrays, drop the first note values and play them again
nt.reverse[1..-1].zip(dt.reverse[1..-1],vt.reverse[1..-1]).each do |x,y,z|
play x,amp: z,attack: y/50,sustain: 0.9*y-y/50,release: 0.1*y
sleep y
end
end
q=0.1
use_synth :saw_s
in_thread do
scaleupdown(:c3,:major,3,0.02,1,q) #c3 major, three octaves, cresc from amp 0.02 to 1, duration of each note 0.1
end
in_thread do
scaleupdown(:e3,:minor,3,0.02,1,q) #e3 minor scale
end
scaleupdown(:g3,:major,3,0.02,1,q) #g3 major scale
OK.
I did :
p = play 60, amp: 0.01, sustain: 4
and then
control p, amp: 1, amp_slide: 3
I suspected that this would slide the amp up to 1 over 3 seconds, but couldn't detect any change
I then tried
control p, amp: 1 #which as you say would change it immediately.
I could detect no change when this was commented out., or when it was active
I then tried
control p, note: 72, note_slide 2
which slid the note up over 2 secs.
I don't understand why this does what I expect but never detect any amp changes.
also tried
control p, note: 72, note_slide: 2, amp: 1, amp: slide 2 #only the note slide works
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.