public override void Initialize() { base.Initialize(); System.Init(32); if (!ChooseRecordDevice(out var recordDriverInfo, out DriverIndex)) { ShouldEndExample = true; return; } nativeRate = recordDriverInfo.SystemRate; driftThreshold = (uint)(nativeRate * Drift_MS / 1000); desiredLatency = (uint)(nativeRate * Latency_MS / 1000); adjustedLatency = desiredLatency; actualLatency = (int)desiredLatency; int nativeChannels = recordDriverInfo.SpeakerModeChannels; CreateSoundInfo info = new CreateSoundInfo() { ChannelCount = nativeChannels, Format = SoundFormat.PCM16, DefaultFrequency = nativeRate, Length = (uint)(nativeRate * sizeof(short) * nativeChannels) }; sound = System.CreateSoundOpenUser(Mode.Loop_Normal, info); }
public override void Initialize() { base.Initialize(); System.Init(32); Sound1 = ReadSound(MediaPath("drumloop.wav"), Mode.Loop_Off); Sound2 = ReadSound(MediaPath("jaguar.wav")); Sound3 = ReadSound(MediaPath("swish.wav")); Sound ReadSound(string file, Mode mode = Mode.Default) { byte[] fileData = File.ReadAllBytes(file); var soundInfo = new CreateSoundInfo() { Length = (uint)fileData.Length }; return(System.CreateSound(fileData, mode | Mode.OpenMemory, soundInfo)); } }