Thanks to Julio Marchi for this space in MSX All
 

MSX Digitized Sound Generator

  A nice tool to convert PC sounds (samples) to run on MSX PSG. Digitize voices and insert into your app!
How to convert PC sounds to MSX   Guide to convert PC sounds to MSX:
  1. Editing sounds on PC
  2. Converting sound to unsigned 8-bit PCM
  3. Converting to MSX
  4. Players
  5. Players settings
  MSX DSG works together with any PC sound editor. Once there are already nice and also free sound editors for PC, there is no need to recreate such thing. We decided to use Audacity [1] because it is a very good sound editor, free and multiplatform.
1. Editing sounds on PC   The first step is to edit the sound. Before converting digital sounds to MSX, we need do make some adjustments like convert from stereo to mono, select a track's piece and set up the proper frequency.
Opening a digital sound on Audacity   Open a digital sound to be converted to MSX. Audacity is compatible with several formats, including WAV, MP3 and MP4 (only the sound).
  On the upper menu bar, click on "File" and "Open". It is also possible to drag and drop files onto the program to open it.
  Once the file is open, we can see the whole file wave format. If only one wave graphic is shown, the sound is mono. Otherwise, if there are two wave graphics (as shown in the picture above), the sound is stereo.
Converting to mono   All MSX formats are mono. So, if our digital sound is stereo, we must convert it to mono.
  Click on "Tracks", "Mix" and "Stereo track to mono". In older Audacities the way is: "Tracks" and "Stereo track to mono".
Selecting a part of the track   Due to the great size of sound files, there are some limitations on the time duration. For example, Video Hits program with delay 14 is able to play up to 12 seconds for each 16 KB block.
  For the SND and S4b formats, the MSX DSG is able to divide the file into 16 KB blocks. Nevertheless, the current players can play only 2 blocks at time.
  Open MSX DSG. On panel "MSX Player", we can calculate the frequency and the maximum time for each 16 KB block, according to the player and the delay.
  After that tool indicate us the correct frequency and maximum time, we will use both data on sound editor. First, the time tell us the maximum duration of the sound part we want to select. Of course we can select a shorter piece, but if we exceed the time limit, the MSX DSG will cut if we save using 16 KB blocks.

  In order to select what we want, we must remove the parts before and after it. Start clicking on the initial part of the desired sound region, as shown by the yellow arrow and the red rectangle on the picture below.   You can drag mouse up to the file beginning. But, press SHIFT + HOME keys to select this region in a easier way.   After selecting the part to be deleted (marked as dark gray), press DELETE key. This part will be removed.   After removing the initial part, the resulting file is moved to the beginning.
  The next step is to select the end part of our interest sound region, as shown on the figure below.   Select from this part to the end, by pressing SHIFT + END keys.   Remove this part by pressing DELETE key.
  Voila. Our sound part is already selected.   Note: if we want to use two 16 KB blocks, we can select the twice time as indicated on MSX DSG, once this tool is able to divide the file into 16 KB blocks. Setting up the sound frequency   The last step before exporting the file is to set up the sound frequency.
  As told before, MSX DSG determines what is the correct frequency according to the player and the delay. So, we will do it in Audacity in two steps.
  The first step is to change the project frequency. At the bottom of Audacity's window, we can see the "Project Rate (Hz)".   Change the value to what MSX DSG shows.
  The second step is to resample the sound file. For that, click on "Tracks" and "Resample" on the menu bar. Keep the value shown, which must be the new project frequency. Click on Ok.   The sound file is ready to be exported. 2. Converting sound to unsigned 8-bit PCM   Still in Audacity, click on "File" and "Export" on the menu bar (also SHIFT + CONTROL + E).
  On the save dialog, we have the "file type" (marked with red rectangle) and "options" (marked with green rectangle).   Select the file type "Other uncompressed files". Then, click on "options".   Choose header "RAW (header-less)" and the codification "Unsigned 8-bit PCM".
  At last, export the file using these options. Use ".raw" extension. 3. Converting to MSX   After setting up and converting the original sound file to unsigned 8-bit PCM, we are ready to use MSX DSG.   Choose the option "PC PCM 16-bit" in "File type". Click on load button .
  After loading, the following informations are shown:
  • Name - file name loaded.
  • Type - file type loaded.
  • Bitstreams - number of samples.
  • Size - file size in bytes.
  • Time - sound duration according to the options selected on "MSX Player" panel.
  Now, select a sound format to be saved also in "File type". Click on button to save.

  Note: remember that the sound frequency has alerady been set in Audacity. So, setting the frequency now will NOT change anything in the file.

  From version 1.1 on, the sound panel was divided into source sound and destiny sound. Thus, the play button was added to execute both source and destiny sounds. Click this button again to stop sound execution.

  For each file type we have the following policies:
  • SND - Ask if you want to save file into 16 KB blocks, despite of the size. In case of yes, if the file is shorter than 16 KB it fills the remaining data with zeros. If it is greater, create the necessary number of 16 KB blocks. In case of no, save as a single file (any size).
  • FRED - Save up to 16 KB. If greater than this, remove the exceeding.
  • S4b - The same as SND.
  • PCM 8 bits - Save the file into a single file (any size).
  Important note: for the players used in this project, we can never exceed 16 KB per block. Otherwise, the sound file will invade the player's memory area.
