예제 #1
0
        public static bool RequestSplitRepresentative(long sessionId)
        {
            AudioEntity audioEntity = GetParentAudioByIdSession(sessionId);

            if (audioEntity == null)
            {
                return(false);
            }

            RequestSplitRepresentativeParam requestSplitRepresentativeParam = new RequestSplitRepresentativeParam();

            requestSplitRepresentativeParam.idAudio = audioEntity.idAudio;

            try
            {
                string postData   = JsonConvert.SerializeObject(requestSplitRepresentativeParam);
                string postResult = SendPostJsonApplicationTypeRequest(
                    AppsSettings.GetInstance().ApiUrl + "/representativeSplit/loadSplitRepresentative",
                    postData);
                BaseMessage message = JsonConvert.DeserializeObject <BaseMessage>(postResult);
                if (message != null && message.status == Constants.RESPONSE_STATUS_SUCCESS)
                {
                    return(true);
                }
            }catch (Exception e)
            {
                return(false);
            }
            return(false);
        }
예제 #2
0
        public async Task <GeneralStatusEnum> InsertOrMergeEntityAsync(AudioEntity entity)
        {
            try
            {
                if (_table is null)
                {
                    await CreateTableAsync();
                }
                if (entity == null)
                {
                    throw new ArgumentNullException(nameof(entity));
                }
                // Create the InsertOrReplace table operation
                TableOperation insertOrMergeOperation = TableOperation.InsertOrMerge(entity);

                // Execute the operation.
                TableResult result = await _table.ExecuteAsync(insertOrMergeOperation);

                var insertedQuote = result.Result as AudioEntity;

                // Get the request units consumed by the current operation. RequestCharge of a TableResult is only applied to Azure CosmoS DB
                if (result.RequestCharge.HasValue)
                {
                    _log.LogInformation($"Request Charge of InsertOrMerge Operation:{ result.RequestCharge}");
                }

                return(GeneralStatusEnum.Ok);
            }
            catch (Exception e)
            {
                _log.LogInformation(e.Message);
                return(GeneralStatusEnum.ServerError);
            }
        }
    public void ReplacePatternBinding(AudioEntity newEntity)
    {
        var index     = GameComponentsLookup.PatternBinding;
        var component = CreateComponent <PatternBindingComponent>(index);

        component.entity = newEntity;
        ReplaceComponent(index, component);
    }
    public void ReplacePatternFollower(AudioEntity newSource)
    {
        var index     = AudioComponentsLookup.PatternFollower;
        var component = CreateComponent <PatternFollowerComponent>(index);

        component.source = newSource;
        ReplaceComponent(index, component);
    }
예제 #5
0
        private void btn_ResetAll_Click(object sender, RibbonControlEventArgs e)
        {
            DialogResult dialogResult = CreateInformationDialog.CreateConfirmBoxWithTwoButton("" +
                                                                                              "Tổng hợp lại toàn bộ sẽ xóa toàn bộ thay đổi trên tệp tổng hợp và ghép lại các băng đã được kiểm duyệt. Bạn có muốn tiếp tục?", "Cảnh báo");

            try
            {
                if (dialogResult == DialogResult.Yes && AppsSettings.GetInstance().Session != null)
                {
                    Debug.WriteLine("Xoa toan bo");
                    ///1. Reset merged request

                    bool resetMergedStatus = Request.ResetMergeDocument(AppsSettings.GetInstance().Session.idSession);

                    if (resetMergedStatus == true)
                    {
                        ///Call remerged document
                        //2. Goi ham merge doc
                        AudioEntity entity = Request.GetParentAudioByIdSession(AppsSettings.GetInstance().Session.idSession);
                        if (entity == null)
                        {
                            CreateInformationDialog.CreateWarningBox("Không tồn tại tệp âm thanh tổng hợp", "cảnh báo");
                        }
                        else
                        {
                            Boolean isRequestSuccessful = Request.RequestMerge(entity.idAudio);
                            if (isRequestSuccessful == true)
                            {
                                NotificationFactor.InfoNotification("Tổng hợp biên bản thành công");
                            }
                            else
                            {
                                NotificationFactor.ErrorNotification("Tổng hợp biên bản thất bại");
                            }
                        }
                        //3.Goi ham lay lai du lieu
                        //Get document Entity
                        DocumentEntity documentEntity = Request.getMergedDocument(AppsSettings.GetInstance().Session.idSession);
                        //4.Clear current document
                        AppsSettings.GetInstance().DocumentName = null; // To avoid save document when call the saveAs method
                        Word.Document document = Globals.ThisAddIn.Application.ActiveDocument;
                        WordProcessingHelper.SaveNewSessionDocument(AppsSettings.GetInstance().Session, document);
                        WordProcessingHelper.CreateDocumentTitle(document, AppsSettings.GetInstance().Session);
                        //4. day du lieu ra ma hinh
                        WordProcessingHelper.InsertDataToMergedDocument(Globals.ThisAddIn.Application.ActiveDocument, documentEntity);
                        AppsSettings.GetInstance().IsRepresentativeSplit = false;
                        AppsSettings.GetInstance().DocumentName          = document.FullName;
                    }
                    else
                    {
                        NotificationFactor.ErrorNotification("Không thể tổng hợp lại biên bản");
                    }
                }
            } catch (Exception ex)
            {
                NotificationFactor.ErrorNotification("Không thể tổng hợp lại biên bản");
            }
        }
        private async Task <GeneralStatusEnum> SaveAudioDetails(
            string fileName,
            string id,
            ProcessStatusEnum status,
            string audioUrl = null)
        {
            var uploadEntity = new AudioEntity("Uploads", id, fileName, status, audioUrl);

            return(await _tableDbContext.InsertOrMergeEntityAsync(uploadEntity));
        }
