Ejemplo n.º 1
0
/*
============================================================================
Loads the log data from a file.
============================================================================
*/
int VTTpddServerLog::LoadFile(MString filename)
{
	FILE*			fd;
	int				c, lineNo, rxTx;
	//VTTpddLogEntry*	pEntry;
	//MString			fmt, hexFmt;
	char			line[256];
	char			*ptr;

	// Test if we are loading from the root window
	if (this == gpLog)
	{
		// Don't load files from the root window.  Create a new window
		VTTpddServerLog* pLog = new VTTpddServerLog(w(), h(), "TPDD Log Viewer");
		
		// Validate the window was created
		if (pLog == NULL)
			return FALSE;

		// Let the new window open the log
		if (!pLog->LoadFile(filename))
		{
			// Load was not successful.  Destroy the window
			delete pLog;
			return FALSE;
		}

		// Now show the new window
		pLog->show();
		pLog->resize(x()+MENU_HEIGHT, y()+MENU_HEIGHT, w(), h());
		return TRUE;
	}

	// Try to open the file
	if ((fd = fopen(filename, "r")) == NULL)
	{
		fl_message("Unable to open file %s", fl_filename_name((const char *) filename)); return FALSE;
	}

	// Loop for all data in the file
	lineNo = 0;
	while (fgets(line, sizeof(line), fd) != NULL)
	{
		// Start at beginning of line
		ptr = line;
		c = 0;
		lineNo++;
		
		// Search for a reference.  This means we log the existing entry and start a new one
		while (*ptr == ' ')
		{
			// Increment ptr and c
			ptr++;
			c++;
		}

		// Test if a reference found
		if (c < 4)
		{
			// Validate the file format
			if (*ptr < '0' || *ptr > '9')
			{
				// Not a trace file!!
				fl_message("This does not appear to be a valid file on line %d", lineNo);
				return FALSE;
			}

			// Reference found.  This entry and start a new one
			if (m_rxCount > 0)
				AddNewEntry(TPDD_LOG_RX, m_rxCount, m_rxBuffer);
			if (m_txCount > 0)
				AddNewEntry(TPDD_LOG_TX, m_txCount, m_txBuffer);
			m_txCount = 0;
			m_rxCount = 0;

			// Skip past the reference and find the ':'
			while (*ptr != ':' && c < sizeof(line))
			{
				// Increment pointer and index
				ptr++;
				c++;
			}

			// Test if ':' found
			if (c >= sizeof(line) || *ptr != ':')
			{
				// Not a trace file!!
				fl_message("This does not appear to be a valid file on line %d", lineNo);
				return FALSE;
			}

			// Skip the ':' and spaces after it
			ptr += 2;
			c += 2;

			// Now get RX/TX marker
			if (*ptr == 'T')
				rxTx = 1;
			else if (*ptr == 'R')
				rxTx = 0;
			else
			{
				// Not a trace file!!
				fl_message("This does not appear to be a valid file on line %d", lineNo);
				return FALSE;
			}

			// Skip past "RX: " or "TX: "
			ptr += 4;
			c += 4;
		}

		// Now we are pointing at the HEX data.  Read all data from this line into
		// either the m_rxBuffer or m_txBuffer
		while (*ptr != ' ' && *ptr != '\0' && c < sizeof(line))
		{
			unsigned char val;

			val = (*ptr > '9' ? *ptr = 'A' + 10 : *ptr - '0') << 4;
			ptr++;
			val += *ptr > '9' ? *ptr = 'A' + 10 : *ptr - '0';
			ptr += 2;
			c += 3;

			// Now save val in either rx or tx buffer
			if (rxTx)
			{
				m_txBuffer[m_txCount++] = val;
				if (m_txCount >= sizeof(m_txBuffer))
				{
					AddNewEntry(TPDD_LOG_TX, m_txCount, m_txBuffer);
					m_txCount = 0;
				}
			}
			else
			{
				m_rxBuffer[m_rxCount++] = val;
				if (m_rxCount >= sizeof(m_rxBuffer))
				{
					AddNewEntry(TPDD_LOG_RX, m_rxCount, m_rxBuffer);
					m_rxCount = 0;
				}
			}
		}
	}

	// Log any remaining data
	if (m_rxCount > 0)
		AddNewEntry(TPDD_LOG_RX, m_rxCount, m_rxBuffer);
	if (m_txCount > 0)
		AddNewEntry(TPDD_LOG_TX, m_txCount, m_txBuffer);
	m_txCount = 0;
	m_rxCount = 0;

	// Close the file
	fclose(fd);
	return TRUE;
}
Ejemplo n.º 2
0
/*
============================================================================
Saves the log data to a file using the current window width
============================================================================
*/
void VTTpddServerLog::SaveFile(MString filename)
{
	FILE*			fd;
	int				count, c, i, dataIdx;
	VTTpddLogEntry*	pEntry;
	MString			fmt, hexFmt;

	// Validate we have data
	if (m_log.GetSize() == 0)
		return;

	// Test if the file exists
	if ((fd = fopen((const char *) filename, "r")) != NULL)
	{
		// Close the file
		fclose(fd);
		int ans = fl_choice("Overwrite existing file %s?", "Ok", "Cancel", NULL, 
				fl_filename_name((const char *) filename));	
		if (ans == 1)
			return;
	}

	// Try to open the file
	if ((fd = fopen((const char *) filename, "w")) == NULL)
	{
		MString err;

		err.Format("Unable to create file %s\n", (const char *) filename);
		fl_message("%s", (const char *) err);
		return;
	}

	// Test if any leftover RX or TX data not logged to an entry yet
	if (m_rxCount > 0)
		AddNewEntry(TPDD_LOG_RX, m_rxCount, m_rxBuffer);
	if (m_txCount > 0)
		AddNewEntry(TPDD_LOG_TX, m_txCount, m_txBuffer);
	m_txCount = 0;
	m_rxCount = 0;
	
	// Now loop for all entries
	count = m_log.GetSize();
	for (c = 0; c < count; c++)
	{
		// Get the next entry
		pEntry = (VTTpddLogEntry *) m_log[c];
		fmt.Format("%4d: %s: ", pEntry->m_ref, pEntry->m_rxTx ? "TX" : "RX");
		i = 0;
		dataIdx = 0;
		while (dataIdx < pEntry->m_count)
		{
			if (dataIdx != 0)
				fmt = "          ";
			// "Print" the HEX data to the line
			for (i = 0; i < m_bytesPerLine && dataIdx + i < pEntry->m_count; i++)
			{
				hexFmt.Format("%02X ", (unsigned char) pEntry->m_pData[dataIdx + i]);
				fmt += hexFmt;
			}

			// Pad with spaces if less then m_bytesPerLine
			for ( ; i < m_bytesPerLine; i++)
				fmt += (char *) "   ";

			// "Print" the ASCII data to the line
			fmt += (char *) "  ";
			for (i = 0; i < m_bytesPerLine && dataIdx + i < pEntry->m_count; i++)
			{
				// Test if it's actual ASCII data or not
				if (pEntry->m_pData[dataIdx + i] >= ' ' && pEntry->m_pData[dataIdx + i] <= '~')
					hexFmt.Format("%c", (unsigned char) pEntry->m_pData[dataIdx + i]);
				else
					hexFmt = '.';
				fmt += hexFmt;
			}

			// Save to the file
			fprintf(fd, "%s\n", (const char *) fmt);
			dataIdx += i;
		}
	}

	// Close the file
	fclose(fd);
}
Ejemplo n.º 3
0
void diviser()
{
    long size = get_size();
    char buffer[buffer_size];
    long i;

    //erreur dans la taille?
    if(size==0) {
        return;
    }


    FILE *file = fopen(I->fichier->value(),"rb");
    if(!file) {
        fn_alert("Erreur, le programme ne peux ouvrir le fichier \"%s\" en lecture...\n",I->fichier->value());
        return;
    }

    //calcule la taille du fichier
    if(fseek(file,0,SEEK_END)) {
        fn_alert("Erreur, le programme ne peux se positionner dans le fichier...");
        fclose(file);
        return;
    }
    long fsize=ftell(file);
    if(fsize==0) {
        fn_alert("Erreur, le programme ne peux lire la taille du fichier...");
        fclose(file);
        return;
    }
    rewind(file); //reviens à la position initiale

    //calcule le nombre de split
    long max_split = (long)(fsize/size) + (((fsize%size)!=0)?1:0);

    //de 1 à 999, sinon err
    if(max_split>999) {
        fn_alert("Erreur, vous avez dépassé le seuil de 999 divisions...\n");
        fclose(file);
        return;
    }

    //les erreurs...
    if(max_split<=1) {
        fn_message("Après le calcul, la taille de ce fichier est de %s. Elle ne dépasse même pas une division.",octet_to_string(fsize));
        fclose(file);
        return;
    }
    if(fsize<=size) {
        fn_alert("La taille du fichier \"%s\" qui est %s est inférieure de la taille d'une seule division!",I->fichier->value(),octet_to_string(fsize));
        fclose(file);
        return;
    }
    if(!fn_ask("Vous êtes sur le point de diviser le fichier:\n\n\"%s\"\n\nEn %i parties... Continuer?",I->fichier->value(),max_split)) {
        fclose(file);
        return;
    }

    //variable ou il y a le nom du fichier qui est divisé...
    const char *name = fl_filename_name(I->fichier->value());
    char *path = (char *)malloc(strlen(I->chemin->value())+1+strlen(name)+5+1);
    strcpy(path,I->chemin->value());

    //ajouter / à la fin
    {
        char *str=path+strlen(path);
        while(*str!=C_RACINE) {
            if(!isspace(*str) && *str!=C_RACINE) {
                strcat(path,S_RACINE);
                break;
            }
            str--;
        }
    }

    strcat(path,name);
    char *path_end = path+strlen(path);

    //supprimer les fichier *.00* qui existent
    for(i=0; i<max_split; i++) {
        sprintf(path_end,".u%03li",i+1);
        FILE *filed = fopen(path,"rb");
        if(filed) {
            fclose(filed);
            if(!fn_ask("Le programme a trouvé quelques anciennes divisions du fichier à diviser.\n\npar exemple:\n\"%s\"\n\nCes fichiers doivent être supprimés...\n\nLe souhaitez vous?",path,I->fichier->value())) {
                fn_alert("Si ces fichiers de divisions existent encore le\nprogramme ne peux diviser le fichier...");
                fclose(file);
                free(path);
                return;
            }

            //supprime tous les fichiers
            for(long i=0; i<1000; i++) {
                sprintf(path_end,".u%03li",i+1);
                remove(path);
            }
            fn_message("Les fichiers sont maintenant supprimés.!\n\nAppuyez sur OK pour divisier le fichier...");
            break;
        }
    }

    progress.show();
    progress.value(0,0,"");


    //division !
    for(i=0; i<max_split; i++) {
        //introduction
        sprintf(path_end,".u%03li",i+1);

        FILE *filed = fopen(path,"wb");
        if(!filed) {
            fn_alert("Erreur dans l'ouverture du fichier \"%s\" en écriture...",path);
            fclose(file);
            fclose(filed);
            for(long j=0; j<=i; j++) {
                sprintf(path_end,".%03li",j+1);
                remove(path);
            }
            free(path);
            progress.hide();
            return;
        }

        {
            //conv le path en un nom de fichier
            const char *s = strrchr(path,C_RACINE);
            if(!s) s=path;
            else s++;
            progress.value(-1,-1,s);
        }

        //traiitteeeeeement !!
        size_t readed=0;
        int actual_percent=0;
        long split_size=(i==max_split-1)?(fsize-((max_split-1)*size)):size;
        double n,d;
        for(long j=split_size; j>0; j-=readed) {
            //calcul actual percent
            //split_size      ----> 100%
            //split_size-j    ----> ?

            //change le value du progress...
            n = split_size-j;
            d = split_size;
            actual_percent = (int)((n*100)/d);

            //met les nouvelles valeurs dans le progress
            {
                n=((i*100)+actual_percent);
                d=max_split;
                progress.value(
                    (int)(n/d)
                    ,actual_percent);
            }

            //pour toujours afficher le progress
            if(!progress.shown()) progress.show();

            // === Fin calcul ====

            size_t read_size = (j<buffer_size)?j:buffer_size;
            readed=fread(buffer,1,read_size,file);
            if(readed==0) break;

            size_t writed = fwrite(buffer,readed,1,filed);

            if(writed<1) {
                fn_alert("Erreur dans l'écriture dans le fichier \"%s\"...\nPeu être pas assez d'espace?\nOu disque protégé en écriture?...",path);
                fclose(file);
                fclose(filed);
                for(long j=0; j<=i; j++) {
                    sprintf(path_end,".%03li",j+1);
                    remove(path);
                }
                free(path);
                progress.hide();
                return;
            }

        }

        progress.value(-1,100);

        fclose(filed);
    }

    progress.value(100,100);

    //et enfin, ferme le fichier...
    fclose(file);

    fn_message("La division du fichier\n\n\"%s\"\n\nen %i parties réussie avec succès !",I->fichier->value(),max_split);

    //fin !
    progress.hide();

    //désalloque path
    free(path);
}
int 
RMGMO::ImportaMidi(char *filename)
{

// Open Midi File 

  FILE *fs;
  int Nutrak, MNtracks, MTiempoBase,MFormato;
  int TrackLen, dato, nota, velo;
  int DeltaMayor=0;
  int TTdelta = 0;
  int Tdelta = 0;
  int tipo, canal, longi;
  int i,j;
  int ya=0;
  int numpa = 0;
  char chtemp[32];
  cMidiRead = 0;
  grabaconta=0;
  memset(&nStyle, 0, sizeof nStyle);
  memset(PEG,0, sizeof PEG);

  if ((fs = fopen (filename, "rb")) != NULL)
   {

     strcpy(nStyle.Name,fl_filename_name(filename));


// Check if is Midi File

  if (MAGIC_FILE != leer_bytes(fs, 4))

     { 
       fclose(fs);
       printf("Sorry %s not seems a midi file\n",filename);
       return(1);
     }


  if ( leer_bytes(fs,4) != 6)

      {
       fclose(fs);
       printf("Sorry %s not seems a midi file\n",filename);
       return(1);
     }



// Check if is Midi File type 1


MFormato= leer_bytes(fs,2);


MNtracks = leer_bytes(fs,2);
MTiempoBase = leer_bytes(fs,2);


nStyle.ppq=MTiempoBase;
nStyle.har=0;
nStyle.bpm=120;
nStyle.nominador=4;
nStyle.denominator=2;
// Search track importable


for (Nutrak = 1; Nutrak <= MNtracks; Nutrak++)

{

//Read track Header


             if (MAGIC_TRACK != leer_bytes(fs, 4))
             {
             printf("Track %d Track Head ?\n",Nutrak);
             }

TrackLen = leer_bytes(fs,4);

// import data

if ( TTdelta > DeltaMayor) DeltaMayor=TTdelta;

tipo= 0;
canal = 0;
cMidiRead = 0;
longi = 0;
TTdelta = 0;
Tdelta = 0;
LaUltima = 0;

while (cMidiRead < TrackLen)
         {
          Tdelta = leer_delta(fs);
          TTdelta += Tdelta;
          dato = leer_bytes(fs,1);
          if ((dato & 0x80) == 0 )
          {
              ungetc(dato,fs);
              cMidiRead--;
          }
          else
          {
          tipo = dato & 0xf0;
          canal = dato & 0x0f;
          }

          switch(tipo)
           {

            case MIDI_CMD_NOTE_ON:

              		nota = leer_bytes(fs,1);
          		velo = leer_bytes(fs,1);
          	        PonGraba(2,TTdelta,nota,canal,velo);
                        break;

            case MIDI_CMD_NOTE_OFF:
                        nota = leer_bytes(fs,1);
                        velo = leer_bytes(fs,1);
                        PonGraba(2,TTdelta,nota,canal,0);
                        break;


            case MIDI_CMD_NOTE_PRESSURE:
                        nota = leer_bytes(fs,1);
                        velo = leer_bytes(fs,1);
                        PonGraba(2,TTdelta,nota,canal,velo);
                        break;

            case MIDI_CMD_CONTROL:
                        nota = leer_bytes(fs,1);
                        velo = leer_bytes(fs,1);
                        PonGraba(3,TTdelta,nota,canal,velo);
                        break;

            case MIDI_CMD_PGM_CHANGE:
                        nota = leer_bytes(fs,1);
                        PonGraba(4,TTdelta,nota,canal,0);
                        break;

            case MIDI_CMD_CHANNEL_PRESSURE:
                        nota = leer_bytes(fs,1);
                        break;

            case MIDI_CMD_BENDER:
                        nota = leer_bytes(fs, 1);
                        nota |= leer_bytes(fs, 1) << 7;
                        nota -= 0x2000;
                        PonGraba(5,TTdelta,nota,canal,0);
                        break;

            case MIDI_CMD_COMMON_SYSEX:
                        if (canal == 0x0f)
                         {
                           int tipo = leer_bytes(fs, 1);

                           if (tipo == 0x2f)
                            {
                              while (cMidiRead < TrackLen)
                                   leer_bytes(fs,1);
                              break;
                             }


                            if (tipo == 0x58)
                             {
                              velo = leer_delta(fs);
                              nStyle.nominador=leer_bytes(fs,1);
                              nStyle.denominator=leer_bytes(fs,1);
                              nStyle.cpq = leer_bytes(fs,1);
                              leer_bytes(fs,1);
                              PonAjusta();
                              break;
                             }

                           if (tipo == 0x51)
                             {
                              velo = leer_delta(fs);
                              nStyle.bpm = (int)( 6e7 / leer_bytes(fs,3));
                              bpm=nStyle.bpm;
                              if ((nStyle.bpm < 40 ) || (nStyle.bpm > 300))
                              {                            
                              nStyle.bpm=100;
                              bpm=100;
                              }
                              break; 
                             }

                           if (tipo == 0x06)
                           {
                             velo = leer_delta(fs);
                             bzero(chtemp,sizeof(chtemp));
                             for (i=0; i<velo; i++) chtemp[i] = leer_bytes(fs,1);
                             char *pepa = chtemp;
                             if (strcmp (pepa , "SInt") == 0) ya=1;
                             if (ya)
                             { 
                             strcpy(nStyle.Pattern[numpa].Name,chtemp);
                             nStyle.Pattern[numpa].start= TTdelta;
                             if (numpa > 0 )
                             {
                             nStyle.Pattern[numpa-1].stop = TTdelta;
                             nStyle.Pattern[numpa-1].bars = (nStyle.Pattern[numpa-1].stop - nStyle.Pattern[numpa-1].start) / (nStyle.ppq * nStyle.nominador / ajusta);
                             }
                            numpa++;
                             }
                            break;
                            }

                          }

                        velo = leer_delta(fs);
                        nota = leer_bytes(fs,velo);
                        break;


            }


}
}

int ajusta=1;
switch(nStyle.denominator)
{
 case 2:
    ajusta=1;
    break;
 case 3:
    ajusta=2;
    break;
 case 4:
    ajusta=4;
}

if (numpa > 0)
{
	nStyle.Pattern[numpa-1].stop = TTdelta;
	nStyle.Pattern[numpa-1].bars = (nStyle.Pattern[numpa-1].stop - nStyle.Pattern[numpa-1].start)/ (nStyle.ppq*nStyle.nominador / ajusta);

}

else
{
	numpa = 1;
	nStyle.Pattern[numpa].start=0;
	strcpy(nStyle.Pattern[numpa].Name,"All");
	nStyle.Pattern[numpa].stop = DeltaMayor;
	nStyle.Pattern[numpa].bars = DeltaMayor / (nStyle.ppq*nStyle.nominador / ajusta);
	nStyle.Pattern[0].bars=0;
	nStyle.Pattern[0].start=0;
	nStyle.Pattern[0].stop =0;

}


nStyle.numpat=numpa;


// leer CASM

i=0;

while( i == 0  )

    {
    i=leer_bytes(fs,1);

    }
  ungetc(i,fs);

  if (CASM  != leer_bytes(fs ,4))

{

	printf("No CASM section found, thst's really bad\n");

	memset (&C ,0 ,sizeof C);

	for (i=0; i<=numpa; i++)
	{
		for (j=0; j<=15; j++)
		{
			C.track=j;
			sprintf(C.Name,"Track %d",j); 
			C.Canal=j;
			if (j<6) C.Canal=10+j;
			if ((j>5) && (j<9)) C.Canal=j+4;
			C.ReadOnly=1;
			C.NoteMute1=0x0f;
			C.NoteMute0=0xff;
			C.ChMute4=0x03;
			C.ChMute3=0xff;
			C.ChMute2=0xff;
			C.ChMute1=0xff;
			C.ChMute0=0xff;
			C.ChRoot=0;
			C.ChType=2;
			C.NTR=1;
			if (j==9) C.NTT=0; else C.NTT=2;
			C.HKey=7;
			C.LLim=0;
			C.HLim=0x7f;
			C.RTR=1;
			memset(C.u, 0 ,sizeof C.u);
			C.ChM = 0;
			C.ChM <<= 8; C.ChM |= C.ChMute4;
			C.ChM <<= 8; C.ChM |= C.ChMute3;
			C.ChM <<= 8; C.ChM |= C.ChMute2;
			C.ChM <<= 8; C.ChM |= C.ChMute1;
			C.ChM <<= 8; C.ChM |= C.ChMute0;
			nStyle.Pattern[i].casm[j] = C;
			nStyle.Pattern[i].numcasm=16;
		}
	}
	printf("I try to generate a CASM section\n");
}

else

{
	int dato;
	int casml;
	int csegl;
	int sdecl;
	int ctabl;
	int cnttl;
	char temp[16000];
	char  temp2[16000];
	int ncomas=0;
	int cnumpat=0;
	int sigo=0;
	int k=0;
	char *ptemp;
	memset (&C ,0 ,sizeof C);
	cMidiRead=0;
	casml=leer_bytes(fs,4);


	while (sigo == 0 )
	{
      		dato = leer_bytes(fs,4);
 		switch (dato)

		 {
		        case CSEG:
		        csegl=leer_bytes(fs,4);
		        break;

		        case Sdec:
        		ncomas=0;
        		sdecl = leer_bytes(fs,4);
        		bzero(temp,sizeof(temp));
        		for(i=0; i<sdecl; i++) 
        		{
        			temp[i]=leer_bytes(fs,1);
        			if (temp[i] == 0x2c ) ncomas++;
        		}
                        break;
 
		        case Cntt:
        		cnttl=leer_bytes(fs,4);
        		leer_bytes(fs,cnttl);
		        break;
 
		        case Ctab:
		        ctabl = leer_bytes(fs,4);
        		C.track=leer_bytes(fs,1);
        		for(i=0; i<8; i++) C.Name[i]=leer_bytes(fs,1);
        		C.Canal=leer_bytes(fs,1);
        		C.ReadOnly=leer_bytes(fs,1);
        		C.NoteMute1=leer_bytes(fs,1);
        		C.NoteMute0=leer_bytes(fs,1);
        		C.ChMute4=leer_bytes(fs,1);
        		C.ChMute3=leer_bytes(fs,1);
        		C.ChMute2=leer_bytes(fs,1);
        		C.ChMute1=leer_bytes(fs,1);
        		C.ChMute0=leer_bytes(fs,1);
        		C.ChRoot=leer_bytes(fs,1);
        		C.ChType=leer_bytes(fs,1);
        		C.NTR=leer_bytes(fs,1);
        		C.NTT=leer_bytes(fs,1);
        		C.HKey=leer_bytes(fs,1);
        		C.LLim=leer_bytes(fs,1);
        		C.HLim=leer_bytes(fs,1);
        		C.RTR=leer_bytes(fs,1);
        		i=26;
        		while (i < ctabl)
        		{
        			C.u[i-26]=leer_bytes(fs,1);
        			i++;
        		} 
        		C.ChM = 0;
        		C.ChM <<= 8; C.ChM |= C.ChMute4;
        		C.ChM <<= 8; C.ChM |= C.ChMute3;
        		C.ChM <<= 8; C.ChM |= C.ChMute2;
        		C.ChM <<= 8; C.ChM |= C.ChMute1;
        		C.ChM <<= 8; C.ChM |= C.ChMute0;

		        // Aqui poner los Tabs a sitio


		        k=0;
        		strcpy(temp2,temp);
        		ptemp= temp2;
        		cnumpat = bpn(strtok(temp2,","));
        		nStyle.Pattern[cnumpat].casm[nStyle.Pattern[cnumpat].numcasm] = C;
        		nStyle.Pattern[cnumpat].numcasm++;
		        while (k < ncomas)
        		{
        			cnumpat = bpn(strtok(NULL,","));
        			nStyle.Pattern[cnumpat].casm[nStyle.Pattern[cnumpat].numcasm] = C;
        			nStyle.Pattern[cnumpat].numcasm++;
        			k++;
        		}
		        break;
		        default:
        		sigo=1;
		}
	}
}




fclose(fs);

//Ordena

if (MFormato==1)
{
	printf("Rearranging Pattern\n");
	for (i=1; i<grabaconta; i++)
  	{
  		for (j=0; j<grabaconta -1; j++)
     		{

			if (EG[j].tick > EG[j+1].tick) 
			{
				tempEG = EG[j];
                 		EG[j] = EG[j+1];
                 		EG[j+1] = tempEG;
		 	}

		}
	}

}



// Prepara mixer de patron


ponbasemix();

// Separa patrones


for(i=0; i<=numpa; i++)
        {

        unsigned int min=nStyle.Pattern[i].start;
        unsigned int max=nStyle.Pattern[i].stop;
        int jj = 0;


        for (j=0; j<grabaconta; j++)
                {

                if ((EG[j].tick >= min) && (EG[j].tick < max) && (jj<6000))

                      {
                      if ((EG[j].tick+EG[j].length) > max) EG[j].length=(max - EG[j].tick) -10;
                      PEG[i][jj] = EG[j];
                      PEG[i][jj].tick = PEG[i][jj].tick - min;
                      jj++;
                      }
                 }

          if (jj >= 6000) printf("Pattern %d is too large\n",i);
          nStyle.Pattern[i].eventos=jj;
          ponmixpattern(i);

         }


return(0);

}

else return(1);

};
Ejemplo n.º 5
0
 FL_EXPORT_C(const char*,flc_filename_name)(const char* filename){
   return fl_filename_name(filename);
 }