Ejemplo n.º 1
0
AutomationPattern::AutomationPattern( AutomationTrack * _auto_track ) :
	TrackContentObject( _auto_track ),
	m_autoTrack( _auto_track ),
	m_objects(),
	m_tension( 1.0 ),
	m_progressionType( DiscreteProgression ),
	m_dragging( false ),
	m_isRecording( false ),
	m_lastRecordedValue( 0 )
{
	changeLength( MidiTime( 1, 0 ) );
	if( getTrack() )
	{
		switch( getTrack()->trackContainer()->type() )
		{
			case TrackContainer::BBContainer:
				setAutoResize( true );
				break;

			case TrackContainer::SongContainer:
				// move down
			default:
				setAutoResize( false );
				break;
		}
	}
}
Ejemplo n.º 2
0
void enterSequential(DoubleIntArrPointer *possible, int solution[SIZE][SIZE], int possibleLen[SIZE][SIZE]){
	int i, j, k;
	
	for(i = 0; i < SIZE; i++){
		for(j = 0; j < SIZE; j++){
			if(possibleLen[i][j] == 1){
				int solutionNum = 0;
				
				for(k = 0; k < SIZE; k++){
					if(possible[i][j][k] != EMPTY){
						solutionNum = possible[i][j][k];
						possible[i][j][k] = 0;
						possibleLen[i][j] = 0;
					}
				}
				
				if(solutionNum != 0){
					solution[i][j] = solutionNum;

					changeLength(possible, solution, possibleLen, solutionNum, i, j);
				}
				
			}
		}
	}
}
Ejemplo n.º 3
0
void AutomationPattern::removeValue( const MidiTime & _time,
									 const bool _quant_pos )
{
	cleanObjects();

	MidiTime newTime = _quant_pos && engine::automationEditor() ?
		note::quantized( _time,
			engine::automationEditor()->quantization() ) :
		_time;

	m_timeMap.remove( newTime );
	m_tangents.remove( newTime );
	timeMap::const_iterator it = m_timeMap.lowerBound( newTime );
	if( it != m_timeMap.begin() )
	{
		it--;
	}
	generateTangents(it, 3);

	if( getTrack() &&
		getTrack()->type() == track::HiddenAutomationTrack )
	{
		changeLength( length() );
	}

	emit dataChanged();
}
Ejemplo n.º 4
0
MidiTime AutomationPattern::putValue( const MidiTime & _time,
							const float _value,
							const bool _quant_pos )
{
	cleanObjects();

	MidiTime newTime = _quant_pos && engine::automationEditor() ?
		note::quantized( _time,
			engine::automationEditor()->quantization() ) :
		_time;

	m_timeMap[newTime] = _value;
	timeMap::const_iterator it = m_timeMap.find( newTime );
	if( it != m_timeMap.begin() )
	{
		it--;
	}
	generateTangents(it, 3);

	// we need to maximize our length in case we're part of a hidden
	// automation track as the user can't resize this pattern
	if( getTrack() && getTrack()->type() == track::HiddenAutomationTrack )
	{
		changeLength( length() );
	}

	emit dataChanged();

	return newTime;
}
Ejemplo n.º 5
0
void SampleTCO::setSampleFile( const QString & _sf )
{
	m_sampleBuffer->setAudioFile( _sf );
	setStartTimeOffset( 0 );
	changeLength( (int) ( m_sampleBuffer->frames() / Engine::framesPerTick() ) );

	emit sampleChanged();
	emit playbackPositionChanged();
}
Ejemplo n.º 6
0
void Pattern::init()
{
	connect( Engine::getSong(), SIGNAL( timeSignatureChanged( int, int ) ),
				this, SLOT( changeTimeSignature() ) );
	saveJournallingState( false );

	ensureBeatNotes();

	changeLength( length() );
	restoreJournallingState();
}
Ejemplo n.º 7
0
AutomationPattern::AutomationPattern( AutomationTrack * _auto_track ) :
	trackContentObject( _auto_track ),
	m_autoTrack( _auto_track ),
	m_objects(),
	m_tension( 1.0 ),
	m_progressionType( DiscreteProgression ),
	m_dragging( false ),
	m_isRecording( false ),
	m_lastRecordedValue( 0 )
{
	changeLength( MidiTime( 1, 0 ) );
}
Ejemplo n.º 8
0
bbTCO::bbTCO( track * _track, unsigned int _color ) :
	trackContentObject( _track ),
	m_color( _color > 0 ? _color : defaultColor() )
{
	tact_t t = engine::getBBTrackContainer()->lengthOfBB( bbTrackIndex() );
	if( t > 0 )
	{
		saveJournallingState( false );
		changeLength( MidiTime( t, 0 ) );
		restoreJournallingState();
	}
}
Ejemplo n.º 9
0
bbTCO::bbTCO( track * _track, unsigned int _color ) :
	trackContentObject( _track ),
	m_color( _color > 0 ? _color : qRgb( 64, 128, 255 ) )
{
	tact_t t = engine::getBBTrackContainer()->lengthOfBB(
					bbTrack::numOfBBTrack( getTrack() ) );
	if( t > 0 )
	{
		saveJournallingState( false );
		changeLength( MidiTime( t, 0 ) );
		restoreJournallingState();
	}
}
Ejemplo n.º 10
0
BBTCO::BBTCO( Track * _track ) :
	TrackContentObject( _track ),
	m_color( 128, 128, 128 ),
	m_useStyleColor( true )
{
	tact_t t = Engine::getBBTrackContainer()->lengthOfBB( bbTrackIndex() );
	if( t > 0 )
	{
		saveJournallingState( false );
		changeLength( MidiTime( t, 0 ) );
		restoreJournallingState();
	}
}
Ejemplo n.º 11
0
void SampleTCO::loadSettings( const QDomElement & _this )
{
	if( _this.attribute( "pos" ).toInt() >= 0 )
	{
		movePosition( _this.attribute( "pos" ).toInt() );
	}
	setSampleFile( _this.attribute( "src" ) );
	if( sampleFile().isEmpty() && _this.hasAttribute( "data" ) )
	{
		m_sampleBuffer->loadFromBase64( _this.attribute( "data" ) );
	}
	changeLength( _this.attribute( "len" ).toInt() );
	setMuted( _this.attribute( "muted" ).toInt() );
}
Ejemplo n.º 12
0
void pattern::loadSettings( const QDomElement & _this )
{
	unfreeze();

	m_patternType = static_cast<PatternTypes>( _this.attribute( "type"
								).toInt() );
	setName( _this.attribute( "name" ) );
	if( _this.attribute( "pos" ).toInt() >= 0 )
	{
		movePosition( _this.attribute( "pos" ).toInt() );
	}
	changeLength( MidiTime( _this.attribute( "len" ).toInt() ) );
	if( _this.attribute( "muted" ).toInt() != isMuted() )
	{
		toggleMute();
	}

	clearNotes();

	QDomNode node = _this.firstChild();
	while( !node.isNull() )
	{
		if( node.isElement() &&
			!node.toElement().attribute( "metadata" ).toInt() )
		{
			note * n = new note;
			n->restoreState( node.toElement() );
			m_notes.push_back( n );
		}
		node = node.nextSibling();
        }

	m_steps = _this.attribute( "steps" ).toInt();
	if( m_steps == 0 )
	{
		m_steps = MidiTime::stepsPerTact();
	}

	ensureBeatNotes();
	checkType();
/*	if( _this.attribute( "frozen" ).toInt() )
	{
		freeze();
	}*/

	emit dataChanged();

	updateBBTrack();
}
Ejemplo n.º 13
0
void bbTCO::loadSettings( const QDomElement & _this )
{
	setName( _this.attribute( "name" ) );
	if( _this.attribute( "pos" ).toInt() >= 0 )
	{
		movePosition( _this.attribute( "pos" ).toInt() );
	}
	changeLength( _this.attribute( "len" ).toInt() );
	if( _this.attribute( "muted" ).toInt() != isMuted() )
	{
		toggleMute();
	}

	if( _this.attribute( "color" ).toUInt() != 0 )
	{
		m_color = _this.attribute( "color" ).toUInt();
	}
}
Ejemplo n.º 14
0
void enterNumber(DoubleIntArrPointer *possible, int solution[SIZE][SIZE], int possibleLen[SIZE][SIZE], int num, int mode){
	stack <int> single;
	int count, row, col, checkOne, checkTwo, savedRow, savedCol, clear; 
	
	for(checkOne = 0; checkOne < SIZE; checkOne++){
		count = 0;
		
		for(checkTwo = 0; checkTwo < SIZE; checkTwo++){
			if(mode == ROWMODE){
				row = checkOne;
				col = checkTwo;
			}else if (mode == COLMODE){
				row = checkTwo;
				col = checkOne;
			}
			
			if(possible[row][col][num-1] != EMPTY){
				count++;
				single.push(col);
				single.push(row);
			}
		}
		
		if(count == 1){
			savedRow = single.top();
			single.pop();
			savedCol = single.top();
			single.pop();
			
			solution[savedRow][savedCol] = num;
			for(clear = 0; clear < SIZE; clear++){
				possible[savedRow][savedCol][clear] = 0;
			}
			possibleLen[savedRow][savedCol] = 0;
			
			changeLength(possible, solution, possibleLen, num, savedRow, savedCol);
		}else{
			while(!single.empty()){
				single.pop();
			}
		}
	}
}
Ejemplo n.º 15
0
Note * Pattern::addNote( const Note & _new_note, const bool _quant_pos )
{
	Note * new_note = new Note( _new_note );
	if( _quant_pos && gui->pianoRoll() )
	{
		new_note->quantizePos( gui->pianoRoll()->quantization() );
	}

	instrumentTrack()->lock();
	if( m_notes.size() == 0 || m_notes.back()->pos() <= new_note->pos() )
	{
		m_notes.push_back( new_note );
	}
	else
	{
		// simple algorithm for inserting the note between two
		// notes with smaller and greater position
		// maybe it could be optimized by starting in the middle and
		// going forward or backward but note-inserting isn't that
		// time-critical since it is usually not done while playing...
		long new_note_abs_time = new_note->pos();
		NoteVector::Iterator it = m_notes.begin();

		while( it != m_notes.end() &&
					( *it )->pos() < new_note_abs_time )
		{
			++it;
		}

		m_notes.insert( it, new_note );
	}
	instrumentTrack()->unlock();

	checkType();
	changeLength( length() );

	emit dataChanged();

	updateBBTrack();

	return new_note;
}
Ejemplo n.º 16
0
void AutomationPattern::loadSettings( const QDomElement & _this )
{
	clear();

	movePosition( _this.attribute( "pos" ).toInt() );
	setName( _this.attribute( "name" ) );
	setProgressionType( static_cast<ProgressionTypes>( _this.attribute(
							"prog" ).toInt() ) );
	setTension( _this.attribute( "tens" ) );
	setMuted(_this.attribute( "mute", QString::number( false ) ).toInt() );

	for( QDomNode node = _this.firstChild(); !node.isNull();
						node = node.nextSibling() )
	{
		QDomElement element = node.toElement();
		if( element.isNull()  )
		{
			continue;
		}
		if( element.tagName() == "time" )
		{
			m_timeMap[element.attribute( "pos" ).toInt()]
				= element.attribute( "value" ).toFloat();
		}
		else if( element.tagName() == "object" )
		{
			m_idsToResolve << element.attribute( "id" ).toInt();
		}
	}

	int len = _this.attribute( "len" ).toInt();
	if( len <= 0 )
	{
		// TODO: Handle with an upgrade method
		updateLength();
	}
	else
	{
		changeLength( len );
	}
	generateTangents();
}
Ejemplo n.º 17
0
void BBTCO::loadSettings( const QDomElement & element )
{
	setName( element.attribute( "name" ) );
	if( element.attribute( "pos" ).toInt() >= 0 )
	{
		movePosition( element.attribute( "pos" ).toInt() );
	}
	changeLength( element.attribute( "len" ).toInt() );
	if( element.attribute( "muted" ).toInt() != isMuted() )
	{
		toggleMute();
	}

	if( element.hasAttribute( "color" ) )
	{
		setColor( QColor( element.attribute( "color" ).toUInt() ) );
	}
	
	if( element.hasAttribute( "usestyle" ) )
	{
		if( element.attribute( "usestyle" ).toUInt() == 1 ) 
		{
			m_useStyleColor = true;
		}
		else
		{
			m_useStyleColor = false;
		}
	}
	else
	{
		if( m_color.rgb() == qRgb( 128, 182, 175 ) || m_color.rgb() == qRgb( 64, 128, 255 ) ) // old or older default color
		{
			m_useStyleColor = true;
		}
		else
		{
			m_useStyleColor = false;
		}
	}
}
Ejemplo n.º 18
0
void pdsp::GrainWindow::process(int bufferSize) noexcept{

        int triggerState;
        const float* triggerBuffer = processInput(input_trigger, triggerState);

        if( run || triggerState == AudioRate ){ //there are still samples to emit or new triggers     
             
                int inputBufferState;
                const float * inputBuffer = processInput(input_signal, inputBufferState);

                int lenState;
                const float* lenBuffer = processInput(input_length_ms, lenState);
                if(lenState==Changed ){
                    changeLength(lenBuffer[0]);
                }

                int switcher = inputBufferState + triggerState*4;

                //process once
                switch (switcher & 42) {
                case 0 : //unchanged, unchanged, unchanged
                        process_audio<false, false>( inputBuffer, triggerBuffer, bufferSize );
                        break;
                case 2 : //changed, unchanged, unchanged
                        process_audio<true, false>( inputBuffer, triggerBuffer, bufferSize );
                        break;
                case 8 : //unchanged, changed, unchanged
                        process_audio<false, true>( inputBuffer, triggerBuffer, bufferSize );
                        break;
                case 10 : //changed, changed, unchanged
                        process_audio<true, true>( inputBuffer, triggerBuffer, bufferSize );
                        break;
                default:
                        break;
                }
                            
        }else{
                setOutputToZero(output);
        }
    
}
Ejemplo n.º 19
0
void SampleTCO::setSampleFile( const QString & _sf )
{
	int length;
	if ( _sf.isEmpty() )
	{	//When creating an empty sample pattern make it a bar long
		float nom = Engine::getSong()->getTimeSigModel().getNumerator();
		float den = Engine::getSong()->getTimeSigModel().getDenominator();
		length = DefaultTicksPerTact * ( nom / den );
	}
	else
	{	//Otherwise set it to the sample's length
		m_sampleBuffer->setAudioFile( _sf );
		length = sampleLength();
	}
	changeLength(length);

	setStartTimeOffset( 0 );

	emit sampleChanged();
	emit playbackPositionChanged();
}
Ejemplo n.º 20
0
void enterBox(DoubleIntArrPointer *possible, int solution[SIZE][SIZE], int possibleLen[SIZE][SIZE], int num){
	stack <int> single;
	int count, row, col, minirow, minicol, savedRow, savedCol, clear;
	
	for(row = 0; row < SQUARES; row++){
		for(col = 0; col < SQUARES; col++){
			count = 0;
			
			for(minirow = 0; minirow < SQUARES; minirow++){
				for(minicol = 0; minicol < SQUARES; minicol++){
					if(possible[row*3 + minirow][col*3 + minicol][num - 1] != EMPTY){
						count++;
						single.push(col*3 + minicol);
						single.push(row*3 + minirow);
					}
				}
			}
			
			if(count == 1){
				savedRow = single.top();
				single.pop();
				savedCol = single.top();
				single.pop();
				
				solution[savedRow][savedCol] = num;
				for(clear = 0; clear < SIZE; clear++){
					possible[savedRow][savedCol][clear] = 0;
				}
			
				possibleLen[savedRow][savedCol] = 0;
				
				changeLength(possible, solution, possibleLen, num, savedRow, savedCol);
			}else{
				while(!single.empty()){
					single.pop();
				}
			}
		}
	}
}
Ejemplo n.º 21
0
void Pattern::removeNote( const Note * _note_to_del )
{
	instrumentTrack()->lock();
	NoteVector::Iterator it = m_notes.begin();
	while( it != m_notes.end() )
	{
		if( *it == _note_to_del )
		{
			delete *it;
			m_notes.erase( it );
			break;
		}
		++it;
	}
	instrumentTrack()->unlock();

	checkType();
	changeLength( length() );

	emit dataChanged();

	updateBBTrack();
}
Ejemplo n.º 22
0
void pixel_drawSquarePixel(long inParam1,long inParam2,int inParam3,int inParam4)
{
    long originA = inParam1;
    long originB = inParam2;
    int size = inParam3;
    int density = inParam4;

    /*  Here density is accepted as a recording of BRIGHTNESS, where 0 is black and 255 is white.
        Later on, density gets scaled to the range that is available for this particular
        pixel+pentip combination, and also inverted so that it becomes a recording of DARKNESS,
        where 0 is white and the higher values are darker.

        (Using the same variable to save on space, really.)

        This is because paper is white, and ink is black, and this density value is used to
        control how many waves are drawn.

        O waves means no ink, so a very light pixel.
        50 waves means lots of ink, so a much darker pixel.
    */

    int halfSize = size / 2;

    long startPointA;
    long startPointB;
    long endPointA;
    long endPointB;

    int calcFullSize = halfSize * 2; // see if there's any rounding errors
    int offsetStart = size - calcFullSize;

    if (globalDrawDirectionMode == DIR_MODE_AUTO)
        globalDrawDirection = pixel_getAutoDrawDirection(originA, originB, motorA._currentPos, motorB._currentPos);


    if (globalDrawDirection == DIR_SE)
    {
//      Serial.println(F("d: SE"));
        startPointA = originA - halfSize;
        startPointA += offsetStart;
        startPointB = originB;
        endPointA = originA + halfSize;
        endPointB = originB;
    }
    else if (globalDrawDirection == DIR_SW)
    {
//      Serial.println(F("d: SW"));
        startPointA = originA;
        startPointB = originB - halfSize;
        startPointB += offsetStart;
        endPointA = originA;
        endPointB = originB + halfSize;
    }
    else if (globalDrawDirection == DIR_NW)
    {
//      Serial.println(F("d: NW"));
        startPointA = originA + halfSize;
        startPointA -= offsetStart;
        startPointB = originB;
        endPointA = originA - halfSize;
        endPointB = originB;
    }
    else //(drawDirection == DIR_NE)
    {
//      Serial.println(F("d: NE"));
        startPointA = originA;
        startPointB = originB + halfSize;
        startPointB -= offsetStart;
        endPointA = originA;
        endPointB = originB - halfSize;
    }

    /* pixel_scaleDensity takes it's input value as a BRIGHTNESS value (ie 255 = white),
       but returns a DARKNESS value (ie 0 = white).
       Here I'm using the same variable to hold both, save space in memory. */
    density = pixel_scaleDensity(density, 255, pixel_maxDensity(penWidth, size));
//    Serial.print(F("Start point: "));
//    Serial.print(startPointA);
//    Serial.print(COMMA);
//    Serial.print(startPointB);
//    Serial.print(F(". end point: "));
//    Serial.print(endPointA);
//    Serial.print(COMMA);
//    Serial.print(endPointB);
//    Serial.println(F("."));

    changeLength(startPointA, startPointB);
    if (density > 1)
    {
        pixel_drawSquarePixel_E(size, size, density, globalDrawDirection);
    }
    changeLength(endPointA, endPointB);

    //outputAvailableMemory();
}
Ejemplo n.º 23
0
void SampleTCO::updateLength( bpm_t )
{
	changeLength( sampleLength() );
}
Ejemplo n.º 24
0
void AutomationPattern::updateLength()
{
	changeLength( timeMapLength() );
}