Пример #1
0
        // 크롤러 모니터 정보 refresh
        public void RefreshGoodsTable()
        {
            GoodsListForm_.ClearList();
            Dictionary <Int32, CGoodsData> plist = GoodsManager.Instance.GetList();

            foreach (var pData in plist)
            {
                AuthorityInfoData pAuthorityInfoData = AuthorityManager.Instance.GetAuthrity(pData.Value.AuthoritySeq_);
                if (pAuthorityInfoData == null)
                {
                    pData.Value.AuthrityName_ = "권리사 찾을수 없음";
                }
                else
                {
                    pData.Value.AuthrityName_ = pAuthorityInfoData.partnerName_;
                }

                ChannelInfoData pChannelInfoData = ChannelManager.Instance.GetChannel(pData.Value.ChannelSeq_);
                if (pChannelInfoData == null)
                {
                    pData.Value.ChannelName_ = "채널 찾을수 없음";
                }
                else
                {
                    pData.Value.ChannelName_ = pChannelInfoData.ChannelName_;
                }

                GoodsListForm_.Add_List(pData.Value);

                //GoodsListForm_.Add_List(pData.Value.Seq_.ToString(), pData.Value.GoodsName_, pData.Value.OptionName_, pData.Value.ChannelName_
                //    , pData.Value.AuthrityName_, "none");
            }
        }
Пример #2
0
        public ModUtils(SongData songData, int paramTicksPerRow, PROTRACKER_COMPATIBILITY_MODE forceProTrackerCompatibility, int portamentoAccuracyThreshold, bool ntscMode)
            : base(songData, paramTicksPerRow, ntscMode)
        {
            modCommands = new ModCommands(songData, paramTicksPerRow);

            this.forceProtrackerCompatibility = forceProTrackerCompatibility;
            this.portamentoAccuracyThreshold  = portamentoAccuracyThreshold;
            instrumentsList = new InstrumentDataMOD[songData.Instruments.Length];

            for (int i = 0; i < instrumentsList.Length; i++)
            {
                instrumentsList[i]         = new InstrumentDataMOD();
                instrumentsList[i].Samples = new InstrumentDataMOD.SampleDataMOD[songData.Instruments[i].Samples.Length];
                for (int a = 0; a < instrumentsList[i].Samples.Length; a++)
                {
                    instrumentsList[i].Samples[a] = new InstrumentDataMOD.SampleDataMOD();
                }
            }
            for (int i = 0; i < channelData.Length; i++)
            {
                ChannelInfoData item = new ChannelInfoData();
                item.ReachedNote = -1;
                channelData[i]   = item;
            }
        }
Пример #3
0
        public int GetModNote(string note, int sampleNumber, int channel, bool isTonePortamentoTriggered)
        {
            //due to lack of base note sample on mod,
            //note is dinamically computed by related sample note and frequency
            int tone2Add = sampleNumber >= 0 ? instrumentsList[sampleNumber].Samples[0].RelatedNote : 0;

            int value = 0;

            string tune = note.Substring(0, 2);

            // useful for finding an item into an array
            int originalNoteIndex = Array.FindIndex(notesArray, delegate(string item)
            {
                return(item.Equals(tune));
            });

            if (originalNoteIndex >= 0)
            {
                int octave = Int16.Parse(note.Substring(2, 1));

                int noteIndex = (octave - 2) * 12 + originalNoteIndex + tone2Add;

                if (isNoteInRange(noteIndex))
                {
                    value = PeriodsRange[noteIndex];

                    int renoiseNote = (octave * 12) + originalNoteIndex;

                    // playingChannelData
                    ChannelInfoData playingChannelData = channelData[channel];

                    playingChannelData.CurrentSample = sampleNumber;
                    if (isTonePortamentoTriggered)
                    {
                        playingChannelData.TonePortamentoNote   = renoiseNote;
                        playingChannelData.TonePortamentoPeriod = value;
                    }
                    else
                    {
                        playingChannelData.CurrentPitch         = 0;
                        playingChannelData.CurrentPeriod        = value;
                        playingChannelData.TonePortamentoPeriod = value;
                        playingChannelData.TonePortamentoNote   = renoiseNote;
                        playingChannelData.ReachedNote          = renoiseNote;
                    }

                    // debug
                    //if (channel == 2)
                    //    System.Diagnostics.Debug.WriteLine(String.Format("Note: Channel: {0} Period: {1} ModNote: {2} OriginalNote {3}",
                    //    channel, value, noteIndex, channelData[channel].ReachedNote));
                }
                else
                {
                    throw new ConversionException(String.Format("note {0} is out of range (can be fixed by changing sample frequency)", note));
                }
            }

            return(value);
        }
