Experimental Recorder

Very raw and basic starter!

' experimental recorder.bas  SmallBASIC 0.12.8 [B+=MGA] 2017-03-28

randomize
const cx = xmax/2
const cy = ymax/2
const maxd = sqr(cx^2 + cy^2)
pen on
dim xy()
menu
while 1
  k = inkey
  select case k
    case "c" : cls : dim xy()
    case "p" : playXY
    case "s" : tsave "Recording.txt", xy
    case "l" : tload "Recording.txt", xy : playXY
  end select
  if pen(3) then
    mx = pen(4) : my = pen(5)
    gr = 255 - 255 * sqr((cx - mx) ^ 2 + (cy - my) ^ 2) / maxd
    cc = rgb(mx/xmax * 255, gr, my/ymax * 255)
    color cc
    sound 150 + my / ymax * 5000, mx / xmax * 1500
    circle mx, my, 10
    xy <<  mx : xy << my
  else
    mx = 0 : my = 0
  end if
wend

sub playXY
  local mx, my, i, cc, ub
  cls
  ub = ubound(xy)
  for i = 0 to ub-1 step 2
    mx = xy(i) : my = xy(i+1)
    ? i, mx, my
    gr = 255 - 255 * sqr((cx - mx) ^ 2 + (cy - my) ^ 2) / maxd
    cc = rgb(mx/xmax * 255, gr, my/ymax * 255)
    color cc
    sound 150 + my / ymax * 5000, mx / xmax * 1500
    circle mx, my, 10
    if i mod 15 = 14 then 'keep screen from scrolling
      rect 0, 0, 150, ymax, 0 filled
      locate 1, 1
    end if
  next
end

sub menu
  locate 1, 50 : ? "press c to clear everything"
  locate 2, 50 : ? "press p to play back"
  locate 3, 50 : ? "press l to load a play the Recording.txt file"
  locate 4, 50 : ? "press s to save to Recording.txt file."
  locate 6, 50 : ? "press mouse left button to sound a note, show a circle."
  locate 7, 50 : ? "left plays fast beat, right slow."
  locate 8, 50 : ? "low frequency upper screen, higher lower screen."
end
 

And a first recording (Save as Recording.txt in same folder as Experimental Recorder code):

710
93
603
148
583
156
708
93
708
93
96
67
96
67
98
69
98
72
90
110
87
144
87
187
86
222
86
273
86
307
86
318
105
278
133
203
147
167
171
117
191
93
229
94
222
131
208
176
218
201
831
117
842
452
842
452
988
551
1015
374
1090
191
833
215
627
354
975
207
806
282
137
507
146
472
175
332
277
322
262
463
277
565
339
448
266
152
351
100
340
152
101
147
94
158
71
213
59
266
53
319
49
405
48
503
47
545
60
468
57
337
51
217
55
173
121
151
190
182
230
308
308
265
423
161
491
275
501
340
600
251
727
188
992
100
1061
171
1144
403
483
490
463
304
527
223
585
189
369
194
278
197

Dang, I better switch to string format.

Well that's alright MGA. We got a sample to work with. (I started on clarinet & band in 5th grade, shifted to violin & orchestra in 7th, and then in 8th went full-time Science and dropped music. It's been on my 'bucket list', to get back to a little something musical.)

I have 2 more days of work, then the weekend off. I am plinking along little by little on my code projects, especially the Bresenham Thick Line. As we dig out from under the big winter, and we stabilize into growing-season, it will slack-up for me because someone else is doing the grass. I will be Senior Design Grunt, and Trails Artist. First time in decades for an easy summer. Will be working about half-time, at most. With good blocks of down-time.

I've been considering options for the same kind of thing you are trying to do with the Recording-txt. It was once common, to use some Text-Processing, and stuff serious material in DATA Statements. Then use a little loop to READ the data out to a file ... and then yer back to normal.

DATA-stuffers were used for ASM routines (we don't have a POKE, do we? or any way to 'drop' to low-level code? I do minor ASM ok). Games packed formatted Terrain coordinates in the DATA. DATA for images - with a Warning to check yer Room Occupancy - were compressed and packed.

By the hundreds of lines even ... which would get a little much for a Forum Post, but within reason it could bridge the gap, here.

That's lunch, back to the job. - Ted