void constraints() {
      // Matt Austern's book puts DefaultConstructible here, the C++
      // standard places it in Container
      //    function_requires< DefaultConstructible<Sequence> >();
      function_requires< Mutable_ForwardContainerConcept<Sequence> >();
      function_requires< DefaultConstructibleConcept<Sequence> >();

      Sequence 
        c(n),
        c2(n, t),
        c3(first, last);

      c.insert(p, t);
      c.insert(p, n, t);
      c.insert(p, first, last);

      c.erase(p);
      c.erase(p, q);

      reference r = c.front();

      ignore_unused_variable_warning(c);
      ignore_unused_variable_warning(c2);
      ignore_unused_variable_warning(c3);
      ignore_unused_variable_warning(r);
      const_constraints(c);
    }
Exemple #2
0
 void const_constraints(const B& b) {
   const typename B::value_type& v = b.top();
   n = b.size();
   bool e = b.empty();
   ignore_unused_variable_warning(v);
   ignore_unused_variable_warning(e);
 }
Exemple #3
0
  Reference access(boost::type<Reference>,index idx,TPtr base,
                   const size_type* extents,
                   const index* strides,
                   const index* index_bases) const {

    ignore_unused_variable_warning(index_bases);
    ignore_unused_variable_warning(extents);
    BOOST_ASSERT(idx - index_bases[0] >= 0);
    BOOST_ASSERT(size_type(idx - index_bases[0]) < extents[0]);
    return *(base + idx * strides[0]);
  }
    void constraints() {
      function_requires< AssociativeContainerConcept<MultipleAssociativeContainer> >();

      MultipleAssociativeContainer c(first, last);
      
      pos = c.insert(t);
      c.insert(first, last);

      ignore_unused_variable_warning(c);
      ignore_unused_variable_warning(pos);
    }
Exemple #5
0
    void constraints()
    {
        gil_function_requires<ColorBaseConcept<P>>();
        gil_function_requires<PixelBasedConcept<P>>();

        static_assert(is_pixel<P>::value, "");
        static const bool is_mutable = P::is_mutable;
        ignore_unused_variable_warning(is_mutable);

        using value_type = typename P::value_type;
        // TODO: Is the cyclic dependency intentional? --mloskot
        // gil_function_requires<PixelValueConcept<value_type>>();

        using reference = typename P::reference;
        gil_function_requires<PixelConcept
            <
                typename detail::remove_const_and_reference<reference>::type
            >>();

        using const_reference = typename P::const_reference;
        gil_function_requires<PixelConcept
            <
                typename detail::remove_const_and_reference<const_reference>::type
            >>();
    }
inline void function_requires(mpl::identity<Concept>* = 0)
{
#if !defined(NDEBUG)
  void (Concept::*x)() = BOOST_FPTR Concept::constraints;
  ignore_unused_variable_warning(x);
#endif
}
Exemple #7
0
 void constraints() {
   b.push(t);
   b.pop();
   typename B::value_type& v = b.top();
   const_constraints(b);
   ignore_unused_variable_warning(v);
 }
    void const_constraints(const TT& b) {
      TT c(b);
#if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL
      a = b;              // const required for argument to assignment
#endif
      ignore_unused_variable_warning(c);
    }
    void constraints() {
      function_requires< SequenceConcept<BackInsertionSequence> >();

      c.push_back(t);
      c.pop_back();
      reference r = c.back();
      ignore_unused_variable_warning(r);
    }
    void constraints() {
      TT b(a);
#if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL
      a = a;              // require assignment operator
#endif
      const_constraints(a);
      ignore_unused_variable_warning(b);
    }
 void swap_ranges_impl(Iterator1 it1, Iterator1 last1,
                       Iterator2 it2, Iterator2 last2,
                       random_access_traversal_tag,
                       random_access_traversal_tag)
 {
     ignore_unused_variable_warning(last2);
     BOOST_ASSERT( last2 - it2 >= last1 - it1 );
     std::swap_ranges(it1, last1, it2);
 }
Exemple #12
0
    void constraints() {
      function_requires< ReadablePropertyGraphConcept<G, X, Property> >();
      function_requires< ReadWritePropertyMapConcept<Map, X> >();

      Map pmap = get(Property(), g);
      pval = get(Property(), g, x);
      put(Property(), g, x, pval);
      ignore_unused_variable_warning(pmap);
    }
