Example #1
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: Clob(java.sql.Clob clob) throws java.sql.SQLException
        internal Clob(java.sql.Clob clob)
        {
            long length = clob.length();

            if (length >= 0)
            {
                value = clob.getSubString(1, (int) length);
            }
        }
 /// <summary>Obtains the audio file format of the File provided.</summary>
 /// <remarks>
 /// Obtains the audio file format of the File provided.
 /// The File must point to valid audio file data.
 /// </remarks>
 /// <param name="file">
 /// the File from which file format information should be
 /// extracted.
 /// </param>
 /// <returns>an AudioFileFormat object describing the audio file format.</returns>
 /// <exception>
 /// UnsupportedAudioFileException
 /// if the File does not point to
 /// a valid audio file data recognized by the system.
 /// </exception>
 /// <exception>
 /// IOException
 /// if an I/O exception occurs.
 /// </exception>
 /// <exception cref="javax.sound.sampled.UnsupportedAudioFileException"></exception>
 /// <exception cref="System.IO.IOException"></exception>
 public override javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.File
     file)
 {
     java.io.InputStream inputStream = null;
     try
     {
         inputStream = new java.io.FileInputStream(file);
         return getAudioFileFormat(inputStream, (int)file.length());
     }
     finally
     {
         inputStream.close();
     }
 }
 internal CharSequenceAdapter(java.lang.CharSequence chseq)
 {
     [email protected](chseq.length());
     sequence = chseq;
 }
Example #4
0
		/// <exception cref="java.nio.charset.CharacterCodingException"></exception>
		private void checkCoderResult(java.nio.charset.CoderResult result)
		{
			if (result.isMalformed() && _malformedInputAction == java.nio.charset.CodingErrorAction
				.REPORT)
			{
				throw new java.nio.charset.MalformedInputException(result.length());
			}
			else
			{
				if (result.isUnmappable() && _unmappableCharacterAction == java.nio.charset.CodingErrorAction
					.REPORT)
				{
					throw new java.nio.charset.UnmappableCharacterException(result.length());
				}
			}
		}
 /// <summary>Obtains an audio input stream from the File provided.</summary>
 /// <remarks>
 /// Obtains an audio input stream from the File provided.
 /// The File must point to valid audio file data.
 /// </remarks>
 /// <param name="file">the File for which the AudioInputStream should be constructed.
 /// 	</param>
 /// <returns>
 /// an AudioInputStream object based on the audio file data pointed to
 /// by the File.
 /// </returns>
 /// <exception>
 /// UnsupportedAudioFileException
 /// if the File does not point to
 /// a valid audio file data recognized by the system.
 /// </exception>
 /// <exception>
 /// IOException
 /// if an I/O exception occurs.
 /// </exception>
 /// <exception cref="javax.sound.sampled.UnsupportedAudioFileException"></exception>
 /// <exception cref="System.IO.IOException"></exception>
 public override javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.File
     file)
 {
     java.io.InputStream inputStream = new java.io.FileInputStream(file);
     try
     {
         return getAudioInputStream(inputStream, (int)file.length());
     }
     catch (javax.sound.sampled.UnsupportedAudioFileException e)
     {
         inputStream.close();
         throw;
     }
     catch (System.IO.IOException e)
     {
         inputStream.close();
         throw;
     }
 }
