Logo Search packages:      
Sourcecode: libjlayer-java version File versions  Download package

int javazoom::jl::converter::WaveFile::OpenForWrite ( String  Filename,
int  SamplingRate,
short  BitsPerSample,
short  NumChannels 
) [inline]

public int OpenForRead (String Filename) { Verify filename parameter as best we can... if (Filename == null) { return DDC_INVALID_CALL; } int retcode = Open ( Filename, RFM_READ );

if ( retcode == DDC_SUCCESS ) { retcode = Expect ( "WAVE", 4 );

if ( retcode == DDC_SUCCESS ) { retcode = Read(wave_format,24);

if ( retcode == DDC_SUCCESS && !wave_format.VerifyValidity() ) { This isn't standard PCM, so we don't know what it is! retcode = DDC_FILE_ERROR; }

if ( retcode == DDC_SUCCESS ) { pcm_data_offset = CurrentFilePosition();

Figure out number of samples from file size, current file position, and WAVE header. retcode = Read (pcm_data, 8 ); num_samples = filelength(fileno(file)) - CurrentFilePosition(); num_samples /= NumChannels(); num_samples /= (BitsPerSample() / 8); } } } return retcode; }

Definition at line 163 of file WaveFile.java.

References CurrentFilePosition(), javazoom::jl::converter::RiffFile::Open(), and javazoom::jl::converter::RiffFile::Write().

Referenced by OpenForWrite(), and javazoom::jl::converter::WaveFileObuffer::WaveFileObuffer().

   {
      // Verify parameters...
      if ( (Filename==null) ||
            (BitsPerSample != 8 && BitsPerSample != 16) ||
            NumChannels < 1 || NumChannels > 2 )
      {
            return DDC_INVALID_CALL;
      }
   
      wave_format.data.Config ( SamplingRate, BitsPerSample, NumChannels );
   
      int retcode = Open ( Filename, RFM_WRITE );
   
      if ( retcode == DDC_SUCCESS )
      {
        byte [] theWave = {(byte)'W',(byte)'A',(byte)'V',(byte)'E'};
            retcode = Write ( theWave, 4 );
   
            if ( retcode == DDC_SUCCESS )
            {
            // Ecriture de wave_format
            retcode = Write (wave_format.header, 8);   
            retcode = Write (wave_format.data.wFormatTag, 2);
            retcode = Write (wave_format.data.nChannels, 2);
            retcode = Write (wave_format.data.nSamplesPerSec, 4);
            retcode = Write (wave_format.data.nAvgBytesPerSec, 4);
            retcode = Write (wave_format.data.nBlockAlign, 2);
            retcode = Write (wave_format.data.nBitsPerSample, 2);
            /* byte[] br = new byte[16];
              br[0] = (byte) ((wave_format.data.wFormatTag >> 8) & 0x00FF);
            br[1] = (byte) (wave_format.data.wFormatTag & 0x00FF);
        
            br[2] = (byte) ((wave_format.data.nChannels >> 8) & 0x00FF);
              br[3] = (byte) (wave_format.data.nChannels & 0x00FF);
        
              br[4] = (byte) ((wave_format.data.nSamplesPerSec >> 24)& 0x000000FF);
              br[5] = (byte) ((wave_format.data.nSamplesPerSec >> 16)& 0x000000FF);
              br[6] = (byte) ((wave_format.data.nSamplesPerSec >> 8)& 0x000000FF);
              br[7] = (byte) (wave_format.data.nSamplesPerSec & 0x000000FF);
        
              br[8] = (byte) ((wave_format.data.nAvgBytesPerSec>> 24)& 0x000000FF);
              br[9] = (byte) ((wave_format.data.nAvgBytesPerSec >> 16)& 0x000000FF);
              br[10] = (byte) ((wave_format.data.nAvgBytesPerSec >> 8)& 0x000000FF);
              br[11] = (byte) (wave_format.data.nAvgBytesPerSec & 0x000000FF);

              br[12] = (byte) ((wave_format.data.nBlockAlign >> 8) & 0x00FF);
              br[13] = (byte) (wave_format.data.nBlockAlign & 0x00FF);
        
              br[14] = (byte) ((wave_format.data.nBitsPerSample >> 8) & 0x00FF);
              br[15] = (byte) (wave_format.data.nBitsPerSample & 0x00FF);                 
                  retcode = Write (br, 16); */
                  
   
                  if ( retcode == DDC_SUCCESS )
                  {
                        pcm_data_offset = CurrentFilePosition();
                        retcode = Write ( pcm_data, 8 );
                  }
            }
      }
   
      return retcode;
   }


Generated by  Doxygen 1.6.0   Back to index