コード例 #1
0
    public void OnKeyDown()
    {
        volumeDown  = false;
        myas.pitch  = MuseUtil.MidiToUnityPitch(pitch);
        myas.volume = 1;
        myas.Stop();
        myas.Play(0);
        print("keydown");

        if (isStarted)
        {
            currentNote       = new Note(Time.time, pitch);
            currentNote.myKey = this;
        }
    }
コード例 #2
0
    public List <KeyInputRef> GetKeyInputRefs(int keynum)
    {
        List <KeyInputRef> pitches = new List <KeyInputRef>();

        int midIndex      = keynum / 2 - 1;
        int scaleCount    = scale.Count;
        int keyScaleIndex = MuseUtil.PitchValue[key.Replace("m", string.Empty)];
        int pindex        = keyScaleIndex - midIndex - 1;

        for (int i = 0; i < keynum; ++i)
        {
            int scaleDiff = Mathf.Abs(pindex) / scaleCount;

            if (pindex < 0)
            {
                scaleDiff = -scaleDiff - 1;
            }

            int index = pindex;
            Debug.Log(index);
            Debug.Log(scaleDiff);
            if (pindex < 0)
            {
                index += scaleCount * Mathf.Abs(scaleDiff);
            }
            else if (pindex > scaleCount - 1)
            {
                index -= scaleCount * Mathf.Abs(scaleDiff);
            }


            KeyInputRef kir = new KeyInputRef();

            int midivalue = MuseUtil.NameToMidi("C") + scale[index] + scaleDiff * 12;
            kir.midi         = midivalue;
            kir.showText     = MuseUtil.MidiToName(midivalue);
            kir.isChordTone  = IsChordTone(midivalue);
            kir.isSteadyTone = IsSteadyTone(midivalue);
            kir.isPentatonic = IsPentatonic(midivalue);


            pitches.Add(kir);
            pindex++;
        }

        return(pitches);
    }
コード例 #3
0
ファイル: Program.cs プロジェクト: coloriz/Tadley
        static int RunExtractAndReturnExitCode(ExtractOptions opts)
        {
            // read data from input file
            var museDataCollection = MuseUtil.ReadMuseData(opts.InputFile);
            var gsrPpgCollection   = GsrPpgUtil.ReadGsrPpgData(opts.InputFile);

            // slice data by specified time span
            var museDataFragments = museDataCollection.SelectByTime(opts.TimeOff, opts.Duration);
            var gsrPpgFragments   = gsrPpgCollection.SelectByTime(opts.TimeOff, opts.Duration);

            // post-process gsr/ppg data
            var processedGsr = GsrPpgUtil.GSRfiltering(gsrPpgFragments["GSR"]);
            var processedPpg = GsrPpgUtil.GetPPGdata(gsrPpgFragments["PPG"], TimeSpan.FromMilliseconds(100));

            using (var fs = new FileStream(opts.OutputFile, FileMode.Create, FileAccess.Write))
                using (var package = new ExcelPackage(fs))
                {
                    // process Muse data
                    foreach (var d in museDataFragments)
                    {
                        var sheet = package.Workbook.Worksheets.Add(d.Key.ToString());

                        switch (d.Value[0])
                        {
                        case Channel _:
                            var channels = d.Value.ChangeType <Channel>();
                            var query    = from c in channels
                                           select new { Timestamp = new TimeSpan(c.Timestamp).ToString("g"), c.TP9, c.AF7, c.AF8, c.TP10 };
                            sheet.Cells[1, 1].LoadFromCollection(query, PrintHeaders: true);
                            sheet.Cells[sheet.Dimension.Address].AutoFitColumns();
                            var table = sheet.Tables.Add(sheet.Dimension, d.Key.ToString());
                            // Set table properties (order matters!)
                            table.ShowRowStripes  = false;
                            table.TableStyle      = TableStyles.Medium9;
                            table.ShowFirstColumn = true;
                            break;

                        default:
                            throw new NotImplementedException();
                        }
                    }

                    // process Raw GSR/PPG data
                    foreach (var d in gsrPpgFragments)
                    {
                        var sheet = package.Workbook.Worksheets.Add(d.Key);

                        var query = from p in d.Value
                                    select new { Timestamp = new TimeSpan(p.Timestamp).ToString("g"), p.Value };
                        sheet.Cells[1, 1].LoadFromCollection(query, PrintHeaders: true);
                        sheet.Cells[sheet.Dimension.Address].AutoFitColumns();
                        var table = sheet.Tables.Add(sheet.Dimension, d.Key);
                        // Set table properties (order matters!)
                        table.ShowRowStripes  = false;
                        table.TableStyle      = TableStyles.Medium14;
                        table.ShowFirstColumn = true;
                    }

                    // process post-processed GSR/PPG data
                    var processedGsrSheet = package.Workbook.Worksheets.Add("Processed GSR");
                    var processedGsrQuery = from p in processedGsr
                                            select new { Timestamp = new TimeSpan(p.Timestamp).ToString("g"), p.Value };
                    processedGsrSheet.Cells[1, 1].LoadFromCollection(processedGsrQuery, PrintHeaders: true);
                    processedGsrSheet.Cells[processedGsrSheet.Dimension.Address].AutoFitColumns();
                    var processedGsrTable = processedGsrSheet.Tables.Add(processedGsrSheet.Dimension, "ProcessedGSR");
                    // Set table properties (order matters!)
                    processedGsrTable.ShowRowStripes  = false;
                    processedGsrTable.TableStyle      = TableStyles.Medium13;
                    processedGsrTable.ShowFirstColumn = true;

                    var bpmSheet = package.Workbook.Worksheets.Add("BPM");
                    var bpmQuery = from p in processedPpg
                                   select new { Timestamp = new TimeSpan(p.Timestamp).ToString("g"), p.Value };
                    bpmSheet.Cells[1, 1].LoadFromCollection(bpmQuery, PrintHeaders: true);
                    bpmSheet.Cells[bpmSheet.Dimension.Address].AutoFitColumns();
                    var bpmTable = bpmSheet.Tables.Add(bpmSheet.Dimension, "BPM");
                    // Set table properties (order matters!)
                    bpmTable.ShowRowStripes  = false;
                    bpmTable.TableStyle      = TableStyles.Medium13;
                    bpmTable.ShowFirstColumn = true;

                    package.Save();
                }

            return(0);
        }