Exemplo n.º 1
0
void RDHPIRecordStream::stop()
{
  if(debug) {
    printf("RDHPIRecordStream: received stop()\n");
  }
  if(is_ready|is_recording|is_paused) {
    HPI_InStreamStop(hpi_subsys,hpi_stream);
    tickClock();
    clock->stop();
    is_recording=false;
    is_paused=false;
    is_ready=false;
    if(pdata!=NULL) {
      delete pdata;
      pdata=NULL;
    }
    emit isStopped(true);
    emit stopped();
    emit stateChanged(card_number,stream_number,RDHPIRecordStream::Stopped);
    emit position(0);
    if(debug) {
      printf("RDHPIRecordStream: emitted isStopped(true)\n");
      printf("RDHPIRecordStream: emitted stopped()\n");
      printf("RDHPIRecordStream: emitted stateChanged(%d,%d,RDHPIRecordStream::Stopped)\n",card_number,stream_number);
      printf("RDHPIRecordStream: emitted position(0)\n");
    }
  }
}
Exemplo n.º 2
0
PlayStream::PlayStream(SoundCard *card,QWidget *parent,const char *name) 
  :QObject(parent,name),WaveFile()
{  
  sound_card=card;
  card_number=-1;
  stream_number=-1;
  is_open=false;
  playing=false;
  is_paused=false;
  repositioned=false;
  stopping=false;
  samples_skipped=0;
  play_length=0;
  play_speed=1000;
  pitch_can_vary=false;
  rate_can_vary=false;
  stream_state=PlayStream::Stopped;
  pdata=NULL;
  restart_transport=false;
  samples_pending=0;
  current_position=0;

  clock=new QTimer(this,"clock");
  connect(clock,SIGNAL(timeout()),this,SLOT(tickClock()));

  play_timer=new QTimer(this,"play_timer");
  connect(play_timer,SIGNAL(timeout()),this,SLOT(pause()));
}
Exemplo n.º 3
0
void RDHPIRecordStream::record()
{
  if(debug) {
    printf("RDHPIRecordStream: received record()\n");
  }
  if(!is_open) {
    return;
  }
  if(!is_ready) {
    recordReady();
  }
  record_started=false;
  HPI_InStreamReset(hpi_subsys,hpi_stream);
  HPI_InStreamStart(hpi_subsys,hpi_stream);
  is_recording=true;
  is_paused=false;
  emit isStopped(false);
  emit recording();
  emit stateChanged(card_number,stream_number,0);  // Recording
  if(debug) {
    printf("RDHPIRecordStream: emitted isStopped(false)\n");
    printf("RDHPIRecordStream: emitted recording()\n");
    printf("RDHPIRecordStream: emitted stateChanged(%d,%d,RDHPIRecordStream::Recording)\n",card_number,stream_number);
  }
  tickClock();
}
Exemplo n.º 4
0
void RDPushButton::Init()
{
  flash_timer=new QTimer();
  connect(flash_timer,SIGNAL(timeout()),this,SLOT(tickClock()));
  flash_state=true;
  flashing_enabled=false;
  off_palette=palette();
  flash_clock_source=RDPushButton::InternalClock;
  flash_period=RDPUSHBUTTON_DEFAULT_FLASH_PERIOD;
  setFlashColor(RDPUSHBUTTON_DEFAULT_FLASH_COLOR);
  button_id=-1;
}
Exemplo n.º 5
0
void tickHandler(void) {

	unsigned int localCounter;

	tickClock();
	YKEnterMutex();
	localCounter = ++YKTickCounter;
	YKExitMutex();

	printString("\nTick: ");
	printInt(localCounter);
	printNewLine();

}
Exemplo n.º 6
0
RDHPIPlayStream::RDHPIPlayStream(RDHPISoundCard *card,
			       QWidget *parent,const char *name) 
  :QObject(parent,name),RDWaveFile()
{  
  //  hpi_err_t hpi_err;
  int quan;
  uint16_t type[HPI_MAX_ADAPTERS];

  sound_card=card;
  card_number=-1;
  stream_number=-1;
  is_open=false;
  playing=false;
  is_paused=false;
  repositioned=false;
  stopping=false;
  samples_skipped=0;
  play_length=0;
  play_speed=1000;
  pitch_can_vary=false;
  rate_can_vary=false;
  stream_state=RDHPIPlayStream::Stopped;
  pdata=NULL;
  restart_transport=false;
  samples_pending=0;
  current_position=0;

  //
  // Get Adapter Indices
  //
#if HPI_VER < 0x00030600
  for(unsigned i=0;i<HPI_MAX_ADAPTERS;i++) {
    card_index[i]=i;
  }
#else
  LogHpi(HPI_SubSysGetNumAdapters(NULL,&quan));
  for(int i=0;i<quan;i++) {
    LogHpi(HPI_SubSysGetAdapter(NULL,i,card_index+i,type+i));
  }
#endif  // HPI_VER

  clock=new QTimer(this,"clock");
  connect(clock,SIGNAL(timeout()),this,SLOT(tickClock()));

  play_timer=new QTimer(this,"play_timer");
  connect(play_timer,SIGNAL(timeout()),this,SLOT(pause()));
}
Exemplo n.º 7
0
RDHPIRecordStream::RDHPIRecordStream(RDHPISoundCard *card,
			     QWidget *parent,const char *name) 
  :QObject(parent,name),RDWaveFile()
{ 
  if(getenv(DEBUG_VAR)==NULL) {
    debug=false;
  }
  else {
    debug=true;
    printf("RDHPIRecordStream: debugging enabled\n");
  }
  if(getenv(XRUN_VAR)==NULL) {
    xrun=false;
  }
  else {
    xrun=true;
    printf("RDHPIRecordStream: xrun notification enabled\n");
  }

  sound_card=card;

  card_number=-1;
  stream_number=-1;
  is_ready=false;
  is_recording=false;
  is_paused=false;
  stopping=false;
  record_started=false;
  record_length=0;
  is_open=false;
  pdata=NULL;

  clock=new QTimer(this,"clock");
  connect(clock,SIGNAL(timeout()),this,SLOT(tickClock()));

  length_timer=new QTimer(this,"length_timer");
  connect(length_timer,SIGNAL(timeout()),this,SLOT(pause()));
}
Exemplo n.º 8
0
boolean MD_MIDIFile::getNextEvent(void)
{
	uint16_t		ticks;

	// if we are paused we are paused!
	if (_paused) 
    return false;

	// sync start all the tracks if we need to
	if (!_syncAtStart)
	{
		synchTracks();
		_syncAtStart = true;
	}

	// check if enough time has passed for a MIDI tick
  if ((ticks = tickClock()) == 0)
		return false;	

  processEvents(ticks);
  
  return(true);
}
Exemplo n.º 9
0
void RDHPIRecordStream::pause()
{
  if(debug) {
    printf("RDHPIRecordStream: received pause()\n");
  }
  if(!is_recording) {
    return;
  }
  HPI_InStreamStop(hpi_subsys,hpi_stream);
  tickClock();
  HPI_InStreamGetInfoEx(hpi_subsys,hpi_stream,
			&state,&buffer_size,&data_recorded,
			&samples_recorded,&reserved);
  is_recording=false;
  is_paused=true;
  HPI_InStreamStart(hpi_subsys,hpi_stream);
  emit paused();
  emit stateChanged(card_number,stream_number,2);  // Paused
  if(debug) {
    printf("RDHPIRecordStream: emitted paused()\n");
    printf("RDHPIRecordStream: emitted stateChanged(%d,%d,RDHPIRecordStream::Paused)\n",card_number,stream_number);
  }
}
Exemplo n.º 10
0
void WallClock::flashButton(bool state)
{
  printf("flashButton()\n");
  flash_state=state;
  tickClock();
}
Exemplo n.º 11
0
MainWidget::MainWidget(QWidget *parent,const char *name)
  :QWidget(parent,name)
{
  QPixmap *pm;
  QPainter *pd;
  QPixmap *mainmap;

  //
  // Fix the Window Size
  //
#ifndef RESIZABLE
  setMinimumWidth(sizeHint().width());
  setMaximumWidth(sizeHint().width());
  setMinimumHeight(sizeHint().height());
  setMaximumHeight(sizeHint().height());
#endif  // RESIZABLE

  //
  // Load the command-line arguments
  //
  RDCmdSwitch *cmd=new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdpanel",
				   RDPANEL_USAGE);

  //
  // Generate Fonts
  //
  QFont button_font=QFont("Helvetica",16,QFont::Bold);
  button_font.setPixelSize(16);

  //
  // Create Icons
  //
  lib_rivendell_map=new QPixmap(rivendell_xpm);
  setIcon(*lib_rivendell_map);

  //
  // Ensure that system daemons are running
  //
  RDInitializeDaemons();

  //
  // Load Local Configs
  //
  panel_config=new RDConfig();
  panel_config->load();

  //
  // Open Database
  //
  panel_db=QSqlDatabase::addDatabase("QMYSQL3");
  if(!panel_db) {
    QMessageBox::warning(this,
	   "Can't Connect","Unable to connect to mySQL Server!",0,1,1);
    exit(0);
  }
  panel_db->setDatabaseName(panel_config->mysqlDbname());
  panel_db->setUserName(panel_config->mysqlUsername());
  panel_db->setPassword(panel_config->mysqlPassword());
  panel_db->setHostName(panel_config->mysqlHostname());
  if(!panel_db->open()) {
    QMessageBox::warning(this,
			 "Can't Connect","Unable to connect to mySQL Server!");
    panel_db->removeDatabase(panel_config->mysqlDbname());
    exit(0);
  }
  new RDDbHeartbeat(panel_config->mysqlHeartbeatInterval(),this);

  //
  // Master Clock Timer
  //
  panel_master_timer=new QTimer(this,"panel_master_timer");
  connect(panel_master_timer,SIGNAL(timeout()),this,SLOT(masterTimerData()));
  panel_master_timer->start(MASTER_TIMER_INTERVAL);

  //
  // CAE Connection
  //
  panel_cae=new RDCae(parent,name);
  panel_cae->connectHost("localhost",CAED_TCP_PORT,panel_config->password());

  //
  // Allocate Global Resources
  //
  rdstation_conf=new RDStation(panel_config->stationName());
  rdairplay_conf=new RDAirPlayConf(panel_config->stationName(),0,"RDPANEL");
  panel_skin_pixmap=new QPixmap(rdairplay_conf->skinPath());
  if(panel_skin_pixmap->isNull()||(panel_skin_pixmap->width()<1024)||
     (panel_skin_pixmap->height()<738)) {
    delete panel_skin_pixmap;
    panel_skin_pixmap=NULL;
  }
  else {
    setErasePixmap(*panel_skin_pixmap);
  }

  //
  // RIPC Connection
  //
  rdripc=new RDRipc(panel_config->stationName());
  connect(rdripc,SIGNAL(userChanged()),this,SLOT(userData()));
  connect(rdripc,SIGNAL(rmlReceived(RDMacro *)),
	  this,SLOT(rmlReceivedData(RDMacro *)));
