Package javax.sound.sampled

Examples of javax.sound.sampled.AudioFormat


 
        public final void run()
        {
            Clip clip=null;
            byte[] data=null;
            AudioFormat format=null;
            while (isRunning)
            {
                synchronized(queue)
                {
                    if (queue.isEmpty())
View Full Code Here


          if (actionKey.equals(audioStrings[i])){
            try {
              String audioFileName = (String)UIManager.get(audioStrings[i]);
              URL audioURL = Win32LookAndFeel.class.getResource(audioFileName);
              AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File(audioURL.getFile()));
              AudioFormat format = audioInputStream.getFormat();
              DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
              SourceDataLine auline = (SourceDataLine) AudioSystem.getLine(info);
              auline.open(format);
              auline.start();
              int nBytesRead = 0;
View Full Code Here

      // From URL
      // stream = AudioSystem.getAudioInputStream(new URL("http://hostname/audiofile"));

      // At present, ALAW and ULAW encodings must be converted
      // to PCM_SIGNED before it can be played
      AudioFormat format = stream.getFormat();
      if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED)
      {
          format = new AudioFormat(
                  AudioFormat.Encoding.PCM_SIGNED,
                  format.getSampleRate(),
                  format.getSampleSizeInBits()*2,
                  format.getChannels(),
                  format.getFrameSize()*2,
                  format.getFrameRate(),
                  true);        // big endian
          stream = AudioSystem.getAudioInputStream(format, stream);
      }
      DataLine.Info info = new DataLine.Info(Clip.class, stream.getFormat(), ((int)stream.getFrameLength()*format.getFrameSize()));
      clip = (Clip) AudioSystem.getLine(info);
      clip.open(stream);
      //clip.start();

     
View Full Code Here

        if (vbr) {
            encoding = encodingsVbr[quality];
        } else {
            encoding = encodingsCbr[quality];
        }
        return new AudioFormat(encoding, sampleRate, 16, 1, 2, sampleRate,
            false);
    }
View Full Code Here

     *         error occured
     */
    public boolean setupSound(Mixer mixer) {
        DataLine.Info info;
        if (started == false) {
            AudioFormat audioFormat = new AudioFormat(
                AudioFormat.Encoding.PCM_SIGNED, 44100.0F, 16, 1, 2, 44100.0F,
                false);

            info = new DataLine.Info(TargetDataLine.class, audioFormat);
            try {
View Full Code Here

        this.preferenceUtils = preferenceUtils;

        mixer = preferenceUtils.getPlaybackMixer();

        player = new AudioPlayer(audioServiceManager);
        AudioFormat audioFormat = new AudioFormat(
            AudioFormat.Encoding.PCM_SIGNED, 44100.0F, 16, 1, 2, 44100.0F,
            false);
        // Initialize the decoder.
        decoderStream = new Speex2PcmAudioInputStream(inputStream, audioFormat,
            AudioSystem.NOT_SPECIFIED);
View Full Code Here

                    "An error occured while initializing the audio record device. The VoIP Session will start anyway. Please check the VoIP Settings at Window > Preferences > Saros > Communication. Maybe this session will be pointless if the other buddy has also no record device.");
            log.warn("No record device initialized");
            return;
        }

        AudioFormat audioFormat = preferenceUtils.getEncodingFormat();
        log.debug("Starting Encoder with " + audioFormat.toString());
        log.info("AudioEncoder will be initalized.");
        encoderStream = new Pcm2SpeexAudioInputStream(
            recorder.getAudioInputStream(), audioFormat,
            AudioSystem.NOT_SPECIFIED);
View Full Code Here

     *         occured
     */
    public boolean setupSound(InputStream in, Mixer mixer) {
        if (started == false) {
            InputStream audioStream = in;
            AudioFormat audioFormat;
            if (mixer == null) {
                log.error("Playback device is already in use.");
                return false;
            }

            try {
                if (audioStream instanceof AudioInputStream) {
                    audioInputStream = (AudioInputStream) audioStream;
                } else {
                    audioInputStream = AudioSystem
                        .getAudioInputStream(audioStream);
                }
            } catch (Exception e) {
                log.error("InputStream is not an AudioStream", e);
                return false;
            }
            audioFormat = audioInputStream.getFormat();
            DataLine.Info info = new DataLine.Info(SourceDataLine.class,
                audioFormat);
            // If the audioFormat is not directly supported

            if (!AudioSystem.isLineSupported(info)) {
                AudioFormat targetFormat = new AudioFormat(
                    AudioFormat.Encoding.PCM_SIGNED, 44100.0F, 16, 1, 2,
                    44100.0F, false);
                audioInputStream = AudioSystem.getAudioInputStream(
                    targetFormat, audioInputStream);
                audioFormat = audioInputStream.getFormat();
View Full Code Here

                            "IO-Error while getting AudioInputStream for "
                                + fileName, e1);
                        return;
                    }

                    AudioFormat format = audioInputStream.getFormat();
                    SourceDataLine auline = null;
                    DataLine.Info info = new DataLine.Info(
                        SourceDataLine.class, format);

                    try {
View Full Code Here

    /** Start audio capture.
     */
    private static void _startCapture() throws IOException {
        boolean signed = true;
        boolean bigEndian = true;
        AudioFormat format = new AudioFormat(_sampleRate, _bitsPerSample,
                _channels, signed, bigEndian);

        DataLine.Info targetInfo = new DataLine.Info(TargetDataLine.class,
                format, AudioSystem.NOT_SPECIFIED);

View Full Code Here

TOP

Related Classes of javax.sound.sampled.AudioFormat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.