void CL_PNGProvider_Generic::init()
{
	//setting up PNGLIB stuff
	png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
	
	if (!png_ptr) 
		throw CL_Error ("CL_PNGProvider_Generic: png_create_read_struct() failed");
	
	info_ptr = png_create_info_struct(png_ptr);

	if (!info_ptr)
	{
		png_destroy_read_struct(&png_ptr, (png_infopp) NULL, (png_infopp) NULL);
		throw CL_Error ("CL_PNGProvider_Generic: png_create_info_struct() failed");
	}

	end_info = png_create_info_struct(png_ptr);

	if (!end_info)
	{
		png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
		cl_assert(false);
	}   
	if (setjmp(png_ptr->jmpbuf))
	{
		png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
		cl_assert(false);
	}  
	
	cl_assert(provider != NULL);
	input_source = provider->open_source(filename);
	cl_assert(input_source!=NULL);

	// tell libpng form whom it get the fileData
	png_set_read_fn(png_ptr, this, &CL_PNGProvider_Generic::pngread_file);

	// reading the header infos and actually read data ...
	read_data();

	// remove our data_provider from libpng
	png_set_read_fn(png_ptr,NULL,NULL);

	// free memory ...
	png_destroy_read_struct(&png_ptr, &info_ptr,&end_info);

	delete input_source;


	// this could be integrated better, but I'm too tired, so I just hack CL_PixelBuffer
	// support into it. -- mbn 21. feb 2002

	CL_PixelBuffer_Generic::format.enable_colorkey(uses_src_colorkey());
	CL_PixelBuffer_Generic::format.set_colorkey(get_src_colorkey());
	CL_PixelBuffer_Generic::pitch = get_pitch();
	CL_PixelBuffer_Generic::width = get_width();
	CL_PixelBuffer_Generic::height = get_height();
	if (is_indexed()) CL_PixelBuffer_Generic::format.set_type(pixelformat_index);
}
示例#2
0
GnashVaapiImage::GnashVaapiImage(boost::shared_ptr<VaapiSurface> surface, ImageType type)
    : GnashImage(NULL, surface->width(), surface->height(), get_pitch(surface->width(), type),
                 type, GNASH_IMAGE_GPU)
    , _surface(surface)
    , _creation_time(get_ticks_usec())
{
    log_debug("GnashVaapiImage::GnashVaapiImage(): surface 0x%08x, size %dx%d\n",
          _surface->get(), _width, _height);
}
示例#3
0
GnashVaapiImage::GnashVaapiImage(const GnashVaapiImage& o)
    : GnashImage(NULL, o.width(), o.height(), get_pitch(o.width(), o.type()),
                 o.type(), GNASH_IMAGE_GPU)
    , _surface(o.surface())
    , _creation_time(get_ticks_usec())
{
    log_debug("GnashVaapiImage::GnashVaapiImage(): VA image %p\n", &o);

    update(o);
}
UStatus
uas_orientation_event_get_pitch(
    UASOrientationEvent* event,
    float* value)
{
    if (event == NULL || value == NULL)
        return U_STATUS_ERROR;

    auto ev = static_cast<ubuntu::application::sensors::OrientationEvent*>(event);
    *value = ev->get_pitch();

    return U_STATUS_SUCCESS;
}
示例#5
0
char *parse_note_string(char *ptr, struct defaults *def, struct note *note){
  char len_string[3];
  char pitch_string[3];
  char octave_string[2];
  char dot[2];

  // eat whitespace / commas and advance the pointer
  char* dummy = malloc(strlen(ptr)+1);
  if (dummy == NULL){ error("malloc failed");}
  dummy[0] = '\0';
  sscanf(ptr,"%[ ,]",dummy);
  ptr += strlen(dummy);
  free(dummy);

  DEBUG&&printf("Begin Parsing Note String...\n");
  ptr = get_len(ptr, len_string, def->len);
  DEBUG&&printf("get_len Successful...\n");
  ptr = get_pitch(ptr, pitch_string);
  DEBUG&&printf("get_pitch Successful...\n");
  ptr = get_octave(ptr, octave_string, def->oct);
  DEBUG&&printf("get_octave Successful...\n");
  ptr = get_dot(ptr, dot);
  DEBUG&&printf("get_dot Successful...\n");

  strcpy(note->pitch, pitch_string);
  sscanf(len_string, "%d", &(note->length));
  sscanf(octave_string, "%d", &(note->octave));

  note->divisor = calc_divisor(pitch_string, octave_string);
  DEBUG&&printf("divisor successful\n");

  note->cycles = calc_cycles(def, len_string, dot);
  DEBUG&&printf("cycles successful\n");

  return ptr;
}
示例#6
0
文件: player.c 项目: cooper6581/dplay
static void update_row(struct Player *p, 
                        struct Module *m, unsigned long count)
{
  // current row
  struct PatternData *cr = p->pos;
  // index for each channel used for freq playback
  // calculate the freq ratio for each channel
  for(int i = 0 ; i < p->num_channels; i++) {
    // ONLY RESET PITCH IF THERE IS A PERIOD VALUE AND PORTA NOT SET
    if(cr[i].period != 0 && cr[i].effect !=3) {
      p->channels[i].pitch = get_pitch(p->channels[i].sample, cr[i].period);
      p->channels[i].note = cr[i].period;
      // ONLY RESET SAMPLE IF THERE IS A PERIOD VALUE
      p->channels[i].offset = 0;
      p->channels[i].played = 0;
    }
    // clear the channel effects
    p->channels[i].effect = 0;
    p->channels[i].eparam = 0;

    // ONLY RESET VOLUME IF THERE IS AN INSTRUMENT NUMBER
    if(cr[i].sample_number != 0) {
      // first let's set the sample
      p->channels[i].sample = &m->samples[cr[i].sample_number-1];
      p->channels[i].volume = p->channels[i].sample->volume / 64.0;
    }
    switch (cr[i].effect) {
    // These effects require processing each tick
    //////////////////////////////////////////////
    // Arpeggio
    case 0x00:
    // Porta up
    case 0x01:
    // Porta down
    case 0x02:
    // Porta to note
    case 0x03:
    // Vibrato
    case 0x04:
    // Volume slide
    case 0x0A:
      p->channels[i].effect = cr[i].effect;
      p->channels[i].eparam = cr[i].eparam;
      break;
     // These effects require processing each row
     ////////////////////////////////////////////
    // Set volume 
    case 0xc:
      if (cr[i].eparam > 64)
	cr[i].eparam = 64;
      p->channels[i].volume = cr[i].eparam / 64.0;
      break;
    // Pattern break
    case 0xd:
      p->p_break = 1;
      get_xy(cr[i].eparam, &p->p_break_x, &p->p_break_y);
      break;
    case 0xe:
      printf("Effect 14: %d\n", cr[i].eparam);
      break;
    // Set speed
    case 0xf: {
      int x = 0;
      int y = 0;
      get_xy(cr[i].eparam, &x, &y);
      int z = x * 16 + y;
      if (z < 32)
	p->speed = z;
      // XXX set bpm
      else {
	p->rate = bpm_to_rate(cr[i].eparam);
	printf("Set rate to %ld\n", p->rate);
      }
      break;
    }
    default:
      ;
      //printf("Effect %d not implemented\n", cr[i].effect);
    }
  }
}
示例#7
0
文件: player.c 项目: cooper6581/dplay
// TODO:  SO insanely ghetto
// This function is used to update effects that need to update each tick
static void update_tick(struct Player *p)
{
  //printf("Tick: %d\n", p->ticks);
  for (int c = 0; c < p->num_channels; c++) {
    struct Channel *cn = &p->channels[c];
    int ex = 0;
    int ey = 0;
    get_xy(cn->eparam, &ex, &ey);
    // check for arp
    if (cn->effect == 0 && cn->eparam != 0) {
      if (cn->note == 0)
	break;
      switch(p->ticks % 3) {
      case 0:
	cn->pitch = get_pitch(cn->sample, cn->note);
	break;
      case 1:
	cn->pitch = get_pitch(cn->sample, cn->note + (ey * 16));
	break;
      case 2:
	cn->pitch = get_pitch(cn->sample, cn->note + (ex * 16));
	break;
      default:
	break;
      }
    }
    // volume slide
    else if (cn->effect == 10 && cn->eparam != 0) {
      if (ex > 0 || (ex > 0 && ey > 0)) {
	float res = (float) ex * (p->ticks - 1);
	float test = cn->volume * 64.0 + res;
	if (test <= 64)
	  cn->volume += res / 64.0;
	else
	  cn->volume = 1.0;
      } else {
	float res = (float) ey * (p->ticks - 1);
	float test = cn->volume * 64.0 - res;
	if (test > 0)
	  cn->volume -= res / 64.0;
	else
	  cn->volume = 0;
      }
    }
    // porta up
    else if (cn->effect == 1) {
      // don't run effect for the first tick
      //if (p->ticks) {
	int b3 = note_from_period(113);
	cn->note += cn->eparam;
	if (cn->note > b3)
	  cn->note = b3;
	cn->pitch = get_pitch(cn->sample, cn->note);
	//}
    }
    // porta down
    else if (cn->effect == 2) {
      // don't run effect for the first tick
      if (p->ticks) {
	int c1 = note_from_period(856);
	cn->note -= cn->eparam;
	if (cn->note < c1)
	  cn->note = c1;
	cn->pitch = get_pitch(cn->sample, cn->note);
      }
    }
    // Porta slide
    else if (cn->effect == 3) {
      if (p->ticks == 0) {
	// we need to read the previous row
	struct PatternData *cr = p->pos - 4;
	if (cn->eparam)
	  p->porta_speed[c] = cn->eparam;
	if (cr[c].period)
	  p->note_to_porta_to[c] = cr[c].period;
	//return;
      }
      if (p->note_to_porta_to[c] > cn->note) {
	cn->note += p->porta_speed[c];
	if (cn->note >= p->note_to_porta_to[c])
	  cn->note = p->note_to_porta_to[c];
	cn->pitch = get_pitch(cn->sample, cn->note);
      }
      else if (p->note_to_porta_to[c] < cn->note) {
	cn->note -= p->porta_speed[c];
	if (cn->note <= p->note_to_porta_to[c])
	  cn->note = p->note_to_porta_to[c];
	cn->pitch = get_pitch(cn->sample, cn->note);
      }
    }
    // Vibrato
    else if (cn->effect == 4) {
      if (p->ticks == 0) {
	cn->vibrato_pos = 0;
	return;
      }
      if (ey)
	cn->vibrato_depth = ey;
      if (ex)
	cn->vibrato_speed = ex;
      int sin_value = sine_table[abs(cn->vibrato_pos)];
      int delta = (sin_value * cn->vibrato_depth) / 128;
      if (cn->vibrato_pos < 0)
	cn->pitch = get_pitch_delta(cn->sample,cn->note,delta);
      else
	cn->pitch = get_pitch_delta(cn->sample,cn->note, -delta);
      cn->vibrato_pos += cn->vibrato_speed;
      if (cn->vibrato_pos > 31)
	cn->vibrato_pos -= 63;
    }
  }
}