Skip to content

Commit

Permalink
Add Shiru's changes
Browse files Browse the repository at this point in the history
  • Loading branch information
N-SPC700 committed Oct 30, 2021
1 parent f2d886d commit 632bd72
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 43 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

### Version 0.2.3

- Game Gear panning is now controlled with `N01` to the left, `N02` to center, `N03` to the right.
- This has the side effect of breaking stereo functionality with modules made in previous SnevenTracker versions.
- Added a new noise reset enable effect, `NE2`, allowing the noise to be reset every frame.

- When a C-# (Copy) note is placed in the noise channel, inputting a note on Channel 3 will allow you to hear what the noise channel will sound like.
- VGM export has been updated and reworked to function similarly to WAV export. The old method of exporting VGMs are still there, however.
- Special thanks to Shiru for the changes made for this update.

### Version 0.2.2

- Overloaded `NE0` / `NE1` for noise reset enable effect
Expand Down
35 changes: 18 additions & 17 deletions FamiTracker.rc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
// ���������� (���) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
Expand Down Expand Up @@ -112,7 +112,7 @@ BEGIN
MENUITEM "Save &As...", ID_FILE_SAVE_AS
MENUITEM SEPARATOR
MENUITEM "&Create NSF...\tCtrl+E", ID_FILE_CREATE_NSF
MENUITEM "Create WAV...", ID_FILE_CREATEWAV
MENUITEM "Create WAV/VGM...", ID_FILE_CREATEWAV
MENUITEM SEPARATOR
MENUITEM "Import text...", ID_FILE_IMPORTTEXT
MENUITEM "Export text...", ID_FILE_EXPORTTEXT
Expand Down Expand Up @@ -705,29 +705,30 @@ CAPTION "About SnevenTracker"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
LTEXT "Copyright (C) 2016 HertzDevil",IDC_ABOUT3,54,92,167,11
DEFPUSHBUTTON "OK",IDOK,228,64,50,16,WS_GROUP
DEFPUSHBUTTON "OK",IDOK,228,68,50,16,WS_GROUP
LTEXT "E-mail:",IDC_STATIC,54,108,24,10
LTEXT "This software is licensed under the GNU General Public\n License. Source is available on the Github repository.",IDC_STATIC,54,167,224,17
ICON IDR_MAINFRAME,IDC_STATIC,7,63,21,20,SS_REALSIZEIMAGE
ICON IDR_MAINFRAME,IDC_STATIC,7,63,20,20,SS_REALSIZEIMAGE
LTEXT "Contributions:",IDC_STATIC,54,191,224,9
LTEXT "All comments and feedback are welcome\nGreets to everyone who has contributed with bug reports and suggestions!",IDC_STATIC,54,137,224,26
LTEXT "[email protected]",IDC_MAIL,84,108,70,10,SS_NOTIFY
LTEXT "http://hertzdevil.info",IDC_WEBPAGE,84,121,95,9,SS_NOTIFY
LTEXT "Web:",IDC_STATIC,54,121,24,9
LTEXT "Libraries:",IDC_STATIC,54,268,224,8
LTEXT "- Blip_buffer 0.4.0 is Copyright (C) blargg (http://www.slack.net/~ant/nes-emu/)\n",IDC_STATIC,54,282,224,16
LTEXT "- Fast Fourier Transform code is (C) Reliable Software",IDC_STATIC,54,301,224,8
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,54,278,211,1
LTEXT "- Icon is made by Kuhneghetz",IDC_STATIC,54,216,224,9
LTEXT "- Toolbar icons are made by ilkke",IDC_STATIC,54,227,224,9
LTEXT "Libraries:",IDC_STATIC,54,272,224,8
LTEXT "- Blip_buffer 0.4.0 is Copyright (C) blargg (http://www.slack.net/~ant/nes-emu/)\n",IDC_STATIC,54,286,224,16
LTEXT "- Fast Fourier Transform code is (C) Reliable Software",IDC_STATIC,54,305,224,8
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,54,282,211,1
LTEXT "- Icon is made by Kuhneghetz",IDC_STATIC,54,215,224,9
LTEXT "- Toolbar icons are made by ilkke",IDC_STATIC,54,226,224,9
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,54,201,211,1
LTEXT "A SN76489 music tracker",IDC_ABOUT2,54,76,167,11,SS_NOPREFIX
LTEXT "- Module text import/export by rainwarrior",IDC_STATIC,54,238,224,9
LTEXT "- Module text import/export by rainwarrior",IDC_STATIC,54,237,224,9
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,49,287,1
LTEXT "A SN76489 music tracker",IDC_ABOUT1,54,58,167,11,SS_NOPREFIX
LTEXT "A SN76489 music tracker",IDC_ABOUT1,54,58,224,11,SS_NOPREFIX
CONTROL "",IDC_HEAD,"Static",SS_OWNERDRAW,0,0,287,49
LTEXT "- Original software by jsr",IDC_STATIC,54,205,224,9
LTEXT "- vgm_cmp VGM compressor by Valley Bell",IDC_STATIC,54,249,224,9
LTEXT "- vgm_cmp VGM compressor by Valley Bell",IDC_STATIC,54,248,224,9
LTEXT "- patched for stereo, noise mode, VGM export by shiru8bit",IDC_STATIC,54,259,224,9
END

