Package de.sciss.eisenkraut.io

Examples of de.sciss.eisenkraut.io.AudioBoxConfig


    final Application        app      = AbstractApplication.getApplication();
//    final JPanel          buttonPanel;
    final Box            buttonPanel;
    final JTabbedPane        ggTabPane;
    final String          abCfgID;
    final AudioBoxConfig      abCfg;
    JButton              ggButton;
//    Param              p;

    audioPrefs      = app.getUserPrefs().node( PrefsUtil.NODE_AUDIO );
    abCfgID        = audioPrefs.get( PrefsUtil.KEY_AUDIOBOX, AudioBoxConfig.ID_DEFAULT );
    abCfg        = new AudioBoxConfig( audioPrefs.node( PrefsUtil.NODE_AUDIOBOXES ).node( abCfgID ));

    audioHwChannels[0= abCfg.numInputChannels;
    audioHwChannels[1= abCfg.numOutputChannels;

    ggTabPane      = new JTabbedPane();
View Full Code Here


    value = AudioBoxConfig.ID_DEFAULT;
    putDontOverwrite( childPrefs, KEY_AUDIOBOX, value );
    try {
      if( !childPrefs.nodeExists( NODE_AUDIOBOXES )) {
        childPrefs2  = childPrefs.node( NODE_AUDIOBOXES );
        new AudioBoxConfig( value, "Default", 8, 8, true ).toPrefs( childPrefs2.node( value ));
      }
    }
    catch( BackingStoreException e1 ) {
      warnings.add( e1.toString() );
    }
View Full Code Here

 
    String          val;
    int            serverPort;  // , idx;
    Param          p;
    final String      abCfgID    = audioPrefs.get( PrefsUtil.KEY_AUDIOBOX, AudioBoxConfig.ID_DEFAULT );
    final AudioBoxConfig  abCfg    = new AudioBoxConfig( audioPrefs.node( PrefsUtil.NODE_AUDIOBOXES ).node( abCfgID ));
   
    p  = Param.fromPrefs( audioPrefs, PrefsUtil.KEY_AUDIORATE, null );
    if( p != null ) so.setSampleRate( p.val );
    so.setNumInputBusChannels( abCfg.numInputChannels );
    so.setNumOutputBusChannels( abCfg.numOutputChannels );
View Full Code Here

    ggPlus.addActionListener( new ActionListener() {
      public void actionPerformed( ActionEvent e )
      {
        final int modelIndex = collAudioBoxConfigs.size();
        final int viewIndex;
        final AudioBoxConfig cfg = createUniqueAudioBox();
        addAudioBox( cfg );
        abtm.fireTableRowsInserted( modelIndex, modelIndex );
        viewIndex = stm.getViewIndex( modelIndex );
        table.setRowSelectionInterval( viewIndex, viewIndex );
        triggerCtrlRoomRefill();
      }
    });
    ggMinus.addActionListener( new ActionListener() {
      public void actionPerformed( ActionEvent e )
      {
        final int firstRow  = Math.max( 0, table.getSelectedRow() );
        final int lastRow  = Math.min( table.getRowCount(), firstRow + table.getSelectedRowCount() ) - 1;
        AudioBoxConfig cfg;
        final int[] modelIndices;
       
        if( firstRow <= lastRow ) {
          modelIndices = new int[ lastRow - firstRow + 1 ];
          for( int i = 0, viewIndex = firstRow; viewIndex <= lastRow; i++, viewIndex++ ) {
View Full Code Here

 
  private void changeAudioBoxActivity( AudioBoxConfig cfg, boolean newActive )
  throws BackingStoreException
  {
    final int idx;
    final AudioBoxConfig newCfg;
   
    idx = collAudioBoxConfigs.indexOf( cfg );
    newCfg = cfg.changeActive( newActive );
    newCfg.toPrefs( abPrefs.node( newCfg.id ));
    collAudioBoxConfigs.set( idx, newCfg );
  }
View Full Code Here

    final JComboBox        ggComboAdd, ggComboActivate, ggComboRemove;
    final int          result;
    JScrollPane          ggScroll;
//    JSeparator          ggSep;
    int              row, action;
    AudioBoxConfig        cfg;
   
    final List          collDetected    = Collections.synchronizedList( new ArrayList() );
    final List           collAdd        = new ArrayList();
    final List           collActivate    = new ArrayList();
    final List           collRemove      = new ArrayList();
   
    // this doesn't show up obivously, so we add it manually...
    collDetected.add( new AudioBoxConfig( AudioBoxConfig.ID_DEFAULT, "Default", 8, 8, true ));
   
    scsynthPath = audioPrefs.get( PrefsUtil.KEY_SUPERCOLLIDERAPP, null );
    if( scsynthPath == null ) {
      System.err.println( getResourceString( "errSCSynthAppNotFound" ));
      return;
    }
   
    pane = new JPanel( new BorderLayout() );
//pane.setBackground( Color.white );
    ggSpinner = new IndeterminateSpinner( 24 );
    b = Box.createHorizontalBox();
//    pane.gridAdd( ggSpinner, 0, 0 );
    b.add( ggSpinner );
    b.add( Box.createHorizontalStrut( 4 ));
    ggLabel = new JLabel( "Searching for Audio Devices..." );
//    ggLabel.setBorder( BorderFactory.createEmptyBorder( 0, 4, 0, 0 ));
//    pane.gridAdd( ggLabel, 1, 0 );
    b.add( ggLabel );
    pane.add( b, BorderLayout.NORTH );
   
    pane2 = new SpringPanel( 0, 0, 4, 2 );
    row = 0;
    ggListAdd = new JList();
    ggScroll = new JScrollPane( ggListAdd );
    pane2.gridAdd( new JLabel( "Detected new devices:" ), 0, row++, 2, 1 );
    pane2.gridAdd( ggScroll, 0, row++, 2, 1 );
    pane2.gridAdd( new JLabel( "Action:", RIGHT ), 0, row );
    ggComboAdd = new JComboBox( new Object[] { "Ignore", "Add to list" });
    pane2.gridAdd( ggComboAdd, 1, row++ );
    pane2.gridAdd( createVSep(), 0, row++, 2, 1 );

    ggListActivate = new JList();
    ggScroll = new JScrollPane( ggListActivate );
    pane2.gridAdd( new JLabel( "Detected deactivated devices:" ), 0, row++, 2, 1 );
    pane2.gridAdd( ggScroll, 0, row++, 2, 1 );
    pane2.gridAdd( new JLabel( "Action:", RIGHT ), 0, row );
    ggComboActivate = new JComboBox( new Object[] { "Ignore", "Make active" });
    pane2.gridAdd( ggComboActivate, 1, row++ );
    pane2.gridAdd( createVSep(), 0, row++, 2, 1 );

//    ggSep  = new JSeparator();
//    ggSep.setBorder( BorderFactory.createEmptyBorder( 8, 0, 8, 0 ));
//    pane2.gridAdd( ggSep, 0, row++, 2, 1 );
    ggListRemove = new JList();
    ggScroll = new JScrollPane( ggListRemove );
    pane2.gridAdd( new JLabel( "Devices not found:" ), 0, row++, 2, 1 );
    pane2.gridAdd( ggScroll, 0, row++, 2, 1 );
    pane2.gridAdd( new JLabel( "Action:", RIGHT ), 0, row );
    ggComboRemove = new JComboBox( new Object[] { "Ignore", "Make inactive", "Remove from list" });   
    pane2.gridAdd( ggComboRemove, 1, row++ );
    pane2.setVisible( false );
    pane.add( pane2, BorderLayout.CENTER );
    AbstractWindowHandler.setDeepFont( pane );
   
//    op = new JOptionPane( pane, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION,
//        new ImageIcon( GUIUtil.class.getResource( "assistent_64x64.png" )));
//    dlg = op.createDialog( getWindow(), getResourceString( "prefsAudioDevicesAssistent" ) );

    runResult = new Runnable() {
      public void run()
      {
//        String      name;
        AudioBoxConfig  cfg3, cfg2;

        for( Iterator iter = collDetected.iterator(); iter.hasNext(); ) {
          cfg2 = (AudioBoxConfig) iter.next();
          if( !setAudioBoxNames.contains( cfg2.name )) {
            collAdd.add( cfg2 );
          } else {
            cfg3 = boxForName( cfg2.name );
            if( (cfg3 != null) && !cfg3.active ) collActivate.add( cfg3 );
          }
        }
iterRemove:    for( Iterator iter = collAudioBoxConfigs.iterator(); iter.hasNext(); ) {
          cfg3 = (AudioBoxConfig) iter.next();
          for( Iterator iter2 = collDetected.iterator(); iter2.hasNext(); ) {
            cfg2 = (AudioBoxConfig) iter2.next();
            if( cfg2.name.equals( cfg3.name )) continue iterRemove;
          }
          collRemove.add( cfg3 );
        }
       
        Collections.sort( collAdd );
        Collections.sort( collActivate );
        Collections.sort( collRemove );
       
        ggListAdd.setListData( collAdd.toArray() );
        ggListAdd.setVisibleRowCount( Math.max( 1, Math.min( collAdd.size(), 6 )));
        if( collAdd.isEmpty() ) {
          ggComboAdd.setEnabled( false );
        } else {
          ggComboAdd.setSelectedIndex( 1 );
        }
        ggListActivate.setListData( collActivate.toArray() );
        ggListActivate.setVisibleRowCount( Math.max( 1, Math.min( collActivate.size(), 6 )));
        ggListAdd.setVisibleRowCount( Math.max( 1, Math.min( collAdd.size(), 6 )));
        if( collActivate.isEmpty() ) {
          ggComboActivate.setEnabled( false );
        } else {
          ggComboActivate.setSelectedIndex( 1 );
        }
        ggListRemove.setListData( collRemove.toArray() );
        ggListRemove.setVisibleRowCount( Math.max( 1, Math.min( collRemove.size(), 6 )));
        if( collRemove.isEmpty() ) {
          ggComboRemove.setEnabled( false );
        } else {
          ggComboRemove.setSelectedIndex( 1 );
        }
        pane2.makeCompactGrid();
        b.setVisible( false );
        pane2.setVisible( true );
//        pane.makeCompactGrid();
       
//        dlg.pack();
        ((JDialog) SwingUtilities.getAncestorOfClass( JDialog.class, pane2 )).pack();
      }
    };
   
    testThread = new Thread( new Runnable() {
      public void run()
      {
        final InputStream      inStream; // , errStream;
 
        final byte[]        inBuf    = new byte[128];
//        final byte[]        errBuf    = new byte[128];
        final File          cwd      = new File( scsynthPath ).getParentFile();
        final ByteArrayOutputStream  baos    = new ByteArrayOutputStream();
        final Pattern        ptrn1    = Pattern.compile( "Number of Devices: \\d+\\n(   \\d+ : \".+\" \\(\\d+ ins, \\d+ outs\\)\\n)+\\n" );
//        final Pattern        ptrn2    = Pattern.compile( "\".+\"" );
        final Pattern        ptrn2    = Pattern.compile( "\"(.+)\" \\((\\d+) ins, (\\d+) outs()" ); // the trailing () makes the numOuts not disappear (why?!)
        final Matcher        m1      = ptrn1.matcher( "" );
        Matcher            m2;
        String            name;
        Process            p      = null;
        int              len, ins, outs; // , resultCode    = -1;
        boolean            pRunning  = true;

        try {
          p      = Runtime.getRuntime().exec( new String[] { scsynthPath, "-u", "0" }, null, cwd );
          // "Implementation note: It is a good idea for the input stream to be buffered."
          inStream  = new BufferedInputStream( p.getInputStream() );
//          errStream  = new BufferedInputStream( p.getErrorStream() );
 
          while( keepThreadRunning.isSet() && pRunning ) {
            try {
              Thread.sleep( 250 );   // a kind of cheesy way to wait for the program to end
            }
            catch( InterruptedException e5 ) { /* ignore */ }
 
            if( inStream.available() > 0 ) {
              try {
                while( inStream.available() > 0 ) {
                  len = Math.min( inBuf.length, inStream.available() );
                  inStream.read( inBuf, 0, len );
                  baos.write( inBuf, 0, len );
                }
              }
              catch( IOException e1 ) { /* ignore for now XXX */ }
             
              m1.reset( baos.toString() );
              if( m1.find() ) {
                pRunning = false;
//                keepThreadRunning.set( false );
                m2 = ptrn2.matcher( m1.group() );
                while( m2.find() ) {
//                  s = m2.group();
//                  System.out.println( "'" + s.substring( 1, s.length() - 1 ) + "'" );
//                  collDetected.add( s.substring( 1, s.length() - 1 ));
                  if( m2.groupCount() == 4 ) {
                    name  = m2.group( 1 );
                    ins    = Integer.parseInt( m2.group( 2 ));
                    outs  = Integer.parseInt( m2.group( 3 ));
                    if( (ins > 0) && (outs > 0) ) { // filter out single direction devices (like mac os x built-in mic and output)
                      collDetected.add( new AudioBoxConfig(
                          null, name, ins, outs, true ));
                    }
                  }
                }
              }
View Full Code Here

    return b;
  }
 
  protected AudioBoxConfig boxForName( String name )
  {
    AudioBoxConfig cfg;
//System.err.println( "box for name '" + name + "'" );
    for( Iterator iter = collAudioBoxConfigs.iterator(); iter.hasNext(); ) {
      cfg = (AudioBoxConfig) iter.next();
      if( cfg.name.equals( name )) return cfg;
    }
View Full Code Here

    String name = test;
    for( int i = 1; setAudioBoxNames.contains( name ); i++ ) {
      name = test + " " + i;
    }
   
    return new AudioBoxConfig( createUniqueAudioBoxID(), name );
  }
View Full Code Here

    collAudioBoxConfigs.clear();
    setAudioBoxIDs.clear();
    setAudioBoxNames.clear();
   
    final String[]    arrayNames;
    AudioBoxConfig    cfg;
    Preferences      cfgPrefs;

    try {
      arrayNames = abPrefs.childrenNames();
    }
    catch( BackingStoreException e1 ) {
      BasicWindowHandler.showErrorDialog( getWindow(), e1, getResourceString( "errLoadPrefs" ));
      return;
    }
     
    for( int i = 0; i < arrayNames.length; i++ ) {
      cfgPrefs  = abPrefs.node( arrayNames[ i ]);
      try {
        cfg    = new AudioBoxConfig( cfgPrefs );
        collAudioBoxConfigs.add( cfg );
        setAudioBoxIDs.add( arrayNames[ i ]);
        setAudioBoxNames.add( cfg.name );
      }
      catch( NumberFormatException e1 ) {
View Full Code Here

   
    public Object getValueAt( int row, int col )
    {
      if( row > collAudioBoxConfigs.size() ) return null;
     
      final AudioBoxConfig c = (AudioBoxConfig) collAudioBoxConfigs.get( row );
   
      switch( col ) {
      case 0:
        return c.name;
      case 1:
View Full Code Here

TOP

Related Classes of de.sciss.eisenkraut.io.AudioBoxConfig

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.