Video: Lesson P35 - Playing Digital Sound with WAV on the AY!

MSX & MSX2 including the V9990 GPU (V9K)
Post Reply
User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Video: Lesson P35 - Playing Digital Sound with WAV on the AY!

Post by akuyou » Wed Apr 24, 2019 12:51 pm



http://www.chibiakumas.com/z80/platform4.php#LessonP35

We've looked before at normal sounds, but lets start to learn how we can convert WAV files so we can play them back on 8 bit machines for Speech and SFX!

Lets take a look!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

John
Posts: 40
Joined: Tue Mar 24, 2020 1:18 am

Re: Video: Lesson P35 - Playing Digital Sound with WAV on the AY!

Post by John » Wed Mar 25, 2020 4:36 am

Hello,

I want to convert a MIDI file of a song, using Arkos Tracker 2, so it works with your MSX-1 hello world cartridge tutorial. Unfortunately It would take too much memory to convert a song, to decent quality, using Chibiwave. I watched your other video tutorial of using Arkos Tracker 1 but unfortunately that does not explain how to convert from MIDI. Can you make a video (preferred) or write instructions on how to take a song in MIDI (with two instruments e.g. 1.piano and 2.violin for the "voice") and use it with Arkos Tracker 2 to add music to your MSX-1 hello world cartridge tutorial?; for the song you can just use a public domain MIDI song and possibly change the voice instrument to violin. I tried to do the conversion, using Arkos Tracker 2, myself but was not able to do so. I guess that conversion process a song in MIDI, using Arkos Tracker 2, for adding music to an MSX-1 cartridge, can be simplified by a using a windows batch file. The advantage of using MIDI, for me or a composer, is I can compose a song in a music program like Finale Notepad and export it to MIDI. You can also use Finale Notepad to change instruments in a MIDI song, e.g. voice notes are played on a violin, this is easy to do.

User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: Video: Lesson P35 - Playing Digital Sound with WAV on the AY!

Post by akuyou » Sun Mar 29, 2020 11:19 pm

It looks like ArkosTracker 2 can import from Midi Files:

http://www.julien-nevo.com/arkostracker/

Due to time constraints I've not looked at ArkosTracker 2 yet, so I'm afraid I do not have a tutorial on it at this time, but I don't suppose it's harder to implement in code than ArkosTracker 1
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

John
Posts: 40
Joined: Tue Mar 24, 2020 1:18 am

Re: Video: Lesson P35 - Playing Digital Sound with WAV on the AY!

Post by John » Mon Mar 30, 2020 3:59 am