Пример #4
0
    // 채널 정보 로드
    public static bool GetChannelList(SqlHelper dbHelper)
    {
        try
        {
            ChannelManager.Instance.InitList();

            MySqlDataReader datareader = dbHelper.call_proc("spNewSelectChannel", null);

            Int32 ComboIndex = 1;
            while (datareader.Read())
            {
                ChannelInfoData pChannelInfoData = new ChannelInfoData();

                if (datareader["seq"] != DBNull.Value)
                {
                    pChannelInfoData.seq_ = Convert.ToInt32(datareader["seq"]);
                }

                if (datareader["ChannelCode"] != DBNull.Value)
                {
                    pChannelInfoData.ChannelCode_ = Convert.ToString(datareader["ChannelCode"]);
                }

                if (datareader["ChannelName"] != DBNull.Value)
                {
                    pChannelInfoData.ChannelName_ = Convert.ToString(datareader["ChannelName"]);
                }

                pChannelInfoData.ComboIndex_ = ComboIndex++;    // 콤보 박스에서 사용되는 인덱스
                ChannelManager.Instance.GetList().Add(pChannelInfoData.seq_, pChannelInfoData);
            }

            datareader.Close();
            datareader.Dispose();
            datareader = null;
        }
        catch (System.Exception ex)
        {
            return(false);
        }

        return(true);
    }
Пример #5
0
        private void StoreChannelPeriod(int portamento, char command, int channel)
        {
            ChannelInfoData playingChannelData = channelData[channel];
            int             directionFlag      = playingChannelData.PortamentoDirectionFlag * -1;
            int             currentPeriod      = playingChannelData.CurrentPeriod + (portamento * directionFlag);

            if (command == 'G')
            {
                if ((directionFlag > 0 && currentPeriod > playingChannelData.TonePortamentoPeriod) ||
                    (directionFlag < 0 && currentPeriod < playingChannelData.TonePortamentoPeriod))
                {
                    currentPeriod = playingChannelData.TonePortamentoPeriod;
                    playingChannelData.ReachedNote  = playingChannelData.TonePortamentoNote;
                    playingChannelData.CurrentPitch = 0;
                }
            }

            playingChannelData.CurrentPeriod = currentPeriod;
            //System.Diagnostics.Debug.WriteLine("current period: " + channelData[channel].CurrentPeriod);
        }
