示例#1
0
void LoopPointsUGenInternal::checkMetaDataCuePoints(const float currentPosition, 
													const float previousPosition, 
													const int numCuePoints,
													const bool forwards) throw()
{	
	CuePointArray& cuePoints = metaData.getCuePoints();
	CuePoint* cuePointArray = cuePoints.getArray();
	
	if(forwards)
	{
		for(int i = 0; i < numCuePoints; i++)
		{
			float cuePosition = cuePointArray[i].getSampleOffset();
			
			if((previousPosition < cuePosition) && (currentPosition >= cuePosition))
			{
				sendMetaData(b, metaData, MetaData::CuePointInfo, -1, i);		
			}
		}
	}
	else
	{
		for(int i = 0; i < numCuePoints; i++)
		{
			float cuePosition = cuePointArray[i].getSampleOffset();
			
			if((previousPosition > cuePosition) && (currentPosition <= cuePosition))
			{
				sendMetaData(b, metaData, MetaData::CuePointInfo, -1, i);		
			}
		}		
	}
}
示例#2
0
void PlayBufUGenInternal::checkMetaDataCuePoints(const double currentPosition, 
												 const double previousPosition, 
												 const int channel, 
												 const int numCuePoints,
												 const bool forwards) throw()
{	
	CuePointArray& cuePoints = metaData.getCuePoints();
	CuePoint* cuePointArray = cuePoints.getArray();
	
	if(forwards)
	{
		for(int i = 0; i < numCuePoints; i++)
		{
			double cuePosition = cuePointArray[i].getSampleOffset();
			
			if((previousPosition < cuePosition) && (currentPosition >= cuePosition))
			{
				sendMetaData(buffer_, metaData, MetaData::CuePointInfo, channel, i);		
			}
		}
	}
	else
	{
		for(int i = 0; i < numCuePoints; i++)
		{
			double cuePosition = cuePointArray[i].getSampleOffset();
			
			if((previousPosition > cuePosition) && (currentPosition <= cuePosition))
			{
				sendMetaData(buffer_, metaData, MetaData::CuePointInfo, channel, i);		
			}
		}		
	}
}
示例#3
0
void DuktoProtocol::sendScreen(QString ipDest, qint16 port, QString path)
{
    // Check for default port
    if (port == 0) port = DEFAULT_TCP_PORT;

    // Verifica altre attività in corso
    if (mIsReceiving || mIsSending) return;
    mIsSending = true;

    // File da inviare
    QStringList files;
    files.append(path);
    mFilesToSend = expandTree(files);
    mFileCounter = 0;
    mSendingScreen = true;

    // Connessione al destinatario
    mCurrentSocket = new QTcpSocket(this);

    // Gestione segnali
    connect(mCurrentSocket, SIGNAL(connected()), this, SLOT(sendMetaData()), Qt::DirectConnection);
    connect(mCurrentSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(sendConnectError(QAbstractSocket::SocketError)), Qt::DirectConnection);
    connect(mCurrentSocket, SIGNAL(bytesWritten(qint64)), this, SLOT(sendData(qint64)), Qt::DirectConnection);

    // Connessione
    mCurrentSocket->connectToHost(ipDest, port);
}
示例#4
0
//send a file to the server
int sendFile(SSL *ssl, char *filePath) {
    char buffer[LENGTH];
    FILE *fs = fopen(filePath, "r");
    if(fs == NULL)
    {
        fprintf(stderr,"ERROR: File: %s not found.\n", filePath);
        return EXIT_FAILURE;
    }
    //send the preliminary metadata to the server
    char *fileName;
    int fileSize = sendMetaData(filePath, ssl, &fileName);
    if(fileName == '\0') {
        fprintf(stderr,"Failed to send file metadata\n");
        return EXIT_FAILURE;
    }
    
    fprintf(stderr,"[Client] Sending %s to the Server...\n", fileName);
    
    memset(buffer, '\0', LENGTH);
    int fs_block_sz;
    int bytesSent = 0;
    int totalSent = 0;
    int n = 5;
    //generate loading bar
    char loading[22];
    memset(loading, ' ', sizeof(loading));
    loading[0] = '[',loading[21] = ']';

    //while there are still bytes to be read from the file send them to the server
    while((fs_block_sz = fread(buffer, sizeof(char), LENGTH, fs)) > 0)
    {
	bytesSent = SSL_write(ssl, buffer, fs_block_sz);   
        if(bytesSent <= 0)
        {
            fprintf(stderr, "[Client] ERROR: Failed to send file %s. (errno = %d)\n", fileName, errno);
            return EXIT_FAILURE;
        }
	totalSent = totalSent + bytesSent;
	//calculate percentage and print loading bar progress
	float percent = ((float)totalSent/(float)fileSize)*100;
        if((int)round(percent) == n) {
		loading[n/5] = '*';
            	n = n+5;
           	fprintf(stderr,"%s\r",loading);
	        memset(buffer, '\0', LENGTH);
	}
    }
    fprintf(stderr,"[Client] File %s was sent to the server\n", fileName);
    return EXIT_SUCCESS;
}
示例#5
0
void DuktoProtocol::sendFile(QString ipDest, QStringList files)
{
    // Verifica altre attività in corso
    if (mIsReceiving || mIsSending) return;
    mIsSending = true;

    // File da inviare
    mFilesToSend = expandTree(files);
    mFileCounter = 0;

    // Connessione al destinatario
    mCurrentSocket = new QTcpSocket(this);
    connect(mCurrentSocket, SIGNAL(connected()), this, SLOT(sendMetaData()), Qt::DirectConnection);
    connect(mCurrentSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(sendConnectError(QAbstractSocket::SocketError)), Qt::DirectConnection);
    connect(mCurrentSocket, SIGNAL(bytesWritten(qint64)), this, SLOT(sendData(qint64)), Qt::DirectConnection);
    mCurrentSocket->connectToHost(ipDest, TCP_PORT);
}
示例#6
0
void DuktoProtocol::sendText(QString ipDest, qint16 port, QString text)
{
    // Check for default port
    if (port == 0) port = DEFAULT_TCP_PORT;

    // Verifica altre attività in corso
    if (mIsReceiving || mIsSending) return;
    mIsSending = true;

    // Testo da inviare
    mFilesToSend.clear();
    mFilesToSend.append("___DUKTO___TEXT___");
    mFileCounter = 0;
    mTextToSend = text;

    // Connessione al destinatario
    mCurrentSocket = new QTcpSocket(this);
    connect(mCurrentSocket, SIGNAL(connected()), this, SLOT(sendMetaData()), Qt::DirectConnection);
    connect(mCurrentSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(sendConnectError(QAbstractSocket::SocketError)), Qt::DirectConnection);
    connect(mCurrentSocket, SIGNAL(bytesWritten(qint64)), this, SLOT(sendData(qint64)), Qt::DirectConnection);
    mCurrentSocket->connectToHost(ipDest, port);
}
示例#7
0
void PlayBufUGenInternal::processBlock(bool& shouldDelete, const unsigned int blockID, const int /*channel*/) throw()
{	
	const int numCuesPoints = metaData.getNumCuePoints();

	const int blockSize = uGenOutput.getBlockSize();
	const int bufferSize = buffer_.size();
	const double lastBufferPosition = bufferSize-1;
	
	double channelBufferPos = 0.0;
	
	for(int channel = 0; channel < getNumChannels(); channel++)
	{
		int numSamplesToProcess = blockSize;
		channelBufferPos = bufferPos;
		float* outputSamples = proxies[channel]->getSampleData();
		float* rateSamples = inputs[Rate].processBlock(shouldDelete, blockID, 0);
		float* trigSamples = inputs[Trig].processBlock(shouldDelete, blockID, 0);
		float* offsetSamples = inputs[Offset].processBlock(shouldDelete, blockID, 0);
		float* loopSamples = inputs[Loop].processBlock(shouldDelete, blockID, 0);
						
		double prevPos = prevPosArray[channel];
		
		while(numSamplesToProcess) 
		{				
			float thisTrig = *trigSamples++;
			
			if(thisTrig > 0.f && lastTrig <= 0.f)
				channelBufferPos = 0.0;
			
			double offset = *offsetSamples++;
			double position = offset + channelBufferPos;
			
			if(*loopSamples++ >= 0.5f) 
			{
				if(position >= bufferSize)
				{
					position -= bufferSize;
				} 
				else if(position < 0)
				{
					position += bufferSize;
				}
				
				*outputSamples++ = buffer_.getSample(channel, position);
				channelBufferPos += *rateSamples++;
			
				if(channelBufferPos >= bufferSize)
				{
					sendMetaData(buffer_, metaData, MetaData::ReachedEnd, channel);
					channelBufferPos -= bufferSize;
					sendMetaData(buffer_, metaData, MetaData::ReachedStart, channel);
					if(numCuesPoints > 0) checkMetaDataCuePoints(channelBufferPos, -1.0, channel, numCuesPoints, true);
					prevPos = channelBufferPos;
				}
				else if(channelBufferPos < 0)
				{
					sendMetaData(buffer_, metaData, MetaData::ReachedEnd, channel);
					channelBufferPos += bufferSize;
					sendMetaData(buffer_, metaData, MetaData::ReachedStart, channel);
					if(numCuesPoints > 0) checkMetaDataCuePoints(channelBufferPos, bufferSize, channel, numCuesPoints, false);
					prevPos = channelBufferPos;
				}
				else if(numCuesPoints > 0) 
				{
					checkMetaDataCuePoints(channelBufferPos, prevPos, channel, numCuesPoints, prevPos <= channelBufferPos);
					prevPos = channelBufferPos;
				}
			}
			else
			{
				if(numCuesPoints > 0) checkMetaDataCuePoints(channelBufferPos, prevPos, channel, numCuesPoints, prevPos <= channelBufferPos);
				prevPos = channelBufferPos;

				if((position <= 0.0) || (position > lastBufferPosition))
				{	
					*outputSamples++ = 0.0;
				}
				else
				{
					*outputSamples++ = buffer_.getSampleUnchecked(channel, position);
				}
				
				channelBufferPos += *rateSamples++;
			}
					
			--numSamplesToProcess;
			lastTrig = thisTrig;
		}		
		
		prevPosArray[channel] = prevPos;
	}
	
	bufferPos = channelBufferPos;
	
	if(bufferPos >= buffer_.size())
	{
		shouldDelete = shouldDelete ? true : shouldDeleteValue;
		setIsDone();
		sendMetaData(buffer_, metaData, MetaData::ReachedEnd);
	}
	else if(bufferPos < 0)
	{
		shouldDelete = shouldDelete ? true : shouldDeleteValue;
		setIsDone();
		sendMetaData(buffer_, metaData, MetaData::ReachedStart);		
	}
}