4. Players MarMSX SND Player   The SND players runs 1-bit sound format. It is composed by "snd.bin" and "mvdata.bin" files.
  The following program in Basic loads the sound data, move to page 0 and runs it.
10 ' SND player MarMSX 2020
20 SCREEN 0:WIDTH40:COLOR 15,0,0:KEY OFF
30 PRINT"MarMSX SND player"
40 PRINT"-----------------"
50 PRINT:PRINT"Loading SND file ... ";
60 BLOAD"file.snd"
70 PRINT"Ok":PRINT"Starting routine to move data ... ";
80 BLOAD"mvdata.bin"
90 DEFUSR=&HD100
100 X=USR(0)
110 PRINT"Ok":PRINT"Sound starts!"
120 BLOAD"snd.bin"
130 DEFUSR=&HD000
140 X=USR(0)
  The default MarMSX SND player deleay is 14. See on "players settings" section how to change delay. MarMSX S4b Player   The SND players runs 4-bits sound format. It is composed by "s4b.bin" and "mvdata.bin" files.
  The following program in Basic loads the sound data, move to page 0 and runs it.
10 ' S4b player MarMSX 2020
20 SCREEN 0:WIDTH40:COLOR 15,0,0:KEY OFF
30 PRINT"MarMSX S4b player"
40 PRINT"-----------------"
50 PRINT:PRINT"Loading S4b file ... ";
60 BLOAD"file.s4b"
70 PRINT"Ok":PRINT"Starting routine to move data ... ";
80 BLOAD"mvdata.bin"
90 DEFUSR=&HD100
100 X=USR(0)
110 PRINT"Ok":PRINT"Sound starts!"
120 BLOAD"s4b.bin"
130 DEFUSR=&HD000
140 X=USR(0)
  The default MarMSX S4b player deleay is 22. See on "players settings" section how to change delay. 5. Players settings Move data   We can use move data to load data on RAM page 1. For that, add (between lines 80-90):
85 POKE &H&HD112,&H40
  This is useful to load two blocks of 16 KB on memory, extending the sound duration. But, we also must change the final address check on the players. MarMSX SND Player   For changing players options, we must insert the pokes after the program loading and before the X=USR(0) execution.
  Possible changes:
  • &hD00E - Low part of initial address.
  • &hD00F - High part of initial address.
  • &hD022 - Change delay value. Do not use 0, once it values here 256.
  • &hD02B - High part of final address.
  The following example changes the delay value to 13.
135 POKE &H&HD022,13
MarMSX S4b Player   For changing players options, we must insert the pokes after the program loading and before the X=USR(0) execution.
  Possible changes:
  • &hD024 - Low part of initial address.
  • &hD025 - High part of initial address.
  • &hD035 - Change delay value. Do not use 0, once it values here 256.
  • &hD040 - High part of final address.
  The following example changes the final address to &H8000. By this way, we can run 2 sounds blocks.
135 POKE &H&HD040,&h80



  References:

  1. Audacity. At: https://www.audacityteam.org
  2. Manual do Audacity. At https://manual.audacityteam.org


Marcelo Silveira
Systems and Computing Engineer
Expert in Image Processing and Artificial Intelligence
© MarMSX 1999-2021