Ejemplo n.º 1
0
        // createSource fix.
        protected internal virtual void  createSource()
        {
            //UPGRADE_NOTE: Exception 'java.lang.Throwable' was converted to 'System.Exception' which has different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1100"'
            System.Exception t = null;
            try
            {
                Line line = AudioSystem.getLine(SourceLineInfo);
                if (line is SourceDataLine)
                {
                    source = (SourceDataLine)line;
                    source.open(fmt, millisecondsToBytes(fmt, 2000));

                    /*
                     * if (source.isControlSupported(FloatControl.Type.MASTER_GAIN))
                     * {
                     * FloatControl c = (FloatControl)source.getControl(FloatControl.Type.MASTER_GAIN);
                     * c.setValue(c.getMaximum());
                     * }*/
                    source.start();
                }
            }
            catch (System.SystemException ex)
            {
                t = ex;
            }
            catch (System.ApplicationException ex)
            {
                t = ex;
            }
            catch (LineUnavailableException ex)
            {
                t = ex;
            }
            if (source == null)
            {
                throw new JavaLayerException("cannot obtain source audio line", t);
            }
        }
Ejemplo n.º 2
0
        private bool read(int codecType, sceAtrac3plus.AtracFileInfo atracFileInfo)
        {
            codec = CodecFactory.getCodec(codecType);
            if (codec == null)
            {
                return(false);
            }

            int result = codec.init(atracFileInfo.atracBytesPerFrame, atracFileInfo.atracChannels, atracFileInfo.atracChannels, atracFileInfo.atracCodingMode);

            if (result < 0)
            {
                return(false);
            }

            AudioFormat audioFormat = new AudioFormat(44100, 16, atracFileInfo.atracChannels, true, false);

            DataLine.Info info = new DataLine.Info(typeof(SourceDataLine), audioFormat);
            try
            {
                mLine = (SourceDataLine)AudioSystem.getLine(info);
                mLine.open(audioFormat);
            }
            catch (LineUnavailableException)
            {
                return(false);
            }
            mLine.start();

            inputOffset        = atracFileInfo.inputFileDataOffset;
            inputPosition      = inputOffset;
            inputBytesPerFrame = atracFileInfo.atracBytesPerFrame;
            channels           = atracFileInfo.atracChannels;

            return(true);
        }