Package javax.sound.sampled

Examples of javax.sound.sampled.Mixer$Info


     
      int mixerIndex = getMixerIndex();
     
      // get the requested TargetDataLine from the mixer and open it
      Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
      Mixer mixer = AudioSystem.getMixer(mixerInfo[mixerIndex]);
      targetDataLine = (TargetDataLine)mixer.getLine(new DataLine.Info(TargetDataLine.class, null));
            if (TRACE) logger.fine("targetDataLine=" + targetDataLine);
     
      // calculate buffer size
      buflen = (int)((javaSoundAudioFormat.getFrameSize() * javaSoundAudioFormat.getSampleRate() * buflenMS) / 1000);
      targetDataLine.open(javaSoundAudioFormat, buflen);
View Full Code Here


    {
      return null;
    }
   
    // Fetch the mixer
    Mixer mixer = AudioSystem.getMixer(mixerInfo[mixerIndex]);

    Line.Info[] infos = mixer.getTargetLineInfo();
    for (int i=0; i<infos.length; i++)
    {
      if ( infos[i] instanceof DataLine.Info )
      {
        javax.sound.sampled.AudioFormat[] af = ((DataLine.Info)infos[i]).getFormats();
View Full Code Here

    final Properties prop = new Properties();
    loadSoundProperties(prop);

    final Map<String, AudioFormat> formatMap = new TreeMap<String, AudioFormat>();
    final Map<String, String> fileFormatMap = new TreeMap<String, String>();
    final Mixer defaultMixer = TESTPLAY_SAMPLES? AudioSystem.getMixer(null): null;

    // get sound library filepath
    final String soundBase = prop.getProperty("soundbase", "data/sounds");

    // read all load-permitted sounds listed in properties
    // from soundfile into cache map
    for (final Entry<String, String> entry : ((Map<String, String>) (Map<?,?>) prop).entrySet()) {
      if (isValidEntry(entry.getKey(), entry.getValue())) {
        final String name = entry.getKey().substring(4);
        String filename = entry.getValue();
        final int pos = filename.indexOf(',');
        if (pos > -1) {
          filename = filename.substring(0, pos);
        }

        try {
          final InputStream is = CheckSounds.class.getClassLoader().getResourceAsStream(
              soundBase + "/" + filename);
          final AudioInputStream ais = AudioSystem.getAudioInputStream(is);
          final AudioFormat format = ais.getFormat();
          final String formatString = format.toString();

          if (TESTPLAY_SAMPLES) {
            // testplay the sound
            final DataLine.Info info = new DataLine.Info(Clip.class, format);
            if (defaultMixer.isLineSupported(info)) {
              AudioInputStream playStream = ais;
              final AudioFormat defaultFormat = new AudioFormat(
                  format.getSampleRate(), 16, 1, false, true);
              if (AudioSystem.isConversionSupported(
                  defaultFormat, format)) {
                playStream = AudioSystem.getAudioInputStream(
                    defaultFormat, ais);
              } else {
                System.out.println("conversion not supported (to "
                    + defaultFormat + ")");
              }

              System.out.println("testplaying " + name + " "
                  + playStream.getFormat());

              final Clip line = (Clip) defaultMixer.getLine(info);
              line.open(playStream);
              line.loop(2);
              final TestLineListener testListener = new TestLineListener();
              line.addLineListener(testListener);
              while (testListener.active) {
                Thread.yield();
              }
              line.close();
            }
          }

          fileFormatMap.put(name, formatString);
          if (!formatMap.containsKey(formatString)) {
            formatMap.put(formatString, format);
          }
        } catch (final UnsupportedAudioFileException e) {
          System.out.println(name
              + " cannot be read, the file format is not supported");
        }
      }
    }

    final Mixer.Info[] mixerList = AudioSystem.getMixerInfo();
    final int[] width = new int[mixerList.length];

    System.out.println("\n\n--- Result ---\n");
    System.out.println("installed mixer: ");
    for (int i = 0; i < mixerList.length; i++) {
      final Mixer.Info mixer = mixerList[i];
      width[i] = Math.max(mixer.getName().length(),
          "unsupported".length());
      System.out.println(mixer.getName() + " - " + mixer.getDescription());
    }
    System.out.println("Default: "
        + AudioSystem.getMixer(null).getMixerInfo().getName());
    System.out.println("\n");

    System.out.println(formatMap.size()
        + " audio formats\nThe maximum available lines for the format is in brackets.");
    for (int i = 0; i < mixerList.length; i++) {
      System.out.print(getString(mixerList[i].getName(), width[i], ' ')
          + " | ");
    }
    System.out.println("Format");
    for (int i = 0; i < mixerList.length; i++) {
      System.out.print(getString("", width[i], '-') + "-+-");
    }
    System.out.println("---------------------");

    for (final Map.Entry<String, AudioFormat> it_FM : formatMap.entrySet()) {
      String key = it_FM.getKey();
      final DataLine.Info info = new DataLine.Info(Clip.class, it_FM.getValue());
      for (int i = 0; i < mixerList.length; i++) {
        final Mixer mixer = AudioSystem.getMixer(mixerList[i]);
        final boolean supported = mixer.isLineSupported(info);
        StringBuilder stringBuilder = new StringBuilder();
        if (supported) {
          stringBuilder.append("  ");
        } else {
          stringBuilder.append("un");
        }
        stringBuilder.append("supported (");
        stringBuilder.append(mixer.getMaxLines(info));
        stringBuilder.append(")");
        System.out.print(getString(stringBuilder.toString(),
            width[i], ' ') + " | ");
      }
View Full Code Here

      }
      audioFormat = getAudioFormat();

      DataLine.Info dataLineInfo = new DataLine.Info(TargetDataLine.class, audioFormat);

      Mixer mixer = AudioSystem.getMixer(mixerInfo[5]);

      targetDataLine = (TargetDataLine) mixer.getLine(dataLineInfo);

      targetDataLine.open(audioFormat);
      targetDataLine.start();

      Thread captureThread = new CaptureThread();
View Full Code Here

      DataLine.Info dataLineInfo = new DataLine.Info(TargetDataLine.class, audioFormat);

      int choice = 4;

      System.out.println("chose mixer: " + mixerInfo[choice].getName());
      Mixer mixer = AudioSystem.getMixer(mixerInfo[choice]);

      targetDataLine = (TargetDataLine) mixer.getLine(dataLineInfo);

      targetDataLine.open(audioFormat);

      targetDataLine.start();
View Full Code Here

        this.volume = volume;
    }

    private Clip getClip(DataLine.Info info) throws LineUnavailableException {
        for (Mixer.Info mi : AudioSystem.getMixerInfo()) {
            Mixer mixer = AudioSystem.getMixer(mi);
            try {
                return (Clip) mixer.getLine(info);
            } catch (LineUnavailableException ex) {
                resourceLogger.warning("Matching line not available: " + ex.getLocalizedMessage());
            } catch (IllegalArgumentException ex) {
                resourceLogger.warning("Mixer does not support this format. " + ex.getLocalizedMessage());
            }
View Full Code Here

    if(mixers.length == 0) System.out.println("No ASIO mixers found on your system.");
    else if(mixerIndex >= mixers.length) System.out.println("Index " + mixerIndex + " out of range.");
    else{
      System.out.println("Mixer: " + mixers[mixerIndex]);
      System.out.println();
      Mixer mixer = provider.getMixer(mixers[mixerIndex]);
      Line.Info[] targetInfo = mixer.getTargetLineInfo();
      Line.Info[] sourceInfo = mixer.getSourceLineInfo();
      if(targetInfo.length > 0){
        System.out.println("Recording lines:");
        for(int i = 0; i < targetInfo.length; i++){
          System.out.println(i + ": " + targetInfo[i]);
          AudioFormat[] formats = ((DataLine.Info)targetInfo[i]).getFormats();
View Full Code Here

            }
            // Create decoded stream.
            m_audioInputStream = AudioSystem.getAudioInputStream(targetFormat, m_audioInputStream);
            AudioFormat audioFormat = m_audioInputStream.getFormat();
            DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat, AudioSystem.NOT_SPECIFIED);
            Mixer mixer = getMixer(m_mixerName);
            if (mixer != null)
            {
                log.info("Mixer : "+mixer.getMixerInfo().toString());
                m_line = (SourceDataLine) mixer.getLine(info);
            }
            else
            {
                m_line = (SourceDataLine) AudioSystem.getLine(info);
                m_mixerName = null;
View Full Code Here

        if (mInfos != null)
        {
            for (int i = 0; i < mInfos.length; i++)
            {
                Line.Info lineInfo = new Line.Info(SourceDataLine.class);
                Mixer mixer = AudioSystem.getMixer(mInfos[i]);
                if (mixer.isLineSupported(lineInfo))
                {
                    mixers.add(mInfos[i].getName());
                }
            }           
        }
View Full Code Here

        return mixers;       
    }
   
    public Mixer getMixer(String name)
    {
        Mixer mixer = null;
        if (name != null)
        {
            Mixer.Info[] mInfos = AudioSystem.getMixerInfo();
            if (mInfos != null)
            {
View Full Code Here

TOP

Related Classes of javax.sound.sampled.Mixer$Info

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.