예제 #7
0
 /// <summary>
 /// 初期化処理
 /// </summary>
 /// <param name="music">再生楽曲情報</param>
 void Setup(MusicParamObject music)
 {
     musicParam  = music;
     audioEntity = audioPool.Rent();
     audioSource = audioEntity.audioSource;
     if (audioSource == null)
     {
         Debug.LogError("null source");
     }
 }
예제 #8
0
    internal void CreatePattern(int size, AudioEntity source)
    {
        var e = CreatePattern(size, FollowType.Pattern, source);

        e.AddPatternFollower(source);
        var l = new List <AudioEntity>();

        l.Add(e);
        source.AddFollowers(l);
    }
예제 #9
0
    public void ReplaceStepTriggered(int newStepIndex, double newPulseTime, AudioEntity newStep)
    {
        var index     = AudioComponentsLookup.StepTriggered;
        var component = CreateComponent <StepTriggered>(index);

        component.stepIndex = newStepIndex;
        component.pulseTime = newPulseTime;
        component.step      = newStep;
        ReplaceComponent(index, component);
    }
예제 #10
0
    // para0: 再生する音源データのaudioClips中の0から始まる番号。
    // para1: 再生オプション。 型のコメントを参照。
    // para2: ループ再生するか。
    // para3: 音源のタイプ(BGM or SE or 未分別) <= これ正直よくなかった。曲と種類の相関表を作るべきでした。
    // para4: 音源の再生開始位置(秒)
    // para5: 再生開始の遅延(秒)。
    // デフォルトの音量は最大です。*当然ですが、各種Mixerによる影響は受けます。
    public void Play(int index, PLAY_OPTION option, bool isLoop = false, AUDIO_TYPE type = AUDIO_TYPE.NON_CATEGORIZED, float startSec = 0.0f, float delay = 0.0f)
    {
        if (option == PLAY_OPTION.CONTINUOUS)
        { // 指定された音源が再生中かチェック
            AudioEntity entity = audioEntities.Find(x => { return(x.audioName == audioClips[index].name); });

            if (entity != null)
            {
                if (entity.isPlaying)
                {
                    Debug.Log("Already played. The option type is CONTINUOUS: audio name is " + audioClips[index].name + ".");
                    return;
                }
                else
                {
                    entity.Play(delay);
                }
                return;
            }
        }
        else if (option == PLAY_OPTION.RESTART)
        {
            AudioEntity entity = audioEntities.Find(x => { return(x.audioName == audioClips[index].name); });

            if (entity != null)
            {
                if (entity.isPlaying)
                {
                    entity.time = 0.0f;
                    entity.Play(delay);
                    return;
                }
            }
        }
        else //  PLAY_OPTION::ADDITIVE
        {
            AudioEntity entity = audioEntities.Find(x => { return(x.audioName == audioClips[index].name); });

            if (entity != null)
            {
                if (!entity.isPlaying)
                {
                    // 既に確保されたAudioSourceを再利用する。
                    entity.time = 0.0f;
                    entity.ResetSetting();
                    entity.Play(delay);
                    return;
                }
            }
        }

        // 新たにAudio Sourceを生成して、再生する。
        PlayNewAudio(index, isLoop, type, delay);
    }
