Beispiel #1
0
void PixelBufferClass::LayerInfo::calculateMask(const std::string &type, bool mode) {
    switch (DecodeType(type)) {
        case 1:
            createWipeMask(mode);
            break;
        case 2:
            createClockMask(mode);
            break;
        case 3:
            createFromMiddleMask(mode);
            break;
        case 4:
            createSquareExplodeMask(mode);
            break;
        case 5:
            createCircleExplodeMask(mode);
            break;
        case 6:
            createBlindsMask(mode);
            break;
        case 7:
            createBlendMask(mode);
            break;
        case 8:
            createSlideChecksMask(mode);
            break;
        case 9:
            createSlideBarsMask(mode);
            break;
        default:
            break;
    }
}
Beispiel #2
0
void MusicEffect::Render(RenderBuffer &buffer,
    int bars, const std::string& type,
    int sensitivity, bool scale,
    const std::string& scalenotes, int offsetx,
    int startnote, int endnote,
    const std::string& colourtreatment,
    bool fade)
{
    // no point if we have no media
    if (buffer.GetMedia() == NULL)
    {
        return;
    }

    int nType = DecodeType(type);
    int nTreatment = DecodeColourTreatment(colourtreatment);
    int nScaleNotes = DecodeScaleNotes(scalenotes);

    // Grab our cache
    MusicRenderCache *cache = (MusicRenderCache*)buffer.infoCache[id];
    if (cache == nullptr) {
        cache = new MusicRenderCache();
        buffer.infoCache[id] = cache;
    }
    int &_bars = cache->_bars;
    int &_startNote = cache->_startNote;
    int &_endNote = cache->_endNote;
    int &_type = cache->_type;
    int &_offsetx = cache->_offsetx;
    bool &_scale = cache->_scale;
    int &_sensitivity = cache->_sensitivity;
    int &_scalenotes = cache->_scalenotes;
    bool &_fade = cache->_fade;
    int& _colourTreatment = cache->_colourTreatment;
    std::vector<std::list<MusicEvent*>*>& _events = cache->_events;

    int actualbars = std::min(bars, std::min(endnote - startnote + 1, buffer.BufferWi - offsetx));
    int notesperbar = (endnote - startnote + 1) / actualbars;
    int actualendnote = startnote + std::min(endnote, actualbars * notesperbar);
    int lightsperbar = 0.5 + (float)(buffer.BufferWi - offsetx) / (float)actualbars;

    // Check for config changes which require us to reset
    if (buffer.needToInit || _bars != bars || _type != nType || _startNote != startnote || 
        _endNote != endnote || _offsetx != offsetx || _scale != scale || 
        _scalenotes != nScaleNotes || _sensitivity != sensitivity || _colourTreatment != nTreatment || _fade != fade)
    {
        buffer.needToInit = false;
        _bars = bars;
        _fade = fade;
        _startNote = startnote;
        _endNote = endnote;
        _colourTreatment = nTreatment;
        _type = nType;
        _offsetx = offsetx;
        _scale = scale;
        _sensitivity = sensitivity;
        _scalenotes = nScaleNotes;
        cache->ClearEvents();
        // We limit bars to the width of the model less the x offset

        CreateEvents(buffer, _events, _startNote, actualendnote, actualbars, _scalenotes, _sensitivity);
    }

    int per = 1;
    if (_scale)
    {
        per = lightsperbar;
    }

    try
    {
        for (int x = 0; x < _events.size(); x++)
        {
            for (int i = 0; i < per; i++)
            {
                switch (_type)
                {
                case 1:
                    RenderMorph(buffer, (x*per) + i + _offsetx, _bars, _startNote, _endNote, *_events[x], _colourTreatment, false, fade);
                    break;
                case 2:
                    RenderMorph(buffer, (x*per) + i + _offsetx, _bars, _startNote, _endNote, *_events[x], _colourTreatment, true, fade);
                    break;
                case 3:
                    RenderCollide(buffer, (x*per) + i + _offsetx, _bars, _startNote, _endNote, true /* collide */, *_events[x], _colourTreatment, fade);
                    break;
                case 4:
                    RenderCollide(buffer, (x*per) + i + _offsetx, _bars, _startNote, _endNote, false /* uncollide */,* _events[x], _colourTreatment, fade);
                    break;
                case 5:
                    RenderOn(buffer, (x*per) + i + _offsetx, _bars, _startNote, _endNote, *_events[x], _colourTreatment, fade);
                    break;
                }
            }
        }
    }
    catch (...)
    {
        // This is here to let me catch any exceptions and stop the exception causing the render thread to die
        //int a = 0;
    }
}
Beispiel #3
0
char *WriteSeq(    char *outSpec,  /* Output sequence spec              */
               SeqEntry *seq,      /* Seq Entry data structure          */
                    int  format)   /* Output format                     */
{

#define SIZE   255    /* String size                         */

char line[SIZE], header[SIZE], code[SIZE], testCode[SIZE];
char outFName[SIZE];

char *cPos, *pStrand;

int lineSize, blockSize;
int count, nOut;

Boolean twoFiles;
Boolean doText;
char errMsg[SIZE];

static char outFileName[SIZE];    /* Static because it's the return value */

FILE *outFile, *inFile;


/*
** Process available text for formats which allow freely formated text.
*/

	switch ( format ) {
	  case PIR:
	  case GCG:
	    doText = (seq->text != NULL); break;
	  default:
	    doText = 0; break;
	}

/*
** Set LineSize and BlockSize for variou formats
*/
	switch ( seq->spec->format ) {
	  case GCG:
	    lineSize = 50; blockSize= 10; break;
	  case PIR:
	  case IBI:
	    lineSize = 60; blockSize = 10; break;
	  case  IG:
	  case STRIDER:
	  default:
	    lineSize = blockSize= 80;
	}
/*
** Extract the the code from OutSpec for multi-entry files. If OutSpec just 
** has a filename then strip off the extension and use the filename as the code.
** Filenames are to the right of the equals.  
** N.B. does not yet support pathnames.
**
**    Outspec will look like either:
**
**                code=filename.ext     OR    filename.ext
*/

	if ( (cPos = strchr(outSpec,';')) ) *cPos = '\0'; /* Remove version */

	strcpy(code,outSpec);
	if ( (cPos = strchr(code,'=')) ) *cPos = '\0'; /* code=filename.ext */
	if ( (cPos = strchr(code,'.')) ) *cPos = '\0'; /* filename.ext */
	StrToUpper(code);
	strcpy(outFName,outSpec);
	if ( (cPos = strchr(outFName,'=')) ) strcpy(outFName, ++cPos);

/*
**  Are we dealing with a new or old sequence file?  Test for an existing
**  file set "twoFiles" flag accordingly.
*/

	if ( (inFile = fopen(outFName, "r")) ) {
	  if ( !(outFile = fopen(outFName, "w")) ) goto Error;
	  twoFiles = 1;
	} else {
	  if ( !(outFile = fopen(outFName, "w")) ) goto Error;
	  twoFiles = 0;
	}

/*
** Do what needs to be done to prepare the file for writing or over-writing
** the new sequence data.
**
**  PIR    - create header, read into filename until we find the entry to
**           replace or reach EOF. Save existing text if there is no new text.
**
**  IG     - Save any lines beginning with ";" these are comment characters.
**           Write out codeword.  Generate circular/linear flag.
**
**  STADEN - Translate symbols from IUPAC to STADEN, append end of sequence
**           character, "@".
**
**  GCG    - Save all text at the top of the file up to but not including the
**           line with ".." in it, unless we have new text. Convert "-"'s to
**           "."'s.  Recalculate CheckSum.  Write a new GCG descriptor line.
**
**  IBI    - Rewrite the LOCUS line and ORIGIN line.
**
**  STRIDER- Write out strider header line and sequnce title.
**
**  RAWSEQ - Do nothing.
*/

	switch ( format ) {

	  case PIR:
	    strcpy(header, ">");
	    switch (seq->type ) {
	      case  PROTEIN: strcat(header,"P1;"); break;
	      case FRAGMENT: strcat(header,"F1;"); break;
	      case      DNA: 
	        seq->circular ? strcat(header,"DC;"):strcat(header,"DL;") ; break;
	      case      RNA:
	        seq->circular ? strcat(header,"RC;"):strcat(header,"RL;") ; break;
	      case     RRNA: strcat(header,"N1;"); break;
	      case     TRNA: strcat(header,"N3;"); break;
	            default: strcat(header,"XX;"); break;
	    }
	    strcat(header, code);

	    /* 
	    ** Read in/out until the beginning of entry to be overwritten
	    **  or End of File.
	    */
	    
	    if ( twoFiles ) {
	      testCode[0] = '\0';
	      while ( fgets(line, 255, inFile) ) {
	        if( line[0] == '>') {
	          strcpy(testCode, &line[4]);
	          if ( (cPos = strchr(testCode, '\n')) ) *cPos = '\0';
	          StrToUpper(StrCollapse(testCode));
	          if( strcmp(testCode,code) == 0 ) break;
	        }  
                fputs(line,outFile);
	      }
	    }

	    /* 
	    **  Write out the header and title lines.
	    */

	    fprintf(outFile,"%s\n", header);
	    fprintf(outFile,"%s\n", seq->title);
	    break;

	/****************************************************************/

	  case IG:
	  /*
	  **  For IG format save any lines beginning with ";" these
	  **  are comment characters
	  */
	    if ( twoFiles && !doText ) {
	      while ( fgets(line, 255, inFile) ) {
	        if ( line[0] != ';' )  break;
                fputs(line,outFile);
	      }
	    } else if ( doText ) {
	      if ( seq->text ) fputs(seq->text,outFile);
	    } else
	      fprintf(outFile, "; %s\n; %s\n", seq->title,seq->desc);

	    fprintf(outFile, "%s\n", code);
	    break;

	/****************************************************************/

	   case STADEN:
	    if (seq->type >= DNA ) {
	      StrChange(seq->mem,'M','5');
	      StrChange(seq->mem,'K','6');
	      StrChange(seq->mem,'W','7');
	      StrChange(seq->mem,'S','8');
	      StrChange(seq->mem,'m','5');
	      StrChange(seq->mem,'k','6');
	      StrChange(seq->mem,'w','7');
	      StrChange(seq->mem,'s','8');
	    }
	    break;

	/****************************************************************/

	  case GCG:
	    if ( twoFiles && !doText ) {
	      while ( fgets(line, 255, inFile) ) {
	        if ( StrIndex("..",line) )  break;
                fputs(line,outFile);
	      }
	    } else if ( doText ) {
	        if ( seq->text ) fputs(seq->text,outFile);
	    } else
	      fprintf(outFile, "  %s\n  %s\n\n", seq->title,seq->desc);

	    StrChange(seq->mem,'-','.');
	    seq->checkSum = CheckSum(seq->mem);
	    fprintf(outFile, "  %s  Length: %ld  %s  Check: %d ..\n",
	            outFName, seq->length, GetTime(3), seq->checkSum);
	    fprintf(outFile,"        1 ");
	    break;
	  
	/****************************************************************/

	  case IBI:
	    fprintf(outFile,
	      "LOCUS       %s         %ld BP           UPDATED  %s\n",
	       code, seq->length, GetTime(0));
	    if ( twoFiles && !doText ) {
	      while ( fgets(line, 255, inFile) ) {
	        if ( StrIndex("LOCUS",line) ) continue;
	        if ( StrIndex("ORIGIN",line) )  break;
                fputs(line,outFile);
	      }
	    } else if ( doText && seq->text ) {
	      if ( (cPos = StrIndex("LOCUS     ",seq->text)) )
	        strcpy(seq->text,strchr(cPos,'\n'));
	      if ( (cPos = StrIndex("\nORIGIN",seq->text)) )
	        *cPos = '\0';
	      fputs(seq->text,outFile);
	    }
	    fprintf(outFile, "ORIGIN      %s\n", seq->title);
	    fprintf(outFile,"        1 ");
	    break;

	/****************************************************************/

	   case STRIDER:
	    fprintf(outFile,"; ### from DNA Strider  %s\n",GetTime(3));
	    fprintf(outFile,"; %s sequence  %s length %ld",
	      DecodeType(seq->type),seq->name,seq->length);
	    if ( seq->type <= PROTEIN )
	      fprintf(outFile," a.a. complete sequence\n; %s\n",seq->title);
	    else
	      fprintf(outFile," n.a. complete sequence\n; %s\n",seq->title);
	    break;

	/****************************************************************/

	  case RAWSEQ:
	  default:
	    break;

	}
/*
**  Write the sequence in Block/Line size.  "NOut" counts the number 
**  of symbols written in each line.  Support GCG and IBI line numbering
**  schemes.
*/

	nOut = 0;
	count = 1;
	pStrand = seq->mem;
	while( *pStrand ) {
	  fprintf(outFile, "%c", *pStrand);
	  nOut++;
	  count++;
	  if ( nOut == lineSize ) {
	    switch ( format ) {
	      case IBI:
	      case GCG:
	       fprintf(outFile,"\n%9d ",count);
	       break;
	      default:
	       fprintf(outFile, "\n");
	    }
	    nOut=0;
	  } else 
	    if ( nOut%blockSize == 0 ) fprintf(outFile, " ");
	  pStrand++;
	}

/*
** Depending on the format we have some finishing up to do.
**
** PIR     - Add the End of sequence character. Read past the old sequence
**           form the original file. If "DoText" is true, write out the new 
**           text comments, skip over the comments in the old file, if any.
**           Finally, copy the balance of the old file into the new file.
**
** IBI     - Add sequence terminator "//"
**
** IG      - Append linear/circular flag at end of sequence.
**
** STRIDER - Add sequence terminator "//"
**
** STADEN  - Add end of sequence character. Convert sequence symbols back 
**           to IUPAC.
**
** GCG     - Convert "."'s back to "-"'s. Recalc CheckSum.
*/
	
	switch ( format ) {

	  case PIR:

	    fprintf(outFile,"*\n");

	    /* Skip over sequence in the old file */

	    if ( twoFiles )
	      while ( fgets(line, 255, inFile) )
	        if( strchr(line,'*' ) ) break;

	    /* Skip over old comments, if any. */

	    if ( doText ) {
	      if ( seq->text ) fputs(seq->text,outFile);
	      if ( twoFiles )
	        while ( fgets(line, 255, inFile) )
	          if( *line == '>' ) {
	            fputs(line,outFile);
	            break;
	          }
	    }

	    /* Copy the remainder of the file */

	    if ( twoFiles ) {
	      while ( fgets(line, 255, inFile) )
	        fputs(line, outFile);
	    }
	    break;

	/****************************************************************/

	  case IBI:
	    fprintf(outFile,"\n//");  
	    break;

	/****************************************************************/

	  case IG:
	    fprintf(outFile,"%c",seq->circular ? '2' : '1');
	    break;

	/****************************************************************/

	  case STRIDER:
	    fprintf(outFile,"\n//");  
	    break;

	/****************************************************************/

	  case STADEN:
	    fprintf(outFile,"@");  
	    if (seq->type >= DNA ) {
	      StrChange(seq->mem,'5','M');
	      StrChange(seq->mem,'6','K');
	      StrChange(seq->mem,'7','W');
	      StrChange(seq->mem,'8','S');
	    }
	    break;

	/****************************************************************/

	  case GCG:
	    StrChange(seq->mem,'.','-');
	    seq->checkSum = CheckSum(seq->mem);
	    break;
	}	

	/*	fgetname(outFile, outFileName); NO IDEA PUT strcopy to compile il*/
	strcpy(outFileName,outFName);

	fclose(outFile);
	if ( twoFiles ) fclose(inFile);

	return(outFileName);

/*
** The output file could not be created.  Set error message and return
**  NULL
*/

Error:
	sprintf(errMsg, "Output file \"%s\" could not be created.", outFName);
	PostError(2,errMsg);
	return(NULL);

} /* End of WriteSeq */