Exemple #13
0
void EntityDescriptors_t::add(EntityDescriptorPointer bd) const
{
    assert(bd != nullptr);
    if(entitiesMap == nullptr)
        entitiesMap = new linked_map<wstring, EntityDescriptorPointer>();
    bool wasInserted = std::get<1>(entitiesMap->insert(make_pair(bd->name, bd)));
    ignore_unused_variable_warning(wasInserted);
    assert(wasInserted);
}
Exemple #14
0
void ItemDescriptors_t::add(ItemDescriptorPointer bd) const
{
    assert(bd != nullptr);
    if(itemsMap == nullptr)
        itemsMap = new linked_map<std::wstring, ItemDescriptorPointer>();
    bool wasInserted = std::get<1>(itemsMap->insert(make_pair(bd->name, bd)));
    ignore_unused_variable_warning(wasInserted);
    assert(wasInserted);
}
/*	Try to open a file for reading. If the filename ends in one of the 
 defined compressor extensions, pipe the file through the decompressor */
static FILE *try_to_open(char *name, int decompress, int noise_mode)
{
	ignore_unused_variable_warning(decompress, noise_mode);
	FILE *fp;

	fp=fopen(name, OPEN_MODE); /* First just check that the file exists */

	if (!fp)
		return 0;

#ifdef DECOMPRESSOR_LIST
	if (decompress)
	{
		int l,el;
		static char *decompressor_list[] = DECOMPRESSOR_LIST, **dec;
		char tmp[1024], tmp2[1024], *cp, *cp2;
		/* Check if it's a compressed file */ 
		l=strlen(name);
		for (dec=decompressor_list; *dec; dec+=2)
		{
			el=strlen(*dec);
			if ((el>=l) || (strcmp(name+l-el, *dec)))
				continue;

			/* Yes. Close the file, open a pipe instead. */
			fclose(fp);

			/* Quote some special characters in the file name */
			cp=name;
			cp2=tmp2;
			while (*cp)
			{
				switch(*cp)
				{
					case '\'':
					case '\\':
					case ' ':
					case '`':
					case '!':
					case '"':
					case '&':
					case ';':
						*cp2++='\\';
				}
				*cp2++=*cp++;
			}
			*cp2=0;

			sprintf(tmp, *(dec+1), tmp2);
			return popen(tmp, "r");
		}
	}
#endif

	return fp;
}
    void constraints() {
      function_requires< AssociativeContainerConcept<UniqueAssociativeContainer> >();
    
      UniqueAssociativeContainer c(first, last);
      
      pos_flag = c.insert(t);
      c.insert(first, last);

      ignore_unused_variable_warning(c);
    }
    void constraints() {
      function_requires< AssociativeContainerConcept<SortedAssociativeContainer> >();
      function_requires< ReversibleContainerConcept<SortedAssociativeContainer> >();

      SortedAssociativeContainer 
        c(kc),
        c2(first, last),
        c3(first, last, kc);

      p = c.upper_bound(k);
      p = c.lower_bound(k);
      r = c.equal_range(k);
      
      c.insert(p, t);
      
      ignore_unused_variable_warning(c);
      ignore_unused_variable_warning(c2);
      ignore_unused_variable_warning(c3);
    }
    void constraints() {
      function_requires< InputIteratorConcept<TT> >();
#ifndef BOOST_NO_STD_ITERATOR_TRAITS
      typedef typename std::iterator_traits<TT>::iterator_category C;
      function_requires< ConvertibleConcept<C, std::forward_iterator_tag> >();
      typedef typename std::iterator_traits<TT>::reference reference;
      reference r = *i;
      ignore_unused_variable_warning(r);
#endif
    }
