# MP3 ID3 Tag Reader

![GnuCOBOL](https://img.shields.io/badge/GnuCOBOL-3.2.0%2B-blue)

![Fun COBOL Image](assets/images/cobol.png)

This project is a COBOL-based MP3 ID3 tag reader that parses and displays metadata from MP3 files. It uses GnuCOBOL for compilation and execution.

## Software Requirements

- **GnuCOBOL**: Version 3.2.0 or later
  - Ensure GnuCOBOL is installed and accessible via the `cobc` command.
- **Operating System**: Linux (tested on May 5, 2025)
- **Make**: Version 4.3 or later (for building the project)
- **Git**: Version 2.30.0 or later (for version control)

## Project Structure

- `id3cobol.cbl`: Main COBOL program for reading and parsing MP3 ID3 tags.
- `zero-ord.cbl`: COBOL module for zero-based ordinal conversion.
- `Makefile`: Build automation file for compiling and cleaning the project.
- `audio.mp3`: Sample MP3 file for testing (required for the program to run).
- `.gitignore`: Specifies files and directories to be ignored by Git.

## Build Instructions

1. **Compile the `zero-ord` module**:
   ```bash
   make zero-ord
   ```

2. **Compile the `id3cobol` program**:
   ```bash
   make id3cobol
   ```

3. **Clean up build artifacts**:
   ```bash
   make clean
   ```

4. **Perform a deep clean (removes all artifacts)**:
   ```bash
   make distclean
   ```

## Environment Variables

The following environment variables are important for proper execution:

- **COB_LIBRARY_PATH**: Tells COBOL where to find modules
  ```bash
  export COB_LIBRARY_PATH=/path/to/workspace:$COB_LIBRARY_PATH
  ```

- **COB_PRE_LOAD**: Tells COBOL to preload the zero-ord module
  ```bash
  export COB_PRE_LOAD=zero-ord
  ```

- **LD_LIBRARY_PATH**: Helps the Linux dynamic linker find the module
  ```bash
  export LD_LIBRARY_PATH=/path/to/workspace:$LD_LIBRARY_PATH
  ```

These variables are automatically set when using the VS Code debugger.

## Usage

Run the compiled `id3cobol` program to parse an MP3 file:

```bash
# Using default audio.mp3 file:
./id3cobol

# Using a specific MP3 file:
./id3cobol path/to/your/music.mp3
```

> **Note**: Ensure you have an MP3 file with ID3 tags. If no argument is provided, the program will look for `audio.mp3` in the current directory.

## VS Code Integration

This project includes VS Code configuration files:

- **launch.json**: Configures debugging with proper environment variables
- **tasks.json**: Defines build tasks for compiling the project

To debug in VS Code:
1. Press F5 or select "Run and Debug" from the left sidebar
2. Select "COBOL debugger" configuration
3. The debugger will automatically build and launch the program with audio.mp3

## Debugging

To enable debugging, ensure the `WS-DEBUG-MODE` variable in `id3cobol.cbl` is set to `1`. This will display additional debug information during execution.

## License

This project is licensed under the MIT License. See the LICENSE file for details.