Пример #6
0
        /*
         * private int GetTonePortamentoFromChannelPeriodOld(int value, int channel)
         * {
         *  ChannelInfoData playingChannelData = channelData[channel];
         *
         *  if (value == 0 && playingChannelData.LastPortamentoValue > 0)
         *      value = playingChannelData.LastPortamentoValue;
         *
         *  if (value == 0)
         *      throw new ConversionException("tone portamento value equals 0");
         *
         *
         *  if (channel == 1)
         *  {
         *      // debug
         *      System.Diagnostics.Debug.WriteLine("Current Period: " + playingChannelData.CurrentPeriod);
         *  }
         *
         *  const int portamentoCommand = 0x03;
         *
         *  int tonePortamentoPeriod = PeriodsRange[GetModNote(playingChannelData.TonePortamentoNote, playingChannelData.CurrentSample, channel)];
         *
         *  int directionFlag = playingChannelData.CurrentPeriod < tonePortamentoPeriod ? -1 : +1;
         *  int currentPitch = playingChannelData.CurrentPitch + (value * directionFlag);
         *  int currentRenoiseNote = (int)Math.Truncate(((double)currentPitch / 16) + playingChannelData.ReachedNote);
         *
         *  if ((directionFlag > 0 && currentRenoiseNote >= playingChannelData.TonePortamentoNote) ||
         *      (directionFlag < 0 && currentRenoiseNote < playingChannelData.TonePortamentoNote))
         *  {
         *      currentRenoiseNote = playingChannelData.TonePortamentoNote;
         *      currentPitch = 0;
         *  }
         *
         *  int modNote = GetModNote(currentRenoiseNote, playingChannelData.CurrentSample, channel);
         *  int currentPeriod = playingChannelData.CurrentPeriod;
         *  int relativePitch;
         *
         *  relativePitch = currentPitch % 0x10;
         *  if (relativePitch < 0)
         *      relativePitch = relativePitch + 0x10;
         *
         *  if (currentPeriod == 0)
         *      throw new ConversionException("no previous note triggered on this channel");
         *
         *  int firstperiod = PeriodsRange[modNote];
         *
         *  int secondperiod = PeriodsRange[modNote + 1];
         *
         *  int delta = firstperiod - secondperiod;
         *
         *  int portamento = (relativePitch * delta) / 0x10;
         *
         *  int targetPeriod = firstperiod - portamento;
         *
         *  portamento = (currentPeriod - targetPeriod) * directionFlag;
         *
         *  playingChannelData.ReachedNote = currentRenoiseNote;
         *  playingChannelData.CurrentPitch = relativePitch;
         *  playingChannelData.LastPortamentoCommand = portamentoCommand;
         *  playingChannelData.LastPortamentoValue = value;
         *  playingChannelData.PortamentoDirectionFlag = directionFlag;
         *
         *  if (channel == 0)
         *  {
         *      System.Diagnostics.Debug.WriteLine(String.Format("channel: {0} effect: {1} value: {2} note: {3} pitch: {4} portamento: {5}",
         *      channel, portamentoCommand, value, currentRenoiseNote, relativePitch, portamento));
         *      // debug
         *  }
         *
         *  return portamento;
         * }
         */

        private int GetPortamentoFromChannelPeriod(char command, int value, int channel, bool ignorePitchCompatibilityMode)
        {
            ChannelInfoData playingChannelData = channelData[channel];

            if (value == 0 && playingChannelData.LastPortamentoValue > 0)
            {
                value = playingChannelData.LastPortamentoValue;
            }

            // new
            int directionFlag;
            int portamentoCommand;

            switch (command)
            {
            case 'U':
                directionFlag     = 1;
                portamentoCommand = 1;
                break;

            case 'D':
                directionFlag     = -1;
                portamentoCommand = 2;
                break;

            default:
                throw new ConversionException("command not valid");
            }

            int realValue          = ignorePitchCompatibilityMode == false && pitchCompatibilityMode ? value * (ticksPerRow > 1 ? ticksPerRow - 1 : 1) : value;
            int currentPitch       = playingChannelData.CurrentPitch + (realValue * directionFlag);
            int currentRenoiseNote = (int)Math.Truncate(((double)currentPitch / 16) + playingChannelData.ReachedNote);
            int modNote            = GetModNote(currentRenoiseNote, playingChannelData.CurrentSample, channel);
            int currentPeriod      = playingChannelData.CurrentPeriod;
            int relativePitch      = currentPitch % 0x10;

            if (relativePitch < 0)
            {
                relativePitch = relativePitch + 0x10;
            }

            int finalNote = modNote + 1;

            if (currentPeriod == 0)
            {
                throw new ConversionException("no previous note triggered on this channel");
            }

            int firstperiod = PeriodsRange[modNote];

            int secondperiod = PeriodsRange[modNote + 1];

            int delta = firstperiod - secondperiod;

            int portamento = (relativePitch * delta) / 0x10;

            int targetPeriod = firstperiod - portamento;

            portamento = (currentPeriod - targetPeriod) * directionFlag;

            playingChannelData.ReachedNote             = currentRenoiseNote;
            playingChannelData.CurrentPitch            = relativePitch;
            playingChannelData.LastPortamentoCommand   = portamentoCommand;
            playingChannelData.LastPortamentoValue     = value;
            playingChannelData.PortamentoDirectionFlag = directionFlag;

            if (portamento == 0)
            {
                throw new ConversionException("Portamento value resulted to 0 value, no effect was triggered there");
            }

            //if (channel == 2)
            //{
            //    System.Diagnostics.Debug.WriteLine(String.Format("channel: {0} effect: {1} value: {2} note: {3} pitch: {4} portamento: {5}",
            //    channel, portamentoCommand, value, currentRenoiseNote, relativePitch, portamento));
            //    // debug
            //}

            return(portamento);
        }
