public void Play(string name, byte[] soundBuf) { FMOD.CREATESOUNDEXINFO sndInfo = new FMOD.CREATESOUNDEXINFO() { length = (uint)soundBuf.Length, }; FMOD.RESULT result = system.createSound(soundBuf, FMOD.MODE.OPENMEMORY, ref sndInfo, out sound); ERRCHECK(result, "system.createSound"); if (result == FMOD.RESULT.OK) { int numSubSounds; result = sound.getNumSubSounds(out numSubSounds); ERRCHECK(result, "sound.getNumSubSounds"); if (numSubSounds > 0) { result = sound.getSubSound(0, out subSound); ERRCHECK(result, "sound.getSubSound"); result = system.playSound(subSound, null, false, out channel); } else { result = system.playSound(sound, null, false, out channel); } ERRCHECK(result, "sound.playSound"); } }
private void comboBox_SelectedIndexChanged(object sender, System.EventArgs e) { FMOD.RESULT result; string selected = drives[comboBox.SelectedIndex].Remove(2, 1); result = system.createSound(selected, (FMOD.MODE.HARDWARE | FMOD.MODE._2D | FMOD.MODE.CREATESTREAM | FMOD.MODE.OPENONLY), ref cdsound); ERRCHECK(result); result = cdsound.getNumSubSounds(ref numtracks); ERRCHECK(result); result = cdsound.getSubSound(currenttrack, ref sound); ERRCHECK(result); play.Enabled = true; pause.Enabled = true; nextTrack.Enabled = true; comboBox.Enabled = false; }
/// <summary> /// Die Informationen (TOC) einer CD auslesen /// </summary> public CDInfo ReadCDInformation(char driveLetter) { if (Settings.Current.UseMCI) { return(ReadCDInformationMCI(driveLetter)); } CDInfo mciCDInfo = ReadCDInformationMCI(driveLetter); if (mciCDInfo.Tracks.Any(x => x.TrackType != TrackType.Audio)) // Bei einer Daten-CD nehmen wir MCI { return(mciCDInfo); } string drive = string.Format("{0}:", driveLetter); FMOD.Sound cdSound = null; FMOD.RESULT result = system.createStream(drive, FMOD.MODE.OPENONLY, ref cdSound); if (result != FMOD.RESULT.OK || cdSound == null) { return(mciCDInfo); } int numberOfTracks = 0; cdSound.getNumSubSounds(ref numberOfTracks); FMOD.CDTOC cdToc = new FMOD.CDTOC(); int numtags = 0; int numtagsupdated = 0; cdSound.getNumTags(ref numtags, ref numtagsupdated); for (int i = 0; i < numtags; i++) { FMOD.TAG tag = new FMOD.TAG(); if (cdSound.getTag(null, i, ref tag) != FMOD.RESULT.OK) { break; } if (tag.datatype == FMOD.TAGDATATYPE.CDTOC) { cdToc = (FMOD.CDTOC)Marshal.PtrToStructure(tag.data, typeof(FMOD.CDTOC)); break; } } CDInfo cdInfo = new CDInfo(); int trackNr = 0; for (; trackNr < numberOfTracks; trackNr++) { CDInfoTrack track = new CDInfoTrack(); track.StartTime = (((cdToc.min[trackNr] * 60 + cdToc.sec[trackNr]) * 75 + cdToc.frame[trackNr]) * 1000 + 74) / 75; if (trackNr > 0) { cdInfo.Tracks[trackNr - 1].Length = track.StartTime - cdInfo.Tracks[trackNr - 1].StartTime; } track.TrackType = TrackType.Audio; cdInfo.Tracks.Add(track); } cdInfo.TotalLength = (((cdToc.min[numberOfTracks] * 60 + cdToc.sec[numberOfTracks]) * 75 + cdToc.frame[numberOfTracks]) * 1000 + 74) / 75; cdInfo.Tracks[trackNr - 1].Length = cdInfo.TotalLength - cdInfo.Tracks[trackNr - 1].StartTime; cdSound.release(); /*StringBuilder volumeName = new StringBuilder(1000); * StringBuilder fileSystemNameBuffer = new StringBuilder(1000); * uint serialNumber = 0; * uint maximumComponentLength = 0; * uint fileSystemFlags = 0; * GetVolumeInformation(drive, volumeName, 1000, ref serialNumber, ref maximumComponentLength, ref fileSystemFlags, fileSystemNameBuffer, 1000); * * cdInfo.Identity = serialNumber.ToString();*/ cdInfo.Identity = mciCDInfo.Identity; return(cdInfo); }