🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #6202

midi recorder/playbacker

#6202
From: John Logajan
Date: Tue, 28 Nov 1989 15:59
101 lines
3312 bytes
Someone requested a midi recorder-playbacker.

Here is my entry -- in GFA Basic.

     ------

PRINT "Simple midi recorder/playback program." ! by John Logajan, Nov 27, 1989.
DIM bt%(10000),btt%(10000)     ! 10,000 midi bytes and 10,000 byte times.
done=0
WHILE done=0
  INPUT "Enter, r=record, p=play, s=save, l=load, q=quit ";c$
  IF c$="r"
    GOSUB record
  ENDIF
  IF c$="p"
    GOSUB play
  ENDIF
  IF c$="s"
    GOSUB keep
  ENDIF
  IF c$="l"
    GOSUB revue
  ENDIF
  IF c$="q"
    done=1
  ENDIF
WEND
END
REM
REM
REM
PROCEDURE record               ! Record yourself on the midi keyboard.
  WHILE INP?(3)                ! Throw away buffered junk.
    x=INP(3)
  WEND
  PRINT "It would probably be a good idea to power off/on your midi instrument"
  PRINT "at this time to insure that it sends a proper select channel function"
  PRINT "(which it should do upon playing the first key.)"
  PRINT
  PRINT "Begin playing on your midi instrument."
  PRINT "Press any key on the Atari keyboard to exit recording mode."
  st%=TIMER                    ! Start time as a reference.
  bc%=0                        ! Zero byte (midi event) counter.
  WHILE NOT INP?(2)            ! Loop until Atari key pressed.
    IF INP?(3)                 ! Test for midi incoming byte.
      INC bc%                  ! Increment the event counter.
      bt%(bc%)=INP(3)          ! If incoming byte, save byte in byte array.
      btt%(bc%)=TIMER-st%      ! Also save relative time byte arrived.
    ENDIF
  WEND
  x=INP(2)                     ! Throw away useless key pressed.
RETURN
REM
REM
REM
PROCEDURE play                 ! Play back your creations.
  st%=TIMER-btt%(1)            ! Get playback start time as a reference.
  FOR j%=1 TO bc%              ! Do each saved event -- when it is time --
    WHILE btt%(j%)>TIMER-st%   ! -- by delaying until it is time --
    WEND
    OUT 3,bt%(j%)              ! -- and then sending event (byte) to the midi.
  NEXT j%
RETURN
REM
REM
REM
PROCEDURE keep                 ! Save your magnum opus works.
  fn$=""
  WHILE LEN(fn$)=0             ! I won't allow zero length file names.
    INPUT "Enter name of file to store this musical work of art in";fn$
  WEND
  PRINT "... saving file ..."
  OPEN "O",#1,fn$
  FOR j%=1 TO bc%
    WRITE #1,bt%(j%),btt%(j%)
  NEXT j%
  CLOSE #1
  PRINT "File saved."
RETURN
REM
REM
REM
PROCEDURE revue
  fn$=""
  WHILE LEN(fn$)=0
    INPUT "Enter name of music file you wish to hear played";fn$
  WEND
  PRINT "... loading ..."
  OPEN "I",#2,fn$
  bc%=0
  WHILE NOT EOF(#2)
    INC bc%
    INPUT #2,bt%(bc%),btt%(bc%)
  WEND
  CLOSE #2
  PRINT "File loaded and ready to play."
RETURN

-- 
- John M. Logajan @ Network Systems;  7600 Boone Ave; Brooklyn Park, MN 55428 -
- logajan@ns.network.com, john@logajan.mn.org, Phn 612-424-4888, Fax 424-2853 -
Technical Details
Message-ID: <1989Nov28.155921.9129@ns.network.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!uakari.primate.wisc.edu!nic.MR.NET!ns!logajan

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!uakari.primate.wisc.edu!nic.MR.NET!ns!logajan
From: logajan@ns.network.com (John Logajan)
Newsgroups: comp.sys.atari.st
Subject: midi recorder/playbacker
Message-ID: <1989Nov28.155921.9129@ns.network.com>
Date: 28 Nov 89 15:59:21 GMT
Sender: news@ns.network.com
Organization: Network Systems Corp., Mpls., MN
Lines: 101