Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HeLoh (Includes Link to MP3 of dry signal)

0 views
Skip to first unread message

Bohgosity BumaskiL

unread,
Jun 17, 2009, 2:24:29 PM6/17/09
to
' CC-BY-NC-ND
' http://www.playscreen.com/ringtones/preview.php?Cat_Id=1&Cn_Id=10589
' Got better lyrics? Tell me. I do not post with a valid address
' for nothing. You can license the tune separately if I know you
' and from where you want to distribute. Seventeen syllables that
' fail to indicate season are not a haiku, and this is babble, so
' I do not think it qualifies as a senryu:

' CC-BY-ND.
' http://en.wikipedia.org/wiki/Creative_Commons_Licenses
' I make dry signal available for instruction and use in performance.
' Please do not distribute modz or derivative recordings.
' The -BY- part applies more to this source code with major
' changes
' like a different tune, use in a faster language, or use in a more
' convenient GUI than it does to dry signal, and if someone
' asks, then remember BrewJay's Babble Bin.
' http://ecn.ab.ca/~brewhaha/Sound/HeLoh.mp3

' If lower case occurs on a line, then it was broken from the
' previous line, in case you want to compile this.

' Part, basis frequency, each, for left then right channel.
' Enables channel exchange for biased ears. In the vocal recording
' I change sides.
DATA 1,8,2,8

' I wrote two tunes that stand on their own to some degree, the
' first, on the right, better than the one on the left, and it
' happens that they frequently meet in unison. At first, they were
' only close, so I had things like 32:33, which is a fast beat. So,
' I adjusted some of the numbers to hit low ratios in concert. The
' compromise in what I wrote the first time through did not
' contest my perception of how well these parts stand on their own.
' I tried exchanging the first two notes on the right channel,
' because
' that would make it begin where it ends, only 4:3 becomes 3:4.
' However neat that would hav been, it made for a slow start.
' Left, Right, time, 1/glide = proportion of note gliding from
previous.
DATA 40,20,3,30
' Octave
DATA 30,30,3,30
' Unison
DATA 20,50,3,30
' 5:2, or a major third plus an octave
DATA 30,45,2,30
' Perfect Fifth
DATA 40,55,1,30
' Lesser undecimal tritone
DATA 50,50,2,30
' Unison
DATA 45,45,1,30
' Unison
DATA 40,40,2,30
' Unison
DATA 0,0,1,300

DATA 18,45,3,30
' Five tuh two.
DATA 27,40,2,30
' That is not a wolfnote to my ears in this context.
DATA 35,49,1,30
' Lesser septimal tritone
DATA 45,45,2,30
' Unison.
DATA 40,40,1,30
' Unison.
DATA 35,35,2,30
' Unison
DATA 0,0,1,300

DATA 32,50,2,30
' Twenty-Five to sixteen. Either nobody else uses it or there
' is a name for it that I did not find, yet. It's *close* to an Indian
' Dha or a pythagorean major sixth.
DATA 24,30,3,7
' Minor third.
DATA 36,45,3,30
' Minor third.
DATA 27,50,2,30
' Diminished fifth.
DATA 40,40,4,30
' You guessed it. It's a theme in two-part solos, methinks.
DATA 0,0,11,300

OPTION BASE 1
DIM TwoPi, pi, FlipStart, Temp, BeatsPerSecond AS DOUBLE
DIM angle(4), velocity(4), Acceleration(4), Phase(4) AS DOUBLE
DIM note(4), lastnote(4), length AS SINGLE
DIM harmonics(4) AS SINGLE
DIM samples, t, samplerate AS LONG
DIM k, g, amp, basis, numharmonics AS INTEGER
DIM part(4), Sign(4), glide AS INTEGER
DIM test AS STRING

PRINT
test = "0"
' I frequently flip that.
numharmonics = 2
BeatsPerSecond = 5.5123128#
pi = 3.141592653589793#
TwoPi = pi * 2
samplerate = 8000
lastnote(1) = 0
lastnote(2) = 0

