Example #1
0
        private bool open()
        {
            TargetDataLine targetDataLine = this.getAudioLine();

            if (targetDataLine != null)
            {
                if (!targetDataLine.isOpen())
                {
                    this.logger.info("open");
                    try
                    {
                        targetDataLine.open(this.finalFormat, this.audioBufferSize);
                    }
                    catch (LineUnavailableException ex)
                    {
                        this.logger.severe(new StringBuilder().append("Can't open microphone ").append(Throwable.instancehelper_getMessage(ex)).toString());
                        return(false);
                    }
                    this.audioStream = new AudioInputStream(targetDataLine);
                    if (this.doConversion)
                    {
                        this.audioStream = AudioSystem.getAudioInputStream(this.desiredFormat, this.audioStream);
                        if (!Microphone.assertionsDisabled && this.audioStream == null)
                        {
                            throw new AssertionError();
                        }
                    }
                    float num = (float)this.msecPerRead / 1000f;
                    this.frameSizeInBytes = this.audioStream.getFormat().getSampleSizeInBits() / 8 * ByteCodeHelper.f2i(num * this.audioStream.getFormat().getSampleRate()) * this.desiredFormat.getChannels();
                    this.logger.info(new StringBuilder().append("Frame size: ").append(this.frameSizeInBytes).append(" bytes").toString());
                    return(true);
                }
                return(true);
            }
            this.logger.severe("Can't find microphone");
            return(false);
        }
 internal TargetDataLineInputStream(AudioInputStream _enclosing, TargetDataLine
     line)
     : base()
 {
     this._enclosing = _enclosing;
     this.line = line;
 }
 /// <summary>
 /// Constructs an audio input stream that reads its data from the target
 /// data line indicated.
 /// </summary>
 /// <remarks>
 /// Constructs an audio input stream that reads its data from the target
 /// data line indicated.  The format of the stream is the same as that of
 /// the target data line, and the length is AudioSystem#NOT_SPECIFIED.
 /// </remarks>
 /// <param name="line">the target data line from which this stream obtains its data.</param>
 /// <seealso cref="AudioSystem.NOT_SPECIFIED">AudioSystem.NOT_SPECIFIED</seealso>
 public AudioInputStream(TargetDataLine line)
 {
     AudioInputStream.TargetDataLineInputStream tstream = new AudioInputStream.TargetDataLineInputStream
         (this, line);
     format = line.getFormat();
     frameLength = AudioSystem.NOT_SPECIFIED;
     frameSize = format.getFrameSize();
     if (frameSize == AudioSystem.NOT_SPECIFIED || frameSize <= 0)
     {
         frameSize = 1;
     }
     this.stream = tstream;
     framePos = 0;
     markpos = 0;
 }
		/// <summary>
		/// Constructs an audio input stream that reads its data from the target
		/// data line indicated.
		/// </summary>
		public AudioInputStream(TargetDataLine @line)
		{
		}
 /// <summary>
 /// Constructs an audio input stream that reads its data from the target
 /// data line indicated.
 /// </summary>
 public AudioInputStream(TargetDataLine @line)
 {
 }
Example #6
0
 internal static TargetDataLine access_102(Microphone microphone, TargetDataLine result)
 {
     microphone.audioLine = result;
     return(result);
 }