//  rdripc->connectHost("localhost",RIPCD_TCP_PORT,panel_config->password());

  //
  // User
  //
  rduser=NULL;

  //
  // Meter Timer
  //
  QTimer *timer=new QTimer(this,"meter_timer");
  connect(timer,SIGNAL(timeout()),this,SLOT(meterData()));
  timer->start(METER_INTERVAL);

  //
  // Macro Player
  //
  panel_player=new RDEventPlayer(rdripc,this);

  //
  // Cart Picker
  //
  panel_cart_dialog=new RDCartDialog(&panel_filter,&panel_group,
				     rdairplay_conf->card(3),
				     rdairplay_conf->port(3),
				     0,0,panel_cae,rdripc,rdstation_conf,
				     rdstation_conf->editorPath(),
				     this,"panel_cart_dialog");

  //
  // Sound Panel Array
  //
  if (rdairplay_conf->panels(RDAirPlayConf::StationPanel) || 
      rdairplay_conf->panels(RDAirPlayConf::UserPanel)){
    int card=-1;
    panel_panel=
      new RDSoundPanel(RDPANEL_PANEL_BUTTON_COLUMNS,RDPANEL_PANEL_BUTTON_ROWS,
		       rdairplay_conf->panels(RDAirPlayConf::StationPanel),
		       rdairplay_conf->panels(RDAirPlayConf::UserPanel),
		       rdairplay_conf->flashPanel(),
		       rdairplay_conf->buttonLabelTemplate(),true,panel_player,
		       rdripc,panel_cae,rdstation_conf,panel_cart_dialog,
		       this,"panel_panel");
    panel_panel->setLogfile(panel_config->airplayLogname());
    panel_panel->setGeometry(10,10,panel_panel->sizeHint().width(),
			 panel_panel->sizeHint().height());
    if(panel_skin_pixmap!=NULL) {
      pm=new QPixmap(1024,738);
      pd=new QPainter(pm);
      pd->drawPixmap(-10,-10,*panel_skin_pixmap);
      pd->end();
      panel_panel->setErasePixmap(*pm);
      delete pd;
      delete pm;
    }
    panel_panel->setPauseEnabled(rdairplay_conf->panelPauseEnabled());
    panel_panel->setCard(0,rdairplay_conf->card(2));
    panel_panel->setPort(0,rdairplay_conf->port(2));
    panel_panel->setFocusPolicy(QWidget::NoFocus);
    if((card=rdairplay_conf->card(6))<0) {
      panel_panel->setCard(1,panel_panel->card(0));
      panel_panel->setPort(1,panel_panel->port(0));
    }
    else {
      panel_panel->setCard(1,card);
      panel_panel->setPort(1,rdairplay_conf->port(6));
    }
    if((card=rdairplay_conf->card(7))<0) {
      panel_panel->setCard(2,panel_panel->card(1));
      panel_panel->setPort(2,panel_panel->port(1));
    }
    else {
      panel_panel->setCard(2,card);
      panel_panel->setPort(2,rdairplay_conf->port(7));
    }
    if((card=rdairplay_conf->card(8))<0) {
      panel_panel->setCard(3,panel_panel->card(2));
      panel_panel->setPort(3,panel_panel->port(2));
    }
    else {
      panel_panel->setCard(3,card);
      panel_panel->setPort(3,rdairplay_conf->port(8));
    }
    if((card=rdairplay_conf->card(9))<0) {
      panel_panel->setCard(4,panel_panel->card(3));
      panel_panel->setPort(4,panel_panel->port(3));
    }
    else {
      panel_panel->setCard(4,card);
      panel_panel->setPort(4,rdairplay_conf->port(9));
    }

    //
    // Calculate Valid Ports for Reading Meter Data (No Duplicates)
    //
    for(int i=4;i>=0;i--) {
      meter_data_valid[i]=(panel_panel->card(i)>=0);
      for(int j=0;j<i;j++) {
	if((panel_panel->card(i)==panel_panel->card(j))&&
	   (panel_panel->port(i)==panel_panel->port(j))) {
	  meter_data_valid[i]=false;
	}
      }
    }

    panel_panel->
      setRmls(0,rdairplay_conf->startRml(2),rdairplay_conf->stopRml(2));
    panel_panel->
      setRmls(1,rdairplay_conf->startRml(6),rdairplay_conf->stopRml(6));
    panel_panel->
      setRmls(2,rdairplay_conf->startRml(7),rdairplay_conf->stopRml(7));
    panel_panel->
      setRmls(3,rdairplay_conf->startRml(8),rdairplay_conf->stopRml(8));
    panel_panel->
      setRmls(4,rdairplay_conf->startRml(9),rdairplay_conf->stopRml(9));
    panel_panel->setSvcName(rdairplay_conf->defaultSvc());
    connect(rdripc,SIGNAL(userChanged()),panel_panel,SLOT(changeUser()));
    connect(panel_master_timer,SIGNAL(timeout()),
	    panel_panel,SLOT(tickClock()));
  }

  //
  // Audio Meter
  //
  panel_stereo_meter=new RDStereoMeter(this,"panel_stereo_meter");
  panel_stereo_meter->
    setGeometry(40,
		sizeHint().height()-panel_stereo_meter->sizeHint().height()-7,
		panel_stereo_meter->sizeHint().width(),
		panel_stereo_meter->sizeHint().height());
  panel_stereo_meter->setMode(RDSegMeter::Peak);
  panel_stereo_meter->setFocusPolicy(QWidget::NoFocus);
  if(panel_config->useStreamMeters()) {
    panel_stereo_meter->hide();
  }

  rdripc->connectHost("localhost",RIPCD_TCP_PORT,panel_config->password());

  //
  // Signal Handlers
  //
  signal(SIGCHLD,SigHandler);
}
Exemplo n.º 12
0
void YKTickHandler(void) {

	tickClock();

}