public virtual void TestLifeCycle() { ByRef tearDownCalled = ByRef.NewInstance(false); RunsLifeCycle._tearDownCalled.With(tearDownCalled, new _IRunnable_11()); Assert.IsTrue((((bool)tearDownCalled.value))); }
public static ByRef NewInstance(object initialValue) { var instance = new ByRef(); instance.value = initialValue; return(instance); }
/// <summary> /// vsqファイルのstart_clockクロックからメトロノームを起動する。startは、start_clockをいつから起動したかを指定する。 /// </summary> /// <param name="vsq"></param> /// <param name="start_clock"></param> /// <param name="start"></param> public static void Start(VsqFileEx vsq, int start_clock, double start_time) { s_queue.clear(); m_stop_required = false; m_stop_metronome_required = false; if (s_device0 == null) { s_device0 = new MidiDeviceImp(s_metronome_device); } if (s_metronome_device != s_general_device) { if (s_device1 == null) { s_device1 = new MidiDeviceImp(s_general_device); } } m_vsq = (VsqFileEx)vsq.clone(); m_started_sec = m_vsq.getSecFromClock(start_clock); ByRef <Integer> bar = new ByRef <Integer>(); Timesig timesig = m_vsq.getTimesigAt(start_clock, bar); int clock_at_bartop = m_vsq.getClockFromBarCount(bar.value); int clock_step = 480 * 4 / timesig.denominator; int next_clock = clock_at_bartop + ((start_clock - clock_at_bartop) / clock_step + 1) * clock_step; m_started = start_time; m_started_clock = start_clock; m_temp_exit = false; for (int track = 1; track < m_vsq.Track.size(); track++) { #if DEBUG AppManager.debugWriteLine("Metronome.Start; track=" + track); #endif for (Iterator <VsqEvent> itr = m_vsq.Track.get(track).getNoteEventIterator(); itr.hasNext();) { VsqEvent item = itr.next(); if (start_clock <= item.Clock) { MidiQueue q = new MidiQueue(); q.Track = track; q.Channel = (byte)(track - 1); q.Clock = item.Clock; q.Note = (byte)(item.ID.Note); q.Program = 0; q.Velocity = 0x40; q.Done += new MidiQueueDoneEventHandler(ReGenerateMidiQueue); s_queue.add(q); break; } } } Collections.sort(s_queue); m_thread = new Thread(new ThreadStart(ThreadProc)); m_thread.IsBackground = true; m_thread.Priority = ThreadPriority.Highest; m_thread.Start(); }
public _ICodeBlock_34(SaveAsStorageTestCase _enclosing, string oldFileName, ByRef newPath) { this._enclosing = _enclosing; this.oldFileName = oldFileName; this.newPath = newPath; }
public int getValue(int clock, ByRef <int> index) { if (length == 0) { return(defaultValue); } else { if (index.value < 0) { index.value = 0; } for (int i = index.value; i < length; i++) { int keyclock = clocks[i]; if (clock < keyclock) { if (i > 0) { index.value = i - 1; return(items[i - 1].value); } else { index.value = i - 1; return(defaultValue); } } } index.value = length - 1; return(items[length - 1].value); } }
public void Visit(object a_object) { QCandidate candidate = (QCandidate)a_object; if (candidate.Include()) { TreeInt ids = new TreeInt(candidate._key); ByRef idsNew = new ByRef(); IEnumerator itPath = executionPath.GetEnumerator(); while (itPath.MoveNext()) { idsNew.value = null; string fieldName = (string)(itPath.Current); if (ids != null) { ids.Traverse(new _IVisitor4_385(this, stream, fieldName, idsNew)); } ids = (TreeInt)((TreeInt)idsNew.value); } if (ids != null) { ids.Traverse(new _IVisitor4_406(result)); } } }
private TreeInt ToTreeInt(IIndexedNode result) { ByRef treeInts = ByRef.NewInstance(); result.Traverse(new _IIntVisitor_65(treeInts)); return((TreeInt)treeInts.value); }
internal CreateDescendChildTraversingVisitor(ByRef pending, BooleanByRef innerRes , bool isNot) { _pending = pending; _innerRes = innerRes; _isNot = isNot; }
private AbstractQueryResult ReadQueryResult(Transaction trans) { ByRef result = ByRef.NewInstance(); WithEnvironment(new _IRunnable_670(this, trans, result)); return((AbstractQueryResult)result.value); }
public _IVisitor4_192(ByRef prevSlot, IBlockConverter blockConverter, IList overlaps ) { this.prevSlot = prevSlot; this.blockConverter = blockConverter; this.overlaps = overlaps; }
public _IVisitor4_29(OverlapMap _enclosing, ByRef prevSlot, ISet overlaps ) { this._enclosing = _enclosing; this.prevSlot = prevSlot; this.overlaps = overlaps; }
public virtual ISet Overlaps() { ISet overlaps = new HashSet(); var prevSlot = ByRef.NewInstance(); Tree.Traverse(_slots, new _IVisitor4_29(this, prevSlot, overlaps)); return(overlaps); }
public _IVisitor4_385(_IVisitor4_374 _enclosing, ObjectContainerBase stream, string fieldName, ByRef idsNew) { this._enclosing = _enclosing; this.stream = stream; this.fieldName = fieldName; this.idsNew = idsNew; }
public virtual void TestObjectInfoIsNotAvailableOnCreatingHandler() { var executed = ByRef.NewInstance(false); EventRegistry().Creating += new _IEventListener4_15(executed).OnEvent; Store(new Item()); Assert.IsTrue((((bool)executed.value))); }
public virtual void SizeChanged(Transaction transaction, BTreeNode node, int changeBy ) { NotifyCountChanged(transaction, node, changeBy); ByRef sizeInTransaction = SizeIn(transaction); sizeInTransaction.value = (((int)sizeInTransaction.value)) + changeBy; }
public virtual Sharpen.Util.ISet Overlaps() { Sharpen.Util.ISet overlaps = new HashSet(); ByRef prevSlot = ByRef.NewInstance(); TreeIntObject.Traverse(_slots, new _IVisitor4_29(this, prevSlot, overlaps)); return(overlaps); }
public virtual IList Merged() { IList mergedSlots = new ArrayList(); ByRef mergedSlot = ByRef.NewInstance(new Slot(0, 0)); Tree.Traverse(_slots, new _IVisitor4_32(mergedSlot, mergedSlots)); mergedSlots.Add(((Slot)mergedSlot.value)); return mergedSlots; }
private async Task NonFaultingVoidAsync(ByRef <int> value) { await Task.Yield(); await Task.Delay(500); value.Instance *= 2; }
/// <exception cref="System.Exception"></exception> public virtual void TestDaemon() { ByRef isDaemon = ByRef.NewInstance(); _subject.StartLowPriority("Deamon checker", new _IRunnable_60(isDaemon)); _subject.Join(1000); Assert.IsTrue((((bool)isDaemon.value))); }
public virtual void TestObjectInfoIsNotAvailableOnCreatingHandler() { ByRef executed = ByRef.NewInstance(false); EventRegistry().Creating += new System.EventHandler<Db4objects.Db4o.Events.CancellableObjectEventArgs> (new _IEventListener4_15(executed).OnEvent); Store(new EventsTestCaseBase.Item()); Assert.IsTrue((((bool)executed.value))); }
private bool CreateChildForDescendable(QCandidates parentCandidates, ITypeHandler4 handler, QueryingReadContext queryingReadContext, ITypeHandler4 arrayElementHandler ) { int offset = queryingReadContext.Offset(); bool outerRes = true; // The following construct is worse than not ideal. For each constraint it completely reads the // underlying structure again. The structure could be kept fairly easy. TODO: Optimize! IEnumerator i = parentCandidates.IterateConstraints(); while (i.MoveNext()) { QCon qcon = (QCon)i.Current; QField qf = qcon.GetField(); if (qf != null && !qf.Name().Equals(_fieldMetadata.GetName())) { continue; } QCon tempParent = qcon.Parent(); qcon.SetParent(null); QCandidates candidates = new QCandidates(parentCandidates.i_trans, null, qf, false ); candidates.AddConstraint(qcon); qcon.SetCandidates(candidates); ReadArrayCandidates(handler, queryingReadContext.Buffer(), arrayElementHandler, candidates ); queryingReadContext.Seek(offset); bool isNot = qcon.IsNot(); if (isNot) { qcon.RemoveNot(); } candidates.Evaluate(); ByRef pending = ByRef.NewInstance(); BooleanByRef innerRes = new BooleanByRef(isNot); candidates.Traverse(new QCandidate.CreateDescendChildTraversingVisitor(pending, innerRes , isNot)); if (isNot) { qcon.Not(); } // In case we had pending subresults, we need to communicate them up to our root. if (((Tree)pending.value) != null) { ((Tree)pending.value).Traverse(new _IVisitor4_168(this)); } if (!innerRes.value) { // Again this could be double triggering. // // We want to clean up the "No route" at some stage. qcon.Visit(GetRoot(), qcon.Evaluator().Not(false)); outerRes = false; } qcon.SetParent(tempParent); } return(outerRes); }
public ExcludingReflector(ByRef loaderClass, Type[] excludedClasses) { _excludedClasses = new Collection4(); for (int claxxIndex = 0; claxxIndex < excludedClasses.Length; ++claxxIndex) { Type claxx = excludedClasses[claxxIndex]; _excludedClasses.Add(claxx.FullName); } }
public virtual void TestRunWith() { EnvironmentsTestCase.IWhatever whatever = new _IWhatever_22(); IEnvironment environment = new _IEnvironment_23(whatever); ByRef ran = ByRef.NewInstance(); Environments.RunWith(environment, new _IRunnable_29(ran, whatever)); Assert.IsTrue((((bool)ran.value))); }
public virtual void TestOnDiscard() { CacheTestUnit.TestPuppet puppet = new CacheTestUnit.TestPuppet(); puppet.FillCache(); ByRef discarded = new ByRef(); puppet.Produce(42, new _IProcedure4_19(discarded)); Assert.AreEqual("0", ((string)discarded.value)); }
private IList CollectOverlaps() { IBlockConverter blockConverter = _db.BlockConverter(); IList overlaps = new ArrayList(); ByRef prevSlot = ByRef.NewInstance(); mappings.Traverse(new _IVisitor4_192(prevSlot, blockConverter, overlaps)); return(overlaps); }
private static string readTillMessageEnd(StreamReader sr, string first_line, string entry, ByRef <string> msg, ByRef <string[]> locations) { msg.value = ""; string line = first_line; List <string> location = new List <string>(); bool entry_found = false; if (line.StartsWith(entry)) { // 1行目がすでに"entry"の行だった場合 ByRef <string> dum = new ByRef <string>(""); ByRef <string> dum2 = new ByRef <string>(""); separateEntryAndMessage(line, dum, dum2); msg.value += dum2.value; } else { while ((line = sr.ReadLine()) != null) { if (line.StartsWith("#:")) { line = line.Substring(2).Trim(); location.Add(line); } else if (line.StartsWith(entry)) { ByRef <string> dum = new ByRef <string>(""); ByRef <string> dum2 = new ByRef <string>(""); separateEntryAndMessage(line, dum, dum2); msg.value += dum2.value; break; } } } locations.value = location.ToArray(); string ret = ""; while ((line = sr.ReadLine()) != null) { if (!line.StartsWith("\"")) { msg.value = msg.value.Replace("\\\"", "\""); msg.value = msg.value.Replace("\\n", "\n"); return(line); } int index = line.LastIndexOf("\""); msg.value += line.Substring(1, index - 1); } msg.value = msg.value.Replace("\\\"", "\""); msg.value = msg.value.Replace("\\n", "\n"); if (line == null) { line = ""; } return(line); }
private async Task <ByRef <int> > NonFaultingTypeAsync(ByRef <int> value) { await Task.Yield(); await Task.Delay(500); value.Instance *= 2; return(value); }
/// <exception cref="System.Exception"></exception> public virtual void TestFailureEvent() { var executed = ByRef.NewInstance(false); var exception = new Exception(); _subject.UncaughtException += new _IEventListener4_20(exception, executed).OnEvent; _subject.Start(ReflectPlatform.SimpleName(GetType()) + " throwing exception thread" , new _IRunnable_27(exception)); _subject.Join(1000); Assert.IsTrue((((bool)executed.value))); }
private void Read(ByteArrayBuffer reader) { FreeSlotNode.sizeLimit = DiscardLimit(); _freeBySize = new TreeReader(reader, new FreeSlotNode(0), true).Read(); ByRef addressTree = ByRef.NewInstance(); if (_freeBySize != null) { _freeBySize.Traverse(new _IVisitor4_176(addressTree)); } _freeByAddress = ((Tree)addressTree.value); }
private long[] GetIDsForClass(Transaction trans, ClassMetadata clazz, bool triggerQueryEvents ) { MsgD msg = Msg.GetInternalIds.GetWriterForInts(trans, new int[] { clazz.GetID(), PrefetchDepth(), PrefetchCount(), triggerQueryEvents ? 1 : 0 }); Write(msg); ByRef result = ByRef.NewInstance(); WithEnvironment(new _IRunnable_901(this, trans, result)); return((long[])result.value); }
public static ByRef NewInstance(object initialValue) { var instance = new ByRef(); instance.value = initialValue; return instance; }
/// <summary> /// vsqファイルのstart_clockクロックからメトロノームを起動する。startは、start_clockをいつから起動したかを指定する。 /// </summary> /// <param name="vsq"></param> /// <param name="start_clock"></param> /// <param name="start"></param> public static void Start( VsqFileEx vsq, int start_clock, double start_time ) { s_queue.clear(); m_stop_required = false; m_stop_metronome_required = false; if ( s_device0 == null ) { s_device0 = new MidiDeviceImp( s_metronome_device ); } if ( s_metronome_device != s_general_device ) { if ( s_device1 == null ) { s_device1 = new MidiDeviceImp( s_general_device ); } } m_vsq = (VsqFileEx)vsq.clone(); m_started_sec = m_vsq.getSecFromClock( start_clock ); ByRef<Integer> bar = new ByRef<Integer>(); Timesig timesig = m_vsq.getTimesigAt( start_clock, bar ); int clock_at_bartop = m_vsq.getClockFromBarCount( bar.value ); int clock_step = 480 * 4 / timesig.denominator; int next_clock = clock_at_bartop + ((start_clock - clock_at_bartop) / clock_step + 1) * clock_step; m_started = start_time; m_started_clock = start_clock; m_temp_exit = false; for ( int track = 1; track < m_vsq.Track.size(); track++ ) { #if DEBUG AppManager.debugWriteLine( "Metronome.Start; track=" + track ); #endif for ( Iterator<VsqEvent> itr = m_vsq.Track.get( track ).getNoteEventIterator(); itr.hasNext(); ) { VsqEvent item = itr.next(); if ( start_clock <= item.Clock ) { MidiQueue q = new MidiQueue(); q.Track = track; q.Channel = (byte)(track - 1); q.Clock = item.Clock; q.Note = (byte)(item.ID.Note); q.Program = 0; q.Velocity = 0x40; q.Done += new MidiQueueDoneEventHandler( ReGenerateMidiQueue ); s_queue.add( q ); break; } } } Collections.sort( s_queue ); m_thread = new Thread( new ThreadStart( ThreadProc ) ); m_thread.IsBackground = true; m_thread.Priority = ThreadPriority.Highest; m_thread.Start(); }
public static void RestartMetronome() { m_stop_metronome_required = false; if ( m_vsq != null ) { double now = PortUtil.getCurrentTime(); double elapsed = ((now - m_started) + 0.25) * m_speed; int clock = (int)m_vsq.getClockFromSec( m_started_sec + elapsed ); ByRef<Integer> bar = new ByRef<Integer>(); Timesig timesig = m_vsq.getTimesigAt( clock, bar ); int clock_at_bartop = m_vsq.getClockFromBarCount( bar.value ); int clock_step = 480 * 4 / timesig.denominator; int next_clock = clock_at_bartop + ((clock - clock_at_bartop) / clock_step + 1) * clock_step; MidiQueue mq = new MidiQueue(); mq.Track = 0; mq.Clock = next_clock; mq.Channel = 14; mq.Program = ProgramNormal; mq.Note = NoteNormal; mq.Velocity = 0x40; mq.Done += new MidiQueueDoneEventHandler( ReGenerateMidiQueue ); s_queue.add( mq ); if ( (next_clock - clock_at_bartop) % (timesig.numerator * clock_step) == 0 ) { MidiQueue mq_bell = new MidiQueue(); mq_bell.Track = 0; mq_bell.Clock = next_clock; mq_bell.Channel = 15; mq_bell.Program = ProgramBell; mq_bell.Note = NoteBell; mq_bell.Velocity = 0x40; s_queue.add( mq_bell ); } Collections.sort( s_queue ); } }
/// <summary> /// 音符に付随するピッチベンドの情報を、PIT・PBS カーブに反映する /// </summary> /// <param name="item">音符</param> /// <param name="pitchBend">PIT カーブ</param> /// <param name="pitchBendSensitivity">PBS カーブ</param> /// <param name="tempoTable">テンポ情報</param> protected void reflectNoteEventPitch( VsqEvent item, VsqBPList pitchBend, VsqBPList pitchBendSensitivity, TempoVector tempoTable ) { if ( item.ID.type != VsqIDType.Anote ) return; // AquesTone2 では、note on と同 clock にピッチベンドイベントを送らないと音程が反映されないので、必ずピッチイベントが送られるようにする pitchBend.add( item.Clock, pitchBend.getValue( item.Clock ) ); if ( item.ID.VibratoHandle == null ) { return; } int startClock = item.Clock + item.ID.VibratoDelay; int vibratoLength = item.ID.Length - item.ID.VibratoDelay; var iterator = new VibratoPointIteratorByClock( tempoTable, item.ID.VibratoHandle.RateBP, item.ID.VibratoHandle.StartRate, item.ID.VibratoHandle.DepthBP, item.ID.VibratoHandle.StartDepth, startClock, vibratoLength ); var pitContext = new ByRef<int>( 0 ); var pbsContext = new ByRef<int>( 0 ); int pitAtEnd = pitchBend.getValue( startClock + vibratoLength ); int pbsAtEnd = pitchBendSensitivity.getValue( startClock + vibratoLength ); var pitBackup = (VsqBPList)pitchBend.Clone(); var pbsBackup = (VsqBPList)pitchBendSensitivity.Clone(); bool resetPBS = false; double maxNetPitchBendInCent = 0.0; for ( int clock = startClock; clock < startClock + vibratoLength && iterator.hasNext(); ++clock ) { double vibratoPitchBendInCent = iterator.next() * 100.0; int pit = pitchBend.getValue( clock, pitContext ); int pbs = pitchBendSensitivity.getValue( clock, pbsContext ); const double pow2_13 = 8192; double netPitchBendInCent = (pbs * pit / pow2_13) * 100.0 + vibratoPitchBendInCent; maxNetPitchBendInCent = Math.Max( maxNetPitchBendInCent, Math.Abs( netPitchBendInCent ) ); int draftPitchBend = (int)Math.Round( (netPitchBendInCent / 100.0) * pow2_13 / pbs ); if ( draftPitchBend < pitchBend.Minimum || pitchBend.Maximum < draftPitchBend ) { // pbs を変更せずにビブラートによるピッチベンドを反映しようとすると、 // pit が範囲を超えてしまう。 resetPBS = true; } else { if ( draftPitchBend != pit ) { pitchBend.add( clock, draftPitchBend ); } } } if ( !resetPBS ) { return; } pitchBend.Data = pitBackup.Data; // ピッチベンドの最大値を実現するのに必要なPBS int requiredPitchbendSensitivity = (int)Math.Ceiling( maxNetPitchBendInCent / 100.0 ); int pseudoMaxPitchbendSensitivity = 12; // AquesTone2 は最大 12 半音までベンドできる。 if ( requiredPitchbendSensitivity < pitchBendSensitivity.Minimum ) requiredPitchbendSensitivity = pitchBendSensitivity.Minimum; if ( pseudoMaxPitchbendSensitivity < requiredPitchbendSensitivity ) requiredPitchbendSensitivity = pseudoMaxPitchbendSensitivity; { int i = 0; while ( i < pitchBend.size() ) { var clock = pitchBend.getKeyClock( i ); if ( startClock <= clock && clock < startClock + vibratoLength ) { pitchBend.removeElementAt( i ); } else { ++i; } } } { int i = 0; while ( i < pitchBendSensitivity.size() ) { var clock = pitchBendSensitivity.getKeyClock( i ); if ( startClock <= clock && clock < startClock + vibratoLength ) { pitchBendSensitivity.removeElementAt( i ); } else { ++i; } } } if ( pitchBendSensitivity.getValue( startClock ) != requiredPitchbendSensitivity ) { pitchBendSensitivity.add( startClock, requiredPitchbendSensitivity ); } pitchBend.add( startClock + vibratoLength, pitAtEnd ); pitchBendSensitivity.add( startClock + vibratoLength, pbsAtEnd ); iterator.rewind(); pitContext.value = 0; pbsContext.value = 0; int lastPitchBend = pitchBend.getValue( startClock ); for ( int clock = startClock; clock < startClock + vibratoLength && iterator.hasNext(); ++clock ) { double vibratoPitchBendInCent = iterator.next() * 100.0; int pit = pitBackup.getValue( clock, pitContext ); int pbs = pbsBackup.getValue( clock, pbsContext ); const double pow2_13 = 8192; double netPitchBendInCent = (pbs * pit / pow2_13) * 100.0 + vibratoPitchBendInCent; maxNetPitchBendInCent = Math.Max( maxNetPitchBendInCent, Math.Abs( netPitchBendInCent ) ); int draftPitchBend = (int)Math.Round((netPitchBendInCent / 100.0) * pow2_13 / requiredPitchbendSensitivity); if ( draftPitchBend < pitchBend.Minimum ) draftPitchBend = pitchBend.Minimum; if ( pitchBend.Maximum < draftPitchBend ) draftPitchBend = pitchBend.Maximum; if ( draftPitchBend != lastPitchBend ) { pitchBend.add( clock, draftPitchBend ); lastPitchBend = draftPitchBend; } } }