Exemple #19
0
    void constraints()
    {
        gil_function_requires<Regular<P>>();

        using value_type = typename P::value_type;
        ignore_unused_variable_warning(value_type{});

        static const std::size_t N = P::num_dimensions;
        ignore_unused_variable_warning(N);
        using FT = typename P::template axis<0>::coord_t;
        using LT = typename P::template axis<N - 1>::coord_t;
        FT ft = gil::axis_value<0>(point);
        axis_value<0>(point) = ft;
        LT lt = axis_value<N - 1>(point);
        axis_value<N - 1>(point) = lt;

        //value_type v=point[0];
        //ignore_unused_variable_warning(v);
    }
    void constraints() {
      function_requires<
        RandomAccessContainerConcept<RandomAccessContainer> >();
      function_requires<
        Mutable_ReversibleContainerConcept<RandomAccessContainer> >();
      function_requires< Mutable_RandomAccessIteratorConcept<iterator> >();
      function_requires<
        Mutable_RandomAccessIteratorConcept<reverse_iterator> >();

      reference r = c[i];
      ignore_unused_variable_warning(r);
    }
 void swap_ranges_impl(Iterator1 it1, Iterator1 last1,
                       Iterator2 it2, Iterator2 last2,
                       single_pass_traversal_tag,
                       single_pass_traversal_tag)
 {
     ignore_unused_variable_warning(last2);
     for (; it1 != last1; ++it1, ++it2)
     {
         BOOST_ASSERT( it2 != last2 );
         std::iter_swap(it1, it2);
     }
 }
Exemple #22
0
void EntityDescriptors_t::remove(EntityDescriptorPointer bd) const
{
    assert(bd != nullptr);
    assert(entitiesMap != nullptr);
    size_t removedCount = entitiesMap->erase(bd->name);
    ignore_unused_variable_warning(removedCount);
    assert(removedCount == 1);
    if(entitiesMap->empty())
    {
        delete entitiesMap;
        entitiesMap = nullptr;
    }
}
Exemple #23
0
void ItemDescriptors_t::remove(ItemDescriptorPointer bd) const
{
    assert(bd != nullptr);
    assert(itemsMap != nullptr);
    size_t removedCount = itemsMap->erase(bd->name);
    ignore_unused_variable_warning(removedCount);
    assert(removedCount == 1);
    if(itemsMap->empty())
    {
        delete itemsMap;
        itemsMap = nullptr;
    }
}
Exemple #24
0
void setTerminationRequestHandler(std::function<void()> handler)
{
    if(handler != nullptr) // add exception handler
    {
        auto newHandler = [handler]() noexcept // noexcept handles calling std::terminate
        {
            handler();
        };
        handler = std::function<void()>(newHandler);
    }
    static int unused =
        initTerminateHandler(); // static so we initialize only once and in only one thread
    ignore_unused_variable_warning(unused);
    setOrGetTerminationHandlerFn(handler, true);
}
  void constraints() 
  {
    ST        seg;
    ST const  seg_c;

    typedef typename segment_traits<ST>::topology_type                       topology_type;

    typedef typename segment_traits<ST>::segment_key_iterator                segment_key_iterator;
    typedef typename segment_traits<ST>::segment_skey_iterator               segment_skey_iterator;
    typedef typename segment_traits<ST>::segment_vertex_quantity_iterator    vertex_key_iterator;
    typedef typename segment_traits<ST>::segment_edge_quantity_iterator      edge_key_iterator;
    typedef typename segment_traits<ST>::segment_facet_quantity_iterator     facet_key_iterator;
    typedef typename segment_traits<ST>::segment_cell_quantity_iterator      cell_key_iterator;


    typedef typename segment_traits<ST>::vertex_type    vertex_type;
    typedef typename segment_traits<ST>::edge_type      edge_type;
    typedef typename segment_traits<ST>::facet_type     facet_type;
    typedef typename segment_traits<ST>::cell_type      cell_type;
    
    typedef typename segment_traits<ST>::vertex_handle  vertex_handle;
    typedef typename segment_traits<ST>::edge_handle    edge_handle;
    typedef typename segment_traits<ST>::facet_handle   facet_handle;
    typedef typename segment_traits<ST>::cell_handle    cell_handle;

    typedef typename segment_traits<ST>::vertex_iterator vertex_iterator;
    typedef typename segment_traits<ST>::edge_iterator   edge_iterator;
    typedef typename segment_traits<ST>::facet_iterator  facet_iterator;
    typedef typename segment_traits<ST>::cell_iterator   cell_iterator;

    boost::function_requires< GSSETopologyConcept<topology_type> > ();

    // gsse segment concept checks

    // --------------------------
    // naming
    //
    std::string s;
    seg.set_name(s);
    s = seg_c.get_segment_name();


    // --------------------------
    // segment quantity key iterations
    //
    segment_key_iterator sk_it;
    sk_it = seg_c.segment_key_begin();
    sk_it = seg_c.segment_key_end();

    segment_skey_iterator ssk_it;
    ssk_it = seg_c.segment_skey_begin();
    ssk_it = seg_c.segment_skey_end();

    vertex_key_iterator vk_it;
    vk_it = seg_c.vertex_key_begin();
    vk_it = seg_c.vertex_key_end();

    edge_key_iterator ek_it;
    ek_it = seg_c.edge_key_begin();
    ek_it = seg_c.edge_key_end();

    facet_key_iterator fk_it;
    fk_it = seg_c.facet_key_begin();
    fk_it = seg_c.facet_key_end();

    cell_key_iterator ck_it;
    ck_it = seg_c.cell_key_begin();
    ck_it = seg_c.cell_key_end();


    // --------------------------
    // quantity key sizes
    //
    unsigned int size;

    size = seg_c.vertex_key_size();
    size = seg_c.edge_key_size();
    size = seg_c.facet_key_size();
    size = seg_c.cell_key_size();
    size = seg_c.segment_key_size();

    size = seg_c.vertex_size();
    size = seg_c.edge_size();
    size = seg_c.facet_size();
    size = seg_c.cell_size();


    // --------------------------
    // topological traversal
    //
    vertex_iterator vertex_it = seg_c.vertex_begin();
    vertex_it                 = seg_c.vertex_begin();

    edge_iterator edge_it     = seg.edge_begin();    // [RH][TODO] .. maybe we can a const segment as well 
    edge_it                   = seg.edge_begin();

    facet_iterator facet_it   = seg.facet_begin();
    facet_it                  = seg.facet_begin();

    cell_iterator cell_it     = seg_c.cell_begin();
    cell_it                   = seg_c.cell_begin();


//     boost::function_requires<GSSEIteratorConcept<edge_iterator> > ();
//     boost::function_requires<GSSEIteratorConcept<facet_iterator> > ();

    
    // --------------------------
    // topology retrieval
    //
    topology_type&       topo   = seg.retrieve_topology();
    topology_type const& topo_c = seg_c.retrieve_topology();

    ignore_unused_variable_warning(topo);
    ignore_unused_variable_warning(topo_c);
  }