예제 #11
0
 public void OnPulse(AudioEntity entity, double thisPulseTime, double nextPulseTime,
                     double period, uint pulsesPerBeat, double latency)
 {
     if (data1)
     {
         data1.text = entity.ToString();
     }
     if (data2)
     {
         data2.text = thisPulseTime.ToString();
     }
 }
예제 #12
0
    public override void OnStepTriggered(AudioEntity entity, int stepIndex, double pulseTime, AudioEntity step)
    {
        if (Samples.Count == 0)
        {
            return;
        }

        var currentSample = Samples[_currentSampleIndex];

        _currentSampleIndex = (_currentSampleIndex + 1) % Samples.Count;

        var volume      = step.hasVolume ? step.volume.value : 1f;
        var pitch       = step.hasPitch ? step.pitch.value : 0f;
        var pulsePeriod = entity.pattern.pulseSource.hasPulse ?
                          entity.pattern.pulseSource.pulse.period :                    // Tempo pattern
                          entity.pattern.pulseSource.pattern.pulseSource.pulse.period; // Pattern follower
        var offset = step.hasOffset ? step.offset.value * pulsePeriod : 0f;

        currentSample.Envelope.Volume = volume;
        currentSample.Pitch           = pitch;
        currentSample.Envelope.Offset = offset;
        // if suspended, keep counting sample indices in order to keep in phase
        //if (Suspended)
        //{
        //    return;
        //}

        var currentAudioSource = _audioSources[_currentAudioSourceIndex];

        _currentAudioSourceIndex = (_currentAudioSourceIndex + 1) % _audioSources.Count;

        var envelopeFilter = currentAudioSource.GetComponent <VolumeEnvelopeFilter>();

        if (envelopeFilter != null)
        {
            envelopeFilter.Enabled = currentSample.Envelope.Enabled;

            if (currentSample.Envelope.Enabled)
            {
                envelopeFilter._attackDuration  = currentSample.Envelope.AttackTime;
                envelopeFilter._sustainDuration = currentSample.Envelope.SustainTime;
                envelopeFilter._releaseDuration = currentSample.Envelope.ReleaseTime;
                envelopeFilter.Trigger(pulseTime);
            }
        }
        currentAudioSource.volume = currentSample.Volume;
        currentAudioSource.clip   = currentSample.Clip;
        currentAudioSource.pitch  = currentSample.Pitch;
        //currentAudioSource.timeSamples = currentSample.Offset;
        currentAudioSource.PlayScheduled(pulseTime + offset);
    }
예제 #13
0
    private void PlayNewAudio(int index, bool isLoop = false, AUDIO_TYPE type = AUDIO_TYPE.NON_CATEGORIZED, float startSec = 0.0f, float delay = 0.0f)
    {
        // AudioEntityを生成する。
        AudioEntity entity = new AudioEntity(audioClips[index], gameObject, type);

        audioEntities.Add(entity); // 子にAudio Source Componentを持たせて、参照を保持しておく。

        int endId = audioEntities.Count - 1;

        audioEntities[endId].isLoop = isLoop;
        audioEntities[endId].time   = startSec;

        audioEntities[endId].Play(delay);
    }
예제 #14
0
    internal void CreateButtonLayout(int y, int numButtons, AudioEntity pattern)
    {
        List <GameEntity> buttons = new List <GameEntity>();

        for (int i = 0; i < numButtons; i++)
        {
            buttons.Add(CreateButton(i, y));
        }

        var e = _contexts.game.CreateEntity();

        e.AddHolder(buttons, HolderArrangement.Linear);

        e.AddPatternBinding(pattern);
        pattern.AddAttachedView(e);
    }