Example #6
0
        // ---|
        public virtual void encode(java.io.File srcPath, java.io.File destPath)
        {
            byte[] temp = new byte[2560];
            // stereo UWB requires one to read 2560b
            int HEADERSIZE = 8;
            string RIFF = "RIFF";
            string WAVE = "WAVE";
            string FORMAT = "fmt ";
            string DATA = "data";
            int WAVE_FORMAT_PCM = unchecked((int)(0x0001));
            // Display info
            if (printlevel <= INFO)
            {
                version();
            }
            if (printlevel <= DEBUG)
            {
                System.Console.WriteLine(string.Empty);
            }
            if (printlevel <= DEBUG)
            {
                System.Console.WriteLine("Input File: " + srcPath);
            }
            // Open the input stream
            java.io.DataInputStream dis = new java.io.DataInputStream(new java.io.FileInputStream
                (srcPath));
            // Prepare input stream
            if (srcFormat == FILE_FORMAT_WAVE)
            {
                // read the WAVE header
                dis.readFully(temp, 0, HEADERSIZE + 4);
                // make sure its a WAVE header
                if (!RIFF.Equals(cspeex.StringUtil.getStringForBytes(temp, 0, 4)) && !WAVE.Equals(cspeex.StringUtil.getStringForBytes
                    (temp, 8, 4)))
                {
                    System.Console.Error.WriteLine("Not a WAVE file");
                    return;
                }
                // Read other header chunks
                dis.readFully(temp, 0, HEADERSIZE);
                string chunk = cspeex.StringUtil.getStringForBytes(temp, 0, 4);
                int size = readInt(temp, 4);
                while (!chunk.Equals(DATA))
                {
                    dis.readFully(temp, 0, size);
                    if (chunk.Equals(FORMAT))
                    {
                        if (readShort(temp, 0) != WAVE_FORMAT_PCM)
                        {
                            System.Console.Error.WriteLine("Not a PCM file");
                            return;
                        }
                        channels = readShort(temp, 2);
                        sampleRate = readInt(temp, 4);
                        if (readShort(temp, 14) != 16)
                        {
                            System.Console.Error.WriteLine("Not a 16 bit file " + readShort(temp, 18));
                            return;
                        }
                        // Display audio info
                        if (printlevel <= DEBUG)
                        {
                            System.Console.WriteLine("File Format: PCM wave");
                            System.Console.WriteLine("Sample Rate: " + sampleRate);
                            System.Console.WriteLine("Channels: " + channels);
                        }
                    }
                    dis.readFully(temp, 0, HEADERSIZE);
                    chunk = cspeex.StringUtil.getStringForBytes(temp, 0, 4);
                    size = readInt(temp, 4);
                }
                if (printlevel <= DEBUG)
                {
                    System.Console.WriteLine("Data size: " + size);
                }
            }
            else
            {
                if (sampleRate < 0)
                {
                    switch (mode)
                    {
                        case 0:
                            {
                                sampleRate = 8000;
                                break;
                            }

                        case 1:
                            {
                                sampleRate = 16000;
                                break;
                            }

                        case 2:
                            {
                                sampleRate = 32000;
                                break;
                            }

                        default:
                            {
                                sampleRate = 8000;
                                break;
                            }
                    }
                }
                // Display audio info
                if (printlevel <= DEBUG)
                {
                    System.Console.WriteLine("File format: Raw audio");
                    System.Console.WriteLine("Sample rate: " + sampleRate);
                    System.Console.WriteLine("Channels: " + channels);
                    System.Console.WriteLine("Data size: " + srcPath.length());
                }
            }
            // Set the mode if it has not yet been determined
            if (mode < 0)
            {
                if (sampleRate < 100)
                {
                    // Sample Rate has probably been given in kHz
                    sampleRate *= 1000;
                }
                if (sampleRate < 12000)
                {
                    mode = 0;
                }
                else
                {
                    // Narrowband
                    if (sampleRate < 24000)
                    {
                        mode = 1;
                    }
                    else
                    {
                        // Wideband
                        mode = 2;
                    }
                }
            }
            // Ultra-wideband
            // Construct a new encoder
            org.xiph.speex.SpeexEncoder speexEncoder = new org.xiph.speex.SpeexEncoder();
            speexEncoder.init(mode, quality, sampleRate, channels);
            if (complexity > 0)
            {
                speexEncoder.getEncoder().setComplexity(complexity);
            }
            if (bitrate > 0)
            {
                speexEncoder.getEncoder().setBitRate(bitrate);
            }
            if (vbr)
            {
                speexEncoder.getEncoder().setVbr(vbr);
                if (vbr_quality > 0)
                {
                    speexEncoder.getEncoder().setVbrQuality(vbr_quality);
                }
            }
            if (vad)
            {
                speexEncoder.getEncoder().setVad(vad);
            }
            if (dtx)
            {
                speexEncoder.getEncoder().setDtx(dtx);
            }
            // Display info
            if (printlevel <= DEBUG)
            {
                System.Console.WriteLine(string.Empty);
                System.Console.WriteLine("Output File: " + destPath);
                System.Console.WriteLine("File format: Ogg Speex");
                System.Console.WriteLine("Encoder mode: " + (mode == 0 ? "Narrowband" : (mode== 1 ? "Wideband" : "UltraWideband")));
                System.Console.WriteLine("Quality: " + (vbr ? vbr_quality : quality));
                System.Console.WriteLine("Complexity: " + complexity);
                System.Console.WriteLine("Frames per packet: " + nframes);
                System.Console.WriteLine("Varible bitrate: " + vbr);
                System.Console.WriteLine("Voice activity detection: " + vad);
                System.Console.WriteLine("Discontinouous Transmission: " + dtx);
            }
            // Open the file writer
            org.xiph.speex.AudioFileWriter writer;
            if (destFormat == FILE_FORMAT_OGG)
            {
                writer = new org.xiph.speex.OggSpeexWriter(mode, sampleRate, channels, nframes, vbr
                    );
            }
            else
            {
                if (destFormat == FILE_FORMAT_WAVE)
                {
                    nframes = org.xiph.speex.PcmWaveWriter.WAVE_FRAME_SIZES[mode - 1][channels - 1][quality
                        ];
                    writer = new org.xiph.speex.PcmWaveWriter(mode, quality, sampleRate, channels, nframes
                        , vbr);
                }
                else
                {
                    writer = new org.xiph.speex.RawWriter();
                }
            }
            writer.open(destPath);
            writer.writeHeader("Encoded with: " + VERSION);
            int pcmPacketSize = 2 * channels * speexEncoder.getFrameSize();
            try
            {
                // read until we get to EOF
                while (true)
                {
                    dis.readFully(temp, 0, nframes * pcmPacketSize);
                    for (int i = 0; i < nframes; i++)
                    {
                        speexEncoder.processData(temp, i * pcmPacketSize, pcmPacketSize);
                    }
                    int encsize = speexEncoder.getProcessedData(temp, 0);
                    if (encsize > 0)
                    {
                        writer.writePacket(temp, 0, encsize);
                    }
                }
            }
            catch (java.io.EOFException)
            {
            }
            writer.close();
            dis.close();
        }
Example #7
0
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public long position(java.sql.Clob searchstr, long start) throws java.sql.SQLException
 public virtual long position(java.sql.Clob searchstr, long start)
 {
     return position(searchstr.getSubString(1, (int) searchstr.length()), start--);
 }