/* 
 If panning or note_to_use != -1, it will be used for all samples,
 instead of the sample-specific values in the instrument file. 

 For note_to_use, any value <0 or >127 will be forced to 0.

 For other parameters, 1 means yes, 0 means no, other values are
 undefined.

 TODO: do reverse loops right */
static Instrument *load_instrument(char *name, int percussion,
                                   int panning, int amp, int note_to_use,
                                   int strip_loop, int strip_envelope,
                                   int strip_tail)
{
	ignore_unused_variable_warning(percussion);
	Instrument *ip;
	Sample *sp;
	FILE *fp;
	uint8 tmp[1024];
	int i,j,noluck=0;
#ifdef PATCH_EXT_LIST
	static const char *patch_ext[] = PATCH_EXT_LIST;
#endif

	if (!name) return 0;

	/* Open patch file */
	if ((fp=open_file(name, 1, OF_NORMAL)) == NULL)
	{
		noluck=1;
#ifdef PATCH_EXT_LIST
		/* Try with various extensions */
		for (i=0; patch_ext[i]; i++)
		{
			if (strlen(name)+strlen(patch_ext[i])<1024)
			{
				char path[1024];
				strcpy(path, name);
				strcat(path, patch_ext[i]);
				if ((fp=open_file(path, 1, OF_NORMAL)) != NULL)
				{
					noluck=0;
					break;
				}
			}
		}
#endif
	}

	if (noluck)
	{
		ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 
		          "Instrument `%s' can't be found.", name);
		return 0;
	}

	ctl->cmsg(CMSG_INFO, VERB_NOISY, "Loading instrument %s", current_filename);

	/* Read some headers and do cursory sanity checks. There are loads
	 of magic offsets. This could be rewritten... */

	if ((239 != fread(tmp, 1, 239, fp)) ||
	    (memcmp(tmp, "GF1PATCH110\0ID#000002", 22) &&
	     memcmp(tmp, "GF1PATCH100\0ID#000002", 22))) /* don't know what the
		 differences are */
	{
		ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: not an instrument", name);
		return 0;
	}

	if (tmp[82] != 1 && tmp[82] != 0) /* instruments. To some patch makers, 
		 0 means 1 */
	{
		ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 
		          "Can't handle patches with %d instruments", tmp[82]);
		return 0;
	}

	if (tmp[151] != 1 && tmp[151] != 0) /* layers. What's a layer? */
	{
		ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 
		          "Can't handle instruments with %d layers", tmp[151]);
		return 0;
	}

	ip=safe_Malloc<Instrument>();
	ip->samples = tmp[198];
	ip->sample = safe_Malloc<Sample>(ip->samples);
	for (i=0; i<ip->samples; i++)
	{

		uint8 fractions;
		sint32 tmplong;
		uint16 tmpshort;
		uint8 tmpchar;

#define READ_CHAR(thing) \
		if (1 != fread(&tmpchar, 1, 1, fp)) goto fail; \
		thing = tmpchar;
#define READ_SHORT(thing) \
		if (1 != fread(&tmpshort, 2, 1, fp)) goto fail; \
		thing = LE_SHORT(tmpshort);
#define READ_LONG(thing) \
		if (1 != fread(&tmplong, 4, 1, fp)) goto fail; \
		thing = LE_LONG(tmplong);

		skip(fp, 7); /* Skip the wave name */

		if (1 != fread(&fractions, 1, 1, fp))
		{
		fail:
			ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Error reading sample %d", i);
			for (j=0; j<i; j++)
				free(ip->sample[j].data);
			free(ip->sample);
			free(ip);
			return 0;
		}

		sp=&(ip->sample[i]);

		READ_LONG(sp->data_length);
		READ_LONG(sp->loop_start);
		READ_LONG(sp->loop_end);
		READ_SHORT(sp->sample_rate);
		READ_LONG(sp->low_freq);
		READ_LONG(sp->high_freq);
		READ_LONG(sp->root_freq);
		skip(fp, 2); /* Why have a "root frequency" and then "tuning"?? */

		READ_CHAR(tmp[0]);

		if (panning==-1)
			sp->panning = (tmp[0] * 8 + 4) & 0x7f;
		else
			sp->panning=static_cast<uint8>(panning & 0x7F);

		/* envelope, tremolo, and vibrato */
		if (18 != fread(tmp, 1, 18, fp)) goto fail; 

		if (!tmp[13] || !tmp[14])
		{
			sp->tremolo_sweep_increment=
				sp->tremolo_phase_increment=sp->tremolo_depth=0;
			ctl->cmsg(CMSG_INFO, VERB_DEBUG, " * no tremolo");
		}
		else
		{
			sp->tremolo_sweep_increment=convert_tremolo_sweep(tmp[12]);
			sp->tremolo_phase_increment=convert_tremolo_rate(tmp[13]);
			sp->tremolo_depth=tmp[14];
			ctl->cmsg(CMSG_INFO, VERB_DEBUG,
			          " * tremolo: sweep %d, phase %d, depth %d",
			          sp->tremolo_sweep_increment, sp->tremolo_phase_increment,
			          sp->tremolo_depth);
		}

		if (!tmp[16] || !tmp[17])
		{
			sp->vibrato_sweep_increment=
				sp->vibrato_control_ratio=sp->vibrato_depth=0;
			ctl->cmsg(CMSG_INFO, VERB_DEBUG, " * no vibrato");
		}
		else
		{
			sp->vibrato_control_ratio=convert_vibrato_rate(tmp[16]);
			sp->vibrato_sweep_increment=
				convert_vibrato_sweep(tmp[15], sp->vibrato_control_ratio);
			sp->vibrato_depth=tmp[17];
			ctl->cmsg(CMSG_INFO, VERB_DEBUG,
			          " * vibrato: sweep %d, ctl %d, depth %d",
			          sp->vibrato_sweep_increment, sp->vibrato_control_ratio,
			          sp->vibrato_depth);
		}

		READ_CHAR(sp->modes);

		skip(fp, 40); /* skip the useless scale frequency, scale factor
		 (what's it mean?), and reserved space */

		/* Mark this as a fixed-pitch instrument if such a deed is desired. */
		if (note_to_use!=-1)
			sp->note_to_use=static_cast<uint8>(note_to_use);
		else
			sp->note_to_use=0;

		/* seashore.pat in the Midia patch set has no Sustain. I don't
		 understand why, and fixing it by adding the Sustain flag to
		 all looped patches probably breaks something else. We do it
		 anyway. */

		if (sp->modes & MODES_LOOPING) 
			sp->modes |= MODES_SUSTAIN;

		/* Strip any loops and envelopes we're permitted to */
		if ((strip_loop==1) && 
		    (sp->modes & (MODES_SUSTAIN | MODES_LOOPING | 
		                  MODES_PINGPONG | MODES_REVERSE)))
		{
			ctl->cmsg(CMSG_INFO, VERB_DEBUG, " - Removing loop and/or sustain");
			sp->modes &=~(MODES_SUSTAIN | MODES_LOOPING | 
			              MODES_PINGPONG | MODES_REVERSE);
		}

		if (strip_envelope==1)
		{
			if (sp->modes & MODES_ENVELOPE)
				ctl->cmsg(CMSG_INFO, VERB_DEBUG, " - Removing envelope");
			sp->modes &= ~MODES_ENVELOPE;
		}
		else if (strip_envelope != 0)
		{
			/* Have to make a guess. */
			if (!(sp->modes & (MODES_LOOPING | MODES_PINGPONG | MODES_REVERSE)))
			{
				/* No loop? Then what's there to sustain? No envelope needed
				 either... */
				sp->modes &= ~(MODES_SUSTAIN|MODES_ENVELOPE);
				ctl->cmsg(CMSG_INFO, VERB_DEBUG, 
				          " - No loop, removing sustain and envelope");
			}
			else if (!memcmp(tmp, "??????", 6) || tmp[11] >= 100) 
			{
				/* Envelope rates all maxed out? Envelope end at a high "offset"?
				 That's a weird envelope. Take it out. */
				sp->modes &= ~MODES_ENVELOPE;
				ctl->cmsg(CMSG_INFO, VERB_DEBUG, 
				          " - Weirdness, removing envelope");
			}
			else if (!(sp->modes & MODES_SUSTAIN))
			{
				/* No sustain? Then no envelope.  I don't know if this is
				 justified, but patches without sustain usually don't need the
				 envelope either... at least the Gravis ones. They're mostly
				 drums.  I think. */
				sp->modes &= ~MODES_ENVELOPE;
				ctl->cmsg(CMSG_INFO, VERB_DEBUG, 
				          " - No sustain, removing envelope");
			}
		}

		for (j=0; j<6; j++)
		{
			sp->envelope_rate[j]=
				convert_envelope_rate(tmp[j]);
			sp->envelope_offset[j]= 
				convert_envelope_offset(tmp[6+j]);
		}

		/* Then read the sample data */
		sp->data = safe_Malloc<sample_t>(sp->data_length);
		if (1 != fread(sp->data, sp->data_length, 1, fp))
			goto fail;

		if (!(sp->modes & MODES_16BIT)) /* convert to 16-bit data */
		{
			sint32 i=sp->data_length;
			uint8 *cp=reinterpret_cast<uint8 *>(sp->data);
			uint16 *tmp,*new_dat;
			tmp=new_dat=safe_Malloc<uint16>(sp->data_length);
			while (i--)
				*tmp++ = static_cast<uint16>(*cp++) << 8;
			cp=reinterpret_cast<uint8 *>(sp->data);
			sp->data = reinterpret_cast<sample_t *>(new_dat);
			free(cp);
			sp->data_length *= 2;
			sp->loop_start *= 2;
			sp->loop_end *= 2;
		}
#ifndef TIMIDITY_LITTLE_ENDIAN
		else
			/* convert to machine byte order */
		{
			sint32 i=sp->data_length/2;
			sint16 *tmp=reinterpret_cast<sint16 *>(sp->data),s;
			while (i--)
			{ 
				s=LE_SHORT(*tmp);
				*tmp++=s;
			}
		}
#endif

		if (sp->modes & MODES_UNSIGNED) /* convert to signed data */
		{
			sint32 i=sp->data_length/2;
			sint16 *tmp = sp->data;
			while (i--)
				*tmp++ ^= 0x8000;
		}

		/* Reverse reverse loops and pass them off as normal loops */
		if (sp->modes & MODES_REVERSE)
		{
			sint32 t;
			/* The GUS apparently plays reverse loops by reversing the
			 whole sample. We do the same because the GUS does not SUCK. */

			ctl->cmsg(CMSG_WARNING, VERB_NORMAL, "Reverse loop in %s", name);
			reverse_data(sp->data, 0, sp->data_length/2);

			t=sp->loop_start;
			sp->loop_start=sp->data_length - sp->loop_end;
			sp->loop_end=sp->data_length - t;

			sp->modes &= ~MODES_REVERSE;
			sp->modes |= MODES_LOOPING; /* just in case */
		}

		/* If necessary do some anti-aliasing filtering  */

		if (antialiasing_allowed)
			antialiasing(sp,play_mode->rate);

#ifdef ADJUST_SAMPLE_VOLUMES
		if (amp!=-1)
			sp->volume=static_cast<float>((amp) / 100.0);
		else
		{
			/* Try to determine a volume scaling factor for the sample.
			 This is a very crude adjustment, but things sound more
			 balanced with it. Still, this should be a runtime option. */
			sint32 i=sp->data_length/2;
			sint16 maxamp=0,a;
			sint16 *tmp = sp->data;
			while (i--)
			{
				a=*tmp++;
				if (a<0) a=-a;
				if (a>maxamp)
					maxamp=a;
			}
			sp->volume=static_cast<float>(32768.0 / maxamp);
			ctl->cmsg(CMSG_INFO, VERB_DEBUG, " * volume comp: %f", sp->volume);
		}
#else
		if (amp!=-1)
			sp->volume=static_cast<double>(amp) / 100.0;
		else
			sp->volume=1.0;
#endif

		sp->data_length /= 2; /* These are in bytes. Convert into samples. */
		sp->loop_start /= 2;
		sp->loop_end /= 2;

		/* Then fractional samples */
		sp->data_length <<= FRACTION_BITS;
		sp->loop_start <<= FRACTION_BITS;
		sp->loop_end <<= FRACTION_BITS;

		/* Adjust for fractional loop points. This is a guess. Does anyone
		 know what "fractions" really stands for? */
		sp->loop_start |=
			(fractions & 0x0F) << (FRACTION_BITS-4);
		sp->loop_end |=
			((fractions>>4) & 0x0F) << (FRACTION_BITS-4);

		/* If this instrument will always be played on the same note,
		 and it's not looped, we can resample it now. */
		if (sp->note_to_use && !(sp->modes & MODES_LOOPING))
			pre_resample(sp);

#ifdef LOOKUP_HACK
		/* Squash the 16-bit data into 8 bits. */
		{
			uint8 *gulp,*ulp;
			sint16 *swp;
			int l=sp->data_length >> FRACTION_BITS;
			gulp=ulp=safe_Malloc<uint8>(l+1);
			swp=(sint16 *)sp->data;
			while(l--)
				*ulp++ = (*swp++ >> 8) & 0xFF;
			free(sp->data);
			sp->data=(sample_t *)gulp;
		}
#endif

		if (strip_tail==1)
		{
			/* Let's not really, just say we did. */
			ctl->cmsg(CMSG_INFO, VERB_DEBUG, " - Stripping tail");
			sp->data_length = sp->loop_end;
		}
	}

	close_file(fp);
	return ip;
}
 void const_constraints(const Sequence& c) {
   const_reference r = c.front();
   ignore_unused_variable_warning(r);
 }
 void const_constraints(const BackInsertionSequence& c) {
   const_reference r = c.back();
   ignore_unused_variable_warning(r);
 };