Пример #7
0
        private int GetTonePortamentoFromChannelPeriod(int value, int channel, bool isNoteTriggered, bool ignorePitchCompatibilityMode)
        {
            ChannelInfoData playingChannelData = channelData[channel];

            if (value == 0 && playingChannelData.LastPortamentoValue > 0)
            {
                value = playingChannelData.LastPortamentoValue;
            }

            if (value == 0 || playingChannelData.CurrentPeriod == playingChannelData.TonePortamentoPeriod)
            {
                if (isNoteTriggered)
                {
                    return(0);
                }
                else
                {
                    throw new ConversionException("tone portamento value equals 0");
                }
            }

            const int portamentoCommand = 0x03;

            int tonePortamentoPeriod = playingChannelData.TonePortamentoPeriod;

            int realValue          = ignorePitchCompatibilityMode == false && pitchCompatibilityMode ? value * (ticksPerRow > 1 ? ticksPerRow - 1 : 1) : value;
            int directionFlag      = playingChannelData.CurrentPeriod < tonePortamentoPeriod ? -1 : +1;
            int currentPitch       = playingChannelData.CurrentPitch + (realValue * directionFlag);
            int currentRenoiseNote = (int)Math.Truncate(((double)currentPitch / 16) + playingChannelData.ReachedNote);
            int currentPeriod      = playingChannelData.CurrentPeriod;
            int modNote            = GetModNote(currentRenoiseNote, playingChannelData.CurrentSample, channel);
            int relativePitch;

            relativePitch = currentPitch % 0x10;
            if (relativePitch < 0)
            {
                relativePitch = relativePitch + 0x10;
            }

            if (currentPeriod == 0)
            {
                throw new ConversionException("no previous note triggered on this channel");
            }

            int firstperiod = PeriodsRange[modNote];

            int secondperiod = PeriodsRange[modNote + 1];

            int delta = firstperiod - secondperiod;

            int portamento = (relativePitch * delta) / 0x10;

            int targetPeriod = firstperiod - portamento;

            portamento = (currentPeriod - targetPeriod) * directionFlag;

            playingChannelData.ReachedNote             = currentRenoiseNote;
            playingChannelData.CurrentPitch            = relativePitch;
            playingChannelData.LastPortamentoCommand   = portamentoCommand;
            playingChannelData.LastPortamentoValue     = value;
            playingChannelData.PortamentoDirectionFlag = directionFlag;


            return(portamento);
        }
Пример #8
0
    // 채널 정보 로드
    public static bool GetChannelList(SqlHelper dbHelper)
    {
        try
        {
            ChannelManager.Instance.InitList();

            MySqlDataReader datareader = dbHelper.call_proc("spNewSelectChannel", null);

            Int32 ComboIndex = 1;
            while (datareader.Read())
            {
                ChannelInfoData pChannelInfoData = new ChannelInfoData();

                if (datareader["seq"] != DBNull.Value)
                    pChannelInfoData.seq_ = Convert.ToInt32(datareader["seq"]);

                if (datareader["ChannelCode"] != DBNull.Value)
                    pChannelInfoData.ChannelCode_ = Convert.ToString(datareader["ChannelCode"]);

                if (datareader["ChannelName"] != DBNull.Value)
                    pChannelInfoData.ChannelName_ = Convert.ToString(datareader["ChannelName"]);

                pChannelInfoData.ComboIndex_ = ComboIndex++;    // 콤보 박스에서 사용되는 인덱스
                ChannelManager.Instance.GetList().Add(pChannelInfoData.seq_, pChannelInfoData);
            }

            datareader.Close();
            datareader.Dispose();
            datareader = null;
        }
        catch (System.Exception ex)
        {
            return false;
        }

        return true;
    }