Пример #1
0
 public Tone(string file, Entity entity, ToneType type, bool state = false)
 {
     _entity = entity;
     _file   = file;
     _type   = type;
     SetState(state);
 }
Пример #2
0
        internal Tone(string file, Entity entity, ToneType type, bool allow, bool state = false)
        {
            _entity = entity;
            _file   = file;
            _type   = type;
            SetState(state);
            AllowUse = allow;
            switch (type)
            {
            case ToneType.SrnTon1:
                Type = "WL";
                break;

            case ToneType.SrnTon2:
                Type = "YP";
                break;

            case ToneType.SrnTon3:
                Type = "A1";
                break;

            case ToneType.SrnTon4:
                Type = "A2";
                break;
            }
            soundId = -1;
        }
Пример #3
0
        public void SetToneFromText(ToneType Type, string Text)
        {
            List <int> Tone      = ToneText.ToList(Text);
            var        Parameter = Tone.ToArray();

            SetToneParameter(Type, Parameter);
        }
Пример #4
0
        internal Tone(string file, ELSVehicle entity, ToneType type, bool allow, bool state = false, string soundSet = null)
        {
            _entity   = entity;
            _file     = file;
            _soundSet = soundSet;
            Utils.ReleaseWriteLine($"siren: {type}; soundSet: {_soundSet}; file: {_file}");
            SetState(state);
            AllowUse = allow;
            switch (type)
            {
            case ToneType.SrnTon1:
                Type = "WL";
                break;

            case ToneType.SrnTon2:
                Type = "YP";
                break;

            case ToneType.SrnTon3:
                Type = "A1";
                break;

            case ToneType.SrnTon4:
                Type = "A2";
                break;
            }
            soundId = -2;
        }
Пример #5
0
 public void SetData(ToneType Type, int[] Parameter)
 {
     this.Type = Type;
     switch (Type)
     {
     case ToneType.OPNA: SetDataOPNA(Parameter); break;
     }
 }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tone"></param>
        /// <returns></returns>
        public bool UpdateSettings(Enum tone, ToneType toneType)
        {
            DbManager db = new DbManager();

            if (db.UpdateSettings(_userID, tone, toneType))
            {
                return(true);
            }
            else
            {
                throw new ApplicationException(CustomHttpStatusCode.InvalidNumber.ToString("D"));
            }
        }
Пример #7
0
        private static async Task StartAsyncCore(ToneType tone, AudioStreamPolicy streamPolicy,
                                                 int durationMilliseconds, CancellationToken cancellationToken)
        {
            var tcs = new TaskCompletionSource <bool>();

            Native.Start(tone, streamPolicy.Handle, durationMilliseconds, out var id).
            Validate("Failed to play tone.");

            using (RegisterCancellationAction(tcs, cancellationToken, id))
            {
                await WaitForDuration(tcs, cancellationToken, durationMilliseconds);

                await tcs.Task;
            }
        }
Пример #8
0
        internal Tone(string file, Vehicle entity, ToneType type, bool allow, string soundbank, string soundset, bool state = false)
        {
            _entity = entity;
            elsid   = entity.GetElsId();
            _file   = file;
            _type   = type;
            SetState(state);
            AllowUse = allow;
            switch (type)
            {
            case ToneType.SrnTon1:
                Type = "WL";
                break;

            case ToneType.SrnTon2:
                Type = "YP";
                break;

            case ToneType.SrnTon3:
                Type = "A1";
                break;

            case ToneType.SrnTon4:
                Type = "A2";
                break;
            }
            soundId    = -1;
            oldSoundId = -1;
            if (!String.IsNullOrEmpty(soundbank) && !Global.RegisteredSoundBanks.Contains(soundbank))
            {
                Utils.DebugWriteLine($"Registering sound bank {soundset}");
                API.RequestScriptAudioBank(soundbank, false);
                Global.RegisteredSoundBanks.Add(soundbank);
            }
            if (!String.IsNullOrEmpty(soundset))
            {
                Utils.DebugWriteLine($"Adding soundset {soundset} for {_file}");
                DLCSoundSet = soundset;
            }
        }
