Exemple #1
0
void tonePlayRTTTL(TONE_PLAYER* player, const prog_char str[]){
	toneDetach(player);			// Detach any call back handler
	toneStop(player);			// Stop any current note
	player->type.rtttl.start = str;
	player->type.rtttl.pos = str;
	player->type.rtttl.state = SKIP_NAME;
	nextNote(player);
}
Exemple #2
0
Local void lookahead(struct LOC_processLine *LINK)
{
  Char STR2[256];
  Char STR3[256];

  while (bind_left[(long)nextNote(LINK->voice)])
    sprintf(LINK->note + strlen(LINK->note), " %s",
	    processOther(STR2, getMusicWord(STR3, LINK->voice), LINK));
}
Exemple #3
0
void MusicPlayer::init() {

    recorder = new Recorder(10);
    timer = new QTimer(this);

    timer->setSingleShot(true);
    connect(timer, SIGNAL(timeout()), this, SLOT(nextNote()));

}
Exemple #4
0
void RTTTL::playAtEnd()
{
  // now begin note loop
  while(song[index])
  {
     nextNote();
  }
  noTone(tonePin);
}
Exemple #5
0
void RTTTL::playUntil(int lastNote)
{
  lastNote += index;
  // now begin note loop
  while((song[index]) && (index < lastNote))
  {
     nextNote();
  }
  noTone(tonePin);
}
Exemple #6
0
void Tuner::draw(double time)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	text.print(noteName(notes[currentNote]), 960 - 140, 540 - 16, 32);

	float level = d.rms();
	// scale to 0 .. 1
	level = (level - o.noiseRMS) / (o.signalRMS - o.noiseRMS); 

	d.analyze();
	float detectedFrequency = d.result();
	float cents = centDifference(detectedFrequency, targetFrequency);
	
	char textBuf[64];
	sprintf(textBuf, "%.0f", cents);
	text.print(textBuf, 960 - 100, 540 - 16, 32);
	sprintf(textBuf, "%.2f", level);
	text.print(textBuf, 960 - 400, 540 - 16, 32);
	
	glUseProgram(programId);
	glEnableVertexAttribArray(0);
	glBindBuffer(GL_ARRAY_BUFFER, vertexBufferId);

	drawBackground();

	glUniform3f(uniformTintId, level, level, level);
	// clamp to -50 .. +50
	float clamped = std::min(std::max(cents, -50.0f), 50.0f);
	// scale to -45° .. +45°
	float angle = clamped / 50 * PI / 4;
	gaugeVertices[2] = 960 + needleLength * cosf(angle);
	gaugeVertices[3] = gaugePositions[currentNote] + needleLength * sin(angle);
	glBufferData(GL_ARRAY_BUFFER, sizeof(float) * gaugeVertices.size(), gaugeVertices.data(), GL_STATIC_DRAW);
	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_LINES, 0, 2);
	glDisableVertexAttribArray(0);

	if (!hit && fabs(cents) < o.precisionCentDelta)
	{
		hit = true;
		hitStart = time;
	}
	if (hit && fabs(cents) > o.precisionCentDelta)
	{
		hit = false;
	}
	if (hit && time - hitStart > o.precisionHoldTime)
	{
		nextNote();
	}
}
Exemple #7
0
Tuner::Tuner(std::vector<int> tuning, bool returnToMenu):
	notes(tuning),
	currentNote(-1),
	text("../resources/textures/text_Inconsolata29.dds"),
	hit(false),
	returnToMenu(returnToMenu)
{
	float x = 700;
	float y = 540 + 0.5f * neckHeight;
	float w = 1000;
	float h = 2;
	size_t stringCount = tuning.size();
	float stringSpacing = neckHeight / (stringCount - 1);

	stringSprites.first = sprites.getCount();

	for (size_t id = 0; id < stringCount; id++)
	{
		gaugePositions.push_back(y);
		glm::vec3 tint(o.stringColors[3 * id],
				o.stringColors[3 * id + 1],
				o.stringColors[3 * id + 2]);
		sprites.add(
			x - h / 2,
			y,
			w,
			h,
			tint
		);
		y -= stringSpacing;
	}

	stringSprites.second = sprites.getCount();

	glGenVertexArrays(1, &vertexArrayId);
	glBindVertexArray(vertexArrayId);
	glGenBuffers(1, &vertexBufferId);
	glBindBuffer(GL_ARRAY_BUFFER, vertexBufferId);
	gaugeVertices.push_back(960);
	gaugeVertices.push_back(540);
	gaugeVertices.push_back(960 + needleLength);
	gaugeVertices.push_back(540);
	glBufferData(GL_ARRAY_BUFFER, sizeof(float) * gaugeVertices.size(), gaugeVertices.data(), GL_STATIC_DRAW);
	programId = loadShaders("../resources/shaders/gauge.vs",
		"../resources/shaders/gauge.fs");
	uniformTintId = glGetUniformLocation(programId, "tint");

	nextNote();
	o.load();
	a = new Audio(io, SAMPLE_RATE);
	a->start();
}
void XmTrackerPattern::getNote(uint16_t row, uint8_t channel, struct XmTrackerNote &note)
{
    if (!pattern.nRows) {
        LOG((LGPFX"Error: No pattern loaded, can't load notes!\n"));
        ASSERT(pattern.nRows);
        resetNote(note);
        return;
    }
    if (row >= pattern.nRows) {
        LOG((LGPFX"Error: Row %u is larger than pattern (%u rows)\n",
             row, pattern.nRows));
        ASSERT(row < pattern.nRows);
        resetNote(note);
        return;
    }
    if (channel >= song->nChannels) {
        LOG((LGPFX"Error: Channel %u is too large (song contains %u channels)\n",
             channel, song->nChannels));
        ASSERT(channel < song->nChannels);
        resetNote(note);
        return;
    }
    /* This is not an error condition, but can happen on an empty pattern.
     * Indicated by 64 rows, but no pData/dataSize.
     */
    if (!pattern.dataSize || !pattern.pData) {
        // TODO: test empty patterns
        LOG((LGPFX"Notice: Emitting empty note\n"));
        resetNote(note);
        return;
    }

    uint32_t noteIndex = row * song->nChannels + channel;

    if (noteIndex < noteOffset) {
        /* This happens on fxLoopPattern, but isn't terribly efficient.
         * Composers should avoid if reasonable (Workaround: more patterns).
         */
        if (row * song->nChannels + channel > 0)
            LOG((LGPFX"Notice: Had to seek(0) to get to note %u\n", row * song->nChannels + channel));
        offset = 0;
        noteOffset = 0;
    } else if (noteIndex > noteOffset) {
        /* This happens on fxPatternBreak, but isn't very efficient.
         * Composers should avoid if reasonable (Workaround: more patterns).
         */
        LOG((LGPFX"Notice: Reading past %u notes to get to target\n", row * song->nChannels + channel - noteOffset));
    }

    while(noteIndex >= noteOffset) nextNote(note);
}
Exemple #9
0
NotePadPlugin::NotePadPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID){
  QVBoxLayout *vlay = new QVBoxLayout();
  this->setLayout( new QVBoxLayout() );
    this->layout()->setContentsMargins(0,0,0,0);
    vlay->setContentsMargins(3,3,3,3);
    frame = new QFrame(this);
      frame->setObjectName("notepadbase");
      frame->setStyleSheet("QFrame#notepadbase{border-size: 1px; background: rgba(255,255,255,50); color: black;} QFrame{ border: none; border-radius: 3px; background: rgba(255,255,255,100); color: black;}");
    this->layout()->addWidget(frame);
    frame->setLayout(vlay);
   
  //Setup the title bar header buttons
  QHBoxLayout *hlay = new QHBoxLayout();
  next = new QToolButton(this);
    next->setAutoRaise(true);
  prev = new QToolButton(this);
    prev->setAutoRaise(true);
  add = new QToolButton(this);
    add->setAutoRaise(true);
  rem = new QToolButton(this);
    rem->setAutoRaise(true);
  label = new QLabel(this);
    label->setAlignment(Qt::AlignCenter);
    hlay->addWidget(prev);
    hlay->addWidget(next);
    hlay->addWidget(label);
    hlay->addWidget(add);
    hlay->addWidget(rem);
    vlay->addLayout(hlay);
	
  //Setup the main text widget
  edit = new QPlainTextEdit(this);
    edit->setReadOnly(false);
    vlay->addWidget(edit);
	
  //Now setup the initial values
  cnote = this->settings->value("currentNote", 1).toInt();
  maxnote = this->settings->value("availableNotes",1).toInt();
  this->setInitialSize(200,300);
  //Setup the button connections
  connect(next, SIGNAL(clicked()), this, SLOT(nextNote()) );
  connect(prev, SIGNAL(clicked()), this, SLOT(prevNote()) );
  connect(add, SIGNAL(clicked()), this, SLOT(newNote()) );
  connect(rem, SIGNAL(clicked()), this, SLOT(remNote()) );
  connect(edit, SIGNAL(textChanged()), this, SLOT(noteChanged()) );
  QTimer::singleShot(0,this, SLOT(loadIcons()) );
  QTimer::singleShot(0,this, SLOT(updateContents()) );
  
}
Exemple #10
0
Static void getMeterChange(voice_index voice, Char *new_meter)
{
  short pn1, pn2;
  Char w[256], new_command[256];

  if (nextNote(voice) != mword)
    return;
  getMusicWord(w, voice);
  getMeter(w, &meternum, &meterdenom, &pn1, &pn2);
  full_bar = meternum * (64 / meterdenom);
  /* CMO: process denominator value with function PMXmeterdenom */
  meterWord(new_command, meternum, PMXmeterdenom(meterdenom), pn1, pn2);
  if (*new_meter != '\0' && strcmp(new_meter, new_command))
    error3(voice, "The same meter change must appear in all voices");
  strcpy(new_meter, new_command);
}
Exemple #11
0
void MainWindow::createCentralWidget()
{
    mWebView = new EnView(this);
    mWebView->setContextMenuPolicy(Qt::NoContextMenu);
    if(isFirstRun)
        mWebView->setHtml(defaultPage(false));
    else
        mWebView->setHtml(defaultPage(true));

    connect(mWebView, SIGNAL(noteClicked(QString)), &mEnExport, SLOT(openNote(QString)));
    //connect(mWebView, SIGNAL(linkClicked(QUrl)), SLOT(openUrl(QUrl)));

    QPalette navigationPalette;
    navigationPalette.setColor(QPalette::Window, QColor(mBgColor));

    mToolBar = new QToolBar(this);
    addToolBar(Qt::TopToolBarArea, mToolBar);
    mToolBar->setBackgroundRole(QPalette::Window);
    mToolBar->setAutoFillBackground(true);
    mToolBar->setPalette(navigationPalette);
    mToolBar->setMovable(false);
    mToolBar->setIconSize(QSize(30, 30));

    //mPageNumberLabel = new QLabel("4 / 7", this);
    //mPageNumberLabel->setFont(QFont("Times", 18));

    QAction* settingsAction = new QAction(QIcon(":/images/gear2.png"), tr("Settings"), mToolBar);
    QAction* prevAction = new QAction(QIcon(":/images/prev.png"), tr("Prev"), mToolBar);
    QAction* nextAction = new QAction(QIcon(":/images/next.png"), tr("Next"), mToolBar);

    mToolBar->addAction(settingsAction);
    mToolBar->addAction(prevAction);
    mToolBar->addAction(nextAction);

    mNavigationLabel = new QLabel(mToolBar);
    mNavigationLabel->setFont(QFont("Times", 18));
    mToolBar->addWidget(mNavigationLabel);

    connect(settingsAction, SIGNAL(triggered()), SLOT(loadDialogSettings()));
    //connect(settingsAction, SIGNAL(triggered()), mDialog, SLOT(show()));
    connect(prevAction, SIGNAL(triggered()), SLOT(prevNote()));
    connect(nextAction, SIGNAL(triggered()), SLOT(nextNote()));

    setCentralWidget(mWebView);
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
	// open database connection
    db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("/Users/jdoud/dev/brainstorm.sqlite");
	if(!db.open())
	{
		qDebug() << db.lastError();
		qFatal("Failed to connect.");
	}

	// setup UI
    ui->setupUi(this);
	ui->toolBar->addWidget(ui->comboFonts);
	ui->toolBar->addWidget(ui->comboFontSizes);
	ui->toolBar->addWidget(ui->comboColors);

	// set text editor defaults
	ui->textNote->document()->setIndentWidth(20);
	ui->textNote->setTabStopWidth(20);
	ui->textNote->setTabChangesFocus(false);
	ui->actionIncrease_Indent->setShortcut(Qt::Key_Tab);
	ui->actionDecrease_Indent->setShortcut(Qt::Key_Backtab);

	// setup comboColors
	QPixmap pix(16, 16);
	pix.fill(Qt::white);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::black);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::red);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::blue);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::darkGreen);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::gray);
	ui->comboColors->addItem(pix, "");


	// create system tray icon
	createActions();
	createTrayIcon();

	// create models
    categoriesModel = new QSqlTableModel();
	categoriesModel->setTable("categories");
	categoriesModel->setSort(1, Qt::AscendingOrder);
	categoriesModel->select();
	ui->listCategories->setModel(categoriesModel);
	ui->listCategories->setModelColumn(1);

    notesModel = new QSqlTableModel();
	notesModel->setTable("notes");
	ui->listNotes->setModel(notesModel);
	ui->listNotes->setModelColumn(2);

    // set splitter size
    QList<int> sizes;
    sizes << 230 << 150;
    ui->splitterLists->setSizes(sizes);
    sizes.clear();
    sizes << 230 << 600;
    ui->splitterNote->setSizes(sizes);

    // connect File menu slots
    connect(ui->actionNew_Category, SIGNAL(triggered()), this, SLOT(newCategory()));
    connect(ui->actionRename_Category, SIGNAL(triggered()), this, SLOT(renameCategory()));
    connect(ui->actionDelete_Category, SIGNAL(triggered()), this, SLOT(deleteCategory()));
    connect(ui->actionNew_Note, SIGNAL(triggered()), this, SLOT(newNote()));
    connect(ui->actionRename_Note, SIGNAL(triggered()), this, SLOT(renameNote()));
    connect(ui->actionSave_Note, SIGNAL(triggered()), this, SLOT(saveNote()));
    connect(ui->actionDelete_Note, SIGNAL(triggered()), this, SLOT(deleteNote()));
    connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(quit()));
    // connect Edit menu slots	
    connect(ui->actionFind_Replace, SIGNAL(triggered()), this, SLOT(findAndReplace()));
    // connect Format menu slots
    connect(ui->actionBold, SIGNAL(triggered()), this, SLOT(bold()));
    connect(ui->actionItalic, SIGNAL(triggered()), this, SLOT(italic()));
    connect(ui->actionUnderline, SIGNAL(triggered()), this, SLOT(underline()));
    connect(ui->actionStrikethrough, SIGNAL(triggered()), this, SLOT(strikethrough()));
    connect(ui->actionBullet_List, SIGNAL(triggered()), this, SLOT(bulletList()));
    connect(ui->actionNumber_List, SIGNAL(triggered()), this, SLOT(numberList()));
    connect(ui->actionIncrease_Indent, SIGNAL(triggered()), this, SLOT(increaseIndent()));
    connect(ui->actionDecrease_Indent, SIGNAL(triggered()), this, SLOT(decreaseIndent()));
    connect(ui->actionShow_Colors, SIGNAL(triggered()), this, SLOT(showColors()));
    connect(ui->actionShow_Fonts, SIGNAL(triggered()), this, SLOT(showFonts()));
    connect(ui->actionIncrease_Font, SIGNAL(triggered()), this, SLOT(increaseFont()));
    connect(ui->actionDecrease_Font, SIGNAL(triggered()), this, SLOT(decreaseFont()));
    connect(ui->actionReset_Font, SIGNAL(triggered()), this, SLOT(resetFont()));
    connect(ui->actionAlign_Left, SIGNAL(triggered()), this, SLOT(alignLeft()));
    connect(ui->actionAlign_Center, SIGNAL(triggered()), this, SLOT(alignCenter()));
    connect(ui->actionAlign_Right, SIGNAL(triggered()), this, SLOT(alignRight()));
    connect(ui->actionAlign_Justify, SIGNAL(triggered()), this, SLOT(alignJustify()));
    // connect View menu slots
    connect(ui->actionHide_Window, SIGNAL(triggered()), this, SLOT(hide()));
    connect(ui->actionPrevious_Category, SIGNAL(triggered()), this, SLOT(previousCategory()));
    connect(ui->actionNext_Category, SIGNAL(triggered()), this, SLOT(nextCategory()));
    connect(ui->actionPrevious_Note, SIGNAL(triggered()), this, SLOT(previousNote()));
    connect(ui->actionNext_Note, SIGNAL(triggered()), this, SLOT(nextNote()));
    // connect Help menu slots
    connect(ui->actionAbout_Brainstorm, SIGNAL(triggered()), this, SLOT(aboutBrainstorm()));
    connect(ui->actionAbout_Qt, SIGNAL(triggered()), this, SLOT(aboutQt()));
	// connect application slots
	connect(ui->textNote, SIGNAL(cursorPositionChanged()), this, SLOT(updateMenus()));
	connect(ui->textNote, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(updateMenus()));
    connect(ui->comboFonts, SIGNAL(activated(QString)), this, SLOT(setFont(QString)));
    connect(ui->comboFontSizes, SIGNAL(activated(QString)), this, SLOT(setFontSize(QString)));
    connect(ui->comboColors, SIGNAL(activated(int)), this, SLOT(setFontColor(int)));
	// connect category list slots
	connect(ui->listCategories->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateNoteList(QModelIndex)));
	// connect note list slots
	connect(ui->listNotes->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateNoteText(QModelIndex)));
	// connect text slots
	ui->textNote->installEventFilter((this));
	// connect system tray icon
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));

	// initialize default data
	ui->listCategories->selectionModel()->setCurrentIndex(categoriesModel->index(0, 1), QItemSelectionModel::SelectCurrent);

}