IF test = "0" THEN
OPEN "helloh.bat" FOR OUTPUT AS #1
OPEN "\sox\helloh.raw" FOR OUTPUT AS #4
PRINT #1, "e:\progra~1\freebasic\fbc -lang qb d:\basic
\helloh.bas"
PRINT #1, "helloh.exe"
PRINT #1, "cd \sox"
PRINT #1, "sox -c 2 -r"; samplerate; " -sw helloh.raw
helloh.wav stat"
CLOSE #1, #2
END IF

FOR k = 1 TO numharmonics
READ part(k), harmonics(k)
note(k) = 0
lastnote(k) = 0
NEXT k

100
FOR g = 1 TO 22
READ note(1), note(2), length, glide
' SOUND note(2) * 8, length * 3
' Under Windows XP, QBASIC is faster, and timing is more consistent,
' in full screen mode. It still does not compare to compilation with
' FreeBasic, outside of test mode, which uses the above sound
' statement
' that FreeBasic does not support, instead of writing sine waves.
IF test = "0" THEN
IF note(1) = 0 AND lastnote(1) = 0 THEN
samples = samplerate * length / BeatsPerSecond
GOSUB 300
GOTO 75
END IF
IF note(1) = 0 AND lastnote(1) <> 0 THEN
GOSUB 250
FOR k = 1 TO numharmonics
lastnote(k) = note(k)
NEXT k
samples = samplerate * length / BeatsPerSecond
GOSUB 300
GOTO 75
END IF
IF lastnote(1) = 0 AND note(1) <> 0 THEN
FOR k = 1 TO numharmonics
lastnote(k) = note(k)
NEXT k
samples = samplerate * length / BeatsPerSecond
GOSUB 300
GOTO 75
END IF
IF note(1) <> 0 AND lastnote(1) <> 0 THEN
samples = samplerate * length /
BeatsPerSecond / glide
GOSUB 300
samples = samplerate * length / BeatsPerSecond
FOR k = 1 TO numharmonics
lastnote(k) = note(k)
NEXT k
GOSUB 300
GOTO 75
END IF
END IF

75 NEXT g

END

' Silencer. It still has a click in it, and that is physics of the
' heavyside function. I want to make the last quarter of an
' oscillation, starting at 1 or -1, instantly hit half the amplitude,
' biased by half, and all the way to the opposite pole, where the
' slope
' is zero.
250
FOR k = 1 TO numharmonics
Sign(k) = SGN(Phase(k))
angle(k) = angle(k) + velocity(k)
Temp = SIN(angle(k))

IF SGN(Temp) <> Sign(k) THEN
Phase(k) = 0
angle(k) = angle(k) - velocity(k)
ELSE
Phase(k) = Temp
END IF
NEXT k

GOSUB 400

FOR k = 1 TO numharmonics
IF Phase(k) <> 0 GOTO 250
NEXT k

FlipStart = FlipStart + pi
FOR k = 1 TO numharmonics
angle(k) = FlipStart
NEXT k
RETURN

300
' Calculate constants of change for write loop.
FOR k = 1 TO numharmonics
velocity(k) = TwoPi * lastnote(part(k)) * harmonics(k) /
samplerate
Acceleration(k) = (TwoPi * note(part(k)) * harmonics(k) /
samplerate - velocity(k)) /

samples
NEXT k

' Main write loop. Static Phases problem solved at 250.
FOR t = 1 TO samples
FOR k = 1 TO numharmonics
Phase(k) = SIN(angle(k))
NEXT k

GOSUB 400

FOR k = 1 TO numharmonics
angle(k) = angle(k) + velocity(k)
velocity(k) = velocity(k) + Acceleration(k)
NEXT k
NEXT t
RETURN

400
' Write a sample.
amp = CINT(Phase(1) * 31700)
PRINT #4, CHR$(amp AND 255);
PRINT #4, CHR$((amp AND 65280) / 256);

amp = CINT(Phase(2) * 31700)
PRINT #4, CHR$(amp AND 255);
PRINT #4, CHR$((amp AND 65280) / 256);
RETURN

' For some reason, LAME was clipping my MP3. That's where
' 31700, instead of 32767 comes from.

0 new messages