예제 #1
0
    public void NewDB()
    {
        _ClipPromptPairs.Clear();
        //_Clips.Clear();

        _DataBaseVersionNumber++;
        PlayerPrefs.SetInt("_DataBaseVersionNumber", _DataBaseVersionNumber);
        JsonSerialisationHelper.Save(JSONClipDBPath, _ClipPromptPairs);
    }
예제 #2
0
    // Use this for initialization
    void Start()
    {
        PrintAllRecordingDevices();

        // Get Audio source component
        _AudioSource = GetComponent <AudioSource>();

        // Hook up UI
        _PlayButton.onClick.AddListener(() => SetState(State.Playing));
        _RecordButton.onClick.AddListener(() => RecordToggle());
        _RandomizePromptButton.onClick.AddListener(() => RandomizePrompt());
        _PlaybackRadial.fillAmount = 0;
        _RecordRadial.fillAmount   = 0;

        if (_LoadClipsAtStart)
        {
            print("Loading all clips...");
            if (System.IO.File.Exists(JSONDBInfoPath))
            {
                _DataBaseVersionNumber = PlayerPrefs.GetInt("_DataBaseVersionNumber");
            }

            print("DB ID: " + _DataBaseVersionNumber);

            if (System.IO.File.Exists(JSONClipDBPath))
            {
                _ClipPromptPairs = JsonSerialisationHelper.LoadFromFile <List <ClipPromptPair> >(JSONClipDBPath) as List <ClipPromptPair>;
                print("Loaded clips prompt pairs: " + _ClipPromptPairs.Count);
            }
            else
            {
                print("Can't find JSON clip pair file");
            }

            for (int i = 0; i < _ClipPromptPairs.Count; i++)
            {
                var filepath = Path.Combine(Application.persistentDataPath, _ClipPromptPairs[i]._ClipPath);
                filepath = "file:///" + filepath;

                // Starts coroutine that adds clip to the list if completeed successfully
                StartCoroutine(GetAudioClip(_ClipPromptPairs[i]));
            }
        }
    }
예제 #3
0
    private void SaveProject(string filePath)
    {
        System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath);
        PlayerPrefs.SetString("LastProjectPath", fileInfo.Directory.FullName);
        string fileName = System.IO.Path.GetFileName(filePath);

        _ProjectName = fileName;
        Project proj = new Project();

        proj._Clips = new ProjectClip[16];

        int indexer = 0;

        foreach (ClipPadUI cpu in _ClipPads)
        {
            proj._Clips[indexer] = cpu._ClipData;
            indexer++;
        }
        JsonSerialisationHelper.Save <Project>(filePath, proj);
    }
예제 #4
0
    private void OnLoadProjectSuccess(string filePath)
    {
        System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath);
        PlayerPrefs.SetString("LastProjectPath", fileInfo.Directory.FullName);
        string fileName = System.IO.Path.GetFileName(filePath);

        _ProjectName = fileName;
        Project loadedProj = (Project)JsonSerialisationHelper.LoadFromFile <Project>(filePath);
        int     i          = 0;

        foreach (ProjectClip clipData in loadedProj._Clips)
        {
            if (clipData != null)
            {
                _ClipPads[i].LoadFromClipData(clipData);
                i++;
            }
            else
            {
                _ClipPads[i].Clear();
            }
        }
        _LoadedProjectPath = filePath;
    }
예제 #5
0
 private void OnApplicationQuit()
 {
     PlayerPrefs.SetInt("_DataBaseVersionNumber", _DataBaseVersionNumber);
     JsonSerialisationHelper.Save(JSONClipDBPath, _ClipPromptPairs);
 }