Пример #1
0
static void processKeys(void)
{
	uint8_t i;
	uint8_t hex_max = 0;

	for (i = 0; i < 48; i++)
	{
		//if the current sensor value of a key is positive and it was zero on last count
		if (manta_data_lock == 0)
		{
			
			if ((butt_states[i] > 0) && (pastbutt_states[i] <= 0))
			{
				addNote(i,butt_states[i]);
			}

			else if ((butt_states[i] <= 0) && (pastbutt_states[i] > 0))
			{
				removeNote(i);	
			}
			if (butt_states[i] > hex_max)
			{
				hex_max = butt_states[i];
			}

			// update the past keymap array (stores the previous values of every key's sensor reading)
			pastbutt_states[i] = butt_states[i];
		}
	
	}
	dacsend(3,0,(hex_max * 16)); 
	noteOut();
}
Пример #2
0
void Pattern::removeSteps()
{
	int _n = MidiTime::stepsPerTact();
	if( _n < m_steps )
	{
		for( int i = m_steps - _n; i < m_steps; ++i )
		{
			for( NoteVector::Iterator it = m_notes.begin();
						it != m_notes.end(); ++it )
			{
				if( ( *it )->pos() ==
					( i * MidiTime::ticksPerTact() ) /
						MidiTime::stepsPerTact() &&
							( *it )->length() <= 0 )
				{
					removeNote( *it );
					break;
				}
			}
		}
		m_steps -= _n;
		emit dataChanged();
	}
	updateBBTrack();
}
Пример #3
0
NotesContentsWidget::NotesContentsWidget(Window *window) : ContentsWidget(window),
	m_ui(new Ui::NotesContentsWidget)
{
	m_ui->setupUi(this);

	QMenu *addMenu(new QMenu(m_ui->addButton));
	addMenu->addAction(ThemesManager::getIcon(QLatin1String("inode-directory")), tr("Add Folder"), this, SLOT(addFolder()));
	addMenu->addAction(tr("Add Note"), this, SLOT(addNote()));
	addMenu->addAction(tr("Add Separator"), this, SLOT(addSeparator()));

	m_ui->addButton->setMenu(addMenu);
	m_ui->notesViewWidget->setViewMode(ItemViewWidget::TreeViewMode);
	m_ui->notesViewWidget->setModel(NotesManager::getModel());
	m_ui->notesViewWidget->setExpanded(NotesManager::getModel()->getRootItem()->index(), true);
	m_ui->notesViewWidget->setFilterRoles(QSet<int>({BookmarksModel::UrlRole, BookmarksModel::TitleRole, BookmarksModel::DescriptionRole, BookmarksModel::KeywordRole}));
	m_ui->notesViewWidget->viewport()->installEventFilter(this);
	m_ui->notesViewWidget->viewport()->setMouseTracking(true);
	m_ui->filterLineEdit->installEventFilter(this);
	m_ui->textEdit->setPlaceholderText(tr("Add note…"));

	if (!window)
	{
		m_ui->actionsWidget->hide();
	}

	connect(NotesManager::getModel(), SIGNAL(modelReset()), this, SLOT(updateActions()));
	connect(m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(removeNote()));
	connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addNote()));
	connect(m_ui->textEdit, SIGNAL(textChanged()), this, SLOT(updateText()));
	connect(m_ui->filterLineEdit, SIGNAL(textChanged(QString)), m_ui->notesViewWidget, SLOT(setFilterString(QString)));
	connect(m_ui->notesViewWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openUrl(QModelIndex)));
	connect(m_ui->notesViewWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
	connect(m_ui->notesViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateActions()));
}
Пример #4
0
void Chunk::setTimingDescription(const TimingDescription &timing_description)
{
    ChunkNotes old_notes = _notes;
    _notes.clear();
    for(const auto & n : old_notes)
    {
        int m_start  = _timing_description.measure(n.first.startPos());
        int b_start  = _timing_description.beat(n.first.startPos());
        int sb_start = _timing_description.note(n.first.startPos());

        int m_dur    = _timing_description.measure(n.first.endPos() - n.first.startPos() + 1);
        int b_dur    = _timing_description.beat(n.first.endPos() - n.first.startPos() + 1);
        int sb_dur   = _timing_description.note(n.first.endPos() - n.first.startPos() + 1);

        ChunkNote nprime = n.first;

        int new_start = m_start*timing_description.columns() + b_start*timingDescription().beatsPerMeasure() + sb_start;
        int new_end   = new_start + timing_description.columns(m_dur) + b_dur * timingDescription().notesPerBeat() + sb_dur - 1;

        nprime.setPos(new_start, new_end);

        removeNote(n.first);
        addNote(nprime);

    }

    _timing_description = timing_description;

    updateViews();
}
Пример #5
0
/// Remove all notes index and related notes.
bool ContentManager::removeAllNotes()
{
    cms::Notes notes;
    allNotes(notes);
    foreach(NoteInfo n, notes)
    {
        removeNote(n.name());
    }
Пример #6
0
void handleMIDIMessage(uint8_t ctrlByte, uint8_t msgByte1, uint8_t msgByte2)
{
	uint8_t control = ctrlByte & 0xf0;

	//uint8_t channel = ctrlByte & 0x0f;
	
	
	//lcd_clear_line(1);
	//dip204_printf_string("control: %u",ctrlByte);
	//lcd_clear_line(2);
	//dip204_printf_string("note: %u", msgByte1);

	switch(control)
	{
		case 144:
			if (msgByte2)
			{
				addNote(msgByte1,msgByte2);
			}
			//to deal with note-offs represented as a note-on with zero velocity
			else
			{
				removeNote(msgByte1);
			}
			noteOut();
			midiVol();
			break;
		case 128:
			removeNote(msgByte1);
			noteOut();
			midiVol();
			break;
		// control change
		case 176:
			controlChange(msgByte1,msgByte2);
			//LED_On(LED2);
			//midiVol();
			break;
		// program change	
		case 192:
			programChange(msgByte1);
			break;
		default:
			break;
	}
}
Пример #7
0
void MidiArp::purgeLatchBuffer()
{
    for (int l1 = 0; l1 < latchBufferCount; l1++) {
        int buf = latchBuffer.at(l1);
        removeNote(&buf, arpTick, 1);
    }
    latchBufferCount = 0;
}
Пример #8
0
void MidiArp::purgeSustainBuffer(int sustick)
{
    for (int l1 = 0; l1 < sustainBufferCount; l1++) {
        int buf = sustainBuffer.at(l1);
        removeNote(&buf, sustick, 1);
    }
    sustainBufferCount = 0;
}
void AutomationGrid::removeAllEvents (const int controller)
{
    for (int i = notes.size ()-1; i >= 0; i--)
    {
        AutomationEvent* note = getEvent (i);
		if (note->getController() == controller)
			removeNote(note, true);
	}
}
Пример #10
0
void CIniFile::readInfo(void)
{
    m_lstNodeInfo.clear();

    std::fstream inStream(m_strFile.c_str(), std::ios::in);
    if (!inStream.good())
    {
        Q_Printf("open file %s error.", m_strFile.c_str());
        inStream.close();

        return;
    }

    char pBuffer[Q_ONEK];
    std::string strTmp;
    std::string strNode;

    while(inStream.good())
    {
        Q_Zero(pBuffer, sizeof(pBuffer));

        inStream.getline(pBuffer, (std::streamsize)(sizeof(pBuffer) - 1));

        strTmp = std::string(pBuffer);
        strTmp = Q_Trim(strTmp);
        if (strTmp.empty()
            || isNote(strTmp))
        {
            continue;
        }

        //去掉注释
        removeNote(strTmp);
        strTmp = Q_Trim(strTmp);
        if (strTmp.empty())
        {
            continue;
        }

        if (isNode(strTmp))
        {
            strNode = getNode(strTmp);

            continue;
        }

        if (isKey(strTmp))
        {
            setStringValue(strNode.c_str(), getKey(strTmp).c_str(), getVal(strTmp).c_str());
        }
    }

    inStream.close();

    return;
}
Пример #11
0
Note * Pattern::rearrangeNote( const Note * _note_to_proc,
							const bool _quant_pos )
{
	// just rearrange the position of the note by removing it and adding
	// a copy of it -> addNote inserts it at the correct position
	Note copy_of_note( *_note_to_proc );
	removeNote( _note_to_proc );

	return addNote( copy_of_note, _quant_pos );
}
Пример #12
0
void MidiArp::getNote(int *tick, int note[], int velocity[], int *length)
{
    QChar c;
    int l1, tmpIndex[MAXCHORD], chordIndex, grooveTmp;
    bool gotCC, outOfRange, pause;
    double attackfn, releasefn;


    chordIndex = 0;
    tmpIndex[0] = 0;
    tmpIndex[1] = -1;
    gotCC = false;
    pause = false;
    if (restartFlag) advancePatternIndex(true);

    if (!patternIndex) initLoop();
    chordSemitone[0] = semitone;
    do {
        if (patternLen)
            c = (pattern.at(patternIndex));
        else
            c = ' ';

        if (c != ' ') {
            if (c.isDigit() || (c == 'p')) {
                tmpIndex[chordIndex] = c.digitValue() + noteOfs;
                if (chordMode) {
                    chordIndex++;
                    chordSemitone[chordIndex] = semitone;
                }
                gotCC = false;
                pause = (c == 'p');
            }
            else {
                gotCC = true;

                switch(c.toAscii()) {
                    case '(':
                        chordMode = true;
                        break;
                    case ')':
                        // mark end of chord
                        tmpIndex[chordIndex] = -1;
                        chordMode = false;
                        gotCC = false;
                        break;
                    case 't':
                        semitone++;
                        break;
                    case 'g':
                        semitone--;
                        break;
                    case '+':
                        semitone+=12;
                        break;
                    case '-':
                        semitone-=12;
                        break;
                    case '=':
                        semitone = 0;
                        break;
                    case '>':
                        stepWidth *= .5;
                        break;
                    case '<':
                        stepWidth *= 2.0;
                        break;
                    case '.':
                        stepWidth = 1.0;
                        break;
                    case '/':
                        vel += 0.2;
                        break;
                    case '\\':
                        vel -= 0.2;
                        break;
                    case 'd':
                        len *= 2.0;
                        break;
                    case 'h':
                        len *= .5;
                        break;
                }
                chordSemitone[chordIndex] = semitone;
            }
        }
    } while (advancePatternIndex(false) && (gotCC || chordMode));

    l1 = 0;
    if (noteCount) do {
        noteIndex[l1] = (noteCount) ? tmpIndex[l1] % noteCount : 0;
        note[l1] = clip(notes[noteBufPtr][0][noteIndex[l1]]
                + chordSemitone[l1], 0, 127, &outOfRange);
        grooveTmp = (grooveIndex % 2) ? -grooveVelocity : grooveVelocity;

        if ((release_time > 0) && (notes[noteBufPtr][3][noteIndex[l1]])) {
            releasefn = 1.0 - (double)(arpTick
                    - notes[noteBufPtr][2][noteIndex[l1]])
                    / (release_time * (double)TPQN * 2);

            if (releasefn < 0.0) releasefn = 0.0;
        }
        else releasefn = 1.0;

        if (attack_time > 0) {
            if (!notes[noteBufPtr][3][noteIndex[l1]]) {
                attackfn = (double)(arpTick
                    - notes[noteBufPtr][2][noteIndex[l1]])
                    / (attack_time * (double)TPQN * 2);

                if (attackfn > 1.0) attackfn = 1.0;
                old_attackfn[noteIndex[l1]] = attackfn;
            }
            else attackfn = old_attackfn[noteIndex[l1]];
        }
        else attackfn = 1.0;

        velocity[l1] = clip((double)notes[noteBufPtr][1][noteIndex[l1]]
                * vel * (1.0 + 0.005 * (double)(randomVelocity + grooveTmp))
                * releasefn * attackfn, 0, 127, &outOfRange);

        if ((notes[noteBufPtr][3][noteIndex[l1]]) && (!velocity[l1])) {
            removeNote(&notes[noteBufPtr][0][noteIndex[l1]], -1, 0);
            releaseNoteCount--;
        }
        else {
            l1++;
        }
    } while (  (tmpIndex[l1] >= 0)
            && (l1 < MAXCHORD - 1)
            && ((l1 < noteCount) || (tmpIndex[l1] == 0))
            && (noteCount));

    note[l1] = -1; // mark end of array
    grooveTmp = (grooveIndex % 2) ? -grooveLength : grooveLength;
    *length = clip(len * stepWidth * (double)TPQN
            * (1.0 + 0.005 * (double)(randomLength + grooveTmp)), 2,
            1000000,  &outOfRange);

    if (!grooveIndex) grooveTick = newGrooveTick;
    grooveTmp = TPQN * stepWidth * grooveTick * 0.01;
    /* pairwise application of new groove shift */
    if (grooveIndex % 2) {
        grooveTmp = -grooveTmp;
        grooveTick = newGrooveTick;
    }
    arpTick += stepWidth * TPQN + grooveTmp;

    if (!trigByKbd && !grooveIndex && !grooveTick) {
        /* round-up to current resolution (quantize) */
        arpTick/= (TPQN * minStepWidth);
        arpTick*= (TPQN * minStepWidth);
    }

    *tick = arpTick + clip(stepWidth * 0.25 * (double)randomTick, 0,
            1000, &outOfRange);

    if (!(patternLen && noteCount) || pause || isMuted) {
        velocity[0] = 0;
    }
    grooveIndex++;
}
Пример #13
0
bool MidiArp::handleEvent(MidiEvent inEv, int tick, int keep_rel)
{
    int bufPtr, index;

    if (inEv.channel != chIn) return(true);
    if ((inEv.type == EV_CONTROLLER) && (inEv.data == CT_FOOTSW)) {
        setSustain((inEv.value == 127), tick);
        return(false);
    }

    if (inEv.type != EV_NOTEON) return(true);
    if (((inEv.data < indexIn[0]) || (inEv.data > indexIn[1]))
        || ((inEv.value < rangeIn[0]) || (inEv.value > rangeIn[1]))) {
        return(true);
    }

    if (inEv.value) {
        // This is a NOTE ON event
        if (!getPressedNoteCount() || trigLegato) {
            purgeLatchBuffer();
            if (restartByKbd) restartFlag = true;
            if (trigByKbd) {
                initArpTick(tick);
                // if we have been triggered, remove pending release notes
                if (release_time > 0) {
                    for (int l1 = 0; l1 < noteCount; l1++) {
                        if (notes[noteBufPtr][3][l1])
                            removeNote(&notes[noteBufPtr][0][l1], -1, 0);
                            releaseNoteCount--;
                    }
                }

            }
        }
        // modify buffer that is not accessed by arpeggio output
        bufPtr = (noteBufPtr) ? 0 : 1;

        if (!noteCount || (inEv.data > notes[bufPtr][0][noteCount - 1]))
            index = noteCount;
        else {
            index = 0;
            while (inEv.data > notes[bufPtr][0][index]) index++;

            for (int l3 = 0; l3 < 4; l3++) {
                for (int l2 = noteCount; l2 > index; l2--) {
                    notes[bufPtr][l3][l2] = notes[bufPtr][l3][l2 - 1];
                }
            }
        }
        notes[bufPtr][0][index] = inEv.data;
        notes[bufPtr][1][index] = inEv.value;
        notes[bufPtr][2][index] = tick;
        notes[bufPtr][3][index] = 0;
        noteCount++;

        if (repeatPatternThroughChord == 2) noteOfs = noteCount - 1;
        if (trigByKbd && ((noteCount == 1) || trigLegato)) {
            nextTick = tick + 2; //schedDelayTicks;
            gotKbdTrig = true;
        }
    }
    else {
        // This is a NOTE OFF event
        // modify buffer that is not accessed by arpeggio output
        bufPtr = (noteBufPtr) ? 0 : 1;
        if (!noteCount) {
            return(false);
        }
        if (sustain) {
            sustainBuffer.replace(sustainBufferCount, inEv.data);
            sustainBufferCount++;
            return(false);
        }

        if (latch_mode) {
            latchBuffer.replace(latchBufferCount, inEv.data);
            latchBufferCount++;
            if (latchBufferCount != noteCount) {
                if ((uint)tick > (uint)(lastLatchTick + 30) && (latchBufferCount > 1)) purgeLatchBuffer();
                lastLatchTick = tick;
            }
            return(false);
        }

        if ((!keep_rel) || (!release_time)) {
            //definitely remove from buffer
            if (inEv.data == notes[bufPtr][0][noteCount - 1]) {
                //note is on top of buffer: only decrement noteCount
                noteCount--;
                if (repeatPatternThroughChord == 2) noteOfs = noteCount - 1;
            }
            else {
                //note is not on top: take out the note and pull down all above
                index = 0;
                while ((index < noteCount) && (inEv.data > notes[bufPtr][0][index])) index++;
                deleteNoteAt(index, bufPtr);
            }
        }
        else tagAsReleased(inEv.data, tick, bufPtr);
    }
    copyNoteBuffer();
    return(false);
}