IDD_MAINFRAME DIALOGEX 0, 0, 413, 126
Expand Down Expand Up @@ -948,7 +949,7 @@ END

IDD_CREATEWAV DIALOGEX 0, 0, 151, 208
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Create wave file"
CAPTION "Create WAV or VGM file"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Begin",IDC_BEGIN,37,187,52,14
Expand Down Expand Up @@ -1695,12 +1696,12 @@ BEGIN
ID_EDIT_VOLUMEMASK "Disables insertion of values in the volume column"
END

#endif // English (United States) resources
#endif // ���������� (���) resources
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
// Swedish (Sweden) resources
// �������� (������) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_SVE)
LANGUAGE LANG_SWEDISH, SUBLANG_SWEDISH
Expand Down Expand Up @@ -1741,7 +1742,7 @@ END

#endif // APSTUDIO_INVOKED

#endif // Swedish (Sweden) resources
#endif // �������� (������) resources
/////////////////////////////////////////////////////////////////////////////


Expand Down
2 changes: 1 addition & 1 deletion Source/AboutDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ BOOL CAboutDlg::OnInitDialog()
AfxFormatString1(aboutString, IDS_ABOUT_VERSION_FORMAT, str);
#endif

SetDlgItemText(IDC_ABOUT1, aboutString);
SetDlgItemText(IDC_ABOUT1, aboutString+".fix1");