Пример #9
0
        /// <summary>
        /// Plays a tone, asynchronously.
        /// </summary>
        /// <param name="tone">A <see cref="ToneType"/> to play.</param>
        /// <param name="streamPolicy">A <see cref="AudioStreamPolicy"/>.</param>
        /// <param name="durationMilliseconds">The tone duration in milliseconds. -1 indicates an infinite duration.</param>
        /// <param name="cancellationToken">The cancellation token which can be used to stop playing the tone.</param>
        /// <returns>A task that represents the asynchronous operation.</returns>
        /// <exception cref="ArgumentException"><paramref name="tone"/> is invalid.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="streamPolicy"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="durationMilliseconds"/> is less than -1.</exception>
        /// <exception cref="InvalidOperationException">Any invalid operations occurred.</exception>
        /// <exception cref="NotSupportedException"><paramref name="tone"/> is not a supported type.</exception>
        /// <exception cref="ObjectDisposedException"><paramref name="streamPolicy"/> has already been disposed of.</exception>
        /// <since_tizen> 3 </since_tizen>
        public static Task StartAsync(ToneType tone, AudioStreamPolicy streamPolicy,
                                      int durationMilliseconds, CancellationToken cancellationToken)
        {
            if (durationMilliseconds < -1)
            {
                throw new ArgumentOutOfRangeException(nameof(durationMilliseconds), durationMilliseconds,
                                                      $"{nameof(durationMilliseconds)} can't be less than -1.");
            }

            if (streamPolicy == null)
            {
                throw new ArgumentNullException(nameof(streamPolicy));
            }

            ValidationUtil.ValidateEnum(typeof(ToneType), tone, nameof(tone));

            if (cancellationToken.IsCancellationRequested)
            {
                return(Task.FromCanceled(cancellationToken));
            }

            return(StartAsyncCore(tone, streamPolicy, durationMilliseconds, cancellationToken));
        }
Пример #10
0
 /// <summary>
 /// Initializes new instance of class with specified line number.
 /// </summary>
 /// <param name="line">Line number.</param>
 /// <param name="tone">Tone type: 0 - unknown, 1 - busy, 2 - ring back, 3 - CED, 4 - CNG, 5 - user, 6 - voice (see <see cref="Diacom.Ev.ToneType">ToneType</see> enumeration).</param>
 public Tone(object line, ToneType tone) : base(line, Ev.EventID.TONE)
 {
     this.Type = tone;
 }
Пример #11
0
 internal static extern TonePlayerError Start(ToneType tone, AudioStreamPolicyHandle streamInfoHandle,
                                              int durationMs, out int id);
Пример #12
0
 public void SetToneParameter(ToneType Type, int[] Parameter)
 {
     ToneData.SetData(Type, Parameter);
 }
Пример #13
0
 /// <summary>
 /// Plays a tone, asynchronously.
 /// </summary>
 /// <param name="tone">A <see cref="ToneType"/> to play.</param>
 /// <param name="streamPolicy">A <see cref="AudioStreamPolicy"/>.</param>
 /// <param name="durationMilliseconds">The tone duration in milliseconds. -1 indicates an infinite duration.</param>
 /// <returns>A task that represents the asynchronous operation.</returns>
 /// <exception cref="ArgumentException"><paramref name="tone"/> is invalid.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="streamPolicy"/> is null.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="durationMilliseconds"/> is less than -1.</exception>
 /// <exception cref="InvalidOperationException">Any invalid operations occurred.</exception>
 /// <exception cref="NotSupportedException"><paramref name="tone"/> is not a supported type.</exception>
 /// <exception cref="ObjectDisposedException"><paramref name="streamPolicy"/> has already been disposed of.</exception>
 /// <since_tizen> 3 </since_tizen>
 public static Task StartAsync(ToneType tone, AudioStreamPolicy streamPolicy,
                               int durationMilliseconds)
 {
     return(StartAsync(tone, streamPolicy, durationMilliseconds, CancellationToken.None));
 }