Example #1
0
CSoundGen::CSoundGen() :
    m_pAPU(NULL),
    m_pSampleMem(NULL),
    m_pDSound(NULL),
    m_pDSoundChannel(NULL),
    m_pAccumBuffer(NULL),
    m_iGraphBuffer(NULL),
    m_pDocument(NULL),
    m_pTrackerView(NULL),
    m_bRendering(false),
    m_bPlaying(false),
    m_pPreviewSample(NULL),
    m_pSampleWnd(NULL),
    m_iSpeed(0),
    m_iTempo(0),
    m_bPlayerHalted(false),
    m_bWaveChanged(false),
    m_iMachineType(NTSC)
{
    pThread = new QThread();

    QObject::connect(this,SIGNAL(postThreadMessage(unsigned int,unsigned int,unsigned int)),this,SLOT(recvThreadMessage(unsigned int,unsigned int,unsigned int)));

    QTimer* timer = new QTimer();
    connect(timer, SIGNAL(timeout()), this, SLOT(onIdleSlot()));
    timer->start();

    pThread->start(/*QThread::TimeCriticalPriority*/);

    // DPCM sample interface
    m_pSampleMem = new CSampleMem();

    // Create APU
    m_pAPU = new CAPU(this, m_pSampleMem);

    m_pAPU->moveToThread(pThread);

//	m_pSoundSemaphore = new CSemaphore(0, 1);

    // Create all kinds of channels
    CreateChannels();

    m_pAPU->SetNamcoMixing(theApp.GetSettings()->m_bNamcoMixing);
}
Example #2
0
MainWindow::MainWindow(QWidget *parent) :
   QMainWindow(parent),
   ui(new Ui::MainWindow)
{
   QSettings settings(QSettings::IniFormat, QSettings::UserScope, "CSPSoftware", "FamiPlayer");
   
   // Randomizeme!
   srand(QDateTime::currentDateTime().toTime_t());
   
   ui->setupUi(this);
   
   m_pTimer = new QTimer;
   m_pSettleTimer = new QTimer;
   
   // Initialize the app...
   backgroundifyFamiTracker("FamiPlayer");
   qtMfcInit(this);
   theApp.InitInstance();
   
   ui->paths->setDuplicatesEnabled(false);
      
   ui->indicators->layout()->addWidget(AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_STATUS_BAR)->GetDlgItem(ID_INDICATOR_TIME)->toQWidget());

   m_bChangeSong = false;
   m_bPlaying = false;
   m_bDraggingPosition = false;
         
   // Enable grabbing the slider while playing.
   ui->position->installEventFilter(this);
   
   // Create play-time widget...from MFC stuff.
   m_pWndMFC = new CWndMFC();   
   m_pWndMFC->Create(0,AfxGetMainWnd());
   QRect qrect = QRect(0,0,132,21);
   m_pWndMFC->setFixedSize(qrect.width(),qrect.height());
//       EDITTEXT        IDC_SECONDS,53,37,44,12,ES_AUTOHSCROLL
   CRect r9(0,0,qrect.width()/2,qrect.height());
   CEdit* mfc9 = new CEdit(m_pWndMFC);
   mfc9->Create(ES_AUTOHSCROLL | WS_VISIBLE,r9,m_pWndMFC,IDC_SECONDS);
   mfc9->toQWidget()->setToolTip("Seconds to Play");
   m_pWndMFC->mfcToQtWidgetMap()->insert(IDC_SECONDS,mfc9);
//       CONTROL         "",IDC_SPIN_TIME,"msctls_updown32",UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,93,36,11,14
   CSpinButtonCtrl* mfc10 = new CSpinButtonCtrl(m_pWndMFC);
   CRect r10(CPoint(0,0),CSize(16,14));
   mfc10->Create(UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_VISIBLE,r10,m_pWndMFC,IDC_SPIN_TIME);   
   mfc10->toQWidget()->setToolTip("Seconds to Play");
   m_pWndMFC->mfcToQtWidgetMap()->insert(IDC_SPIN_TIME,mfc10);
   ui->playTime->layout()->addWidget(m_pWndMFC->toQWidget());
