• Back & Forth - It still sounds MID.. [7b]

    From Hans Bezemer@the.beez.speaks@gmail.com to comp.lang.forth on Fri May 1 19:44:21 2026
    From Newsgroup: comp.lang.forth

    Now on YT: https://youtu.be/ExDbY0X7Cvg

    Hans Bezemer
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From marcel hendrix@mhx@iae.nl to comp.lang.forth on Fri Jul 3 15:24:47 2026
    From Newsgroup: comp.lang.forth

    On 5/1/2026 7:44 PM, Hans Bezemer wrote:
    Now on YT:  https://youtu.be/ExDbY0X7Cvg

    Hans Bezemer

    What about chords and multiple players?

    https://iforth.nl/canonc.mid

    -marcel
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From dxf@dxforth@gmail.com to comp.lang.forth on Sun Jul 5 18:33:58 2026
    From Newsgroup: comp.lang.forth

    On 3/07/2026 11:24 pm, marcel hendrix wrote:
    On 5/1/2026 7:44 PM, Hans Bezemer wrote:
    Now on YT:  https://youtu.be/ExDbY0X7Cvg

    Hans Bezemer

    What about chords and multiple players?

    https://iforth.nl/canonc.mid

    Whatever that is, it reminded me of ...

    https://youtu.be/2r0CCRbHh70


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Hans Bezemer@the.beez.speaks@gmail.com to comp.lang.forth on Sun Jul 5 19:08:37 2026
    From Newsgroup: comp.lang.forth

    On 03-07-2026 15:24, marcel hendrix wrote:
    On 5/1/2026 7:44 PM, Hans Bezemer wrote:
    Now on YT:  https://youtu.be/ExDbY0X7Cvg

    Hans Bezemer

    What about chords and multiple players?

    https://iforth.nl/canonc.mid

    -marcel


    Well, I think I set out my initial design objectives pretty well. And
    yeah -- I think I have a clue on how to do chords.

    But the motto of my project has always been "this is supposed to be
    fun". And at this moment I'm not too motivated to put the effort in.

    If others wanna do that, be my guest. If someone begged me to do that,
    maybe.

    If I come along something that required chords, I think I might pull the
    libs out and enhance them accordingly.

    But right now, I'm fine. It was fun! :-)

    Hans Bezemer
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Hans Bezemer@the.beez.speaks@gmail.com to comp.lang.forth on Thu Jul 9 18:18:44 2026
    From Newsgroup: comp.lang.forth

    On 03-07-2026 15:24, marcel hendrix wrote:
    On 5/1/2026 7:44 PM, Hans Bezemer wrote:
    Now on YT:  https://youtu.be/ExDbY0X7Cvg

    Hans Bezemer

    What about chords and multiple players?

    https://iforth.nl/canonc.mid

    -marcel
    What about this?

    : m.Chord ( p1 p2 p3 px x duration delay --)
    >MID rot swap \ setup (duration n delay)
    [: over if .delay 90 emit rot mid&C dup emit m.Velocity emit >r 1- 0 recurse
    swap dup .delay 80 emit r> emit m.Velocity emit >zero ;then drop ;]
    execute drop drop ; \ execute the chord

    Hans Bezemer
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Hans Bezemer@the.beez.speaks@gmail.com to comp.lang.forth on Fri Jul 10 14:43:35 2026
    From Newsgroup: comp.lang.forth

    On 09-07-2026 18:18, Hans Bezemer wrote:
    $ svn commit -m "Added chords to midi-w.4th"
    Sending 4th.src/lib/midi-w.4th
    Transmitting file data .done
    Committing transaction...
    Committed revision 1780.

    I guessed you bagged too much, I couldn't resist it no more. :-)

    Hans Bezemer

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From albert@albert@SPENARNC.XS4ALL.NL to comp.lang.forth on Sat Jul 11 17:09:19 2026
    From Newsgroup: comp.lang.forth

    Hans Bezemer <the.beez.speaks@gmail.com> wrote:
    Now on YT: https://youtu.be/ExDbY0X7Cvg

    Hans Bezemer
    I hate that you don't mention what it is all about.
    It is about midi. It invites me to type ExDbYo(or 0) in the newsreader
    cause the newsreader don't support cut and place. So I followed
    up, my editor does it better.
    We are at it, This is the rosetta challenge to play a scale.
    A regular speaker required! MAKE-ACCESSABLE is not needed for MSDOS.
    In linux you want XOS generic OS access, e.g. in ciforth.

    ---------------------------------------
    "$-PREFIX" WANTED "-scripting-" WANTED
    : MAKE-ACCESSABLE ( n-) 1 1 $65 XOS
    DUP IF ." You cannot access i/o ports, become root" CR THROW THEN ;
    : MAKE-SPEAKER-ACCESSABLE ( - )
    $42 MAKE-ACCESSABLE $43 MAKE-ACCESSABLE $61 MAKE-ACCESSABLE ;
    : SET-FREQUENCY ( n - ) $B6 $43 PC! DUP $42 PC! 8 RSHIFT $42 PC! ;
    : SPEAKER-ON ( - ) $61 PC@ 3 OR $61 PC! ;
    : SILENT-SPEAKER ( -) $61 PC@ $FC AND $61 PC! ;
    : secunde 17843 18904 */ ;
    CREATE _notes 35613 ( C2) 12 0 DO DUP , secunde LOOP DROP
    : >timing ( n - n) 24 - 12 /MOD SWAP CELLS _notes + @ SWAP RSHIFT ;
    : NOTE-ON ( n-) >timing SET-FREQUENCY SPEAKER-ON ;
    : NOTE-OFF ( n-) DROP SILENT-SPEAKER ;
    : PLAY-NOTE ( n n -) OVER NOTE-ON MS NOTE-OFF ;
    : .. ( n - ) 1000 PLAY-NOTE ;
    \ Play a scale starting at the keyhole c.
    : PLAY-SCALE
    \ c' d' e' f' g' a' b' c''
    60 .. 62 .. 64 .. 65 .. 67 .. 69 .. 71 .. 72 ..
    3000 MS ;
    MAKE-SPEAKER-ACCESSABLE PLAY-SCALE
    ---------------------------------------

    The same scale played on mswindows. (Assuming WINMM.DLL is present
    in SYSTEM32. a multimedia library.)
    openmidi sendmidi closemidi are wrappers around dll calls.
    They are slightly more than wrappers, because if you
    do
    wina -c midi.frt
    a midi.exe is generated that you can transport accross
    windows systems (i.e. no Forth system needs to be present).

    ---------------------------------------
    \ $Id: midi.frt,v 1.7 2015/04/15 02:04:17 albert Exp albert $
    \ Copyright (2012): Albert van der Horst {by GNU Public License}
    \ Uses MIDI facility to play a simple melody.
    \ vrij naar Jones jonesforth

    WANT sendmidi ( and openmidi closemid )
    WANT CASE-INSENSITIVE CASE-INSENSITIVE
    1 CONSTANT 'Grand_Piano'

    VARIABLE instrument

    : midi-errors
    "
    2001 : Failed to open MIDI output device
    2002 : Failed to close MIDI output device
    2003 : Failed to send to MIDI output device
    " TYPE ;

    : -i SHIFT-ARGS 1 ARG[] EVALUATE instrument ! SHIFT-ARGS ;

    : -h midi-errors
    "
    -h this help
    -i <instr> : install instrument to play on
    " ETYPE
    BYE ;

    HEX
    \ Send a midi start message for NOTE
    : StartNote 8 LSHIFT 7F0090 OR sendmidi ;

    \ Send a midi stop message for NOTE
    : StopNote 8 LSHIFT 80 OR sendmidi ;

    \ Send a midi select message for VOICE
    : SetInstrument 8 LSHIFT 7F00C0 OR sendmidi ;
    DECIMAL

    \ Play a NOTE for TIME milliseconds.
    : PlayNote OVER StartNote MS StopNote ;


    : handle-args ARGC 1 > IF 1 ARG[] EVALUATE THEN ;

    : play
    instrument @ SetInstrument
    70 500 PlayNote
    72 500 PlayNote
    68 500 PlayNote
    56 500 PlayNote
    63 1000 PlayNote
    1000 MS
    ;

    : doit openmidi handle-args play closemidi ; ---------------------------------------

    A midiplayer for actual midi files is easy given WINMM.DLL,
    but the margin is too small to contain it.

    Groetjes Albert
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Hans Bezemer@the.beez.speaks@gmail.com to comp.lang.forth on Sat Jul 11 18:21:00 2026
    From Newsgroup: comp.lang.forth

    On 11-07-2026 17:09, albert@SPENARNC.XS4ALL.NL wrote:
    Hans Bezemer <the.beez.speaks@gmail.com> wrote:
    Now on YT: https://youtu.be/ExDbY0X7Cvg

    Hans Bezemer
    I hate that you don't mention what it is all about.
    It is about midi. It invites me to type ExDbYo(or 0) in the newsreader
    cause the newsreader don't support cut and place. So I followed
    up, my editor does it better.
    We are at it, This is the rosetta challenge to play a scale.
    A regular speaker required! MAKE-ACCESSABLE is not needed for MSDOS.
    In linux you want XOS generic OS access, e.g. in ciforth.

    ---------------------------------------
    "$-PREFIX" WANTED "-scripting-" WANTED
    : MAKE-ACCESSABLE ( n-) 1 1 $65 XOS
    DUP IF ." You cannot access i/o ports, become root" CR THROW THEN ;
    : MAKE-SPEAKER-ACCESSABLE ( - )
    $42 MAKE-ACCESSABLE $43 MAKE-ACCESSABLE $61 MAKE-ACCESSABLE ;
    : SET-FREQUENCY ( n - ) $B6 $43 PC! DUP $42 PC! 8 RSHIFT $42 PC! ;
    : SPEAKER-ON ( - ) $61 PC@ 3 OR $61 PC! ;
    : SILENT-SPEAKER ( -) $61 PC@ $FC AND $61 PC! ;
    : secunde 17843 18904 */ ;
    CREATE _notes 35613 ( C2) 12 0 DO DUP , secunde LOOP DROP
    : >timing ( n - n) 24 - 12 /MOD SWAP CELLS _notes + @ SWAP RSHIFT ;
    : NOTE-ON ( n-) >timing SET-FREQUENCY SPEAKER-ON ;
    : NOTE-OFF ( n-) DROP SILENT-SPEAKER ;
    : PLAY-NOTE ( n n -) OVER NOTE-ON MS NOTE-OFF ;
    : .. ( n - ) 1000 PLAY-NOTE ;
    \ Play a scale starting at the keyhole c.
    : PLAY-SCALE
    \ c' d' e' f' g' a' b' c''
    60 .. 62 .. 64 .. 65 .. 67 .. 69 .. 71 .. 72 ..
    3000 MS ;
    MAKE-SPEAKER-ACCESSABLE PLAY-SCALE ---------------------------------------

    The same scale played on mswindows. (Assuming WINMM.DLL is present
    in SYSTEM32. a multimedia library.)
    openmidi sendmidi closemidi are wrappers around dll calls.
    They are slightly more than wrappers, because if you
    do
    wina -c midi.frt
    a midi.exe is generated that you can transport accross
    windows systems (i.e. no Forth system needs to be present).

    ---------------------------------------
    \ $Id: midi.frt,v 1.7 2015/04/15 02:04:17 albert Exp albert $
    \ Copyright (2012): Albert van der Horst {by GNU Public License}
    \ Uses MIDI facility to play a simple melody.
    \ vrij naar Jones jonesforth

    WANT sendmidi ( and openmidi closemid )
    WANT CASE-INSENSITIVE CASE-INSENSITIVE
    1 CONSTANT 'Grand_Piano'

    VARIABLE instrument

    : midi-errors
    "
    2001 : Failed to open MIDI output device
    2002 : Failed to close MIDI output device
    2003 : Failed to send to MIDI output device
    " TYPE ;

    : -i SHIFT-ARGS 1 ARG[] EVALUATE instrument ! SHIFT-ARGS ;

    : -h midi-errors
    "
    -h this help
    -i <instr> : install instrument to play on
    " ETYPE
    BYE ;

    HEX
    \ Send a midi start message for NOTE
    : StartNote 8 LSHIFT 7F0090 OR sendmidi ;

    \ Send a midi stop message for NOTE
    : StopNote 8 LSHIFT 80 OR sendmidi ;

    \ Send a midi select message for VOICE
    : SetInstrument 8 LSHIFT 7F00C0 OR sendmidi ;
    DECIMAL

    \ Play a NOTE for TIME milliseconds.
    : PlayNote OVER StartNote MS StopNote ;


    : handle-args ARGC 1 > IF 1 ARG[] EVALUATE THEN ;

    : play
    instrument @ SetInstrument
    70 500 PlayNote
    72 500 PlayNote
    68 500 PlayNote
    56 500 PlayNote
    63 1000 PlayNote
    1000 MS
    ;

    : doit openmidi handle-args play closemidi ; ---------------------------------------

    A midiplayer for actual midi files is easy given WINMM.DLL,
    but the margin is too small to contain it.

    Groetjes Albert

    I have no idea what your beef is. If I wonder what's it all about in YT,
    I pull up the description, which in this case says:

    "Last time, we learned how to create Midi files using Forth. We were
    able to convert old ZX BASIC programs to the library we created - and replicate these melodies without too much effort.

    In this second part, we say goodbye to the Midi piano and learn how to
    use different instruments. We will see how we can encode musical notes -
    and even raw frequencies."

    I have no idea what you want with "playing a scale". Because that's
    trivial in the lib I wrote, since you can reference the notes themselves
    by their name.

    I can't remember the last time I used the beeper -- since PCs come with
    sound cards since the turn of the century. But don't let me keep you
    from having fun. If that wets your taste for nostalgia, let it be.

    I have no idea whether there is an actual MIDI device in my current
    soundcard -- and frankly I don't care. I tend to use timidity - and that
    works with files.

    If I wanna use a Midi sample, I'll pass it through LAME and I got an MP3
    which works just fine with Kdenlive.

    The latter example was just fun. I converted it to the library and this
    came out:

    include lib/midi-w.4th

    ---8<---
    s" ce3k.mid" MIDopen abort" Can't open Midi file"

    Bright_Acoustic_Piano m.Use

    50 10 m.Beep
    50 12 m.Beep
    50 8 m.Beep
    50 -4 m.Beep
    100 3 m.Beep

    MIDclose
    ---8<---

    This was the first time I created a "beep" file from a MIDI file. Note
    that this format was derived from the ZX Spectrum. So I fired up Fuse
    and typed:

    10 BEEP 0.5,10: BEEP 0.5,12: BEEP 0.5,8: BEEP 0.5,-4: BEEP 1,3

    And then ran it. Perfect rendition! Written in 4tH, transcribed to BASIC
    and ported to the ZX Spectrum.

    You know: we all have our nostalgia weaknesses! :-)

    Hans Bezemer

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Hans Bezemer@the.beez.speaks@gmail.com to comp.lang.forth on Sat Jul 11 18:49:12 2026
    From Newsgroup: comp.lang.forth

    On 11-07-2026 17:09, albert@SPENARNC.XS4ALL.NL wrote:
    Hans Bezemer <the.beez.speaks@gmail.com> wrote:
    Now on YT: https://youtu.be/ExDbY0X7Cvg

    Hans Bezemer
    I hate that you don't mention what it is all about.
    It is about midi. It invites me to type ExDbYo(or 0) in the newsreader
    cause the newsreader don't support cut and place. So I followed
    up, my editor does it better.
    We are at it, This is the rosetta challenge to play a scale.
    A regular speaker required! MAKE-ACCESSABLE is not needed for MSDOS.
    In linux you want XOS generic OS access, e.g. in ciforth.

    ---------------------------------------
    "$-PREFIX" WANTED "-scripting-" WANTED
    : MAKE-ACCESSABLE ( n-) 1 1 $65 XOS
    DUP IF ." You cannot access i/o ports, become root" CR THROW THEN ;
    : MAKE-SPEAKER-ACCESSABLE ( - )
    $42 MAKE-ACCESSABLE $43 MAKE-ACCESSABLE $61 MAKE-ACCESSABLE ;
    : SET-FREQUENCY ( n - ) $B6 $43 PC! DUP $42 PC! 8 RSHIFT $42 PC! ;
    : SPEAKER-ON ( - ) $61 PC@ 3 OR $61 PC! ;
    : SILENT-SPEAKER ( -) $61 PC@ $FC AND $61 PC! ;
    : secunde 17843 18904 */ ;
    CREATE _notes 35613 ( C2) 12 0 DO DUP , secunde LOOP DROP
    : >timing ( n - n) 24 - 12 /MOD SWAP CELLS _notes + @ SWAP RSHIFT ;
    : NOTE-ON ( n-) >timing SET-FREQUENCY SPEAKER-ON ;
    : NOTE-OFF ( n-) DROP SILENT-SPEAKER ;
    : PLAY-NOTE ( n n -) OVER NOTE-ON MS NOTE-OFF ;
    : .. ( n - ) 1000 PLAY-NOTE ;
    \ Play a scale starting at the keyhole c.
    : PLAY-SCALE
    \ c' d' e' f' g' a' b' c''
    60 .. 62 .. 64 .. 65 .. 67 .. 69 .. 71 .. 72 ..
    3000 MS ;
    MAKE-SPEAKER-ACCESSABLE PLAY-SCALE ---------------------------------------

    The same scale played on mswindows. (Assuming WINMM.DLL is present
    in SYSTEM32. a multimedia library.)
    openmidi sendmidi closemidi are wrappers around dll calls.
    They are slightly more than wrappers, because if you
    do
    wina -c midi.frt
    a midi.exe is generated that you can transport accross
    windows systems (i.e. no Forth system needs to be present).

    ---------------------------------------
    \ $Id: midi.frt,v 1.7 2015/04/15 02:04:17 albert Exp albert $
    \ Copyright (2012): Albert van der Horst {by GNU Public License}
    \ Uses MIDI facility to play a simple melody.
    \ vrij naar Jones jonesforth

    WANT sendmidi ( and openmidi closemid )
    WANT CASE-INSENSITIVE CASE-INSENSITIVE
    1 CONSTANT 'Grand_Piano'

    VARIABLE instrument

    : midi-errors
    "
    2001 : Failed to open MIDI output device
    2002 : Failed to close MIDI output device
    2003 : Failed to send to MIDI output device
    " TYPE ;

    : -i SHIFT-ARGS 1 ARG[] EVALUATE instrument ! SHIFT-ARGS ;

    : -h midi-errors
    "
    -h this help
    -i <instr> : install instrument to play on
    " ETYPE
    BYE ;

    HEX
    \ Send a midi start message for NOTE
    : StartNote 8 LSHIFT 7F0090 OR sendmidi ;

    \ Send a midi stop message for NOTE
    : StopNote 8 LSHIFT 80 OR sendmidi ;

    \ Send a midi select message for VOICE
    : SetInstrument 8 LSHIFT 7F00C0 OR sendmidi ;
    DECIMAL

    \ Play a NOTE for TIME milliseconds.
    : PlayNote OVER StartNote MS StopNote ;


    : handle-args ARGC 1 > IF 1 ARG[] EVALUATE THEN ;

    : play
    instrument @ SetInstrument
    70 500 PlayNote
    72 500 PlayNote
    68 500 PlayNote
    56 500 PlayNote
    63 1000 PlayNote
    1000 MS
    ;

    : doit openmidi handle-args play closemidi ; ---------------------------------------

    A midiplayer for actual midi files is easy given WINMM.DLL,
    but the margin is too small to contain it.

    Groetjes Albert

    BTW, according to my research, this is a much closer approximation to
    that theme:

    ---8<---
    include lib/midi-w.4th

    s" ce3k.mid" MIDopen abort" Can't open Midi file"

    Square_Wave_Lead m.Use \ PC 81: Lead 1 (Square)

    0 &D 50 m.Play
    0 &E 50 m.Play
    0 &C 50 m.Play

    -1 +to m.Octave

    0 &C 50 m.Play
    0 &G 100 m.Play

    MIDclose depth .
    ---8<---

    Hans Bezemer
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From dxf@dxforth@gmail.com to comp.lang.forth on Sun Jul 12 15:02:06 2026
    From Newsgroup: comp.lang.forth

    On 12/07/2026 2:21 am, Hans Bezemer wrote:
    ...
    I have no idea whether there is an actual MIDI device in my current soundcard -- and frankly I don't care. I tend to use timidity - and that works with files.

    Wondering what might be available to play MID under DOSBOX, I found this:

    https://mateusz.fr/dosmid/

    It played a MID file straight up without any extra parms on the command line. That's probably because DOSBOX was already preconfigured for sound.
    FWIW here's what's in my 'dosbox-0.74-3.conf'

    mount C D:\
    C:\
    SET BLASTER=A220 I5 D1 H5 P330 T6
    PATH Z:\;C:\COMMAND
    CD \FORTH\DX
    MIXER SB 75:75 /NOSHOW
    TURBOKEY D 1

    Not sure what the MIXER command did - maybe volume.

    Generating midi notes from DX-Forth would require a DOS BAT file - first generate the MID file, then invoke the utility above to play it. Probably
    it can all be done within forth as there's a SHELL command.

    Wow - I've almost incentivised myself to do it. You need to stop that :)

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Hans Bezemer@the.beez.speaks@gmail.com to comp.lang.forth on Sun Jul 12 16:15:27 2026
    From Newsgroup: comp.lang.forth

    On 12-07-2026 07:02, dxf wrote:
    On 12/07/2026 2:21 am, Hans Bezemer wrote:
    ...
    I have no idea whether there is an actual MIDI device in my current soundcard -- and frankly I don't care. I tend to use timidity - and that works with files.

    Wondering what might be available to play MID under DOSBOX, I found this:

    https://mateusz.fr/dosmid/

    It played a MID file straight up without any extra parms on the command line. That's probably because DOSBOX was already preconfigured for sound.
    FWIW here's what's in my 'dosbox-0.74-3.conf'

    mount C D:\
    C:\
    SET BLASTER=A220 I5 D1 H5 P330 T6
    PATH Z:\;C:\COMMAND
    CD \FORTH\DX
    MIXER SB 75:75 /NOSHOW
    TURBOKEY D 1

    Not sure what the MIXER command did - maybe volume.

    Generating midi notes from DX-Forth would require a DOS BAT file - first generate the MID file, then invoke the utility above to play it. Probably
    it can all be done within forth as there's a SHELL command.

    Wow - I've almost incentivised myself to do it. You need to stop that :)


    MIXER is a DOSbox utility: https://www.dosbox.com/wiki/index.php?title=MIXER

    It selects the device, left:right volume settings, and executes in quiet
    mode. You'll find it on your "Z:" drive.

    4tH does have an external "SYSTEM", which uses the pipes in 4th:

    [UNDEFINED] system [IF] ( a n -- f)
    : system output pipe + open error? tuck if drop ;then close ;
    [THEN]

    Unfortunately, I had some issues with the popen() command in DJGPP, so I disabled the pipes. Turbo C v2 didn't have them anyway.

    So -- in theory I could do all this, but because I put reliability
    before functionality, no go on DOS. :-(

    I must say I've got very little incentive to do anything with DOS
    anyway, so I don't think I'll put much effort into this. I may do on
    Linux, cause it's trivial:

    ---8<---
    include lib/system.4th

    128 string cmdline

    argn 1- if
    cmdline >r s" timidity --quiet=2 " r@ place 1 args r@ +place
    r> count system abort" Can't execute 'timidity'"
    then
    ---8<---

    You could bind the thing into a program that generates it -- but why?

    - First you have to issue a command line parameter, otherwise the file
    name and location are predetermined and that makes the whole thing
    awkward. I mean: Why select a filename and directory in the first place?
    - Second, if you *would* use a fixed name, you don't need the whole
    shebang. s" timidity --quiet=2 ce3k.mid" would do just fine;
    - Third, is it about file generation - or just playing the thing? If
    it's the latter, you could wipe the MID file after completion. This to
    prevent leaving corpses all over your machine.

    Hans Bezemer
    --- Synchronet 3.22a-Linux NewsLink 1.2