public override uint RealSampleLength(int value, SAMPLE sample) { if (sample == null) { return(0); } return((uint)((sample.length * ((sample.flags & SharpMikCommon.SF_16BITS) == SharpMikCommon.SF_16BITS ? 2 : 1)) + 16)); }
static void Main() { SAMPLE s = () => "Hello"; Console.WriteLine("result={0}", s()); int a = 3; int b = 7; TEST t = (c, d) => c + d; Console.WriteLine("add{0}+{1}={2}", a, b, t(a, b)); }
public static SAMPLOAD SL_RegisterSample(SAMPLE s, int type, ModuleReader reader) { SAMPLOAD news; SAMPLOAD cruise = null; if (type == (int)SharpMikCommon.MDTypes.MD_MUSIC) { cruise = musiclist; } else if (type == (int)SharpMikCommon.MDTypes.MD_SNDFX) { cruise = sndfxlist; } else { return(null); } /* Allocate and add structure to the END of the list */ news = new SAMPLOAD(); if (cruise != null) { while (cruise.next != null) { cruise = cruise.next; } cruise.next = news; } else { if (type == (int)SharpMikCommon.MDTypes.MD_MUSIC) { musiclist = news; } else if (type == (int)SharpMikCommon.MDTypes.MD_SNDFX) { sndfxlist = news; } } news.infmt = (uint)(s.flags & SharpMikCommon.SF_FORMATMASK); news.outfmt = news.infmt; news.reader = reader; news.sample = s; news.length = s.length; news.loopstart = s.loopstart; news.loopend = s.loopend; return(news); }
internal static void Voice_Play_internal(sbyte voice, SAMPLE s, uint start) { uint repend; if ((voice < 0) || (voice >= md_numchn)) { return; } md_sample[voice] = s; repend = s.loopend; if ((s.flags & SharpMikCommon.SF_LOOP) == SharpMikCommon.SF_LOOP) { /* repend can't be bigger than size */ if (repend > s.length) { repend = s.length; } } m_Driver.VoicePlay((byte)voice, s.handle, start, s.length, s.loopstart, repend, s.flags); }
public static bool MikMod_SetNumVoices_internal(int music, int sfx) { bool resume = false; int t, oldchn = 0; if ((music == 0) && (sfx == 0)) { return(true); } if (isplaying) { MikMod_DisableOutput_internal(); oldchn = md_numchn; resume = true; } if (sfxinfo != null) { sfxinfo = null; } if (md_sample != null) { md_sample = null; } if (music != -1) { md_sngchn = (byte)music; } if (sfx != -1) { md_sfxchn = (byte)sfx; } md_numchn = (byte)(md_sngchn + md_sfxchn); LimitHardVoices(m_Driver.HardVoiceLimit); LimitSoftVoices(m_Driver.SoftVoiceLimit); if (m_Driver.SetNumVoices()) { MikMod_Exit_internal(); md_numchn = md_softchn = md_hardchn = md_sfxchn = md_sngchn = 0; return(true); } if ((md_sngchn + md_sfxchn) != 0) { md_sample = new SAMPLE[md_sngchn + md_sfxchn]; for (int i = 0; i < md_sngchn + md_sfxchn; i++) { md_sample[i] = new SAMPLE(); } } if (md_sfxchn != 0) { sfxinfo = new byte[md_sfxchn]; } /* make sure the player doesn't start with garbage */ for (t = oldchn; t < md_numchn; t++) { Voice_Stop_internal((byte)t); } if (resume) { MikMod_EnableOutput_internal(); } return(false); }
public override short SampleLoad(SAMPLOAD sload, int type) { SAMPLE s = sload.sample; int handle; uint t, length, loopstart, loopend; if (type == (int)SharpMikCommon.MDDecodeTypes.MD_HARDWARE) { return(0); } /* Find empty slot to put sample address in */ for (handle = 0; handle < SharpMikCommon.MAXSAMPLEHANDLES; handle++) { if (m_Samples[handle] == null) { break; } } if (handle == SharpMikCommon.MAXSAMPLEHANDLES) { // Throw an exception so it reaches all the way up to the loader to show the load failed. throw new Exception("Out of handles"); } /* Reality check for loop settings */ if (s.loopend > s.length) { s.loopend = s.length; } if (s.loopstart >= s.loopend) { int flags = s.flags; flags &= ~SharpMikCommon.SF_LOOP; s.flags = (ushort)flags; } length = s.length; loopstart = s.loopstart; loopend = s.loopend; SampleLoader.SL_SampleSigned(sload); SampleLoader.SL_Sample8to16(sload); uint len = ((length + 20) << 1); m_Samples[handle] = new short[len]; /* read sample into buffer */ if (SampleLoader.SL_Load(m_Samples[handle], sload, length)) { return(-1); } /* Unclick sample */ if ((s.flags & SharpMikCommon.SF_LOOP) == SharpMikCommon.SF_LOOP) { if ((s.flags & SharpMikCommon.SF_BIDI) == SharpMikCommon.SF_BIDI) { for (t = 0; t < 16; t++) { m_Samples[handle][loopend + t] = m_Samples[handle][(loopend - t) - 1]; } } else { for (t = 0; t < 16; t++) { m_Samples[handle][loopend + t] = m_Samples[handle][t + loopstart]; } } } else { for (t = 0; t < 16; t++) { m_Samples[handle][t + length] = 0; } } return((short)handle); }
public abstract uint RealSampleLength(int value, SAMPLE sample);
public override uint RealSampleLength(int value, SAMPLE sample) { return(m_SoftwareMixer.RealSampleLength(value, sample)); }
public short SampleLoad(SAMPLOAD sload, int type) { SAMPLE s = sload.sample; int handle; uint t, length, loopstart, loopend; if (type == (int)SharpMikCommon.MDDecodeTypes.MD_HARDWARE) { return(0); } /* Find empty slot to put sample address in */ for (handle = 0; handle < m_Samples.Count; handle++) { if (m_Samples[handle] == null) { break; } } if (handle == m_Samples.Count) { m_Samples.Add(null); } /* Reality check for loop settings */ if (s.loopend > s.length) { s.loopend = s.length; } if (s.loopstart >= s.loopend) { int flags = s.flags; flags &= ~SharpMikCommon.SF_LOOP; s.flags = (ushort)flags; } length = s.length; loopstart = s.loopstart; loopend = s.loopend; SampleLoader.SL_SampleSigned(sload); SampleLoader.SL_Sample8to16(sload); uint len = ((length + 20) << 1); m_Samples[handle] = new short[len]; /* read sample into buffer */ if (SampleLoader.SL_Load(m_Samples[handle], sload, length)) { return(-1); } /* Unclick sample */ if ((s.flags & SharpMikCommon.SF_LOOP) == SharpMikCommon.SF_LOOP) { if ((s.flags & SharpMikCommon.SF_BIDI) == SharpMikCommon.SF_BIDI) { for (t = 0; t < 16; t++) { m_Samples[handle][loopend + t] = m_Samples[handle][(loopend - t) - 1]; } } else { for (t = 0; t < 16; t++) { m_Samples[handle][loopend + t] = m_Samples[handle][t + loopstart]; } } } else { for (t = 0; t < 16; t++) { m_Samples[handle][t + length] = 0; } } return((short)handle); }