internal override void UpdateDevice(int deviceIndex) { if (!IsLoaded) { return; } // counter-intuitively, this is the correct API to use to migrate a sample to a new device. Bass.ChannelSetDevice(SampleId, deviceIndex); BassUtils.CheckFaulted(true); }
public bool IsResource(string path) { char drive; byte trackNo; if (!TryExtract(path, out drive, out trackNo)) { return(false); } return(BassUtils.GetNumAudioTracks(drive + ":") > trackNo); }
public static bool GetDiscMatchAndUpdate(string fileName, TrackInfo trackInfo) { int trackNo = 1; //TODO: Detect track from filename? if (trackInfo.TrackNum > 0) { trackNo = trackInfo.TrackNum; } string root = Path.GetPathRoot(fileName); if (string.IsNullOrEmpty(root)) { return(false); } char rootLetter = root[0]; if (PHYSICAL_DISK_ROOTS.Contains(rootLetter) == false) { int drive = BassUtils.Drive2BassID(rootLetter); if (drive > -1) { string cdDbId = BassCd.BASS_CD_GetID(drive, BASSCDId.BASS_CDID_CDDB); string musicBrainzId = BassCd.BASS_CD_GetID(drive, BASSCDId.BASS_CDID_MUSICBRAINZ); string upc = BassCd.BASS_CD_GetID(drive, BASSCDId.BASS_CDID_UPC); string irsc = BassCd.BASS_CD_GetID(drive, BASSCDId.BASS_CDID_ISRC + (trackNo - 1)); BassCd.BASS_CD_Release(drive); if (!string.IsNullOrEmpty(cdDbId)) { trackInfo.AlbumCdDdId = cdDbId; } if (!string.IsNullOrEmpty(musicBrainzId)) { trackInfo.AlbumMusicBrainzDiscId = musicBrainzId; } if (!string.IsNullOrEmpty(upc)) { trackInfo.AlbumUpcEanId = upc; } if (!string.IsNullOrEmpty(irsc)) { trackInfo.IsrcId = irsc; } return(true); } else { PHYSICAL_DISK_ROOTS.Add(rootLetter); } } return(false); }
public string GetCDDBDiscIDInfo(char driveLetter, char separator) { string retval = null; int drive = BassUtils.Drive2BassID(driveLetter); if (drive > -1) { string id = BassCd.BASS_CD_GetID(drive, BASSCDId.BASS_CDID_CDDB); retval = id.Replace(' ', separator); BassCd.BASS_CD_Release(drive); } return(retval); }
public void SetPluginHost(IPluginHost Host) { this.FHost = Host; this.manager = ChannelsManager.GetInstance(); BassUtils.LoadPlugins(); this.FHost.CreateValueInput("Device", 1, null, TSliceMode.Single, TPinVisibility.True, out this.FPinInDevice); this.FPinInDevice.SetSubType(-1, double.MaxValue, 1, -1, false, false, true); this.FHost.CreateValueInput("Handles In", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out this.FPinInHandle); this.FPinInHandle.SetSubType(double.MinValue, double.MaxValue, 1, 0, false, false, true); }
public string GetCDDBDiscID(char driveLetter) { string retval = null; int drive = BassUtils.Drive2BassID(driveLetter); if (drive > -1) { string id = BassCd.BASS_CD_GetID(drive, BASSCDId.BASS_CDID_CDDB); retval = id.Substring(0, 8); BassCd.BASS_CD_Release(drive); } return(retval); }
void IBassAudio.UpdateDevice(int deviceIndex) { Bass.ChannelSetDevice(activeStream, deviceIndex); BassUtils.CheckFaulted(true); // Bass may leave us in an invalid state after the output device changes (this is true for "No sound" device) // if the observed state was playing before change, we should force things into a good state. if (isPlayed) { // While on windows, changing to "No sound" changes the playback state correctly, // on macOS it is left in a playing-but-stalled state. Forcefully stopping first fixes this. stopInternal(); startInternal(); } }
internal override void UpdateDevice(int deviceIndex) { // The sample may not have already loaded if a device wasn't present in a previous load attempt. if (!IsLoaded) { loadSample(); } if (!IsLoaded) { return; } // counter-intuitively, this is the correct API to use to migrate a sample to a new device. Bass.ChannelSetDevice(SampleId, deviceIndex); BassUtils.CheckFaulted(true); }
public void SetPluginHost(IPluginHost Host) { this.FHost = Host; this.manager = ChannelsManager.GetInstance(); //We play this channel trough Asio output, so we choose the device NOSOUND Bass.BASS_Init(0, 48000, 0, IntPtr.Zero, null); //int cnt = BassAsio.BASS_ASIO_GetDeviceCount(); //List<string> devices = new List<string>(); //BASS_ASIO_DEVICEINFO[] devinfo = BassAsio.BASS_ASIO_GetDeviceInfos(); //for (int i = 0; i < devinfo.Length; i++) //{ // BASS_ASIO_DEVICEINFO d = devinfo[i]; // devices.Add(d.name); //} //this.FHost.UpdateEnum("Bass Asio Devices", devices[0], devices.ToArray()); BassUtils.LoadPlugins(); //this.FHost.CreateEnumInput("Device Id", TSliceMode.Single, TPinVisibility.True, out this.FPinInDeviceEnum); // this.FPinInDeviceEnum.SetSubType("Bass Asio Devices"); this.FHost.CreateValueInput("Device", 1, null, TSliceMode.Single, TPinVisibility.True, out this.FPinInDevice); this.FPinInDevice.SetSubType(0, double.MaxValue, 1, 0, false, false, true); this.FHost.CreateValueInput("Control Panel", 1, null, TSliceMode.Single, TPinVisibility.True, out this.FControlPanel); this.FControlPanel.SetSubType(0, 1, 1, 0, true, false, false); this.FHost.CreateValueInput("Is Active", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out this.FPinInActive); this.FPinInActive.SetSubType(0.0, 1.0, 1, 0, false, true, true); this.FHost.CreateValueInput("Volume", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out this.FPinInVolumeOutput); this.FPinInVolumeOutput.SetSubType(0, 1, 0.01, 1, false, false, false); this.FHost.CreateValueInput("Handles In", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out this.FPinInChannels); this.FPinInChannels.SetSubType(double.MinValue, double.MaxValue, 1, -1, false, false, true); this.FHost.CreateStringOutput("Status", TSliceMode.Single, TPinVisibility.True, out this.FPinErrorCode); this.myAsioProc = new ASIOPROC(AsioCallback); }
/// <summary> /// Detects if an audio CD/DVD/BD is contained in the given <paramref name="drive"/>. /// </summary> /// <param name="drive">The drive to be examined.</param> /// <param name="tracks">Returns a collection of audio tracks for the audio CD in the given <paramref name="drive"/>.</param> /// <param name="extractedMIATypeIDs">IDs of the media item aspect types which were extracted from the returned <paramref name="tracks"/>.</param> /// <returns><c>true</c>, if an audio CD was identified, else <c>false</c>.</returns> public static bool DetectAudioCD(string drive, out ICollection <MediaItem> tracks, out ICollection <Guid> extractedMIATypeIDs) { tracks = null; extractedMIATypeIDs = null; if (string.IsNullOrEmpty(drive) || drive.Length < 2) { return(false); } drive = drive.Substring(0, 2); // Clip potential '\\' at the end try { IList <BassUtils.AudioTrack> audioTracks = BassUtils.GetAudioTracks(drive); // BassUtils can report wrong audio tracks for some devices, we filter out "Duration = -1" here audioTracks = audioTracks?.Where(t => t.Duration > 0).ToList(); if (audioTracks == null || audioTracks.Count == 0) { return(false); } ISystemResolver systemResolver = ServiceRegistration.Get <ISystemResolver>(); string systemId = systemResolver.LocalSystemId; tracks = new List <MediaItem>(audioTracks.Count); char driveChar = drive[0]; foreach (BassUtils.AudioTrack track in audioTracks) { tracks.Add(CreateMediaItem(track, driveChar, audioTracks.Count, systemId)); } extractedMIATypeIDs = new List <Guid> { ProviderResourceAspect.ASPECT_ID, MediaAspect.ASPECT_ID, AudioAspect.ASPECT_ID, }; } catch (IOException) { ServiceRegistration.Get <ILogger>().Warn("Error enumerating tracks of audio CD in drive {0}", drive); tracks = null; return(false); } return(true); }
public void SetPluginHost(IPluginHost Host) { this.FHost = Host; this.FManager = ChannelsManager.GetInstance(); BassUtils.LoadPlugins(); this.FHost.CreateValueInput("Handle", 1, null, TSliceMode.Single, TPinVisibility.True, out this.FPinInHandle); this.FPinInHandle.SetSubType(double.MinValue, double.MaxValue, 1, 0, false, false, true); this.FHost.CreateStringInput("File Name", TSliceMode.Single, TPinVisibility.True, out this.FPinInFilename); this.FPinInFilename.SetSubType("", true); this.FHost.CreateValueInput("Record", 1, null, TSliceMode.Single, TPinVisibility.True, out this.FPinInRecord); this.FPinInRecord.SetSubType(0, 1, 1, 0, false, true, true); this.FHost.CreateStringOutput("Status", TSliceMode.Single, TPinVisibility.True, out this.FPinOutStatus); this.OnPluginHostSet(); }
/// <summary> /// Initializes a new instance. /// </summary> private void Initialize() { Log.Debug("BassCDTrackInputSource.Initialize()"); Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_CD_FREEOLD, false); const BASSFlag flags = BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT; int bassDrive = BassUtils.Drive2BassID(_drive); int handle = BassCd.BASS_CD_StreamCreate(bassDrive, BassTrackNo, flags); if (handle == 0) { if (Bass.BASS_ErrorGetCode() == BASSError.BASS_ERROR_ALREADY) { // Drive is already playing - stream must be lazily initialized return; } throw new BassLibraryException("BASS_CD_StreamCreate"); } _bassStream = BassStream.Create(handle); }
protected override void Update() { base.Update(); float[] levels = new float[2]; if (isOutputChannel) { Bass.ChannelGetLevel(ChannelHandle, levels, 1 / 1000f * sample_window, LevelRetrievalFlags.Stereo); } else { BassMix.ChannelGetLevel(ChannelHandle, levels, 1 / 1000f * sample_window, LevelRetrievalFlags.Stereo); } float curPeakL = levels[0]; float curPeakR = levels[1]; float curPeak = (curPeakL + curPeakR) / 2f; if (curPeak > maxPeak || Clock.CurrentTime - lastMaxPeakTime > peak_hold_time) { lastMaxPeakTime = Clock.CurrentTime; maxPeak = float.MinValue; } maxPeak = Math.Max(maxPeak, curPeak); volBarL.ResizeHeightTo(curPeakL, sample_window * 4); volBarR.ResizeHeightTo(curPeakR, sample_window * 4); string peakDisplay = curPeak == 0 ? "-∞ " : $"{BassUtils.LevelToDb(curPeak):F}"; string maxPeakDisplay = maxPeak == 0 ? "-∞ " : $"{BassUtils.LevelToDb(maxPeak):F}"; peakText.Text = $"curr: {peakDisplay}dB"; maxPeakText.Text = $"peak: {maxPeakDisplay}dB"; peakText.Colour = BassUtils.LevelToDb(curPeak) > 0 ? Colour4.Red : Colour4.White; maxPeakText.Colour = BassUtils.LevelToDb(maxPeak) > 0 ? Colour4.Red : Colour4.White; mixerLabel.Text = isOutputChannel ? "MIXER OUT" : " "; }
public void SetPluginHost(IPluginHost Host) { Bass.BASS_Init(-1, 44100, 0, IntPtr.Zero, null); BassUtils.LoadPlugins(); //assign host this.FHost = Host; this.FHost.CreateStringInput("Path", TSliceMode.Single, TPinVisibility.True, out this.FPinInPath); this.FPinInPath.SetSubType("", true); this.FHost.CreateValueInput("FFT Size", 1, null, TSliceMode.Single, TPinVisibility.True, out this.FPinInSize); this.FPinInSize.SetSubType(0, double.MaxValue, 1, 256, false, false, true); this.FHost.CreateValueInput("Windowed", 1, null, TSliceMode.Single, TPinVisibility.True, out this.FPinInWindowed); this.FPinInWindowed.SetSubType(0, 1, 1, 1, false, true, false); this.FHost.CreateValueInput("Individual", 1, null, TSliceMode.Single, TPinVisibility.True, out this.FPinInInvidivual); this.FPinInInvidivual.SetSubType(0, 1, 1, 1, false, true, false); this.FHost.CreateValueInput("Position", 1, null, TSliceMode.Single, TPinVisibility.True, out this.FPinInPosition); this.FPinInPosition.SetSubType(0, double.MaxValue, 0.01, 0, false, false, false); this.FHost.CreateValueOutput("FFT Left", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out this.FPinOutLeft); this.FPinOutLeft.SetSubType(double.MinValue, double.MaxValue, 0.01, 0, false, false, false); this.FHost.CreateValueOutput("FFT Right", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out this.FPinOutRight); this.FPinOutRight.SetSubType(double.MinValue, double.MaxValue, 0.01, 0, false, false, false); this.FHost.CreateValueOutput("Position", 1, null, TSliceMode.Single, TPinVisibility.True, out this.FPinOutPosition); this.FPinOutPosition.SetSubType(0, double.MaxValue, 0.01, 0, false, false, false); this.FHost.CreateStringOutput("Status", TSliceMode.Single, TPinVisibility.True, out this.FPinOutStatus); this.FPinOutStatus.SetSubType("", false); }
/// <summary> /// Detects if an audio CD/DVD/BD is contained in the given <paramref name="drive"/>. /// </summary> /// <param name="drive">The drive to be examined.</param> /// <param name="tracks">Returns a collection of audio tracks for the audio CD in the given <paramref name="drive"/>.</param> /// <param name="extractedMIATypeIDs">IDs of the media item aspect types which were extracted from the returned <paramref name="tracks"/>.</param> /// <returns><c>true</c>, if an audio CD was identified, else <c>false</c>.</returns> public static bool DetectAudioCD(DriveInfo driveInfo, out ICollection <MediaItem> tracks, out ICollection <Guid> extractedMIATypeIDs) { tracks = null; extractedMIATypeIDs = null; string drive = driveInfo.Name; if (string.IsNullOrEmpty(drive) || drive.Length < 2) { return(false); } drive = drive.Substring(0, 2); // Clip potential '\\' at the end try { IList <BassUtils.AudioTrack> audioTracks = BassUtils.GetAudioTracks(drive); // BassUtils can report wrong audio tracks for some devices, we filter out "Duration = -1" here audioTracks = audioTracks?.Where(t => t.Duration > 0).ToList(); if (audioTracks == null || audioTracks.Count == 0) { return(false); } ISystemResolver systemResolver = ServiceRegistration.Get <ISystemResolver>(); string systemId = systemResolver.LocalSystemId; tracks = new List <MediaItem>(audioTracks.Count); char driveChar = drive[0]; int driveId = BassUtils.Drive2BassID(driveChar); if (driveId > -1) { BASS_CD_INFO info = BassCd.BASS_CD_GetInfo(driveId); if (info.cdtext) { string[] tags = BassCd.BASS_CD_GetIDText(driveId); string album = GetCDText(tags, "TITLE"); string albumArtist = GetCDText(tags, "PERFORMER"); foreach (BassUtils.AudioTrack track in audioTracks) { tracks.Add(CreateMediaItem(track, driveChar, audioTracks.Count, systemId, album, albumArtist, album, albumArtist, irsc: BassCd.BASS_CD_GetISRC(driveId, track.TrackNo - 1))); } } else { foreach (BassUtils.AudioTrack track in audioTracks) { tracks.Add(CreateMediaItem(track, driveChar, audioTracks.Count, systemId, irsc: BassCd.BASS_CD_GetISRC(driveId, track.TrackNo - 1))); } } BassCd.BASS_CD_Release(driveId); } else { foreach (BassUtils.AudioTrack track in audioTracks) { tracks.Add(CreateMediaItem(track, driveChar, audioTracks.Count, systemId)); } } extractedMIATypeIDs = new List <Guid> { ProviderResourceAspect.ASPECT_ID, MediaAspect.ASPECT_ID, AudioAspect.ASPECT_ID, ExternalIdentifierAspect.ASPECT_ID, }; } catch (IOException) { ServiceRegistration.Get <ILogger>().Warn("Error enumerating tracks of audio CD in drive {0}", drive); tracks = null; return(false); } return(true); }