//       EDITTEXT        IDC_TIMES,73,19,36,12,ES_AUTOHSCROLL
   CEdit* mfc6 = new CEdit(m_pWndMFC);
   CRect r6((qrect.width()/2)+1,0,qrect.width(),qrect.height());
   mfc6->Create(ES_AUTOHSCROLL | WS_VISIBLE,r6,m_pWndMFC,IDC_TIMES);
   mfc6->toQWidget()->setToolTip("Loops to Play");
   m_pWndMFC->mfcToQtWidgetMap()->insert(IDC_TIMES,mfc6);
//       CONTROL         "",IDC_SPIN_LOOP,"msctls_updown32",UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,105,17,11,17
   CSpinButtonCtrl* mfc7 = new CSpinButtonCtrl(m_pWndMFC);
   CRect r7(CPoint((qrect.width()/2)+1,0),CSize(16,14));
   mfc7->Create(UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_VISIBLE,r7,m_pWndMFC,IDC_SPIN_LOOP);
   mfc7->toQWidget()->setToolTip("Loops to Play");
   m_pWndMFC->mfcToQtWidgetMap()->insert(IDC_SPIN_LOOP,mfc7);
   
   m_pWndMFC->OnInitDialog();
   
   ui->sampleWindow->installEventFilter(this);
   
   ui->current->completer()->setCompletionMode(QCompleter::PopupCompletion);
   QObject::connect(ui->current->lineEdit(),SIGNAL(returnPressed()),this,SLOT(current_returnPressed()));
   ui->current->setInsertPolicy(QComboBox::NoInsert);
   
   ui->visuals->setChecked(settings.value("Visuals",true).toBool());
   on_visuals_toggled(settings.value("Visuals",true).toBool());
   
   restoreGeometry(settings.value("WindowGeometry").toByteArray());
   restoreState(settings.value("WindowState").toByteArray());
   
   if ( settings.value("PlaylistFile").toString().isEmpty() )
   {
      updateUiFromINI(false);
   }
   else
   {
      updateUiFromPlaylist(false);
   }

   m_bTimeLimited = settings.value("TimeLimiting",true).toBool();   
   m_bLoopLimited = settings.value("LoopLimiting",true).toBool();
   ui->limit->setChecked(m_bTimeLimited || m_bLoopLimited);
   
   m_pLimitMenu = new QMenu;
   QAction* action = m_pLimitMenu->addAction("Time-limiting");
   action->setData(0);
   action->setCheckable(true);
   action = m_pLimitMenu->addAction("Loop-limiting");
   action->setData(1);
   action->setCheckable(true);
   ui->limit->setMenu(m_pLimitMenu);
   QObject::connect(m_pLimitMenu,SIGNAL(aboutToShow()),this,SLOT(limitMenu_aboutToShow()));
   QObject::connect(m_pLimitMenu,SIGNAL(triggered(QAction*)),this,SLOT(limitMenu_triggered(QAction*)));
   
   m_iCurrentShuffleIndex = 0;
   ui->shuffle->setChecked(settings.value("Shuffle",false).toBool());
   on_shuffle_toggled(settings.value("Shuffle",false).toBool());
   
   ui->repeat->setChecked(settings.value("Repeat",false).toBool());
   on_repeat_toggled(settings.value("Repeat",false).toBool());

   ui->playOnStart->setChecked(settings.value("PlayOnStart",false).toBool());
   if ( ui->playStop->isEnabled() && settings.value("PlayOnStart",false).toBool() )
   {
      on_playStop_clicked();
   }
   
   QObject::connect(m_pTimer,SIGNAL(timeout()),this,SLOT(onIdleSlot()));
   m_pTimer->start();
   
   QObject::connect(m_pSettleTimer,SIGNAL(timeout()),this,SLOT(settleTimer_timeout()));
   m_bCheck = true;
}
Example #3
0
void MainWindow::startSettleTimer()
{
   QObject::disconnect(m_pTimer,SIGNAL(timeout()),this,SLOT(onIdleSlot()));
   m_pSettleTimer->start(200);
}
Example #4
0
void MainWindow::settleTimer_timeout()
{
   QObject::connect(m_pTimer,SIGNAL(timeout()),this,SLOT(onIdleSlot()));
   m_pSettleTimer->stop();
}