bool BilinearScalerInternal_2x(SDL_Surface *tex, sint32 sx, sint32 sy, sint32 sw, sint32 sh,
                               uint8 *pixel, sint32 dw, sint32 dh, sint32 pitch, bool clamp_src) {
	ignore_unused_variable_warning(dh);
	// Source buffer pointers
	int tpitch = tex->pitch / sizeof(uintS);
	uintS *texel = reinterpret_cast<uintS *>(tex->pixels) + (sy * tpitch + sx);
	uintS *tline_end = texel + (sw - 1);
	uintS *tex_end = texel + (sh - 4) * tpitch;
	int tex_diff = (tpitch * 4) - sw;

	uint8 a[4], b[4], c[4], d[4], e[4], f[4], g[4], h[4], i[4], j[4];
	int p_diff    = (pitch * 8) - (dw * sizeof(uintX));

	bool clip_x = true;
	if (sw + sx < tpitch && clamp_src == false) {
		clip_x = false;
		tline_end = texel + (sw + 1);
		tex_diff--;
	}

	bool clip_y = true;
	if (sh + sy < tex->h && clamp_src == false) {
		clip_y = false;
		tex_end = texel + (sh) * tpitch;
	}

	// Src Loop Y
	do {
		Read5(a, b, c, d, e);
		texel++;

		// Src Loop X
		do {
			Read5(f, g, h, i, j);
			texel++;

			ScalePixel2x(a, b, f, g);
			ScalePixel2x(b, c, g, h);
			ScalePixel2x(c, d, h, i);
			ScalePixel2x(d, e, i, j);

			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;

			Read5(a, b, c, d, e);
			texel++;

			ScalePixel2x(f, g, a, b);
			ScalePixel2x(g, h, b, c);
			ScalePixel2x(h, i, c, d);
			ScalePixel2x(i, j, d, e);

			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;

		} while (texel != tline_end);

		// Final X (clipping)
		if (clip_x) {
			Read5(f, g, h, i, j);
			texel++;

			ScalePixel2x(a, b, f, g);
			ScalePixel2x(b, c, g, h);
			ScalePixel2x(c, d, h, i);
			ScalePixel2x(d, e, i, j);

			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;

			ScalePixel2x(f, g, f, g);
			ScalePixel2x(g, h, g, h);
			ScalePixel2x(h, i, h, i);
			ScalePixel2x(i, j, i, j);

			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;
		};

		pixel  += p_diff;

		texel += tex_diff;
		tline_end += tpitch * 4;
	} while (texel != tex_end);

	//
	// Final Rows - Clipping
	//

	// Src Loop Y
	if (clip_y) {
		Read5_Clipped(a, b, c, d, e);
		texel++;

		// Src Loop X
		do {
			Read5_Clipped(f, g, h, i, j);
			texel++;
			ScalePixel2x(a, b, f, g);
			ScalePixel2x(b, c, g, h);
			ScalePixel2x(c, d, h, i);
			ScalePixel2x(d, e, i, j);
			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;

			Read5_Clipped(a, b, c, d, e);
			texel++;
			ScalePixel2x(f, g, a, b);
			ScalePixel2x(g, h, b, c);
			ScalePixel2x(h, i, c, d);
			ScalePixel2x(i, j, d, e);
			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;
		} while (texel != tline_end);

		// Final X (clipping)
		if (clip_x) {
			Read5_Clipped(f, g, h, i, j);
			texel++;

			ScalePixel2x(a, b, f, g);
			ScalePixel2x(b, c, g, h);
			ScalePixel2x(c, d, h, i);
			ScalePixel2x(d, e, i, j);

			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;

			ScalePixel2x(f, g, f, g);
			ScalePixel2x(g, h, g, h);
			ScalePixel2x(h, i, h, i);
			ScalePixel2x(i, j, i, j);

			pixel -= pitch * 8;
			pixel += sizeof(uintX) * 2;
		};

		pixel  += p_diff;

		texel += tex_diff;
		tline_end += tpitch * 4;
	}

	return true;
}
Exemple #30
0
 void const_constraints(const G& g) {
   const_Map pmap = get(Property(), g);
   pval = get(Property(), g, x);
   ignore_unused_variable_warning(pmap);
 }