예제 #15
0
    internal AudioEntity CreatePattern(int size, FollowType type, AudioEntity pulseSource)
    {
        var e = _contexts.audio.CreateEntity();
        List <AudioEntity> steps = new List <AudioEntity>();

        for (int i = 0; i < size; i++)
        {
            var s = _contexts.audio.CreateEntity();
            s.AddStep(false);
            s.AddVolume(1f);
            s.AddPitch(0);
            s.AddOffset(0);
            steps.Add(s);
        }
        e.AddPattern(steps, type, pulseSource);
        e.AddStepIndex(0);
        e.AddPosition(new IntVector2(0, type == FollowType.Pulse ? 0 : -3));
        e.isInteractive = true;
        e.AddAsset(type == FollowType.Pulse ? Res.KickSampler : Res.XyloSampler);
        e.AddPulseTrigger(AudioSettings.dspTime);
        entityService.CreateButtonLayout(type == FollowType.Pulse ? 0:-3, size, e);
        return(e);
    }
    public void ReplacePattern(System.Collections.Generic.List <AudioEntity> newSteps, FollowType newFollowType, AudioEntity newPulseSource)
    {
        var index     = AudioComponentsLookup.Pattern;
        var component = CreateComponent <Pattern>(index);

        component.steps       = newSteps;
        component.followType  = newFollowType;
        component.pulseSource = newPulseSource;
        ReplaceComponent(index, component);
    }
예제 #17
0
파일: Audio.cs 프로젝트: IdeaFortune/Monaco
 public static bool CreateAudio(ref AudioEntity entity)
 {
     return SqlAudio.Instance.CreateAudio(ref entity);
 }
예제 #18
0
        /// <summary>
        /// 刷新当前机器状态
        /// </summary>
        internal static void refreshDeviceInfo()
        {
            #region 刷新摄像头状态
            var remindCamera = XmlHelper.XmlHelper.FindAll <CameraEntity>();
            if (remindCamera == null)
            {
                remindCamera = new List <CameraEntity>();
            }
            //当前可以获取到的所有摄像头
            DsDevice[] findCamera = GetAllVideoDevice();

            if (findCamera == null || findCamera.Length == 0)
            {
                //更新集合
                if (remindCamera?.Count > 0)
                {
                    //所有的摄像头不可用
                    remindCamera.ForEach(m =>
                    {
                        m.Status = 3;
                    }
                                         );
                    XmlHelper.XmlHelper.SaveList <CameraEntity>(remindCamera);
                }

                throw new Exception("未找到可用的摄像头");
            }

            List <DsDevice> findCameraList = findCamera.ToList();

            //遍历已经记录的摄像,在当前可寻找到的摄像头中查找
            foreach (var item in remindCamera)
            {
                DsDevice CameraDevice = findCameraList.Find(m => m.Name == item.Name);
                if (CameraDevice == null)
                {
                    item.Status = 3;
                }
            }

            //遍历寻找到的摄像头,在记录的摄像头中进行寻找
            foreach (var item in findCameraList)
            {
                CameraEntity cameraEntity = remindCamera.Find(m => m.Name == item.Name);
                if (cameraEntity == null)
                {
                    cameraEntity        = new CameraEntity();
                    cameraEntity.Name   = item.Name;
                    cameraEntity.Status = 0;
                    remindCamera.Add(cameraEntity);
                }
            }
            XmlHelper.XmlHelper.SaveList <CameraEntity>(remindCamera);
            #endregion


            #region 刷新音频状态
            var remindAudio = XmlHelper.XmlHelper.FindAll <AudioEntity>();
            if (remindAudio == null)
            {
                remindAudio = new List <AudioEntity>();
            }
            //当前可以获取到的所有摄像头
            DsDevice[] findAudio = GetAllAudioDevice();

            if (findAudio == null || findAudio.Length == 0)
            {
                //更新集合
                if (remindAudio?.Count > 0)
                {
                    //所有的摄像头不可用
                    remindAudio.ForEach(m =>
                    {
                        m.Status = 3;
                    }
                                        );
                    XmlHelper.XmlHelper.SaveList <AudioEntity>(remindAudio);
                }

                throw new Exception("未找到可用的音频");
            }

            List <DsDevice> findAudioList = findAudio.ToList();

            //遍历已经记录的摄像,在当前可寻找到的摄像头中查找
            foreach (var item in remindAudio)
            {
                DsDevice CameraDevice = findAudioList.Find(m => m.Name == item.Name);
                if (CameraDevice == null)
                {
                    item.Status = 3;
                }
            }

            //遍历寻找到的摄像头,在记录的摄像头中进行寻找
            foreach (var item in findAudioList)
            {
                AudioEntity audioEntity = remindAudio.Find(m => m.Name == item.Name);
                if (audioEntity == null)
                {
                    audioEntity        = new AudioEntity();
                    audioEntity.Name   = item.Name;
                    audioEntity.Status = 0;
                    remindAudio.Add(audioEntity);
                }
                XmlHelper.XmlHelper.SaveList <AudioEntity>(remindAudio);
            }
            #endregion
        }
