コード例 #1
0
ファイル: main.cpp プロジェクト: jhakonen/wot-teamspeak-mod
void pluginInit( QObject *parent )
{
	auto teamSpeakPlugin = Driver::TeamSpeakPlugin::singleton();

	Log::setSink( teamSpeakPlugin );
	// for debugging purposes
	// Log::setSink( new Log::FileLogger( "C:/temp/tessumod_plugin.log" ) );
	Log::logQtMessages();

	QString dataPath = teamSpeakPlugin->getPluginDataPath();
	QString dataPathNative = QDir::toNativeSeparators( dataPath );
	dllSearchCookie = AddDllDirectory( (wchar_t*)dataPathNative.utf16() );

	auto iniSettingsFile = new Driver::IniSettingsFile( parent );
	auto openALBackend = new Driver::OpenALBackend( dataPath, parent );
	auto openALBackendTest = new Driver::OpenALBackend( dataPath, parent );
	auto openALConfFile = new Driver::OpenALConfFile( dataPath, parent );
	auto wotConnector = new Driver::WotConnector( parent );

	auto userStorage = new Storage::UserStorage( parent );
	auto cameraStorage = new Storage::CameraStorage( parent );
	auto adapterStorage = new Storage::AdapterStorage( parent );
	auto settingsStorage = new Storage::SettingsStorage( iniSettingsFile, parent );

	auto useCaseFactory = new UseCase::UseCaseFactory( parent );
	useCaseFactory->userStorage = userStorage;
	useCaseFactory->cameraStorage = cameraStorage;
	useCaseFactory->settingsStorage = settingsStorage;
	useCaseFactory->adapterStorage = adapterStorage;

	adapterStorage->setAudio( Entity::BuiltInBackend, new Adapter::AudioAdapter( teamSpeakPlugin->createAudioBackend(), dataPath, parent ) );
	adapterStorage->setAudio( Entity::OpenALBackend, new Adapter::AudioAdapter( openALBackend, dataPath, parent ) );
	adapterStorage->setTestAudio( Entity::BuiltInBackend, new Adapter::AudioAdapter( teamSpeakPlugin->createAudioBackend(), dataPath, parent ) );
	adapterStorage->setTestAudio( Entity::OpenALBackend, new Adapter::AudioAdapter( openALBackendTest, dataPath, parent ) );
	adapterStorage->setVoiceChat( new Adapter::VoiceChatAdapter( teamSpeakPlugin, useCaseFactory, parent ) );
	adapterStorage->setGameData( new Adapter::GameDataAdapter( wotConnector, useCaseFactory, parent ) );
	adapterStorage->setUi( new Adapter::UiAdapter( useCaseFactory, openALConfFile, parent ) );

	teamSpeakPlugin->setAudioSink( openALBackend );

	QTimer *setupTimer = new QTimer( parent );
	setupTimer->setSingleShot( true );
	setupTimer->setInterval( 0 );
	setupTimer->start();

	QObject::connect( setupTimer, &QTimer::timeout, [=] {
		teamSpeakPlugin->initialize();
		wotConnector->initialize();
		useCaseFactory->applicationInitialize();
		openALConfFile->start();
	} );
}
コード例 #2
0
ファイル: MainPanel.cpp プロジェクト: EQ4/DSPFiltersDemo
void MainPanel::comboBoxChanged (ComboBox* ctrl)
{
  if (ctrl == m_menuFamily)
  {
    buildTypeMenu (m_menuType);

    // try to map the previous type to this one via menu item id
    int id = 1;
    if (m_lastTypeId != 0)
    {
      // does a corresponding type exist enabled in the new menu?
      if (m_menuType->indexOfItemId (m_lastTypeId) != -1 )
      {
        id = m_lastTypeId;
      }
    }
    m_menuType->setSelectedId (id);
  }
  else if (ctrl == m_menuType)
  {
    m_lastTypeId = m_menuType->getSelectedId();

    createFilter ();
  }
  else if (ctrl == m_menuStateType )
  {
    createFilter ();
  }
  else if (ctrl == m_menuSmoothing)
  {
    createFilter ();
  }
  else if (ctrl == m_menuAudio)
  {
    setAudio (ctrl->getSelectedId());
  }
}
コード例 #3
0
int selectAudio()
{
  int top = 0, current = 0; /***** selection menu related variables */
  int max_view = 9;

  int retval = 0;           /***** return value */

  int request_finish = 0;   /***** leave current dialog, if request_finish is set to 1 */

  int width = 45, height = 15, i, j;               /***** ncurses related variables */
  WINDOW *audioscr = popupWindow (width, height);

  while (!request_finish)
  {
    wattrset (audioscr, color_term ? COLOR_PAIR(2) | A_BOLD : A_NORMAL); /***** set bg color of the dialog */

    /*****
     * draw a box around the dialog window
     * and empty it.
     *****/
    werase (audioscr);
    box (audioscr, 0, 0);
    for (i = 1; i < width-1; i++)
      for (j = 1; j < height-1; j++)
	mvwaddch(audioscr, j, i, ' ');

    /***** dialog header */

    mvwaddstr(audioscr, 1, 2, "Select Audio Device:");
    mvwaddseparator(audioscr, 2, width);

    /***** selection area */

    for (i = 0; i < MIN2(audio_devices->count, max_view); i++)
    {
      setHighlight(audioscr, ok, i == current);
      mvwaddstr(audioscr, 4+i, 4, "/dev/");
      waddstr(audioscr, audio_devices->name[top+i]);
    }
    wattroff(audioscr, A_REVERSE);

    /*****
     * show up/down arrow to the left, if more items are available
     * than can be displayed
     *****/
    if (top > 0)
    {
      mvwaddch(audioscr,4, 2, ACS_UARROW);
      mvwaddch(audioscr,4+1, 2, ACS_VLINE);
    }
    if (audio_devices->count > max_view && top+max_view <= audio_devices->count-1)
    {
      mvwaddch(audioscr,4+max_view-2, 2, ACS_VLINE);
      mvwaddch(audioscr,4+max_view-1, 2, ACS_DARROW);
    }

    wmove(audioscr, 1, 23);  /***** set cursor to an appropriate location */
    wrefresh (audioscr);     /***** refresh the dialog */

    /* process the command keystroke */

    switch(getch())
    {
    case KEY_UP:   /***** cursor up */
      if (current > 0)
	current--;
      else
	top = (top > 0 ? top-1 : 0);
      break;
    case KEY_DOWN: /***** cursor down */
      if (top+current < audio_devices->count-1)
      {
	if (current < max_view-1)
	 current++;
	else
	  top++;
      }
      break;
    case ESCAPE:   /***** Hit Escape to leave dialog */
      retval = AUDIO_ERR;
      request_finish = 1;
      break;
    case ENTER:   /***** make selection with Enter or Space bar */
    case BLANK:
      setAudio(audio_devices->name[top+current]); /***** set audio device to highlighted item */
      retval = initAudio();                       /***** retval is ok, if initAudio() returned ok */
      if (retval == AUDIO_ERR)
	noAudio();
      request_finish = 1;                         /***** leave dialog */
      break;
    }
  }

  delwin(audioscr);   /***** delete ncurses dialog window */
  return(retval);
}
コード例 #4
0
int main(int argc, char *argv[])
{
  /*****
   * boolean value indicates when to break main loop
   * (and thus finish this configuration tool)
   *****/
  int request_finish = 0;

  int current         = 0; /***** menu related variables */
  int menu_items      = 7;
  enum state status[] = {invalid, invalid, inactive, inactive, inactive, inactive, invalid};

  WINDOW *mainscr; /***** ncurses related variables */
  int i, j;

  /* ***** detect available mixer devices */

  mixer_devices = scanMixerDevices();
  if (mixer_devices == NULL || mixer_devices->count == 0)
  {
    /* ***** no mixer devices available -> exit! */

    fprintf(stderr, "No mixer devices available!\n");
    fprintf(stderr, "Please purchase a sound card and install it!\n");
    exit(-1);
  }
  else
  {
    if (mixer_devices->count == 1) /***** exactly one mixer device available */
    {
      setMixer(mixer_devices->name[0]); /***** set this mixer */

      if (initMixer() == MIXER_OK) /***** if mixer is ok, keep it */
      {
	status[0] = ok;
	status[2] = invalid;
      }
      else                         /***** otherwise, exit!*/
      {
	fprintf(stderr, "Couldn't init the only available mixer device: /dev/%s\n",
		mixer_devices->name[0]);
	exit(-1);
      }
    }
    else /* ***** more than one device available! */
    {
      /* ***** use /dev/mixer as default if it exists */

      for (i = 0; i < mixer_devices->count; i++)
      {
	if (strcmp(mixer_devices->name[i], "mixer") == 0)
	{
	  setMixer("mixer");
	  if (initMixer() == MIXER_OK)
	  {
	    status[0] = ok;
	    status[2] = invalid;
	  }
	  else
	    noMixer();
	
	  break;
	}
      }
    }
  }

  /* ***** detect available audio devices */

  audio_devices = scanAudioDevices();
  if (audio_devices == NULL || audio_devices->count == 0)
  {
    /* ***** no audio devices available! */

    fprintf(stderr, "No audio device available that\n");
    fprintf(stderr, "supports 16bit recording!\n");
    fprintf(stderr, "Please purchase a sound card and install it!\n");
    exit(-1);
  }
  else
  {
    if (audio_devices->count == 1) /***** exactly one audio device available */
    {
      setAudio(audio_devices->name[0]); /***** set this audio device */

      if (initAudio() == AUDIO_OK) /***** if audio device is ok, keep it */
      {
	status[1] = ok;
      }
      else                         /***** otherwise, exit!*/
      {
	fprintf(stderr, "Couldn't init the only available audio device: /dev/%s\n",
		audio_devices->name[0]);
	exit(-1);
      }
    }
    else /* ***** more than one device available! */
    {
      /* ***** use /dev/dspW as default if it exists */

      for (i = 0; i < audio_devices->count; i++)
      {
	if (strcmp(audio_devices->name[i], "dspW") == 0)
	{
	  setAudio("dspW");
	  if (initAudio() == AUDIO_OK)
	    status[1] = ok;
	  else
	    noAudio();
	
	  break;
	}
      }
    }
  }

  /*****
   * if mixer and audio device have been selected successfully,
   * set menu cursor to next available menu item
   *****/
  if (status[0] == ok && status[1] == ok)
    current = 2;

  /***** ignore Ctrl-C */

  signal(SIGINT, SIG_IGN);

  /* ***** ncurses stuff */

  initscr();      /* initialize the curses library */

  if (color_term != -1) /***** define dialog color pairs if terminal supports colors */
   {
      start_color ();
      if ((color_term = has_colors ()))
      {
         color_term = 1;
         init_pair (1, COLOR_WHITE, COLOR_BLUE);
         init_pair (2, COLOR_YELLOW, COLOR_BLUE);
         init_pair (3, COLOR_BLUE, COLOR_YELLOW);
         init_pair (4, COLOR_YELLOW, COLOR_CYAN);
      }
   }
   else
      color_term = 0;

  keypad(stdscr, TRUE);  /* enable keyboard mapping */
  scrollok (stdscr, FALSE);
  cbreak();              /* take input chars one at a time, no wait for \n */
  noecho();              /* don't echo input */
  refresh();

  mainscr = popupWindow(COLS, LINES); /***** dialog window that contains the main menu */
  leaveok (mainscr, FALSE);

  while (!request_finish)
  {
    wattrset (mainscr, color_term ? COLOR_PAIR(2) | A_BOLD : A_NORMAL); /***** set bg color of the dialog */

    /*****
     * draw a box around the dialog window
     * and empty it.
     *****/
    box(mainscr, 0, 0);
    for (i = 1; i < COLS-1; i++)
      for (j = 1; j < LINES-1; j++)
	mvwaddch(mainscr, j, i, ' ');

    /***** dialog header */

    mvwaddstr(mainscr, 1, 2, "CVoiceControl");
    mvwaddstr(mainscr, 1, COLS - strlen("(c) 2000 Daniel Kiecza") - 2, "(c) 2000 Daniel Kiecza");
    mvwaddseparator(mainscr, 2, COLS);

    mvwaddstr(mainscr, 3, (COLS / 2) - (strlen ("Recording Device Configuration Tool") / 2),
	      "Recording Device Configuration Tool");
    mvwaddseparator(mainscr, 4, COLS);

    /***** main menu */

    mvwaddstr(mainscr, 5, 2, "Please Select:");

    setHighlight(mainscr, status[0], current == 0);
    mvwaddstr(mainscr, 7,5,"Select Mixer Device");
    if (mixerOK() == MIXER_OK)
    {
      mvwaddstr(mainscr, 7,24," ("); waddstr(mainscr, getMixer()); waddstr(mainscr, ")");
    }
    else
      mvwaddstr(mainscr, 7,24," (none selected!)");

    setHighlight(mainscr, status[1], current == 1);
    mvwaddstr(mainscr, 8,5,"Select Audio Device");
    if (audioOK() == AUDIO_OK)
    {
      mvwaddstr(mainscr, 8,24," ("); waddstr(mainscr, getAudio()); waddstr(mainscr, ")");
    }
    else
      mvwaddstr(mainscr, 8,24," (none selected!)");

    setHighlight(mainscr, status[2], current == 2);
    mvwaddstr(mainscr,  9,5,"Adjust Mixer Levels");
    setHighlight(mainscr, status[3], current == 3);
    mvwaddstr(mainscr, 10,5,"Calculate Recording Thresholds");
    setHighlight(mainscr, status[4], current == 4);
    mvwaddstr(mainscr, 11,5,"Estimate Characteristics of Recording Channel");
    setHighlight(mainscr, status[5], current == 5);
    mvwaddstr(mainscr, 12,5,"Write Configuration");
    setHighlight(mainscr, status[6], current == 6);
    mvwaddstr(mainscr, 13,5,"Exit");

    wmove(mainscr, 5, 17);  /***** set cursor to an appropriate location */
    wrefresh(mainscr);     /***** refresh the dialog */

    /* process the command keystroke */

    switch(getch())
    {
    case KEY_UP:   /***** cursor up */
      current = (current == 0 ? menu_items - 1 : current - 1);
      while(status[current] == inactive)
	current = (current == 0 ? menu_items - 1 : current - 1);
      break;
    case KEY_DOWN: /***** cursor down */
      current = (current == menu_items-1 ? 0 : current + 1);
      while(status[current] == inactive)
	current = (current == menu_items-1 ? 0 : current + 1);
      break;
    case ENTER:    /***** handle menu selections */
    case BLANK:
      switch (current)
      {
      case 0: /***** select mixer device */
	status[0] = invalid;
	status[2] = inactive;
	status[3] = inactive;
	status[4] = inactive;
	status[5] = inactive;
	noMixer();
	if (selectMixer() == MIXER_OK)
	{
	  status[0] = ok;
	  status[2] = invalid;
	}
	break;
      case 1: /***** select audio device */
	status[1] = invalid;
	status[3] = inactive;
	status[4] = inactive;
	status[5] = inactive;
	noAudio();
	if (selectAudio() == AUDIO_OK)
	  status[1] = ok;
	break;
      case 2: /***** adjust mixer levels */
	if (adjustMixerLevels())
	{
	  status[2] = ok;
	  status[3] = invalid;
	  status[4] = invalid;
	}
	break;
      case 3: /***** calculate recording thresholds */
	if (calculateThresholds())
	  status[3] = ok;
	else
	  status[3] = invalid;
	break;
      case 4: /***** estimate the characteristics of the recording channel */
	if (estimateChannelMean())
	  status[4] = ok;
	else
	  status[4] = invalid;
	break;
      case 5: /***** save configuration! */
	if (saveConfiguration())
	{
	  status[5] = ok;
	  status[6] = ok;
	}
	break;
      case 6: /***** leave program */
	if (status[6] == ok  ||  (status[6] != ok && safeExit()))
	{
	  wrefresh(mainscr);     /***** refresh the dialog */
  	  request_finish = 1;
	  delwin(mainscr);   /***** delete ncurses dialog window */
	 }
	break;
      }
      break;
    }

    /***** if the configuration is done, activate the menu item "Save Configuration" */

    if (status[0] != ok || status[1] != ok ||
	status[2] != ok || status[3] != ok ||
	status[4] != ok)
      status[5] = inactive;
    else if (status[5] != ok)
      status[5] = invalid;
  }

  endwin();               /* we're done */

  /***** free memory used by the list of mixer and audio devices */

  if (mixer_devices != NULL)
  {
    for (i = 0; i < mixer_devices->count; i++)
      free(mixer_devices->name[i]);
    free(mixer_devices->name);
    free(mixer_devices);
  }

  if (audio_devices != NULL)
  {
    for (i = 0; i < audio_devices->count; i++)
      free(audio_devices->name[i]);
    free(audio_devices->name);
    free(audio_devices);
  }

  exit(0);
}
コード例 #5
0
ファイル: mythread.cpp プロジェクト: sscanf/rasp-atvrepeater
void mythread ::run()
{
    bool bSended=false;
    //Ponemos todos los bits de los reles como salidas
    for (int n=0;n<m_bReles.count();n++)
        m_gpio.setOutput(m_bReles[n]);

    QSettings settings("/mnt/config/carta.ini",QSettings::IniFormat);
    setAllReles (settings.value ("reles/status").toInt());

//    for (int n=0;n<m_bReles.count();n++)
//        m_gpio.bitClear(m_bReles[n]);

    //Ponemos MOSI como salidas
    m_gpio.setOutput (MOSI);
    m_gpio.setInput  (MISO);
    m_gpio.setOutput (SCLK);
    m_gpio.setOutput (CS);

    m_gpio.setInput (STROBE);
    m_gpio.setInput(TONE_B3);
    m_gpio.setInput(TONE_B2);
    m_gpio.setInput(TONE_B1);
    m_gpio.setInput(TONE_B0);
    m_gpio.setInput(SIGNAL_IN);

    m_gpio.bitSet (MOSI);
    m_gpio.bitSet (SCLK);
    m_gpio.bitClear (CS);
    msleep(1);
    m_gpio.bitSet (CS);

    setAudio(true);

    float   sample=0;
    float   temp;
    int     msecs=1;

    quint8  antTone=0;

    while (1)
    {
        if (m_gpio.bitValue (STROBE))
        {
            quint8 tTone = getTone();

            if (antTone != tTone)
            {
                emit tone(tTone);
                antTone=tTone;
            }
        }
        else
        {
            antTone=0;
            if (--msecs == 0)
            {
                msecs=1;
                temp=0;
                //Leemos la temperatura
                for (int n=0;n<10;n++)
                {
                    sample = getSample (channel0);
                    temp += (((sample)*165)/819)-55;
                }
                emit temperature(temp/10);

                temp=0;
                for (int n=0;n<10;n++)
                {
                    sample= getSample (channel1);
                    temp += (((sample)*2)/819);
                }
                emit wats(temp/10);
            }
        }

        m_bSignalIn = m_gpio.bitValue(SIGNAL_IN);

        if (m_bSignalIn && bSended==false)
        {
            emit signalIn (true);
            bSended=true;
        }

        if (!m_bSignalIn && bSended==true)
        {
            emit signalIn (false);
            bSended=false;
        }
        msleep(100);
    }
}