/[svn]/linuxsampler/trunk/src/engines/gig/InstrumentScriptVMFunctions.cpp
ViewVC logotype

Annotation of /linuxsampler/trunk/src/engines/gig/InstrumentScriptVMFunctions.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2600 - (hide annotations) (download)
Sat Jun 7 00:16:03 2014 UTC (9 years, 10 months ago) by schoenebeck
File size: 2177 byte(s)
* Implemented built-in instrument script function "set_controller()".
* Fixed built-in script functions "ignore_event()" and
  "ignore_controller()".
* Added extended instrument script VM for the Gigasampler/GigaStudio format
  sampler engine, which extends the general instrument script VM with Giga
  format specific variables and functions.
* Giga format instrument scripts: added built-in script int constant
  variables $GIG_DIM_CHANNEL, $GIG_DIM_LAYER, $GIG_DIM_VELOCITY,
  $GIG_DIM_AFTERTOUCH, $GIG_DIM_RELEASE, $GIG_DIM_KEYBOARD,
  $GIG_DIM_ROUNDROBIN, $GIG_DIM_RANDOM, $GIG_DIM_SMARTMIDI,
  $GIG_DIM_ROUNDROBINKEY, $GIG_DIM_MODWHEEL, $GIG_DIM_BREATH,
  $GIG_DIM_FOOT, $GIG_DIM_PORTAMENTOTIME, $GIG_DIM_EFFECT1,
  $GIG_DIM_EFFECT2, $GIG_DIM_GENPURPOSE1, $GIG_DIM_GENPURPOSE2,
  $GIG_DIM_GENPURPOSE3, $GIG_DIM_GENPURPOSE4, $GIG_DIM_SUSTAIN,
  $GIG_DIM_PORTAMENTO, $GIG_DIM_SOSTENUTO, $GIG_DIM_SOFT,
  $GIG_DIM_GENPURPOSE5, $GIG_DIM_GENPURPOSE6, $GIG_DIM_GENPURPOSE7,
  $GIG_DIM_GENPURPOSE8, $GIG_DIM_EFFECT1DEPTH, $GIG_DIM_EFFECT2DEPTH,
  $GIG_DIM_EFFECT3DEPTH, $GIG_DIM_EFFECT4DEPTH, $GIG_DIM_EFFECT5DEPTH.
* Giga format instrument scripts: Implemented built-in script function
  "gig_set_dim_zone(event_id, dimension, zone)", which allows to override
  dimension zone(s) for new voices.
* Bumped version (1.0.0.svn45).

1 schoenebeck 2600 /*
2     * Copyright (c) 2014 Christian Schoenebeck
3     *
4     * http://www.linuxsampler.org
5     *
6     * This file is part of LinuxSampler and released under the same terms.
7     * See README file for details.
8     */
9    
10     #include "InstrumentScriptVMFunctions.h"
11     #include "InstrumentScriptVM.h"
12     #include "EngineChannel.h"
13    
14     namespace LinuxSampler { namespace gig {
15    
16     /////////////////////////////////////////////////////////////////////////
17     // Function:
18     // gig_set_dim_zone(event_id, dimension, zone)
19    
20     InstrumentScriptVMFunction_gig_set_dim_zone::InstrumentScriptVMFunction_gig_set_dim_zone(InstrumentScriptVM* parent)
21     : m_vm(parent)
22     {
23     }
24    
25     VMFnResult* InstrumentScriptVMFunction_gig_set_dim_zone::exec(VMFnArgs* args) {
26     int id = args->arg(0)->asInt()->evalInt();
27     int dim = args->arg(1)->asInt()->evalInt();
28     int zone = args->arg(2)->asInt()->evalInt();
29    
30     if (id < 0) {
31     wrnMsg("gig_set_dim_zone(): argument 1 may not be a negative event ID");
32     return successResult();
33     }
34    
35     int note = m_vm->m_event->cause.Param.Note.Key;
36    
37     EngineChannel* pEngineChannel =
38     static_cast<EngineChannel*>(m_vm->m_event->cause.pEngineChannel);
39    
40     ::gig::Region* pRegion = pEngineChannel->pInstrument->GetRegion(note);
41     if (!pRegion) return successResult();
42    
43     int idx = -1, baseBits = 0;
44     for (int i = 0; i < pRegion->Dimensions; ++i) {
45     if (pRegion->pDimensionDefinitions[i].dimension == dim) {
46     idx = i;
47     break;
48     }
49     baseBits += pRegion->pDimensionDefinitions[i].bits;
50     }
51     if (idx < 0) return successResult(); // no such dimension found
52    
53     RTList<Event>::Iterator itEvent = pEngineChannel->pEngine->EventByID(id);
54     if (!itEvent) return successResult();
55    
56     int bits = pRegion->pDimensionDefinitions[idx].bits;
57     int mask = 0;
58     for (int i = 0; i < bits; ++i) mask |= (1 << (baseBits + i));
59    
60     itEvent->Format.Gig.DimMask |= mask;
61     itEvent->Format.Gig.DimBits |= (zone << baseBits) & mask;
62    
63     return successResult();
64     }
65    
66     }} // namespace LinuxSampler::gig

  ViewVC Help
Powered by ViewVC