예제 #19
0
 public void OnPosition(AudioEntity entity, IntVector2 value)
 {
     OnPosition(value);
 }
예제 #20
0
 public virtual void OnDestroyed(AudioEntity entity)
 {
     destroy();
 }
예제 #21
0
 public void Return(AudioEntity entity)
 {
     pool.Return(entity);
 }
예제 #22
0
{//
    public abstract void OnStepTriggered(AudioEntity entity, int stepIndex, double pulseTime, AudioEntity step);
예제 #23
0
 public void OnAsset(AudioEntity entity, string value)
 {
     OnAsset((IViewable)entity, value);
 }
예제 #24
0
        private void Btn_Merge_Click(object sender, RibbonControlEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                Word.Document document = Globals.ThisAddIn.Application.ActiveDocument;
                //0. Kiem tra danh sach dai bieu

                /*string missingName;
                 * if (WordProcessingHelper.CheckRepresentativeList(document,
                 *  mRepresentativeForm.GetRepresentativeList(), out missingName) == false)
                 * {
                 *  //Tai lai danh sach
                 *  mRepresentativeForm.FillingData();
                 *  if (WordProcessingHelper.CheckRepresentativeList(document,
                 *  mRepresentativeForm.GetRepresentativeList(), out missingName) == false)
                 *  {
                 *      ///Notify nguoi dung tao moi
                 *      DialogResult result = CreateInformationDialog.CreateConfirmBoxWithTwoButton("Không tìm thấy đại biểu: " + missingName + "  Bạn có muốn thêm mới?", "Cảnh báo");
                 *      if (result == DialogResult.Yes)
                 *      {
                 *          System.Diagnostics.Process.Start(AppsSettings.GetInstance().ApiUrl + "/quan-ly-dai-bieu");
                 *      }
                 *  }
                 * }*/
                //1. Luu lai cac thay doi
                ///Kiem tra xem co thay doi nao khoong, neu co, luu lai thay doi

                /*DocumentEntity documentEntity = WordProcessingHelper.ParsingDocument(
                 *  document, mRepresentativeForm.GetRepresentativeList());
                 * documentEntity.sessionId = AppsSettings.GetInstance().Session.idSession;
                 * Request.SaveDocument(documentEntity);*/
                //2. Goi ham merge doc
                AudioEntity entity = Request.GetParentAudioByIdSession(AppsSettings.GetInstance().Session.idSession);
                if (entity == null)
                {
                    CreateInformationDialog.CreateWarningBox("Không tồn tại tệp âm thanh tổng hợp", "cảnh báo");
                }
                else
                {
                    DocumentEntity mergedDocument = Request.RequestMergeAndGetResult(entity.idAudio);

                    if (mergedDocument == null)
                    {
                        NotificationFactor.ErrorNotification("Tổng hợp biên bản thất bại");
                        return;
                    }

                    //3.Goi ham lay lai du lieu
                    //Get document Entity
                    //documentEntity = Request.getMergedDocument(AppsSettings.GetInstance().Session.idSession);
                    //4.Clear current document
                    //TextHelpers.RemoveContent(document);
                    //4. day du lieu ra ma hinh
                    WordProcessingHelper.InsertDataToEndDocument(Globals.ThisAddIn.Application.ActiveDocument, mergedDocument);
                    AppsSettings.GetInstance().IsRepresentativeSplit = false;
                    NotificationFactor.InfoNotification("Tổng hợp biên bản thành công");
                }
            } catch (Exception ee)
            {
                NotificationFactor.ErrorNotification("Tổng hợp biên bản thất bại");
            }

            Cursor.Current = Cursors.Default;
        }