I still can't I can figure out the Arkos Tracker 2 for use with MIDI.
So another way to do it would be I suggest that you do, or an interested reader,
is to modifiy you Chibisound so it can play, a lot of professional songs, in MIDI format-the way to do this will be as follows.
My song is in the scale of C Major on a piano . So you would need
to encode all the notes, which are C D E F G A B C, for the scale of C in Chibisound -this will be easy to do if you know where to find the frequency of each note (which I don't). After that you would need encode rest notes (i.e. silences) in Chibisound from Long down to Hemidemisemiquaver. Then you would
need to read the MIDI file, of the song in the scale of C major,
which contains the information about the rest notes and the piano
notes. You would need to do this for three channels and simulate
the 4th possible channel/voice channel by multiplexing.
You probably need to convert the MIDI to a binary file so it can
be "incuded" in the assembly code. This modification,of course,
will work for any song in C major and there are lots of such songs.

John
Posts: 40
Joined: Tue Mar 24, 2020 1:18 am

Re: Video: Lesson P35 - Playing Digital Sound with WAV on the AY!

Post by John » Mon Apr 13, 2020 10:15 am

I think i can make Arkos Tracker 2 work -but first I need to know how to make
a .BIN file work. All the files in this message are in the
ZIP file.
So I am trying to learn how to make a .BIN MSX program with VASM assembler.
I am having a problem,using VASM, compiling a minimal .BIN program that
simply should make a beep sound int the emulator (BlueMSX)-but does not.
The program is given below (named "TEST.asm"

db "FE" ; BLOAD header signature
dw Begin ; begin address of the program
dw Programend ; end address of the program
dw Begin ; address of where to execute program
org &C000 ;
Begin:
CALL &C0 ; Call the BEEP bios routine
RET
Programend:


I am using the VASM command below to compile it

vasmz80_oldstyle_win32.exe "C:\MSXassemblyprograms\TEST.asm" -Fbin -o "C:\MSXassemblyprograms\TESTBIN.BIN"

The program compiles and creates the file TESTBIN.BIN

I am then using the MSX windows utility "Disk Manager" (author L. Leschz) to create a floppy disk (the DISKBIN.flp file),
that contains
TESTBIN.BIN,I am using the default setting whics creates the 740KB disk .
I am loading this disk into Blue MSX,
The files does appear on the disk after typing FILES "A:" into the emulator.
But when BLOAD "TESTBIN.BIN",R is typed I get the error message "bad file mode" from, the MSX.
I have also attached a screen grab of the MSX emulator with above commands.
So how to I fix the simple program for making a loadable BIN file using VASM?
Attachments
BLOADprogramfiles.zip
(52.34 KiB) Downloaded 366 times
SCREENGRAB.PNG
SCREENGRAB.PNG (29.72 KiB) Viewed 7092 times

User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: Video: Lesson P35 - Playing Digital Sound with WAV on the AY!

Post by akuyou » Mon Apr 13, 2020 10:01 pm

Your file is 49 KB, it should just be a few bytes... that's why it's not working

Because you have no ORG statement at the start of the file, the file is being built from org &0000, then padded to &C000, which isn't what we need.

Your header is 7 bytes, so if you put ORG &C000-7 at the start of the file (before the header) I think it will work.

Please give it a go.
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

John
Posts: 40
Joined: Tue Mar 24, 2020 1:18 am

Re: Video: Lesson P35 - Playing Digital Sound with WAV on the AY!

Post by John » Tue Apr 14, 2020 8:15 pm

Hi,

I did do what you suggested, program is below, but still the simple program does not compile with VASM.

org &BFF9 ;
db "FE" ; Bload header signature
dw Begin ; begin address of the program
dw Programend ; end address of the program
dw Begin ; adress of where to execute program
Begin:
CALL &C0 ; Call the BEEP bios routine
RET
Programend:

C000 minus 7 is BFF9 in hex. This resulted in a .BIN that is 12 bytes in size.
As before I made the .BIN with VASM. Then I made a MSX disk, same way as described before,
as before I loaded the new .BIN file with a BLOAD command, and I got the same error in BlueMSX
which was "bad file mode". I have also attached the program. The .BIN was the proper size this time though.
I have also attached version 2 of the files (the ASM,BIN and MSX disk image).
It obviously a small program so I wonder why it still doesn't work?
Attachments
BLOAD-files-version2.zip
(2.19 KiB) Downloaded 373 times

User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: Video: Lesson P35 - Playing Digital Sound with WAV on the AY!

Post by akuyou » Tue Apr 14, 2020 9:20 pm

you're defining the header as a string - I believe it should be a byte

Your code:
db "FE" ; Bload header signature

Change this to:
db &FE ; Bload header signature

I think it will work then.
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

John
Posts: 40
Joined: Tue Mar 24, 2020 1:18 am

Re: Video: Lesson P35 - Playing Digital Sound with WAV on the AY!

Post by John » Fri Apr 17, 2020 9:15 am

Yes, it works now.

So for anyone else solving the same problem;
the correct simple MSX BLOAD program
,using VASM, is


org &BFF9 ; replace with your required address
db &FE ; Bload header signature
dw Begin ; begin address of the program
dw Programend ; end address of the program
dw Begin ; adress of where to execute program
Begin:
CALL &C0 ; Call the BEEP bios routine
RET
Programend:

I am now starting to make Arkos Tracker 2 fully work-
I will write up here later how I did it.

John
Posts: 40
Joined: Tue Mar 24, 2020 1:18 am

Re: Video: Lesson P35 - Playing Digital Sound with WAV on the AY!

Post by John » Thu Jun 04, 2020 9:19 am

I have been learning z80 assembly using this site
and using the method of using OpenMSX,VASM,Winape to develop
code. But this method does not work for Arkos Tracker 2.
I have attached a minimal example of using Arkos Tracker
2 for the MSX and it plays a song in the OpenMSX Emulator.
. The problem is the minimal example with
Arkos Tracker 2 works on the OpenMSX emulator but (weirdly)
it does not work on real MSX-1 hardware;I have been using Caslink2
to upload to a real MSX-1 (a Toshiba HX-10 with 64K RAM).

I think the minimal example may work, on real hardware,if an interrupt handler
is added to the code (that saves the registers and the shadow
register). So what is the exact code for the interrupt
handler for this minimal Arkos Tracker 2 program?

The program is also given below
;-------------------------------------------------------


org &A000 ;
;-----------------------------------------------
db &FE; BIN file signature
dw Testerstart ; start address
dw Testerend ;
dw Testerstart ;




Testerstart: ; Program code entry point label


ld sp,&9300 ;move the stack pointer
call &006F ; init32 bios call to use screen 1

ld hl,6144 ; topleft of screen
ld a,65 ; ascii for A
call &004D ; write A to screen
ld hl,6145
ld a,66 ;ascii for B
call &004D; the two letter's )font) just show screen 1 have been entered

;initiliase arkos player 2 song
ld hl,UNTITLED_START
xor a
call PLY_AKG_INIT

;below initiliase interrupt for Arkos player invoked by the VDP
; this program does NOT work on a real MSX computer
; but it does work in the OpenMSX emulator
;maybe it will work if an interrupt handler is added
ei
nop
halt
di
LD A,&C3
LD (&FD9F),A
LD HL,PLY_AKG_PLAY
LD (&FDA0),HL
;the 4 lines of code above load the address to call
;when the interrupts are invoked by the VDP





mainloop:
sub a,0 ; does nothing but keep the main loop non empty


jp mainloop
;the song is contained the At2files

include "C:\ARKOSfiles\AT2Files.asm"


Testerend:
Attachments
AT2minimalexample.zip
(8.4 KiB) Downloaded 344 times

Post Reply

Return to “MSX & MSX2 Assembly Programming”