Package javax.sound.sampled

Examples of javax.sound.sampled.AudioFormat


        } catch (IOException e1) {
            e1.printStackTrace();
            return;
        }

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

        try {
            auline = (SourceDataLine) AudioSystem.getLine(info);
View Full Code Here


        streamConfiguration.setChannelCount(1);


        try {
            AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(inputFile);
            AudioFormat format = audioInputStream.getFormat();

            int frameSize = format.getFrameSize();

            FLACEncoder flacEncoder = new FLACEncoder();
            FLACFileOutputStream flacOutputStream = new FLACFileOutputStream(outputFile);

            flacEncoder.setStreamConfiguration(streamConfiguration);
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

          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

        }
        else
        {
            //comparer le format audio qu'attend la sortie son et celui du flux
            //s'ils sont différents, fermer puis rouvrir la ligne
            AudioFormat lineAudioFormat = this.sortieSon.getFormat();
            AudioFormat audioInputStreamFormat = (this.audioInputStream == null ? null : this.audioInputStream.getFormat());
            if (!lineAudioFormat.equals(audioInputStreamFormat))
            {
                this.sortieSon.close();
                openLine();
            }
View Full Code Here

    private void createLine() throws LineUnavailableException
    {
        if (this.sortieSon == null)
        {
            //récupérer le format de la source
            AudioFormat sourceFormat = this.audioInputStream.getFormat();
            //pour les fichiers MP3 choisis nSampleSizeInBits = 16;
            AudioFormat targetFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
                                                       sourceFormat.getSampleRate(), 16,
                                                       sourceFormat.getChannels(),
                                                       2 * sourceFormat.getChannels(),
                                                       sourceFormat.getSampleRate(), false);
            // garder une référence sur le flux audio pour la progression de la lecture
            // encodedAudioInputStream est le format encodé de départ (IO)
            // audioInputStream sera le format décodé (système audio)
            this.encodedAudioInputStream = this.audioInputStream;
            //Créer le flux décodé
            this.audioInputStream = AudioSystem.getAudioInputStream(targetFormat, this.audioInputStream);
            //récupérer le format décodé
            AudioFormat audioFormat = this.audioInputStream.getFormat();
            //Informer la sortie son
            DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat, AudioSystem.NOT_SPECIFIED);
            this.sortieSon = (SourceDataLine) AudioSystem.getLine(info);
        }
    }
View Full Code Here

    {
        if (this.sortieSon != null)
        {
//            if (this.sortieSon.isOpen ()) this.sortieSon.close ();
            //créer une sortie son
            AudioFormat audioFormat = this.audioInputStream.getFormat();
            int buffersize = this.sortieSon.getBufferSize();
           
            this.sortieSon.open(audioFormat, buffersize);
            //la sortie son supporte-t-elle les modifications de volume ?
            if (this.sortieSon.isControlSupported(FloatControl.Type.MASTER_GAIN))
View Full Code Here

    try {
      // Get AudioInputStream from given file.
      AudioInputStream in = AudioSystem.getAudioInputStream(file);
      AudioInputStream din = null;
      if (in != null) {
        AudioFormat baseFormat = in.getFormat();
        AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16,
            baseFormat.getChannels(), baseFormat.getChannels() * 2, baseFormat.getSampleRate(), false);
        // Get AudioInputStream that will be decoded by underlying
        // VorbisSPI
        din = AudioSystem.getAudioInputStream(decodedFormat, in);
        // Play now !
View Full Code Here

    try {
      // Get AudioInputStream from given file.
      AudioInputStream in = AudioSystem.getAudioInputStream(file);
      AudioInputStream din = null;
      if (in != null) {
        AudioFormat baseFormat = in.getFormat();
        AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16,
            baseFormat.getChannels(), baseFormat.getChannels() * 2, baseFormat.getSampleRate(), false);
        // Get AudioInputStream that will be decoded by underlying
        // VorbisSPI
        din = AudioSystem.getAudioInputStream(decodedFormat, in);
        // Play now !
View Full Code Here

       AudioInputStream stream;
       URL loadedSound = getClass().getResource(path);
       if(loadedSound!=null)stream=AudioSystem.getAudioInputStream(loadedSound.openStream());
        else stream=AudioSystem.getAudioInputStream(new File(path));
                    
            AudioFormat format = stream.getFormat();
          
            DataLine.Info info = new DataLine.Info(
                                      Clip.class,
                                      stream.getFormat(),
                                      ((int) stream.getFrameLength() *
                                          format.getFrameSize()));

            Clip clip = (Clip) AudioSystem.getLine(info);
            clip.open(stream);
          sounds.put(sound,clip);
    }catch (IOException e)
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.