VAG Encode Libraty<BR><BR>for PC

VAG Encode Libraty

for PC

Outline

VAG Encode Library for PC is the library of routines required to generate VAG file, which is the sound format for PlayStation. It is provided in the form of Dynamic Link Library (DLL) for Win32.

1 Contents of Package

The package to be distrubuted is composed of the following directories.

        library	-		Library itself (.dll, .lib, .h)
        
        sample	-  bin		Execute Form of Sample Code (A2V_Win)
        	-  source	Source for Sample Code (Project for VisualC++ 5.0)
        
        doc	-  eng 		English documents
        	-  jp 		Japanese documents

Encode Routine

1 Flow of Encoding

Encoding is performed in units of 1 block consisting of 28 samples of 16-bit data (56 bytes). Loop information is added not to VAG header but to waveform data itself.
Encoding is executed according to the following procedure using the group of functions explained in the next section.
  1. Specify the mode with EncVagInit(), and initialize the encode routine.
  2. Call EncVag() in units of 28 samples, and make compression conversion.
  3. Repeat (2) above.
  4. Pad the last block with 0, and call EncVag(). In case of one-shot waveform, however, call EncVagFin().

2 VAG File

Encode routine itself does not output VAG header etc. In making data as VAG file, first write the VAG header of 30H starting with 'VAGp' or 'pGAV' and the waveform start block of 16 bytes (all the data is 0), and then write the waveform data (output of EncVag()). In case of one-shot waveform (loop-free waveform), it is
necessary to add waveform end block at the end.

        VAG header ('VAGp' ... )
        30H (48 bytes)
        
        Waveform Start Block (all 0)
        10H (16 bytes)
        
        Waveform Data
        Arbitrary
        
        Waveform End Block (Only for one-shot waveform)
        10H (16 bytes)

Omission of waveform end block addition may result in malfunction when SPU interrupt is used. For the waveform with loop as explained above, however, waveform end block is unnecesary.

Functional Specification

1 void EncVagInit ( short conv_mode )


This function initializes the encode routine. When encoding waveform data, it is necessary to make a call at first.

Conversion mode "conv_mode" is set by selecting one from "Stndard", "High Band", "Low Band" and "4bit Straight".
  1. Standard
  2. High Band (Effective in waveform with many high-frequency elements)
  3. Low Band (Effective in waveform with many low-frequency elements)
  4. 4bit Straight (Linear conversion from 16 bits to 4 bits)

____________________________________________________________

2 void EncVag ( short x[ ], short y[ ] , short block_attribute )


Apply compression conversion to the data of 28 samples (56 bytes), which has been specified in Array x, and then store the data in Array y of 16 bytes. Array y consists of 8 short words.

Set block_attribute to one of the following (1) to (5) as loop setting
  1. Loop-free waveform (one shot)
  2. Loop-free waveform and waveform end block
  3. Waveform with loop and loop start block
  4. Waveform with loop (Not start/end block)
  5. Waveform with loop and waveform end block

____________________________________________________________

3 void EncVagFin ( short y[ ] )


When compression conversion is applied to one-shot (loop-free) waveform, it is necessary to call this function and add waveform end block at the end. Array y consists of 8 short words.

Sample Application

A2V_Win is a simple sample application, which uses the VAG Encode Library for PC. This application reads 16-bit non-compressed aiff file and converts it to VAG.
It has been confirmed that A2V_Win runs in Windows95 and WindowsNT 4.0 environments.

1 Build

All the source code of A2V_Win is included in the sample/source directory. The attached project is for Visual C++ 5.0.
The project refers to encvag.h and encvag.lib in the library directory with a relative path. When the configuration of the directory is changed, set the paths for the include and library files correctly in "Project Setting" menu.

2 Execution

To execute A2V_Win, encvag.dll in the library directory is required. Copy it to the current directory or Windows system directory.
When A2V_Win is activated, the following window appears. Specify the aiff file (source) in the "Input file" box and the converted file name in the "Output file" box. The aiff file to be specified has to be 16-bit data in non-compressed form.
When the "Convert" button is pressed, the conversion from aiff to VAG is implemented.



↑TOP
Copyright (c) 1998 Sony Computer Entertainment Inc. All Rights Reserved.