m_pMail = new CLinkLabel(LINK_MAIL);
m_pWeb = new CLinkLabel(LINK_WEB);
Expand Down
18 changes: 11 additions & 7 deletions Source/ChannelsSN7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ void CChannelHandlerSN7::HandleCustomEffects(int EffNum, int EffParam)
// Custom effects
switch (EffNum) {
case EF_SN_CONTROL: // // //
if (EffParam >= 0x00 && EffParam <= 0x1F) {
SetStereo(EffParam && EffParam <= 0x10, EffParam >= 0x10);
break;
}
//if (EffParam >= 0x00 && EffParam <= 0x1F) {
// SetStereo(EffParam && EffParam <= 0x10, EffParam >= 0x10);
if (EffParam == 0x00 || EffParam == 2) SetStereo(true, true); //sh8bit
if (EffParam == 0x01) SetStereo(true, false);
if (EffParam == 0x03) SetStereo(false,true);
// break;
//}
break;
case EF_DUTY_CYCLE:
m_iDefaultDuty = m_iDutyPeriod = EffParam;
Expand Down Expand Up @@ -281,7 +284,7 @@ void CNoiseChan::RefreshChannel()
char NoiseMode = !(m_iDutyPeriod & 0x01); // // //

int newCtrl = (NoiseMode << 2) | Period; // // //
if ((m_bTrigger && m_bNoiseReset) || newCtrl != m_iLastCtrl) {
if ((m_bTrigger && m_bNoiseReset == 1) || (m_bNoiseReset == 2) || newCtrl != m_iLastCtrl) { //sh8bit
WriteRegister(0x06, newCtrl);
m_iLastCtrl = newCtrl;
}
Expand All @@ -295,8 +298,9 @@ void CNoiseChan::HandleCustomEffects(int EffNum, int EffParam)
switch (EffNum) {
case EF_SN_CONTROL:
switch (EffParam) {
case 0xE0: m_bNoiseReset = false; return;
case 0xE1: m_bNoiseReset = m_bTrigger = true; return;
case 0xE0: m_bNoiseReset = 0; return;
case 0xE1: m_bNoiseReset = 1; m_bTrigger = true; return; //sh8bit
case 0xE2: m_bNoiseReset = 2; return; //sh8bit
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/ChannelsSN7.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class CNoiseChan : public CChannelHandlerSN7 {

private:
int m_iLastCtrl; // // //
bool m_bNoiseReset; // // //
int m_bNoiseReset; // // // sh8bit: 0 no reset, 1 once at effect, 2 every frame until effect disabled
bool m_bTrigger; // // // 0CC-FT has this built-in
};

Expand Down
4 changes: 2 additions & 2 deletions Source/CreateWaveDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ void CCreateWaveDlg::OnBnClickedBegin()
}

CWavProgressDlg ProgressDlg;
CString fileFilter = LoadDefaultFilter(IDS_FILTER_WAV, _T(".wav"));
CFileDialog SaveDialog(FALSE, _T("wav"), FileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, fileFilter);
CString fileFilter = _T("VGM file (*.vgm)|*.vgm|")+LoadDefaultFilter(IDS_FILTER_WAV, _T(".wav")); //sh8bit
CFileDialog SaveDialog(FALSE, _T("vgm"), FileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, fileFilter);

// Close this dialog
EndDialog(0);
Expand Down
40 changes: 40 additions & 0 deletions Source/FamiTrackerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,26 @@ void CFamiTrackerView::PlayNote(unsigned int Channel, unsigned int Note, unsigne

theApp.GetSoundGenerator()->QueueNote(Channel, NoteData, NOTE_PRIO_2);

if (Channel >= 2) //sh8bit
{
CFamiTrackerDoc *pDoc = GetDocument();
stChanNote ChanNote;
int Track = static_cast<CMainFrame*>(GetParentFrame())->GetSelectedTrack();
int Frame = m_pPatternEditor->GetFrame();
int Row = m_pPatternEditor->GetRow();

if (Channel == 2)
{
pDoc->GetNoteData(Track, Frame, 3, Row, &ChanNote);
theApp.GetSoundGenerator()->QueueNote(3, ChanNote, NOTE_PRIO_1);
}
if (Channel == 3)
{
pDoc->GetNoteData(Track, Frame, 2, Row, &ChanNote);
theApp.GetSoundGenerator()->QueueNote(2, ChanNote, NOTE_PRIO_1);
}
}

if (theApp.GetSettings()->General.bPreviewFullRow) {
CFamiTrackerDoc *pDoc = GetDocument();
stChanNote ChanNote;
Expand Down Expand Up @@ -1749,6 +1769,26 @@ void CFamiTrackerView::HaltNote(unsigned int Channel)

theApp.GetSoundGenerator()->QueueNote(Channel, NoteData, NOTE_PRIO_2);

if (Channel >= 2) //sh8bit
{
CFamiTrackerDoc *pDoc = GetDocument();
stChanNote ChanNote;
int Track = static_cast<CMainFrame*>(GetParentFrame())->GetSelectedTrack();
int Frame = m_pPatternEditor->GetFrame();
int Row = m_pPatternEditor->GetRow();

if (Channel == 2)
{
NoteData.Note = HALT;
theApp.GetSoundGenerator()->QueueNote(3, NoteData, NOTE_PRIO_1);
}
if (Channel == 3)
{
NoteData.Note = HALT;
theApp.GetSoundGenerator()->QueueNote(2, NoteData, NOTE_PRIO_1);
}
}

if (theApp.GetSettings()->General.bPreviewFullRow) {
CFamiTrackerDoc *pDoc = GetDocument();
int Channels = pDoc->GetChannelCount();
Expand Down
18 changes: 9 additions & 9 deletions Source/PatternData.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@

// Channel note struct, holds the data for each row in patterns
struct stChanNote {
unsigned char Note;
unsigned char Octave;
unsigned char Vol;
unsigned char Instrument;
unsigned char EffNumber[MAX_EFFECT_COLUMNS];
unsigned char EffParam[MAX_EFFECT_COLUMNS];

static const stChanNote BLANK;
unsigned char Note = 0;
unsigned char Octave = 0;
unsigned char Vol = MAX_VOLUME;
unsigned char Instrument = MAX_INSTRUMENTS;
unsigned char EffNumber[MAX_EFFECT_COLUMNS] = { EF_NONE,EF_NONE,EF_NONE,EF_NONE };
unsigned char EffParam[MAX_EFFECT_COLUMNS] = { 0,0,0,0 };

//static const stChanNote BLANK;
};

const stChanNote stChanNote::BLANK = {0, 0, MAX_VOLUME, MAX_INSTRUMENTS, {EF_NONE, EF_NONE, EF_NONE, EF_NONE}, {0, 0, 0, 0}};
//const stChanNote stChanNote::BLANK = {0, 0, MAX_VOLUME, MAX_INSTRUMENTS, {EF_NONE, EF_NONE, EF_NONE, EF_NONE}, {0, 0, 0, 0}};

// TODO rename to CTrack perhaps?

Expand Down
31 changes: 25 additions & 6 deletions Source/SoundGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ bool CSoundGen::PlayBuffer()
{
if (m_bRendering) {
// Output to file
m_wfWaveFile.WriteWave(m_pAccumBuffer, m_iBufSizeBytes);
if(m_bRenderingWave) m_wfWaveFile.WriteWave(m_pAccumBuffer, m_iBufSizeBytes); //sh8bit
m_iBufferPtr = 0;
}
else {
Expand Down Expand Up @@ -1360,12 +1360,23 @@ bool CSoundGen::RenderToFile(LPTSTR pFile, render_end_t SongEndType, int SongEnd
m_iRenderEndParam = m_pDocument->ScanActualLength(Track, m_iRenderEndParam, m_iRenderRowCount);
}

if (!m_wfWaveFile.OpenFile(pFile, theApp.GetSettings()->Sound.iSampleRate, theApp.GetSettings()->Sound.iSampleSize, 2)) { // // //
AfxMessageBox(IDS_FILE_OPEN_ERROR);
return false;
m_bRenderingWave = true;

if (_stricmp(PathFindExtensionA(pFile), ".vgm") == 0) m_bRenderingWave = false;

if (m_bRenderingWave) //sh8bit
{
if (!m_wfWaveFile.OpenFile(pFile, theApp.GetSettings()->Sound.iSampleRate, theApp.GetSettings()->Sound.iSampleSize, 2)) { // // //
AfxMessageBox(IDS_FILE_OPEN_ERROR);
return false;
}
}
else
PostThreadMessage(WM_USER_START_RENDER, 0, 0);
{
VGMStartLogging(pFile);
}

PostThreadMessage(WM_USER_START_RENDER, 0, 0);

return true;
}
Expand All @@ -1383,7 +1394,15 @@ void CSoundGen::StopRendering()
m_bRendering = false;
m_iPlayFrame = 0;
m_iPlayRow = 0;
m_wfWaveFile.CloseFile();

if (m_bRenderingWave) //sh8bit
{
m_wfWaveFile.CloseFile();
}
else
{
VGMStopLogging();
}

MakeSilent();
ResetBuffer();
Expand Down
1 change: 1 addition & 0 deletions Source/SoundGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ class CSoundGen : public CWinThread, IAudioCallback

// Rendering
bool m_bRendering;
bool m_bRenderingWave; //sh8bit
bool m_bRequestRenderStop;
render_end_t m_iRenderEndWhen;
unsigned int m_iRenderEndParam;
Expand Down

0 comments on commit 632bd72

Please sign in to comment.