Converting MIDI files into a playable music application on the PlayStation 1 (PS1), also known as PSX, involves several steps. This process includes preparing your MIDI files, converting them into a format compatible with the PS1’s audio system, developing a homebrew application to play the music, and running it on the PS1 console. Below is a detailed, step-by-step guide to help you through the process.
Homebrew Development: Developing and using homebrew software on the PS1 is possible but involves navigating around proprietary software and hardware limitations.
Legal Compliance: Use only original music or music you have the rights to distribute. Do not use this guide for piracy or any illegal activities.
Proceed with Caution: Burning discs and modifying hardware involves risks. Follow instructions carefully and understand each step before proceeding.
Copy Protection: The PS1 has copy protection measures that prevent it from reading burned discs unless modified. Modifying your console may void your warranty and could be illegal in some jurisdictions.
Before you begin, ensure you have the following:
A MIDI file that you wish to convert.
A computer capable of running the necessary software (Windows recommended).
Basic knowledge of programming concepts and command-line operations.
PS1 Development Tools:
PSn00bSDK or PSXSDK: Open-source development kits for PS1 development.
MIPS Compiler Toolchain: For compiling code for the PS1’s MIPS R3000A CPU.
Audio Tools:
Audacity: For audio editing and conversion.
TiMidity++ or SynthFont: To convert MIDI to audio formats.
Emulator:
Hardware:
PlayStation 1 Console capable of running burned discs or modified to do so.
CD-R Discs and a CD Burner.
Modchip or Swap Trick: To bypass the PS1’s copy protection.
1. Simplify the MIDI File
The PS1’s audio capabilities are robust, but optimizing your MIDI file can improve performance.
Use a MIDI editor to adjust instrument assignments, tempos, and channels as needed.
Recommended MIDI Editors:
Anvil Studio (Windows)
MuseScore (Windows, macOS, Linux)
LMMS (Windows, macOS, Linux)
1. Understand PS1 Audio Formats
The PS1’s Sound Processing Unit (SPU) can handle:
16-bit PCM Samples: Uncompressed audio data.
VAG Files: PS1’s native audio format, compressed ADPCM audio.
For this guide, we’ll convert the MIDI file to a format compatible with the SPU.
2. Convert MIDI to WAV Format
Recommended Tools:
TiMidity++: Converts MIDI files to WAV.
SynthFont (Windows): Renders MIDI files using soundfonts.
Steps to Convert:
Open your MIDI file in the chosen software.
Select a high-quality soundfont for realistic instrument sounds.
Export the file as a WAV with the following specifications:
Sample Rate: 44,100 Hz.
Bit Depth: 16-bit.
Channels: Stereo (2 channels).
3. Prepare the Audio File
Trim and Edit: Use Audacity to trim silence and adjust volume levels.
Normalize Audio: Ensure consistent volume levels.
Split into Smaller Samples: The PS1 SPU has limited memory (512 KB). Consider splitting the audio into loops or shorter samples if necessary.
1. Use PSYQ Tools or Alternative Converters
VAG Format: The PS1 uses VAG format for compressed audio samples.
PSYQ SDK: The official PS1 SDK includes tools like VAG Converter.
Alternative Tools:
VAG Converter GUI: Community-made tools to convert WAV to VAG.
VAGEdit: A tool for converting and editing VAG files.
2. Steps to Convert WAV to VAG
Download VAG Conversion Tool:
Convert the WAV File:
Open the converter tool.
Load your your_song.wav
file.
Convert and save it as your_song.vag
.
3. Note on Looping
1. Install PSn00bSDK or PSXSDK
PSn00bSDK:
Visit the PSn00bSDK GitHub Repository.
Download the latest release or clone the repository.
PSXSDK:
Visit the PSXSDK GitHub Repository.
Download the latest release or clone the repository.
2. Install the MIPS Compiler Toolchain
The PS1 uses a MIPS R3000A CPU.
For Windows Users:
For macOS/Linux Users:
Install GCC MIPS Compiler via package manager or build from source.
Example for Ubuntu:
sudo apt-get install gcc-mipsel-linux-gnu
3. Set Environment Variables
1. Create a New Project Directory
ps1_music_player
).2. Set Up the Directory Structure
Inside your project directory, create the following subdirectories:
ps1_music_player/
├── src/
│ └── main.c
├── assets/
│ └── your_song.vag
├── include/
├── lib/
└── Makefile
Copy your your_song.vag
file into the assets
directory.
1. Create main.c
in the src
Directory
#include <psx.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
PSX_InitEx(0);
// Initialize the SPU
SpuInit();
SpuInitMalloc(SPU_MALLOC_RECSIZ, 1);
SpuSetTransferMode(SpuTransByDMA);
// Load VAG data
FILE *file = fopen("cdrom:\\YOUR_SONG.VAG;1", "rb");
if (!file) {
printf("Failed to open VAG file.\n");
while (1);
}
// Get file size
fseek(file, 0, SEEK_END);
int vag_size = ftell(file);
fseek(file, 0, SEEK_SET);
// Allocate memory for VAG data
unsigned char *vag_data = (unsigned char *)malloc(vag_size);
fread(vag_data, 1, vag_size, file);
fclose(file);
// Upload VAG data to SPU
unsigned long spu_address = SpuMalloc(vag_size);
SpuSetTransferStartAddr(spu_address);
SpuWrite(vag_data + 0x30, vag_size - 0x30); // Skip VAG header (48 bytes)
// Set voice parameters
SpuVoiceAttr voice_attr;
memset(&voice_attr, 0, sizeof(SpuVoiceAttr));
voice_attr.mask = SPU_VOICE_VOLL | SPU_VOICE_VOLR | SPU_VOICE_PITCH |
SPU_VOICE_WDSA | SPU_VOICE_ADSR_AMODE | SPU_VOICE_ADSR_SMODE |
SPU_VOICE_ADSR_RMODE | SPU_VOICE_ADSR_AR | SPU_VOICE_ADSR_DR |
SPU_VOICE_ADSR_SR | SPU_VOICE_ADSR_RR | SPU_VOICE_ADSR_SL;
voice_attr.voice = SPU_VOICECH(0);
voice_attr.volume.left = 0x3fff;
voice_attr.volume.right = 0x3fff;
voice_attr.pitch = SPU_MyPitch2SpuPitch(44100); // Adjust if necessary
voice_attr.addr = spu_address;
voice_attr.a_mode = SPU_VOICE_LINEARIncN;
voice_attr.s_mode = SPU_VOICE_LINEARIncN;
voice_attr.r_mode = SPU_VOICE_LINEARDecN;
voice_attr.ar = 0x0;
voice_attr.dr = 0x0;
voice_attr.sr = 0x0;
voice_attr.rr = 0x0;
voice_attr.sl = 0xf;
SpuSetVoiceAttr(&voice_attr);
// Start playing
SpuSetKey(SPU_ON, SPU_VOICECH(0));
// Main loop
while (1) {
// Keep the program running
}
// Clean up (unreachable in this example)
SpuFree(spu_address);
free(vag_data);
PSX_End();
return 0;
}
Notes:
Replace "cdrom:\\YOUR_SONG.VAG;1"
with the correct filename. PS1 file paths are in uppercase and may require the ;1
version number.
The SPU requires proper initialization and memory management.
The example plays the audio once; you may need to implement looping if desired.
2. Update the Makefile
Create a Makefile
in your project directory with the following content:
TARGET = ps1_music_player
OBJS = src/main.o
CC = mipsel-unknown-elf-gcc
CFLAGS = -I$(PSYQ_INC) -O2 -G0 -Wall
LDFLAGS = -nostartfiles -T $(PSYQ_LIB)/linker.ld -L$(PSYQ_LIB) -lpsx
all: $(TARGET).exe
$(TARGET).exe: $(OBJS)
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(TARGET).exe
src/%.o: src/%.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -f $(OBJS) $(TARGET).exe
Notes:
Adjust CC
and CFLAGS
according to your compiler and include paths.
Ensure that the paths to the PS1 SDK libraries and includes (PSYQ_INC
, PSYQ_LIB
) are set correctly.
3. Include Necessary Headers and Libraries
Ensure that the PS1 SDK headers and libraries are available and properly referenced.
You may need to adjust the code to match the specific SDK you are using (PSn00bSDK or PSXSDK).
1. Open a Command Prompt
2. Run the Build Command
make
ps1_music_player.exe
).3. Convert the Executable to PS1 Binary
Use the exe2ps
tool (part of PSn00bSDK or PSXSDK) to convert the executable into a PS1-compatible binary.
exe2ps -o PS1.EXE ps1_music_player.exe
Notes:
PS1.EXE
) is the PS1 executable.1. Prepare the CD File System
Create a directory structure for the CD image.
cd_root/
├── SYSTEM.CNF
├── PS1.EXE
└── YOUR_SONG.VAG
2. Create SYSTEM.CNF
File
Create a SYSTEM.CNF
file with the following content:
[BOOT]
ROMNAME=PS1.EXE
[INFO]
PC=80010000
SP=801FFFF0
3. Copy Necessary Files
PS1.EXE
and YOUR_SONG.VAG
into the cd_root
directory.4. Generate the CD Image
Use a tool like mkpsxiso to create a PS1-compatible ISO image.
Download mkpsxiso:
Build mkpsxiso (if necessary) and run:
mkpsxiso -y cd_root -o ps1_music_player.iso
The -y
option includes system area files needed for booting.
1. Choose an Emulator
PCSX-R (Windows, macOS, Linux): Download PCSX-R
ePSXe (Windows, macOS, Linux): Download ePSXe
2. Load and Test the ISO
Open the emulator and load your compiled .iso
file.
Verify that the music plays correctly.
Use emulator debugging tools if necessary.
1. Prepare to Burn the Disc
Use quality CD-R discs (not CD-RW).
Note: The PS1 uses a wobble groove for copy protection. Regular PS1 consoles cannot read burned discs without modification.
2. Modchip or Swap Trick
Modchip: Install a modchip in your PS1 to allow it to read burned discs.
Swap Trick: A method involving swapping discs at a specific time during boot (not recommended due to potential hardware damage).
3. Burn the ISO
Use a CD burning software that supports RAW mode and Disc-At-Once (DAO) burning.
Recommended Software:
Steps to Burn:
Open your burning software.
Select the option to burn an image to disc.
Choose your .iso
file.
Burn at the slowest speed possible (e.g., 1x or 4x) to ensure compatibility.
1. Insert the Burned Disc
2. Power On the Console
Turn on the PS1.
If using a modchip, the console should boot the disc normally.
If not, you may need to perform the swap trick (not recommended).
3. Verify Functionality
Confirm that the music plays as intended on actual hardware.
Use a controller to interact if you’ve programmed additional functionality.
Understanding the PS1’s Audio Hardware
The SPU can handle multiple channels of audio, ADSR envelopes, and effects.
Optimizing audio playback requires careful management of SPU resources.
Optimize Audio Quality
VAG files are compressed; ensure the quality is acceptable after conversion.
Consider splitting long audio tracks into shorter loops to conserve SPU memory.
Use Existing Libraries
PSn00bSDK and PSXSDK provide functions for audio playback; utilize them to simplify your code.
Explore SDK examples for additional features and functionalities.
Community Resources
PSXDEV: psxdev.net - A community dedicated to PS1 development.
PSXDEV Discord Server: Engage with other developers for support.
SDK Documentation: Review the SDK’s documentation for detailed information.
Legal Considerations
Only use music that you have the rights to distribute.
Be cautious of licensing when using soundfonts or reproducing existing songs.
By following these steps, you can successfully convert MIDI files into a playable music application on the PlayStation 1:
Prepare and convert your MIDI file into a WAV audio format.
Convert the WAV file to VAG format, compatible with the PS1’s SPU.
Install PS1 development tools, including PSn00bSDK or PSXSDK and necessary compilers.
Set up your project structure with appropriate directories and files.
Write a homebrew application that plays your audio file on the PS1.
Configure the build process to include your audio file and compile the project.
Build your application to create a PS1 executable.
Create a CD image containing your application and audio file.
Test your application in an emulator to verify functionality.
Burn the ISO to a CD-R using appropriate software.
Run the disc on your PS1 console, ensuring it can read burned discs.
Verify that the music plays as intended on actual hardware.
This process allows you to experience custom music on your PlayStation 1 console and provides valuable experience in retro console development.
Disclaimer: Modifying your PlayStation 1 console and creating custom discs involves risks and may be subject to legal restrictions in some jurisdictions. Copying or modifying game consoles may violate the console’s terms of service and local laws. Always ensure you are complying with local laws and do not engage in piracy or distribute copyrighted material.
PSn00bSDK Documentation: Review for guidance on using the SDK.
PSXSDK Documentation: Provides examples and explanations for PS1 development.
CD Burning Best Practices: Research proper techniques to avoid damaging your console.
PS1 Development Tutorials: Look for community-made tutorials to deepen your understanding.