├── res
├── About.bmp
├── Document.ico
├── Inst_FDS.ico
├── Inst_S5B.ico
├── Application.ico
├── Inst_2A03.ico
├── Inst_2A07.ico
├── Inst_N163.ico
├── Inst_VRC6.ico
├── Inst_VRC7.ico
├── LeftArrow.ico
├── RightArrow.ico
├── VisualizerBg.bmp
├── MainToolbar-16.bmp
├── MainToolbar-256.bmp
├── key_black_pressed.bmp
├── key_white_pressed.bmp
├── InstrumentToolbar-16.bmp
├── InstrumentToolbar-256.bmp
├── key_black_unpressed.bmp
├── key_white_unpressed.bmp
├── FamiTracker.rc2
└── FamiTracker.manifest
├── Source
├── drivers
│ └── config.h
├── FamiTrackerView.cpp
├── vgmtools
│ ├── vgm_cmp.h
│ ├── stdbool.h
│ ├── stdtype.h
│ └── vgm_lib.h
├── CommandLineExport.h
├── stdafx.cpp
├── FFT
│ ├── Complex.h
│ └── Fft.h
├── Document
│ ├── EffectCommand.h
│ ├── TrackIdent.h
│ ├── PatternNote.h
│ ├── PatternNote.cpp
│ ├── PatternData_new.h
│ ├── TrackData.h
│ ├── TrackData.cpp
│ └── PatternData_new.cpp
├── Exception.h
├── APU
│ ├── Types.h
│ ├── External.h
│ ├── Channel.h
│ └── Mixer.h
├── WaveFile.h
├── TextExporter.h
├── VGM
│ ├── Writer
│ │ ├── Base.cpp
│ │ ├── Base.h
│ │ ├── SN76489.h
│ │ └── SN76489.cpp
│ └── Constants.h
├── VisualizerStatic.h
├── ConfigWindow.h
├── Clipboard.h
├── DialogReBar.h
├── PerformanceDlg.h
├── Common.h
├── VisualizerScope.h
├── ConfigSound.h
├── SpeedDlg.h
├── ConfigMIDI.h
├── ControlPanelDlg.h
├── SequenceSetting.h
├── VisualizerSpectrum.h
├── WavProgressDlg.h
├── CreateWaveDlg.h
├── ConfigMixer.h
├── ConfigWindow.cpp
├── ModuleImportDlg.h
├── InstrumentFileTree.h
├── SizeEditor.h
├── CommentsDlg.h
├── VisualizerStatic.cpp
├── ChannelsDlg.h
├── ConfigShortcuts.h
├── ExportTest
│ └── ExportTest.h
├── Sequence.h
├── TrackerChannel.h
├── ChannelMap.h
├── Graphics.h
├── AboutDlg.h
├── ExportDialog.h
├── ModulePropertiesDlg.h
├── InstrumentEditor2A03.h
├── PatternCompiler.h
├── SequenceEditor.h
├── resampler
│ ├── sinc.hpp
│ └── sinc.cpp
├── ChunkRenderBinary.h
├── Clipboard.cpp
├── ControlPanelDlg.cpp
├── ChunkRenderText.h
├── SpeedDlg.cpp
├── DocumentFile.h
├── Driver.h
├── Accelerator.h
├── DialogReBar.cpp
├── ChannelsSN7.h
├── ConfigAppearance.h
├── ConfigGeneral.h
├── Action.h
├── InstrumentEditDlg.h
├── Instrument.cpp
├── PerformanceDlg.cpp
├── FrameAction.h
├── Sequence.cpp
├── VisualizerWnd.h
├── WaveFile.cpp
├── stdafx.h
├── Action.cpp
├── InstrumentEditPanel.h
└── MIDI.h
├── UnitTests
├── Source
│ ├── testMain.cpp
│ └── testPattern.cpp
└── UnitTests.vcxproj.filters
├── .gitignore
├── README.md
├── CHANGES.md
├── version.h
├── FUTURE.md
├── FamiTracker.sln
└── NOTES.md
/res/About.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/About.bmp
--------------------------------------------------------------------------------
/res/Document.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/Document.ico
--------------------------------------------------------------------------------
/res/Inst_FDS.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/Inst_FDS.ico
--------------------------------------------------------------------------------
/res/Inst_S5B.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/Inst_S5B.ico
--------------------------------------------------------------------------------
/res/Application.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/Application.ico
--------------------------------------------------------------------------------
/res/Inst_2A03.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/Inst_2A03.ico
--------------------------------------------------------------------------------
/res/Inst_2A07.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/Inst_2A07.ico
--------------------------------------------------------------------------------
/res/Inst_N163.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/Inst_N163.ico
--------------------------------------------------------------------------------
/res/Inst_VRC6.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/Inst_VRC6.ico
--------------------------------------------------------------------------------
/res/Inst_VRC7.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/Inst_VRC7.ico
--------------------------------------------------------------------------------
/res/LeftArrow.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/LeftArrow.ico
--------------------------------------------------------------------------------
/res/RightArrow.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/RightArrow.ico
--------------------------------------------------------------------------------
/Source/drivers/config.h:
--------------------------------------------------------------------------------
1 | const unsigned int VIBRATO_TABLE_LOCATION_NONE = 0x156d;
2 | // // //
3 |
--------------------------------------------------------------------------------
/res/VisualizerBg.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/VisualizerBg.bmp
--------------------------------------------------------------------------------
/res/MainToolbar-16.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/MainToolbar-16.bmp
--------------------------------------------------------------------------------
/res/MainToolbar-256.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/MainToolbar-256.bmp
--------------------------------------------------------------------------------
/Source/FamiTrackerView.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/Source/FamiTrackerView.cpp
--------------------------------------------------------------------------------
/res/key_black_pressed.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/key_black_pressed.bmp
--------------------------------------------------------------------------------
/res/key_white_pressed.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/key_white_pressed.bmp
--------------------------------------------------------------------------------
/res/InstrumentToolbar-16.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/InstrumentToolbar-16.bmp
--------------------------------------------------------------------------------
/res/InstrumentToolbar-256.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/InstrumentToolbar-256.bmp
--------------------------------------------------------------------------------
/res/key_black_unpressed.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/key_black_unpressed.bmp
--------------------------------------------------------------------------------
/res/key_white_unpressed.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HertzDevil/SnevenTracker/HEAD/res/key_white_unpressed.bmp
--------------------------------------------------------------------------------
/Source/vgmtools/vgm_cmp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 | extern int CompressVGM(const char *Filename);
8 |
9 | #ifdef __cplusplus
10 | }
11 | #endif
12 |
--------------------------------------------------------------------------------
/UnitTests/Source/testMain.cpp:
--------------------------------------------------------------------------------
1 | #define DOCTEST_CONFIG_IMPLEMENT
2 | #include "doctest.h"
3 |
4 | int main(int argc, char **argv)
5 | {
6 | doctest::Context context;
7 | context.applyCommandLine(argc, argv);
8 | context.setOption("sort", "name");
9 |
10 | int res = context.run();
11 |
12 | // if(context.shouldExit())
13 | // return res;
14 |
15 | return res;
16 | }
17 |
--------------------------------------------------------------------------------
/Source/vgmtools/stdbool.h:
--------------------------------------------------------------------------------
1 | // custom stdbool.h to for 1-byte bool types
2 |
3 | #ifndef _CSTM_STDBOOL_H_
4 | #define _CSTM_STDBOOL_H_
5 |
6 | #ifndef __cplusplus // C++ already has the bool-type
7 |
8 | #define false 0x00
9 | #define true 0x01
10 |
11 | // the MS VC++ 6 compiler uses a one-byte-type (unsigned char, to be exact), so I'll reproduce this here
12 | typedef unsigned char bool;
13 |
14 | #endif // !__cplusplus
15 |
16 | #endif // !_CSTM_STDBOOL_H_
17 |
--------------------------------------------------------------------------------
/res/FamiTracker.rc2:
--------------------------------------------------------------------------------
1 | //
2 | // FamiTracker.RC2 - resources Microsoft Visual C++ does not edit directly
3 | //
4 |
5 | #ifdef APSTUDIO_INVOKED
6 | #error this file is not editable by Microsoft Visual C++
7 | #endif //APSTUDIO_INVOKED
8 |
9 |
10 | /////////////////////////////////////////////////////////////////////////////
11 | // Add manually edited resources here...
12 |
13 | /////////////////////////////////////////////////////////////////////////////
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Specify filepatterns you want git to ignore.
2 |
3 | Example:
4 | #ignore thumbnails created by windows
5 | Thumbs.db
6 | #Ignore files build by Visual Studio
7 | *.user
8 | *.aps
9 | *.pch
10 | *.vspscc
11 | *_i.c
12 | *_p.c
13 | *.ncb
14 | *.suo
15 | *.bak
16 | *.cache
17 | *.ilk
18 | *.log
19 | [Bb]in
20 | [Dd]ebug*/
21 | *.sbr
22 | obj/
23 | [Rr]elease*/
24 | _ReSharper*/
25 | hlp/
26 | *.db
27 | *.opendb
28 | *.sdf
29 | .vs/*
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SnevenTracker
2 |
3 | SnevenTracker (SN76489 Tracker) is a fork of FamiTracker version 0.4.6 that emulates the Texas Instruments SN76489 sound chip, which is used in a wide variety of computers and gaming consoles. The project's ultimate aim is to support multiple sound chips in a more modular manner than 0.4.6, and then forward-port these changes to [0CC-FamiTracker](https://github.com/HertzDevil/0CC-FamiTracker).
4 |
5 | As in 0CC-FT, all changes to the source code are marked with `// // //`.
6 |
7 | See `NOTES.md` for a brief overview of the stuffs actually added.
8 |
9 | ### To-do
10 |
11 | - Should support multiple master clock rates and both versions of the LFSR
12 | - Should support all sound chips as described in the notes
13 | - KSS export is planned, but low priority
14 |
--------------------------------------------------------------------------------
/res/FamiTracker.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 | A Famicom/NES music tracker
10 |
11 |
12 |
20 |
21 |
22 |
23 |
24 | true
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Source/vgmtools/stdtype.h:
--------------------------------------------------------------------------------
1 | #ifndef __CST_STDTYPE_H__
2 | #define __CST_STDTYPE_H__
3 |
4 |
5 | // typedefs to use MAME's (U)INTxx types (copied from MAME\src\ods\odscomm.h)
6 | /* 8-bit values */
7 | typedef unsigned char UINT8;
8 | typedef signed char INT8;
9 |
10 | /* 16-bit values */
11 | typedef unsigned short UINT16;
12 | typedef signed short INT16;
13 |
14 | /* 32-bit values */
15 | #ifndef _WINDOWS_H
16 | typedef unsigned int UINT32;
17 | typedef signed int INT32;
18 | #endif
19 |
20 | /* 64-bit values */
21 | #ifndef _WINDOWS_H
22 | #ifdef _MSC_VER
23 | typedef signed __int64 INT64;
24 | typedef unsigned __int64 UINT64;
25 | #else
26 | __extension__ typedef unsigned long long UINT64;
27 | __extension__ typedef signed long long INT64;
28 | #endif
29 | #endif
30 |
31 | // also, for convenience, the INLINE keyword
32 | #ifndef INLINE
33 | #if defined(_MSC_VER)
34 | #define INLINE static __inline // __forceinline
35 | #elif defined(__GNUC__)
36 | #define INLINE static __inline__
37 | #else
38 | #define INLINE static inline
39 | #endif
40 | #endif
41 |
42 |
43 |
44 | #endif // __CST_STDTYPE_H__
45 |
--------------------------------------------------------------------------------
/Source/CommandLineExport.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | class CCommandLineExport
24 | {
25 | public:
26 | void CommandLineExport(const CString& fileIn, const CString& fileOut, const CString& fileLog); // // //
27 | };
28 |
--------------------------------------------------------------------------------
/Source/stdafx.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | // stdafx.cpp : source file that includes just the standard includes
22 | // FamiTracker.pch will be the pre-compiled header
23 | // stdafx.obj will contain the pre-compiled type information
24 |
25 | #include "stdafx.h"
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Source/FFT/Complex.h:
--------------------------------------------------------------------------------
1 | #if !defined COMPLEX_H
2 | #define COMPLEX_H
3 | //------------------------------------
4 | // complex.h
5 | // Complex number
6 | // (c) Reliable Software, 1996
7 | //------------------------------------
8 |
9 | #include
10 |
11 | class Complex
12 | {
13 | public:
14 | Complex () {}
15 | Complex (double re): _re(re), _im(0.0) {}
16 | Complex (double re, double im): _re(re), _im(im) {}
17 | double Re () const { return _re; }
18 | double Im () const { return _im; }
19 | void operator += (const Complex& c)
20 | {
21 | _re += c._re;
22 | _im += c._im;
23 | }
24 | void operator -= (const Complex& c)
25 | {
26 | _re -= c._re;
27 | _im -= c._im;
28 | }
29 | void operator *= (const Complex& c)
30 | {
31 | double reT = c._re * _re - c._im * _im;
32 | _im = c._re * _im + c._im * _re;
33 | _re = reT;
34 | }
35 | Complex operator- ()
36 | {
37 | return Complex (-_re, -_im);
38 | }
39 | double Mod () const { return sqrt (_re * _re + _im * _im); }
40 | private:
41 | double _re;
42 | double _im;
43 | };
44 |
45 | #endif
--------------------------------------------------------------------------------
/Source/Document/EffectCommand.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** SnevenTracker is (C) HertzDevil 2016
6 | **
7 | ** This program is free software; you can redistribute it and/or modify
8 | ** it under the terms of the GNU General Public License as published by
9 | ** the Free Software Foundation; either version 2 of the License, or
10 | ** (at your option) any later version.
11 | **
12 | ** This program is distributed in the hope that it will be useful,
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | ** Library General Public License for more details. To obtain a
16 | ** copy of the GNU Library General Public License, write to the Free
17 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 | **
19 | ** Any permitted reproduction of these routines, in whole or in part,
20 | ** must bear this legend.
21 | */
22 |
23 |
24 | #pragma once
25 |
26 | #include
27 |
28 | namespace FTExt {
29 |
30 | struct CEffectCommand
31 | {
32 | char Name = '\0';
33 | uint8_t Param = 0u;
34 | };
35 |
36 | } // namespace FTExt
37 |
--------------------------------------------------------------------------------
/Source/Exception.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | #ifndef _DEBUG
25 | // Enable crash handler
26 | //#define ENABLE_CRASH_HANDLER
27 | #endif /* _DEBUG */
28 |
29 | #ifdef ENABLE_CRASH_HANDLER
30 | void InstallExceptionHandler();
31 | void UninstallExceptionHandler();
32 | #endif /* ENABLE_CRASH_HANDLER */
33 |
--------------------------------------------------------------------------------
/CHANGES.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | ### Version 0.2.2
4 |
5 | - Overloaded `NE0` / `NE1` for noise reset enable effect
6 | - Added SN76489 stereo separation to mixer menu
7 | - Re-added file association
8 | - SN76489 VGM logger now eliminates extra register writes that have no side effects
9 | - Extended VGM header size so that it will not be misinterpreted by certain players
10 | - Fixed text export and import (for SN7T only)
11 | - Renamed `NCx` to "Channel swap"
12 | - Samples are now properly downmixed to mono for visualizers
13 |
14 | ### Version 0.2.1
15 |
16 | - Overloaded `N00` - `N1F` for Game Gear stereo control
17 | - Channels no longer reduce to zero volume when the mixed volume is less than 0 (to match 0CC-FT's 5B behaviour)
18 | - Fixed arpeggio on noise channel now maps 0 to `L-#` and 2 to `H-#` **(backward-incompatible change, modify your modules accordingly)**
19 | - Fixed VGM logs putting 0 in the sample count fields
20 |
21 | ### Version 0.2.0
22 |
23 | - Added VGM logger (with `vgm_cmp` postprocessing and proper GD3 tag support); use `vgmlpfnd` manually for looped songs
24 | - Added `NCx` noise pitch rebind effect
25 | - Channels now use subtractive mixing instead of multiplicative mixing for channel volume and instrument volume
26 |
27 | ### Version 0.1.0
28 |
29 | - Initial release
30 |
--------------------------------------------------------------------------------
/version.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // Application version information
25 |
26 | // Define this for beta builds
27 | //#define WIP
28 |
29 | // Version info
30 | #define VERSION_MAJ 0
31 | #define VERSION_MIN 2
32 | #define VERSION_REV 2
33 |
34 | #define VERSION_WIP 0
35 |
36 | // // //
37 | #define VERSION VERSION_MAJ,VERSION_MIN,VERSION_REV,VERSION_WIP
38 |
--------------------------------------------------------------------------------
/Source/APU/Types.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | #include "../Common.h"
24 |
25 | const uint8 SNDCHIP_NONE = 0;
26 | // // //
27 |
28 | enum chan_id_t {
29 | CHANID_SQUARE1,
30 | CHANID_SQUARE2,
31 | CHANID_SQUARE3,
32 | CHANID_NOISE,
33 | // // //
34 | CHANNELS /* Total number of channels */
35 | };
36 |
37 | enum apu_machine_t {
38 | MACHINE_NTSC,
39 | MACHINE_PAL
40 | };
41 |
--------------------------------------------------------------------------------
/Source/Document/TrackIdent.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** SnevenTracker is (C) HertzDevil 2016
6 | **
7 | ** This program is free software; you can redistribute it and/or modify
8 | ** it under the terms of the GNU General Public License as published by
9 | ** the Free Software Foundation; either version 2 of the License, or
10 | ** (at your option) any later version.
11 | **
12 | ** This program is distributed in the hope that it will be useful,
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | ** Library General Public License for more details. To obtain a
16 | ** copy of the GNU Library General Public License, write to the Free
17 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 | **
19 | ** Any permitted reproduction of these routines, in whole or in part,
20 | ** must bear this legend.
21 | */
22 |
23 |
24 | #pragma once
25 |
26 | #include
27 |
28 | namespace FTExt {
29 |
30 | enum class ESoundChip : uint8_t
31 | {
32 | SN76489,
33 | T6W28,
34 | YM2413,
35 | YM2612,
36 | };
37 |
38 | struct CTrackIdent
39 | {
40 | ESoundChip Chip;
41 | uint8_t Index;
42 | };
43 |
44 | } // namespace FTExt
45 |
--------------------------------------------------------------------------------
/Source/WaveFile.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | #include
25 |
26 | class CWaveFile
27 | {
28 | public:
29 | bool OpenFile(LPTSTR Filename, int SampleRate, int SampleSize, int Channels);
30 | void CloseFile();
31 | void WriteWave(char *Data, int Size);
32 |
33 | private:
34 | PCMWAVEFORMAT WaveFormat;
35 | MMCKINFO ckOutRIFF, ckOut;
36 | MMIOINFO mmioinfoOut;
37 | HMMIO hmmioOut;
38 |
39 | };
40 |
41 |
--------------------------------------------------------------------------------
/Source/TextExporter.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | class CFamiTrackerDoc; // forward declaration
24 |
25 | class CTextExport : public CObject
26 | {
27 | public:
28 | CTextExport();
29 | virtual ~CTextExport();
30 |
31 | // returns an empty string on success, otherwise returns a descriptive error
32 | const CString& ImportFile(LPCTSTR FileName, CFamiTrackerDoc *pDoc);
33 | const CString& ExportFile(LPCTSTR FileName, CFamiTrackerDoc *pDoc);
34 | };
35 |
--------------------------------------------------------------------------------
/Source/VGM/Writer/Base.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** SnevenTracker is (C) HertzDevil 2016
6 | **
7 | ** This program is free software; you can redistribute it and/or modify
8 | ** it under the terms of the GNU General Public License as published by
9 | ** the Free Software Foundation; either version 2 of the License, or
10 | ** (at your option) any later version.
11 | **
12 | ** This program is distributed in the hope that it will be useful,
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | ** Library General Public License for more details. To obtain a
16 | ** copy of the GNU Library General Public License, write to the Free
17 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 | **
19 | ** Any permitted reproduction of these routines, in whole or in part,
20 | ** must bear this legend.
21 | */
22 |
23 | #include "Base.h"
24 |
25 | CVGMWriterBase::CVGMWriterBase(CVGMLogger &logger) : m_Logger(logger)
26 | {
27 | m_Logger.RegisterWriter(*this);
28 | }
29 |
30 | CVGMWriterBase::~CVGMWriterBase()
31 | {
32 | m_Logger.UnregisterWriter(*this);
33 | }
34 |
35 | void CVGMWriterBase::WriteReg(uint32_t adr, uint32_t val, uint32_t port) const
36 | {
37 | m_Logger.InsertByte(Command(adr, val, port));
38 | }
39 |
--------------------------------------------------------------------------------
/Source/VisualizerStatic.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CVisualizerStatic, static picture visualizer
25 |
26 | class CVisualizerStatic : public CVisualizerBase
27 | {
28 | public:
29 | CVisualizerStatic();
30 | virtual ~CVisualizerStatic();
31 |
32 | void Create(int Width, int Height);
33 | void SetSampleRate(int SampleRate);
34 | void Draw();
35 | void Display(CDC *pDC, bool bPaintMsg);
36 |
37 | private:
38 | CBitmap m_bmpImage;
39 | CBitmap *m_pOldBmp;
40 | CDC m_dcImage;
41 | };
42 |
--------------------------------------------------------------------------------
/Source/ConfigWindow.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2012 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | #include "ConfigGeneral.h"
24 | #include "ConfigAppearance.h"
25 |
26 | // CConfigWindow
27 |
28 | class CConfigWindow : public CPropertySheet
29 | {
30 | DECLARE_DYNAMIC(CConfigWindow)
31 |
32 | public:
33 | CConfigWindow(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
34 | CConfigWindow(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
35 | virtual ~CConfigWindow();
36 |
37 | protected:
38 | DECLARE_MESSAGE_MAP()
39 | public:
40 | void SetupPages(void);
41 | };
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Source/Document/PatternNote.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** SnevenTracker is (C) HertzDevil 2016
6 | **
7 | ** This program is free software; you can redistribute it and/or modify
8 | ** it under the terms of the GNU General Public License as published by
9 | ** the Free Software Foundation; either version 2 of the License, or
10 | ** (at your option) any later version.
11 | **
12 | ** This program is distributed in the hope that it will be useful,
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | ** Library General Public License for more details. To obtain a
16 | ** copy of the GNU Library General Public License, write to the Free
17 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 | **
19 | ** Any permitted reproduction of these routines, in whole or in part,
20 | ** must bear this legend.
21 | */
22 |
23 |
24 | #pragma once
25 |
26 | #include "EffectCommand.h"
27 | #include "../FamiTrackerTypes.h" // constant
28 |
29 | namespace FTExt {
30 |
31 | struct CPatternNote
32 | {
33 | uint8_t Note = 0u;
34 | uint8_t Octave = 0u;
35 | uint8_t Inst = MAX_INSTRUMENTS;
36 | uint8_t Vol = MAX_VOLUME;
37 | CEffectCommand Effect[MAX_EFFECT_COLUMNS] = { };
38 |
39 | void Reset();
40 | operator bool() const;
41 |
42 | private:
43 | static const CPatternNote BLANK;
44 | };
45 |
46 | } // namespace FTExt
47 |
--------------------------------------------------------------------------------
/Source/Document/PatternNote.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** SnevenTracker is (C) HertzDevil 2016
6 | **
7 | ** This program is free software; you can redistribute it and/or modify
8 | ** it under the terms of the GNU General Public License as published by
9 | ** the Free Software Foundation; either version 2 of the License, or
10 | ** (at your option) any later version.
11 | **
12 | ** This program is distributed in the hope that it will be useful,
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | ** Library General Public License for more details. To obtain a
16 | ** copy of the GNU Library General Public License, write to the Free
17 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 | **
19 | ** Any permitted reproduction of these routines, in whole or in part,
20 | ** must bear this legend.
21 | */
22 |
23 | #include "PatternNote.h"
24 | #include
25 |
26 | using namespace FTExt;
27 |
28 |
29 |
30 | const CPatternNote CPatternNote::BLANK = CPatternNote { };
31 |
32 |
33 |
34 | void CPatternNote::Reset()
35 | {
36 | *this = CPatternNote { };
37 | }
38 |
39 | CPatternNote::operator bool() const
40 | {
41 | if (Note != 0 || Inst != MAX_INSTRUMENTS || Vol != MAX_VOLUME)
42 | return true;
43 | for (const auto &x : Effect)
44 | if (x.Name)
45 | return true;
46 | return false;
47 | }
48 |
--------------------------------------------------------------------------------
/Source/APU/External.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #ifndef EXTERNAL_H
22 | #define EXTERNAL_H
23 |
24 | class CMixer;
25 |
26 | #include "../Common.h" // // //
27 |
28 | class CExternal {
29 | public:
30 | CExternal() {};
31 | CExternal(CMixer *pMixer) : m_pMixer(pMixer) {};
32 | virtual ~CExternal() {};
33 |
34 | virtual void Reset() = 0;
35 | virtual void Process(uint32 Time) = 0;
36 | virtual void EndFrame() = 0;
37 |
38 | virtual void Write(uint16 Address, uint8 Value) = 0;
39 | virtual uint8 Read(uint16 Address, bool &Mapped) = 0;
40 |
41 | protected:
42 | CMixer *m_pMixer;
43 | };
44 |
45 | #endif /* EXTERNAL_H */
--------------------------------------------------------------------------------
/Source/Clipboard.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // Clipboard wrapper class, using this ensures that clipboard is closed when finished
25 | class CClipboard
26 | {
27 | public:
28 | CClipboard(CWnd *pWnd, UINT Clipboard);
29 | ~CClipboard();
30 |
31 | bool IsOpened() const;
32 | HGLOBAL AllocMem(UINT Size) const;
33 | void SetData(HGLOBAL hMemory) const;
34 | bool SetDataPointer(LPVOID pData, UINT Size) const;
35 | HGLOBAL GetData() const;
36 | LPVOID GetDataPointer();
37 | bool IsDataAvailable()const;
38 |
39 | private:
40 | bool m_bOpened;
41 | UINT m_iClipboard;
42 | HGLOBAL m_hMemory;
43 | };
44 |
--------------------------------------------------------------------------------
/Source/DialogReBar.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // COctaveDlgBar dialog
25 |
26 | class CDialogReBar : public CDialogBar
27 | {
28 | DECLARE_DYNAMIC(CDialogReBar)
29 |
30 | public:
31 | CDialogReBar(CWnd* pParent = NULL); // standard constructor
32 | virtual ~CDialogReBar();
33 |
34 | // Dialog Data
35 | enum { IDD = IDD_OCTAVE };
36 |
37 | protected:
38 | DECLARE_MESSAGE_MAP()
39 | public:
40 | afx_msg BOOL OnEraseBkgnd(CDC* pDC);
41 | afx_msg void OnMove(int x, int y);
42 | afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
43 | virtual BOOL Create(CWnd* pParentWnd, UINT nIDTemplate, UINT nStyle, UINT nID);
44 | };
45 |
--------------------------------------------------------------------------------
/Source/PerformanceDlg.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CPerformanceDlg dialog
25 |
26 | class CPerformanceDlg : public CDialog
27 | {
28 | DECLARE_DYNAMIC(CPerformanceDlg)
29 |
30 | public:
31 | CPerformanceDlg(CWnd* pParent = NULL); // standard constructor
32 | virtual ~CPerformanceDlg();
33 |
34 | // Dialog Data
35 | enum { IDD = IDD_PERFORMANCE };
36 |
37 | protected:
38 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
39 |
40 | DECLARE_MESSAGE_MAP()
41 | public:
42 | virtual BOOL OnInitDialog();
43 | afx_msg void OnTimer(UINT nIDEvent);
44 | afx_msg void OnBnClickedOk();
45 | virtual BOOL DestroyWindow();
46 | };
47 |
--------------------------------------------------------------------------------
/UnitTests/UnitTests.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {cef7f67a-60ad-4927-ae0d-15755a50ea03}
14 |
15 |
16 |
17 |
18 | Source Files
19 |
20 |
21 | Source Files
22 |
23 |
24 | Source Files\External
25 |
26 |
27 | Source Files\External
28 |
29 |
30 | Source Files\External
31 |
32 |
33 |
34 |
35 | Header Files
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Source/Common.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | typedef unsigned char uint8;
24 | typedef unsigned short uint16;
25 | typedef unsigned long uint32;
26 | typedef unsigned __int64 uint64;
27 | typedef signed char int8;
28 | typedef signed short int16;
29 | typedef signed long int32;
30 | typedef signed __int64 int64;
31 |
32 | #define _MAIN_H_
33 |
34 | // // //
35 |
36 | const int SPEED_AUTO = 0;
37 | const int SPEED_NTSC = 1;
38 | const int SPEED_PAL = 2;
39 |
40 | // // //
41 |
42 | // Used to play the audio when the buffer is full
43 | class IAudioCallback {
44 | public:
45 | virtual void FlushBuffer(int16 *Buffer, uint32 Size) = 0;
46 | };
47 |
48 | // // //
49 |
--------------------------------------------------------------------------------
/Source/VisualizerScope.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CVisualizerScope, scope style visualizer
25 |
26 | class CVisualizerScope : public CVisualizerBase
27 | {
28 | public:
29 | CVisualizerScope(bool bBlur);
30 | virtual ~CVisualizerScope();
31 |
32 | void Create(int Width, int Height);
33 | void SetSampleRate(int SampleRate);
34 | void Draw();
35 | void Display(CDC *pDC, bool bPaintMsg);
36 |
37 | private:
38 | void RenderBuffer();
39 | void ClearBackground();
40 |
41 | private:
42 | COLORREF *m_pBlitBuffer;
43 |
44 | bool m_bBlur;
45 | int m_iWindowBufPtr;
46 | short *m_pWindowBuf;
47 |
48 | #ifdef _DEBUG
49 | int m_iPeak;
50 | #endif
51 | };
52 |
--------------------------------------------------------------------------------
/Source/VGM/Writer/Base.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** SnevenTracker is (C) HertzDevil 2016
6 | **
7 | ** This program is free software; you can redistribute it and/or modify
8 | ** it under the terms of the GNU General Public License as published by
9 | ** the Free Software Foundation; either version 2 of the License, or
10 | ** (at your option) any later version.
11 | **
12 | ** This program is distributed in the hope that it will be useful,
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | ** Library General Public License for more details. To obtain a
16 | ** copy of the GNU Library General Public License, write to the Free
17 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 | **
19 | ** Any permitted reproduction of these routines, in whole or in part,
20 | ** must bear this legend.
21 | */
22 |
23 |
24 | #pragma once
25 |
26 | #include "../Logger.h"
27 |
28 | // // // base class for VGM writer, provides slightly higher abstraction
29 |
30 | class CVGMWriterBase
31 | {
32 | protected:
33 | CVGMWriterBase(CVGMLogger &logger);
34 |
35 | public:
36 | virtual ~CVGMWriterBase();
37 |
38 | public:
39 | virtual VGMChip GetChip() const = 0;
40 | virtual void UpdateHeader(CVGMLogger::Header &h) const = 0;
41 | virtual void WriteReg(uint32_t adr, uint32_t val, uint32_t port = 0) const final;
42 |
43 | private:
44 | virtual std::vector Command(uint32_t adr, uint32_t val, uint32_t port) const = 0;
45 |
46 | protected:
47 | CVGMLogger &m_Logger;
48 | };
49 |
--------------------------------------------------------------------------------
/Source/VGM/Writer/SN76489.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** SnevenTracker is (C) HertzDevil 2016
6 | **
7 | ** This program is free software; you can redistribute it and/or modify
8 | ** it under the terms of the GNU General Public License as published by
9 | ** the Free Software Foundation; either version 2 of the License, or
10 | ** (at your option) any later version.
11 | **
12 | ** This program is distributed in the hope that it will be useful,
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | ** Library General Public License for more details. To obtain a
16 | ** copy of the GNU Library General Public License, write to the Free
17 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 | **
19 | ** Any permitted reproduction of these routines, in whole or in part,
20 | ** must bear this legend.
21 | */
22 |
23 |
24 | #pragma once
25 |
26 | #include "Base.h"
27 |
28 | // // // SN76489 specialization of the writer class
29 |
30 | class CVGMWriterSN76489 : public CVGMWriterBase
31 | {
32 | public:
33 | enum class Mode {GameGear, BBCMicro, SN76496};
34 |
35 | public:
36 | CVGMWriterSN76489(CVGMLogger &logger, Mode m = Mode::GameGear);
37 |
38 | void SetClockRate(uint32_t hz);
39 |
40 | private:
41 | VGMChip GetChip() const override final;
42 | void UpdateHeader(CVGMLogger::Header &h) const override final;
43 | std::vector Command(uint32_t adr, uint32_t val, uint32_t port) const override final;
44 |
45 | protected:
46 | Mode m_iMode;
47 | uint32_t m_iClockRate;
48 | };
49 |
--------------------------------------------------------------------------------
/Source/ConfigSound.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CConfigSound dialog
25 |
26 | class CConfigSound : public CPropertyPage
27 | {
28 | DECLARE_DYNAMIC(CConfigSound)
29 |
30 | public:
31 | CConfigSound();
32 | virtual ~CConfigSound();
33 |
34 | // Dialog Data
35 | enum { IDD = IDD_CONFIG_SOUND };
36 |
37 | protected:
38 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
39 |
40 | void UpdateTexts();
41 |
42 | DECLARE_MESSAGE_MAP()
43 | public:
44 | virtual BOOL OnInitDialog();
45 | afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
46 | virtual BOOL OnApply();
47 | afx_msg void OnCbnSelchangeSampleRate();
48 | afx_msg void OnCbnSelchangeSampleSize();
49 | afx_msg void OnCbnSelchangeDevices();
50 | };
51 |
--------------------------------------------------------------------------------
/Source/SpeedDlg.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CSpeedDlg dialog
25 |
26 | class CSpeedDlg : public CDialog
27 | {
28 | DECLARE_DYNAMIC(CSpeedDlg)
29 |
30 | public:
31 | CSpeedDlg(CWnd* pParent = NULL); // standard constructor
32 | virtual ~CSpeedDlg();
33 |
34 | // Dialog Data
35 | enum { IDD = IDD_SPEED };
36 |
37 | protected:
38 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
39 |
40 | int m_iInitSpeed;
41 | int m_iSpeed;
42 |
43 | DECLARE_MESSAGE_MAP()
44 | public:
45 | int GetSpeedFromDlg(int InitialSpeed);
46 | afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
47 | // virtual BOOL Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL);
48 | virtual BOOL OnInitDialog();
49 | afx_msg void OnBnClickedCancel();
50 | };
51 |
--------------------------------------------------------------------------------
/Source/ConfigMIDI.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CConfigMIDI dialog
25 |
26 | class CConfigMIDI : public CPropertyPage
27 | {
28 | DECLARE_DYNAMIC(CConfigMIDI)
29 |
30 | public:
31 | CConfigMIDI();
32 | virtual ~CConfigMIDI();
33 |
34 | // Dialog Data
35 | enum { IDD = IDD_CONFIG_MIDI };
36 |
37 | protected:
38 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
39 |
40 | DECLARE_MESSAGE_MAP()
41 | public:
42 | virtual BOOL OnInitDialog();
43 | virtual BOOL OnApply();
44 | afx_msg void OnCbnSelchangeDevices();
45 | afx_msg void OnBnClickedMasterSync();
46 | afx_msg void OnBnClickedKeyRelease();
47 | afx_msg void OnBnClickedChanmap();
48 | afx_msg void OnBnClickedVelocity();
49 | afx_msg void OnBnClickedArpeggiate();
50 | afx_msg void OnCbnSelchangeOutdevices();
51 | };
52 |
--------------------------------------------------------------------------------
/Source/ControlPanelDlg.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routin, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CControlPanelDlg dialog
25 |
26 | class CControlPanelDlg : public CDialog
27 | {
28 | DECLARE_DYNAMIC(CControlPanelDlg)
29 |
30 | public:
31 | CControlPanelDlg(CWnd* pParent = NULL); // standard constructor
32 | virtual ~CControlPanelDlg();
33 |
34 | void SetFrameParent(CWnd *pMainFrm = NULL);
35 |
36 | // Dialog Data
37 | enum { IDD = IDD_MAINFRAME };
38 |
39 | protected:
40 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
41 |
42 | CWnd *m_pMainFrame;
43 |
44 | DECLARE_MESSAGE_MAP()
45 | public:
46 | virtual BOOL PreTranslateMessage(MSG* pMsg);
47 | virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
48 | protected:
49 | virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
50 | };
51 |
--------------------------------------------------------------------------------
/Source/SequenceSetting.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | class CSequenceSetting : public CWnd
24 | {
25 | DECLARE_DYNAMIC(CSequenceSetting)
26 | CSequenceSetting(CWnd *pParent);
27 | virtual ~CSequenceSetting();
28 | public:
29 | void Setup(CFont *pFont);
30 | void SelectSequence(CSequence *pSequence, int Type, int InstrumentType);
31 |
32 | private:
33 | CWnd *m_pParent;
34 | CMenu m_menuPopup;
35 | CFont *m_pFont;
36 | CSequence *m_pSequence;
37 | int m_iInstType;
38 | int m_iType;
39 | bool m_bMouseOver;
40 | protected:
41 | DECLARE_MESSAGE_MAP()
42 | public:
43 | afx_msg void OnPaint();
44 | afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
45 | afx_msg void OnMenuArpAbsolute();
46 | afx_msg void OnMenuArpRelative();
47 | afx_msg void OnMenuArpFixed();
48 | afx_msg void OnMouseMove(UINT nFlags, CPoint point);
49 | afx_msg void OnMouseLeave();
50 | };
51 |
--------------------------------------------------------------------------------
/Source/FFT/Fft.h:
--------------------------------------------------------------------------------
1 | #if !defined FFT_H
2 | #define FFT_H
3 | //------------------------------------
4 | // fft.h
5 | // Fast Fourier Transform
6 | // (c) Reliable Software, 1996
7 | //------------------------------------
8 |
9 | #include "complex.h"
10 | //#include "assert.h"
11 |
12 | class SampleIter;
13 |
14 | class Fft
15 | {
16 | public:
17 | Fft (int Points, long sampleRate);
18 | ~Fft ();
19 | int Points () const { return m_Points; }
20 | void Transform ();
21 | void CopyIn (/*SampleIter& iter*/int SampleCount, short *Samples);
22 |
23 | double GetIntensity (int i) const
24 | {
25 | // Assert (i < _Points);
26 | return m_X[i].Mod()/m_sqrtPoints;
27 | }
28 |
29 | int GetFrequency (int point) const
30 | {
31 | // return frequency in Hz of a given point
32 | // Assert (point < _Points);
33 | long x =m_sampleRate * point;
34 | return x / m_Points;
35 | }
36 |
37 | int HzToPoint (int freq) const
38 | {
39 | return (long)m_Points * freq / m_sampleRate;
40 | }
41 |
42 | int MaxFreq() const { return m_sampleRate; }
43 |
44 | int Tape (int i) const
45 | {
46 | // Assert (i < _Points);
47 | return (int) m_aTape[i];
48 | }
49 |
50 | private:
51 |
52 | void PutAt ( int i, double val )
53 | {
54 | m_X [m_aBitRev[i]] = Complex (val);
55 | }
56 |
57 | int m_Points;
58 | long m_sampleRate;
59 | int m_logPoints;
60 | double m_sqrtPoints;
61 | int *m_aBitRev; // bit reverse vector
62 | Complex *m_X; // in-place fft array
63 | Complex **m_W; // exponentials
64 | double *m_aTape; // recording tape
65 | };
66 |
67 | #endif
68 |
--------------------------------------------------------------------------------
/Source/VisualizerSpectrum.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CVisualizerSpectrum, spectrum style visualizer
25 |
26 | class Fft;
27 |
28 | const int FFT_POINTS = 256;
29 |
30 | class CVisualizerSpectrum : public CVisualizerBase
31 | {
32 | public:
33 | CVisualizerSpectrum();
34 | virtual ~CVisualizerSpectrum();
35 |
36 | void Create(int Width, int Height);
37 | void SetSampleRate(int SampleRate);
38 | void SetSampleData(short *iSamples, unsigned int iCount);
39 | void Draw();
40 | void Display(CDC *pDC, bool bPaintMsg);
41 |
42 | protected:
43 | void Transform(short *pSamples, unsigned int Count);
44 |
45 | private:
46 | static const COLORREF BG_COLOR = 0;
47 |
48 | COLORREF *m_pBlitBuffer;
49 | Fft *m_pFftObject;
50 |
51 | int m_iFillPos;
52 | short m_pSampleBuffer[FFT_POINTS];
53 | float m_fWindow[FFT_POINTS];
54 | float m_fFftPoint[FFT_POINTS];
55 | };
56 |
--------------------------------------------------------------------------------
/Source/WavProgressDlg.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CWavProgressDlg dialog
25 |
26 | class CWavProgressDlg : public CDialog
27 | {
28 | DECLARE_DYNAMIC(CWavProgressDlg)
29 |
30 | public:
31 | CWavProgressDlg(CWnd* pParent = NULL); // standard constructor
32 | virtual ~CWavProgressDlg();
33 |
34 | void BeginRender(CString &File, render_end_t LengthType, int LengthParam, int Track);
35 |
36 | // Dialog Data
37 | enum { IDD = IDD_WAVE_PROGRESS };
38 |
39 | protected:
40 | DWORD m_dwStartTime;
41 | render_end_t m_iSongEndType;
42 | int m_iSongEndParam;
43 | int m_iTrack;
44 |
45 | CString m_sFile;
46 |
47 | protected:
48 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
49 |
50 | DECLARE_MESSAGE_MAP()
51 | public:
52 | afx_msg void OnBnClickedCancel();
53 | virtual BOOL OnInitDialog();
54 | afx_msg void OnTimer(UINT_PTR nIDEvent);
55 | };
56 |
--------------------------------------------------------------------------------
/Source/CreateWaveDlg.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CCreateWaveDlg dialog
25 |
26 | class CCreateWaveDlg : public CDialog
27 | {
28 | DECLARE_DYNAMIC(CCreateWaveDlg)
29 |
30 | public:
31 | CCreateWaveDlg(CWnd* pParent = NULL); // standard constructor
32 | virtual ~CCreateWaveDlg();
33 |
34 | void ShowDialog();
35 |
36 | // Dialog Data
37 | enum { IDD = IDD_CREATEWAV };
38 |
39 | protected:
40 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
41 |
42 | int GetFrameLoopCount() const;
43 | int GetTimeLimit() const;
44 |
45 | CCheckListBox m_ctlChannelList;
46 | CComboBox m_ctlTracks;
47 |
48 | DECLARE_MESSAGE_MAP()
49 | public:
50 | afx_msg void OnBnClickedBegin();
51 | virtual BOOL OnInitDialog();
52 | afx_msg void OnDeltaposSpinLoop(NMHDR *pNMHDR, LRESULT *pResult);
53 | afx_msg void OnDeltaposSpinTime(NMHDR *pNMHDR, LRESULT *pResult);
54 | };
55 |
--------------------------------------------------------------------------------
/Source/ConfigMixer.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CConfigMixer dialog
25 |
26 | class CConfigMixer : public CPropertyPage
27 | {
28 | DECLARE_DYNAMIC(CConfigMixer)
29 |
30 | public:
31 | CConfigMixer();
32 | virtual ~CConfigMixer();
33 |
34 | // Dialog Data
35 | enum { IDD = IDD_CONFIG_MIXER };
36 |
37 | static const int LEVEL_RANGE;
38 | static const int LEVEL_SCALE;
39 |
40 | private:
41 | int m_iLevelSN7L;
42 | int m_iLevelSN7R;
43 | int m_iLevelSN7Sep; // // //
44 |
45 | protected:
46 | void SetupSlider(int nID) const;
47 | void UpdateLevels();
48 | void UpdateLevel(int nID, int Level);
49 |
50 | protected:
51 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
52 |
53 | DECLARE_MESSAGE_MAP()
54 | public:
55 | virtual BOOL OnInitDialog();
56 | virtual BOOL OnApply();
57 | afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
58 | };
59 |
--------------------------------------------------------------------------------
/Source/ConfigWindow.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2012 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #include "stdafx.h"
22 | #include "FamiTracker.h"
23 | #include "ConfigWindow.h"
24 | #include "ConfigGeneral.h"
25 | #include "ConfigAppearance.h"
26 | #include "ConfigSound.h"
27 | #include "Settings.h"
28 |
29 |
30 | // CConfigWindow
31 |
32 | IMPLEMENT_DYNAMIC(CConfigWindow, CPropertySheet)
33 | CConfigWindow::CConfigWindow(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
34 | :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
35 | {
36 | }
37 |
38 | CConfigWindow::CConfigWindow(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
39 | :CPropertySheet(pszCaption, pParentWnd, iSelectPage, NULL, NULL)
40 | {
41 | }
42 |
43 | CConfigWindow::~CConfigWindow()
44 | {
45 | }
46 |
47 |
48 | BEGIN_MESSAGE_MAP(CConfigWindow, CPropertySheet)
49 | END_MESSAGE_MAP()
50 |
51 |
52 | // CConfigWindow message handlers
53 |
54 | void CConfigWindow::SetupPages(void)
55 | {
56 | }
57 |
--------------------------------------------------------------------------------
/Source/ModuleImportDlg.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | #include "FamiTrackerTypes.h"
24 |
25 | class CFamiTrackerDoc;
26 |
27 | // CModuleImportDlg dialog
28 |
29 | class CModuleImportDlg : public CDialog
30 | {
31 | DECLARE_DYNAMIC(CModuleImportDlg)
32 |
33 | public:
34 | CModuleImportDlg(CFamiTrackerDoc *pDoc);
35 | virtual ~CModuleImportDlg();
36 |
37 | // Dialog Data
38 | enum { IDD = IDD_IMPORT };
39 |
40 | public:
41 | bool LoadFile(CString Path, CFamiTrackerDoc *pDoc);
42 |
43 | private:
44 | CFamiTrackerDoc *m_pDocument;
45 | CFamiTrackerDoc *m_pImportedDoc;
46 |
47 | int m_iInstrumentTable[MAX_INSTRUMENTS];
48 |
49 | protected:
50 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
51 |
52 | bool ImportInstruments();
53 | bool ImportTracks();
54 |
55 | protected:
56 | CCheckListBox m_ctlTrackList;
57 |
58 | DECLARE_MESSAGE_MAP()
59 | public:
60 | afx_msg void OnBnClickedOk();
61 | virtual BOOL OnInitDialog();
62 | afx_msg void OnBnClickedCancel();
63 | };
64 |
--------------------------------------------------------------------------------
/Source/InstrumentFileTree.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CInstrumentFileTree
25 |
26 | class CInstrumentFileTree
27 | {
28 | public:
29 | CInstrumentFileTree();
30 | ~CInstrumentFileTree();
31 |
32 | bool BuildMenuTree(CString instrumentPath);
33 | CMenu *GetMenu() const;
34 | CString GetFile(int Index) const;
35 | bool ShouldRebuild() const;
36 | void Changed();
37 |
38 | public:
39 | // Limits, to avoid very deep recursions
40 | static const int RECURSION_LIMIT = 6;
41 | static const int MAX_MENUS = 200;
42 |
43 | static const int MENU_BASE = 0x9000; // Choose a range where no strings are located
44 |
45 | static const int CACHE_TIMEOUT = 60000; // 1 minute
46 |
47 | protected:
48 | bool ScanDirectory(CString path, CMenu *pMenu, int level);
49 | void DeleteMenuObjects();
50 |
51 | private:
52 | CMenu *m_pRootMenu;
53 | int m_iFileIndex;
54 | CArray m_fileList;
55 | CArray m_menuArray;
56 | DWORD m_iTimeout;
57 | bool m_bShouldRebuild;
58 | int m_iTotalMenusAdded;
59 | };
60 |
--------------------------------------------------------------------------------
/Source/SizeEditor.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | // Size editor
24 | class CSizeEditor : public CWnd
25 | {
26 | DECLARE_DYNAMIC(CSizeEditor)
27 | CSizeEditor(CWnd *pParent);
28 | virtual ~CSizeEditor();
29 | public:
30 | void SetValue(int Value);
31 | int GetValue() const;
32 | private:
33 | int m_iValue;
34 | int m_iButtonPressed;
35 | CWnd *m_pParentWnd;
36 | bool m_bSizeCursor;
37 | private:
38 | void MouseAction(UINT nFlags, CPoint point);
39 | void IncreaseValue();
40 | void DecreaseValue();
41 | protected:
42 | DECLARE_MESSAGE_MAP()
43 | public:
44 | afx_msg void OnPaint();
45 | afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
46 | afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
47 | afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
48 | afx_msg void OnMouseMove(UINT nFlags, CPoint point);
49 | afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
50 | afx_msg void OnTimer(UINT_PTR nIDEvent);
51 | afx_msg void OnSetFocus(CWnd* pOldWnd);
52 | afx_msg void OnKillFocus(CWnd* pNewWnd);
53 | };
54 |
--------------------------------------------------------------------------------
/Source/CommentsDlg.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CCommentsDlg dialog
25 |
26 | class CCommentsDlg : public CDialog
27 | {
28 | DECLARE_DYNAMIC(CCommentsDlg)
29 |
30 | public:
31 | CCommentsDlg(CWnd* pParent = NULL); // standard constructor
32 | virtual ~CCommentsDlg();
33 |
34 | // Dialog Data
35 | enum { IDD = IDD_COMMENTS };
36 |
37 | static LPCTSTR FONT_FACE;
38 | static int FONT_SIZE;
39 |
40 | protected:
41 | static RECT WinRect;
42 |
43 | protected:
44 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
45 |
46 | void SaveComment();
47 |
48 | protected:
49 | bool m_bChanged;
50 | CFont *m_pFont;
51 |
52 | DECLARE_MESSAGE_MAP()
53 | public:
54 | afx_msg void OnBnClickedOk();
55 | afx_msg void OnBnClickedCancel();
56 | afx_msg void OnSize(UINT nType, int cx, int cy);
57 | virtual BOOL OnInitDialog();
58 | virtual BOOL DestroyWindow();
59 | afx_msg void OnEnChangeComments();
60 | afx_msg void OnBnClickedShowonopen();
61 | afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
62 | };
63 |
--------------------------------------------------------------------------------
/Source/VGM/Constants.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** SnevenTracker is (C) HertzDevil 2016
6 | **
7 | ** This program is free software; you can redistribute it and/or modify
8 | ** it under the terms of the GNU General Public License as published by
9 | ** the Free Software Foundation; either version 2 of the License, or
10 | ** (at your option) any later version.
11 | **
12 | ** This program is distributed in the hope that it will be useful,
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | ** Library General Public License for more details. To obtain a
16 | ** copy of the GNU Library General Public License, write to the Free
17 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 | **
19 | ** Any permitted reproduction of these routines, in whole or in part,
20 | ** must bear this legend.
21 | */
22 |
23 |
24 | #pragma once
25 |
26 | enum class VGMChip
27 | {
28 | SN76489, // $0C
29 | YM2413, // $10
30 | YM2612, // $2C
31 | YM2151, // $30
32 | SegaPCM, // $38
33 | RF5C68, // $40
34 | YM2203, // $44
35 | YM2608, // $48
36 | YM2610, // $4C
37 | YM3812, // $50
38 | YM3526, // $54
39 | Y8950, // $58
40 | YMF262, // $5C
41 | YMF278B, // $60
42 | YMF271, // $64
43 | YMZ280B, // $68
44 | RF5C164, // $6C
45 | PWM, // $70
46 | AY8910, // $74
47 | GB, // $80
48 | NES, // $84
49 | MultiPCM, // $88
50 | uPD7759, // $8C
51 | OKIM6258, // $90
52 | OKIM6295, // $98
53 | SCC1, // $9C
54 | K054539, // $A0
55 | HuC6280, // $A4
56 | C140, // $A8
57 | K053260, // $AC
58 | Pokey, // $B0
59 | QSound, // $B4
60 | // SCSP, // $B8
61 | // WonderSwan, // $C0
62 | // VSU, // $C4
63 | // SAA1099, // $C8
64 | // ES5503, // $CC
65 | // ES5506, // $D0
66 | // X1_010, // $D8
67 | // C352, // $DC
68 | // GA20, // $E0
69 | _Count,
70 | };
71 |
--------------------------------------------------------------------------------
/Source/VisualizerStatic.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #include "stdafx.h"
22 | #include "VisualizerWnd.h"
23 | #include "VisualizerStatic.h"
24 | #include "resource.h"
25 |
26 | /*
27 | * Display a static image
28 | *
29 | */
30 |
31 | CVisualizerStatic::CVisualizerStatic()
32 | {
33 | }
34 |
35 | CVisualizerStatic::~CVisualizerStatic()
36 | {
37 | if (m_dcImage.m_hDC != NULL) {
38 | m_dcImage.SelectObject(m_pOldBmp);
39 | }
40 | }
41 |
42 | void CVisualizerStatic::Create(int Width, int Height)
43 | {
44 | CVisualizerBase::Create(Width, Height);
45 | }
46 |
47 | void CVisualizerStatic::SetSampleRate(int SampleRate)
48 | {
49 | }
50 |
51 | void CVisualizerStatic::Draw()
52 | {
53 | }
54 |
55 | void CVisualizerStatic::Display(CDC *pDC, bool bPaintMsg)
56 | {
57 | if (!bPaintMsg)
58 | return;
59 |
60 | if (m_dcImage.m_hDC == NULL) {
61 | m_bmpImage.LoadBitmap(IDB_VISUALIZER);
62 | m_dcImage.CreateCompatibleDC(pDC);
63 | m_pOldBmp = m_dcImage.SelectObject(&m_bmpImage);
64 | }
65 |
66 | pDC->BitBlt(0, 0, m_iWidth, m_iHeight, &m_dcImage, 0, 0, SRCCOPY);
67 | }
68 |
--------------------------------------------------------------------------------
/Source/Document/PatternData_new.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** SnevenTracker is (C) HertzDevil 2016
6 | **
7 | ** This program is free software; you can redistribute it and/or modify
8 | ** it under the terms of the GNU General Public License as published by
9 | ** the Free Software Foundation; either version 2 of the License, or
10 | ** (at your option) any later version.
11 | **
12 | ** This program is distributed in the hope that it will be useful,
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | ** Library General Public License for more details. To obtain a
16 | ** copy of the GNU Library General Public License, write to the Free
17 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 | **
19 | ** Any permitted reproduction of these routines, in whole or in part,
20 | ** must bear this legend.
21 | */
22 |
23 |
24 | #pragma once
25 |
26 | #include
27 | #include "PatternNote.h"
28 |
29 | namespace FTExt {
30 |
31 | class CPatternData
32 | {
33 | public:
34 | explicit CPatternData(size_t MaxSize = MAX_SIZE);
35 | ~CPatternData() = default;
36 |
37 | CPatternData(const CPatternData &other) = default;
38 | CPatternData(CPatternData &&other) = default;
39 | CPatternData &operator=(CPatternData other);
40 | friend void swap(CPatternData &a, CPatternData &b);
41 |
42 | CPatternNote GetNote(size_t Row) const;
43 | void SetNote(size_t Row, const CPatternNote &Note);
44 |
45 | size_t GetSize() const;
46 | void SetSize(size_t Size);
47 |
48 | bool IsEmpty() const;
49 | void Clear();
50 |
51 | typename std::vector::iterator begin();
52 | typename std::vector::iterator end();
53 |
54 | public:
55 | static const size_t MAX_SIZE;
56 |
57 | private:
58 | std::vector m_pNotes;
59 | size_t m_iActualSize = 0u;
60 | };
61 |
62 | } // namespace FTExt
63 |
--------------------------------------------------------------------------------
/Source/APU/Channel.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #ifndef CHANNEL_H
22 | #define CHANNEL_H
23 |
24 | class CMixer;
25 | class CVGMWriterBase; // // //
26 |
27 | //
28 | // This class is used to derive the audio channels
29 | //
30 |
31 | // // //
32 |
33 | class CExChannel {
34 | public:
35 | CExChannel(CMixer *pMixer, uint8 Chip, uint8 ID) :
36 | m_pMixer(pMixer),
37 | m_iChip(Chip),
38 | m_iChanId(ID) // // //
39 | {
40 | }
41 |
42 | virtual inline void EndFrame() {
43 | m_iTime = 0;
44 | }
45 |
46 | virtual inline void SetVGMWriter(const CVGMWriterBase *pWrite) { // // //
47 | m_pVGMWriter = pWrite;
48 | }
49 |
50 | protected:
51 | inline void Mix(int32 Value) {
52 | m_pMixer->AddValue(m_iChanId, m_iChip, Value, Value, m_iTime); // // //
53 | }
54 | inline void Mix(int32 Left, int32 Right) {
55 | m_pMixer->AddValue(m_iChanId, m_iChip, Left, Right, m_iTime); // // //
56 | }
57 |
58 | protected:
59 | CMixer *m_pMixer;
60 | const CVGMWriterBase *m_pVGMWriter = nullptr;
61 |
62 | uint32 m_iTime = 0; // Cycle counter, resets every new frame
63 | uint8 m_iChip;
64 | uint8 m_iChanId;
65 | };
66 |
67 | #endif /* CHANNEL_H */
68 |
--------------------------------------------------------------------------------
/Source/ChannelsDlg.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | const int ROOT_ITEM_COUNT = 7;
24 |
25 | // CChannelsDlg dialog
26 |
27 | class CChannelsDlg : public CDialog
28 | {
29 | DECLARE_DYNAMIC(CChannelsDlg)
30 |
31 | public:
32 | CChannelsDlg(CWnd* pParent = NULL); // standard constructor
33 | virtual ~CChannelsDlg();
34 |
35 | // Dialog Data
36 | enum { IDD = IDD_CHANNELS };
37 |
38 | protected:
39 | CTreeCtrl *m_pAvailableTree;
40 | CListCtrl *m_pAddedChannels;
41 |
42 | HTREEITEM m_hRootItems[ROOT_ITEM_COUNT];
43 |
44 | void AddChannel(int ChanID);
45 | void InsertChannel(HTREEITEM hItem);
46 |
47 | protected:
48 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
49 |
50 | DECLARE_MESSAGE_MAP()
51 | public:
52 | virtual BOOL OnInitDialog();
53 | afx_msg void OnClickAvailable(NMHDR *pNMHDR, LRESULT *result);
54 | afx_msg void OnDblClickAvailable(NMHDR *pNMHDR, LRESULT *result);
55 | afx_msg void OnDblClickAdded(NMHDR *pNMHDR, LRESULT *result);
56 | afx_msg void OnBnClickedMoveDown();
57 | afx_msg void OnNMRClickAvailableTree(NMHDR *pNMHDR, LRESULT *pResult);
58 | afx_msg void OnBnClickedMoveUp();
59 | };
60 |
--------------------------------------------------------------------------------
/Source/ConfigShortcuts.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CConfigShortcuts dialog
25 |
26 | class CConfigShortcuts : public CPropertyPage
27 | {
28 | DECLARE_DYNAMIC(CConfigShortcuts)
29 |
30 | public:
31 | CConfigShortcuts(); // standard constructor
32 | virtual ~CConfigShortcuts();
33 |
34 | // Dialog Data
35 | enum { IDD = IDD_CONFIG_SHORTCUTS };
36 |
37 | private:
38 | int m_iSelectedItem;
39 | bool m_bShift;
40 | bool m_bControl;
41 | bool m_bAlt;
42 |
43 | int *m_iKeys;
44 | int *m_iMods;
45 |
46 | protected:
47 | void SetupKey(int Key);
48 | void KeyPressed(int Key);
49 | void KeyReleased(int Key);
50 | void StoreKey(int Item, int Key, int Mod);
51 |
52 | CString AssembleKeyString(int Mod, int Key);
53 |
54 | protected:
55 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
56 |
57 | DECLARE_MESSAGE_MAP()
58 | public:
59 | virtual BOOL OnInitDialog();
60 | afx_msg void OnNMClickShortcuts(NMHDR *pNMHDR, LRESULT *pResult);
61 | afx_msg void OnBnClickedDefault();
62 | virtual BOOL OnApply();
63 | virtual BOOL PreTranslateMessage(MSG* pMsg);
64 | afx_msg void OnBnClickedClear();
65 | };
66 |
--------------------------------------------------------------------------------
/Source/ExportTest/ExportTest.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | #ifdef EXPORT_TEST
24 |
25 | struct stRegs {
26 | unsigned char R_2A03[0x20];
27 | // // //
28 | };
29 |
30 | // DLL imports
31 | typedef void (*LoadFile_t)(char*, int, void*);
32 | typedef int (*RunFrame_t)(unsigned int, int);
33 | typedef unsigned char (*ReadResult_t)(unsigned int, int);
34 |
35 | struct stNSFHeader;
36 |
37 | // Test class
38 | class CExportTest
39 | {
40 | public:
41 | CExportTest();
42 | ~CExportTest();
43 |
44 | bool Setup(LPCTSTR lpszFile = NULL);
45 | void RunInit(int Song);
46 | void RunPlay();
47 |
48 | void ReportSuccess();
49 | bool ReportError(stRegs *pInternalRegs, stRegs *pExternalRegs, int UpdateFrames, int Chip);
50 |
51 | unsigned char ReadReg(int Reg, int Chip);
52 |
53 | private:
54 | void PrintErrorReport(stRegs *pInternalRegs, stRegs *pExternalRegs, int UpdateFrames, int Chip);
55 |
56 | private:
57 | struct {
58 | LoadFile_t LoadFileFunc;
59 | RunFrame_t RunFrameFunc;
60 | ReadResult_t ReadResultFunc;
61 | } ImportFuncs;
62 |
63 | stNSFHeader *m_pHeader;
64 | int m_iFileSize;
65 | HMODULE m_hModule;
66 | bool m_bErrors;
67 | };
68 |
69 | #endif /* EXPORT_TEST */
70 |
--------------------------------------------------------------------------------
/Source/Sequence.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // // //
25 | #include "FamiTrackerTypes.h"
26 |
27 | class CDocumentFile;
28 |
29 | /*
30 | ** This class is used to store instrument sequences
31 | */
32 | class CSequence { // // //
33 | public:
34 | CSequence();
35 |
36 | void Clear();
37 | signed char GetItem(int Index) const;
38 | unsigned int GetItemCount() const;
39 | unsigned int GetLoopPoint() const;
40 | unsigned int GetReleasePoint() const;
41 | unsigned int GetSetting() const;
42 | void SetItem(int Index, signed char Value);
43 | void SetItemCount(unsigned int Count);
44 | void SetLoopPoint(unsigned int Point);
45 | void SetReleasePoint(unsigned int Point);
46 | void SetSetting(unsigned int Setting);
47 | void Copy(const CSequence *pSeq);
48 |
49 | private:
50 | // Sequence data
51 | unsigned int m_iItemCount;
52 | unsigned int m_iLoopPoint;
53 | unsigned int m_iReleasePoint;
54 | unsigned int m_iSetting;
55 | signed char m_cValues[MAX_SEQUENCE_ITEMS];
56 | int m_iPlaying;
57 | };
58 |
59 |
60 | // Settings
61 | enum arp_setting_t {
62 | ARP_SETTING_ABSOLUTE = 0,
63 | ARP_SETTING_FIXED = 1,
64 | ARP_SETTING_RELATIVE = 2
65 | };
66 |
67 | // // //
68 |
--------------------------------------------------------------------------------
/FUTURE.md:
--------------------------------------------------------------------------------
1 | ### plans
2 |
3 | fix `CChannelMap`
4 | - contained by `CFamiTrackerDoc`, as originally planned
5 | - `unordered_map` lookup by chip name?
6 | - multiple instrument types for each sound chip
7 |
8 | `CSongView`
9 | - decouples cursor/selection stuff from the pattern editor
10 | - also put the iterator classes from 0cc-ft near here
11 | - should be possible to reorder channels with this
12 | - the actual pattern editor view must be able to hide channels without disabling them
13 |
14 | each channel handler will control its `CExternal`-derived class immediately
15 | - no shared register writes among chips, no need to emulate mapper circuitry tbh
16 | - if that is required, add also a `CSoundSystem` class containing at most one instance of each chip
17 |
18 | `CSoundChip`
19 | - present in 0cc-ft, but here it should use composite pattern (over `CExChannel`)
20 | - interface for dealing with chip-specific configuration (refresh rate, region etc.)
21 |
22 | `CChipHandler`
23 | - **dual sn76489** (this is actually prohibited since the vgm format will enable t6w28 mode for that)
24 | - can this use composite just like `CSoundChip`?
25 |
26 | will i be able to implement the new pattern effect interface here???
27 | - turn `effect_t` into a true effect type
28 | - proper dispatch for effect types
29 | - effect handler, each CChannelHandler stores a list of them
30 | - channel state object, filtered through entire effect chain, final state processed by `RefreshChannel`
31 |
32 | opn2 / ym2612
33 | - 24 tracks, since each operator has one; 6 masters (op4), 18 slaves (op1-3)
34 | - `N00` - `N07` changes which operators are automatically controlled by the master tracks, default `N07` so that other operator tracks can be ignored unless needed
35 | - slave tracks have sound effect track semantics (refine this), trigger/halt controls operator
36 | - ch3 extended mode is just a special case where 3 slave tracks get their frequencies written
37 | - `Kxx` and `Vxx` will dispatch to the different operator parameters on the current track
38 | - no plans for one instrument sequence per operator parameter
39 | - no plans for software-mixed pcm, but 0cc-ft's successor should have them by leveraging ch6's 4 tracks directly
40 |
41 |
--------------------------------------------------------------------------------
/Source/Document/TrackData.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** SnevenTracker is (C) HertzDevil 2016
6 | **
7 | ** This program is free software; you can redistribute it and/or modify
8 | ** it under the terms of the GNU General Public License as published by
9 | ** the Free Software Foundation; either version 2 of the License, or
10 | ** (at your option) any later version.
11 | **
12 | ** This program is distributed in the hope that it will be useful,
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | ** Library General Public License for more details. To obtain a
16 | ** copy of the GNU Library General Public License, write to the Free
17 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 | **
19 | ** Any permitted reproduction of these routines, in whole or in part,
20 | ** must bear this legend.
21 | */
22 |
23 |
24 | #pragma once
25 |
26 | #include "../FamiTrackerTypes.h"
27 | #include "../Utility/GenCollection.h"
28 | #include
29 |
30 | namespace FTExt {
31 |
32 | class CPatternData;
33 |
34 | class CTrackData {
35 | public:
36 | CTrackData() = default;
37 |
38 | const CPatternData *GetPattern(size_t Index) const;
39 | CPatternData *GetPattern(size_t Index);
40 | CPatternData *NewPattern(size_t Index, size_t Size);
41 |
42 | const CPatternData *GetPatternAtFrame(size_t Frame) const;
43 | CPatternData *GetPatternAtFrame(size_t Frame);
44 | /* do not allow each track to have its own number of frames yet, too many things will break
45 | size_t GetTrackLength() const;
46 | void SetTrackLength(size_t Size);
47 | */
48 | size_t GetPatternIndex(size_t Frame) const;
49 | void SetPatternIndex(size_t Frame, size_t Index);
50 |
51 | int GetEffectColumnCount() const;
52 | void SetEffectColumnCount(int Count);
53 |
54 | private:
55 | CGenCollection m_pPatterns;
56 | std::vector m_iFrameList = std::vector(MAX_PATTERN);
57 | // size_t m_iLength = 1u;
58 | int m_iEffectColumnCount = 1;
59 | };
60 |
61 | } // namespace FTExt
62 |
--------------------------------------------------------------------------------
/Source/TrackerChannel.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CTrackerChannel
25 |
26 | #include // For CMutex
27 |
28 | enum note_prio_t {
29 | NOTE_PRIO_0,
30 | NOTE_PRIO_1,
31 | NOTE_PRIO_2
32 | };
33 |
34 | class CTrackerChannel
35 | {
36 | public:
37 | CTrackerChannel(LPCTSTR pName, const int iChip, const int iID);
38 | ~CTrackerChannel(void);
39 | LPCTSTR GetChannelName() const;
40 | const char GetChip() const;
41 | const int GetID() const;
42 | const int GetColumnCount() const;
43 | void SetColumnCount(int Count);
44 |
45 | stChanNote GetNote();
46 | void SetNote(stChanNote &Note, note_prio_t Priority);
47 | bool NewNoteData() const;
48 | void Reset();
49 |
50 | void SetVolumeMeter(int Value);
51 | int GetVolumeMeter() const;
52 |
53 | void SetPitch(int Pitch);
54 | int GetPitch() const;
55 |
56 | bool IsInstrumentCompatible(int Instrument, CFamiTrackerDoc *pDoc) const;
57 |
58 | private:
59 | LPCTSTR m_pChannelName;
60 |
61 | private:
62 | int m_iChip;
63 | int m_iChannelID;
64 | int m_iColumnCount;
65 |
66 | stChanNote m_Note;
67 | bool m_bNewNote;
68 | note_prio_t m_iNotePriority;
69 |
70 | int m_iVolumeMeter;
71 | int m_iPitch;
72 |
73 | private:
74 | CCriticalSection m_csNoteLock;
75 | };
76 |
--------------------------------------------------------------------------------
/Source/ChannelMap.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CChannelMap
25 |
26 | class CChannelMap
27 | {
28 | public:
29 | CChannelMap();
30 | ~CChannelMap();
31 | void SetupSoundChips();
32 |
33 | int GetChipCount() const;
34 | LPCTSTR GetChipName(int Index) const;
35 | int GetChipIdent(int Index) const;
36 | int GetChipIndex(int Ident) const;
37 | CInstrument *GetChipInstrument(int Chip) const;
38 |
39 | // Active channel map
40 | void ResetChannels();
41 | void RegisterChannel(CTrackerChannel *pChannel, int ChannelType, int ChipType);
42 | CTrackerChannel *GetChannel(int Index) const;
43 | int GetChannelType(int Channel) const;
44 | int GetChipType(int Channel) const;
45 |
46 | public:
47 | static const int CHIP_COUNT = 8; // Number of allowed expansion chips
48 |
49 | protected:
50 | void AddChip(int Ident, CInstrument *pInst, LPCTSTR pName);
51 |
52 | protected:
53 | // Chips
54 | int m_iAddedChips;
55 | int m_iChipIdents[CHIP_COUNT];
56 | LPCTSTR m_pChipNames[CHIP_COUNT];
57 | CInstrument *m_pChipInst[CHIP_COUNT];
58 |
59 | // Current set
60 | CTrackerChannel *m_pChannels[CHANNELS];
61 | int m_iRegisteredChannels;
62 | int m_iChannelTypes[CHANNELS];
63 | int m_iChannelChip[CHANNELS];
64 |
65 | };
66 |
--------------------------------------------------------------------------------
/Source/Graphics.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2013 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // Various graphics helpers
25 |
26 | // Color macros
27 |
28 | #define RED(x) (x & 255)
29 | #define GREEN(x) ((x >> 8) & 255)
30 | #define BLUE(x) ((x >> 16) & 255)
31 | #define ALPHA(x) ((x >> 24) & 255)
32 |
33 | #define COMBINE(r, g, b) (((b) << 16) | ((g) << 8) | r)
34 |
35 | #define DIM(c, l) (COMBINE((RED(c) * l) / 100, (GREEN(c) * l) / 100, (BLUE(c) * l) / 100))
36 |
37 | #define BLEND_COLOR(c1, c2, level) ((c1 * level) / 100 + (c2 * (100 - level)) / 100)
38 |
39 | #define BLEND(c1, c2, level) (COMBINE(BLEND_COLOR(RED(c1), RED(c2), (level)), \
40 | BLEND_COLOR(GREEN(c1), GREEN(c2), (level)), \
41 | BLEND_COLOR(BLUE(c1), BLUE(c2), (level))))
42 |
43 | #define INTENSITY(c) ((((c >> 16) & 0xFF) + ((c >> 8) & 0xFF) + (c & 0xFF)) / 3)
44 |
45 | // Functions
46 |
47 | void GradientRectTriple(CDC *pDC, int x, int y, int w, int h, COLORREF c1, COLORREF c2, COLORREF c3);
48 | void GradientBar(CDC *pDC, int x, int y, int w, int h, COLORREF col_fg, COLORREF col_bg);
49 | void GradientRect(CDC *pDC, int x, int y, int w, int h, COLORREF top_col, COLORREF bottom_col);
50 | void BlurBuffer(COLORREF *pBuffer, int Width, int Height, const int *pColorDecay);
51 | void PutPixel(COLORREF *pBuffer, int Width, int Height, float x, float y, COLORREF col);
52 |
--------------------------------------------------------------------------------
/Source/AboutDlg.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CAboutDlg, about dialog
25 |
26 | class CLinkLabel : public CStatic
27 | {
28 | public:
29 | CLinkLabel(CString address);
30 | protected:
31 | DECLARE_MESSAGE_MAP()
32 | CString m_strAddress;
33 | bool m_bHover;
34 | public:
35 | afx_msg HBRUSH CtlColor(CDC* /*pDC*/, UINT /*nCtlColor*/);
36 | afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
37 | afx_msg void OnMouseLeave();
38 | afx_msg void OnMouseMove(UINT nFlags, CPoint point);
39 | };
40 |
41 |
42 | class CHead : public CStatic
43 | {
44 | public:
45 | CHead();
46 | protected:
47 | DECLARE_MESSAGE_MAP()
48 | public:
49 | virtual void CHead::DrawItem(LPDRAWITEMSTRUCT);
50 | };
51 |
52 |
53 | class CAboutDlg : public CDialog
54 | {
55 | public:
56 | CAboutDlg();
57 | ~CAboutDlg();
58 |
59 | // Dialog Data
60 | enum { IDD = IDD_ABOUTBOX };
61 |
62 | protected:
63 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
64 |
65 | CLinkLabel *m_pMail, *m_pWeb;
66 | CToolTipCtrl m_wndToolTip;
67 |
68 | CFont *m_pLinkFont, *m_pBoldFont, *m_pTitleFont;
69 | CHead *m_pHead;
70 |
71 | // Implementation
72 | protected:
73 | DECLARE_MESSAGE_MAP()
74 | public:
75 | virtual BOOL OnInitDialog();
76 | afx_msg void OnBnClickedOk();
77 | virtual BOOL PreTranslateMessage(MSG* pMsg);
78 | };
79 |
--------------------------------------------------------------------------------
/Source/ExportDialog.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | class CExportDialog;
24 |
25 | typedef void (CExportDialog::*exportFunc_t)();
26 |
27 | // CExportDialog dialog
28 |
29 | class CExportDialog : public CDialog
30 | {
31 | DECLARE_DYNAMIC(CExportDialog)
32 |
33 | public:
34 | CExportDialog(CWnd* pParent = NULL); // standard constructor
35 | virtual ~CExportDialog();
36 |
37 | // Dialog Data
38 | enum { IDD = IDD_EXPORT };
39 |
40 | protected:
41 | static int m_iExportOption;
42 |
43 | protected:
44 | static const exportFunc_t DEFAULT_EXPORT_FUNCS[];
45 | static const LPTSTR DEFAULT_EXPORT_NAMES[];
46 | static const int DEFAULT_EXPORTERS;
47 |
48 | static LPCTSTR NSF_FILTER[2];
49 | static LPCTSTR NES_FILTER[2];
50 | static LPCTSTR RAW_FILTER[2];
51 | // // //
52 | static LPCTSTR PRG_FILTER[2];
53 | static LPCTSTR ASM_FILTER[2];
54 |
55 | #ifdef _DEBUG
56 | CString m_strFile;
57 | #endif
58 |
59 | protected:
60 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
61 | void CreateNSF();
62 | void CreateNES();
63 | void CreateBIN();
64 | void CreatePRG();
65 | void CreateASM();
66 | // // //
67 |
68 | DECLARE_MESSAGE_MAP()
69 | public:
70 | virtual BOOL OnInitDialog();
71 | afx_msg void OnBnClickedClose();
72 | afx_msg void OnBnClickedExport();
73 | afx_msg void OnBnClickedPlay();
74 | };
75 |
--------------------------------------------------------------------------------
/Source/ModulePropertiesDlg.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CModulePropertiesDlg dialog
25 |
26 | class CModulePropertiesDlg : public CDialog
27 | {
28 | DECLARE_DYNAMIC(CModulePropertiesDlg)
29 |
30 | private:
31 | void SelectSong(int Song);
32 | void UpdateSongButtons();
33 |
34 | unsigned int m_iSelectedSong;
35 |
36 | CFamiTrackerDoc *m_pDocument;
37 |
38 | public:
39 | CModulePropertiesDlg(CWnd* pParent = NULL); // standard constructor
40 | virtual ~CModulePropertiesDlg();
41 |
42 | // Dialog Data
43 | enum { IDD = IDD_PROPERTIES };
44 |
45 | protected:
46 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
47 |
48 | void FillSongList();
49 |
50 | DECLARE_MESSAGE_MAP()
51 | public:
52 | virtual BOOL OnInitDialog();
53 | afx_msg void OnBnClickedOk();
54 | afx_msg void OnBnClickedSongAdd();
55 | afx_msg void OnBnClickedSongRemove();
56 | afx_msg void OnBnClickedSongUp();
57 | afx_msg void OnBnClickedSongDown();
58 | afx_msg void OnEnChangeSongname();
59 | afx_msg void OnClickSongList(NMHDR *pNMHDR, LRESULT *pResult);
60 | afx_msg void OnBnClickedSongImport();
61 | afx_msg void OnCbnSelchangeExpansion();
62 | afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
63 | afx_msg void OnLvnItemchangedSonglist(NMHDR *pNMHDR, LRESULT *pResult);
64 | virtual BOOL PreTranslateMessage(MSG* pMsg);
65 | };
66 |
--------------------------------------------------------------------------------
/Source/InstrumentEditor2A03.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | class CSequenceEditor;
24 |
25 | class CInstrumentEditor2A03 : public CSequenceInstrumentEditPanel
26 | {
27 | DECLARE_DYNAMIC(CInstrumentEditor2A03)
28 |
29 | public:
30 | CInstrumentEditor2A03(CWnd* pParent = NULL); // standard constructor
31 | virtual ~CInstrumentEditor2A03();
32 | virtual int GetIDD() const { return IDD; };
33 | virtual TCHAR *GetTitle() const { return _T("SN76489 settings"); }; // // //
34 |
35 | // Public
36 | virtual void SelectInstrument(int Instrument);
37 | virtual void SetSequenceString(CString Sequence, bool Changed);
38 |
39 | // Dialog Data
40 | enum { IDD = IDD_INSTRUMENT_INTERNAL };
41 |
42 | protected:
43 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
44 | virtual void OnKeyReturn();
45 |
46 | void TranslateMML(CString String, int Max, int Min);
47 | void SelectSequence(int Sequence, int Type);
48 |
49 | protected:
50 | static LPCTSTR INST_SETTINGS_2A03[CInstrument2A03::SEQUENCE_COUNT];
51 |
52 | protected:
53 | CInstrument2A03 *m_pInstrument;
54 |
55 | DECLARE_MESSAGE_MAP()
56 | public:
57 | virtual BOOL OnInitDialog();
58 | afx_msg void OnLvnItemchangedInstsettings(NMHDR *pNMHDR, LRESULT *pResult);
59 | afx_msg void OnEnChangeSeqIndex();
60 | afx_msg void OnBnClickedFreeSeq();
61 | afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
62 | virtual BOOL DestroyWindow();
63 | afx_msg void OnCloneSequence();
64 | };
65 |
--------------------------------------------------------------------------------
/Source/VGM/Writer/SN76489.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** SnevenTracker is (C) HertzDevil 2016
6 | **
7 | ** This program is free software; you can redistribute it and/or modify
8 | ** it under the terms of the GNU General Public License as published by
9 | ** the Free Software Foundation; either version 2 of the License, or
10 | ** (at your option) any later version.
11 | **
12 | ** This program is distributed in the hope that it will be useful,
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | ** Library General Public License for more details. To obtain a
16 | ** copy of the GNU Library General Public License, write to the Free
17 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 | **
19 | ** Any permitted reproduction of these routines, in whole or in part,
20 | ** must bear this legend.
21 | */
22 |
23 | #include "SN76489.h"
24 |
25 | CVGMWriterSN76489::CVGMWriterSN76489(CVGMLogger &logger, Mode m) :
26 | CVGMWriterBase(logger), m_iMode(m), m_iClockRate(3579545)
27 | {
28 | }
29 |
30 | VGMChip CVGMWriterSN76489::GetChip() const
31 | {
32 | return VGMChip::SN76489;
33 | }
34 |
35 | std::vector
36 | CVGMWriterSN76489::Command(uint32_t adr, uint32_t val, uint32_t port) const
37 | {
38 | // ignore adr since the SN76489 doesn't really have one
39 | if (port == 0x06) // GG stereo port
40 | return {0x4F, (char)val};
41 | return {0x50, (char)val};
42 | }
43 |
44 | void CVGMWriterSN76489::UpdateHeader(CVGMLogger::Header &h) const
45 | {
46 | const size_t CLOCK_ADR = 0x0C;
47 | const size_t FEEDBACK_ADR = 0x28;
48 | const size_t WIDTH_ADR = 0x2A;
49 | const size_t FLAGS_ADR = 0x2B;
50 |
51 | h.WriteAt(CLOCK_ADR, m_iClockRate);
52 |
53 | switch (m_iMode) {
54 | case Mode::GameGear:
55 | h.WriteAt(FEEDBACK_ADR, 0x0009);
56 | h.WriteAt(WIDTH_ADR, 0x10);
57 | break;
58 | case Mode::BBCMicro:
59 | h.WriteAt(FEEDBACK_ADR, 0x0003);
60 | h.WriteAt(WIDTH_ADR, 0x10);
61 | break;
62 | case Mode::SN76496:
63 | h.WriteAt(FEEDBACK_ADR, 0x0006);
64 | h.WriteAt(WIDTH_ADR, 0x0F);
65 | break;
66 | }
67 |
68 | h.WriteAt(FLAGS_ADR, 0x00);
69 | }
70 |
71 | void CVGMWriterSN76489::SetClockRate(uint32_t hz)
72 | {
73 | m_iClockRate = hz;
74 | }
75 |
--------------------------------------------------------------------------------
/Source/PatternCompiler.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | class CFamiTrackerDoc;
24 | class CCompilerLog;
25 |
26 | // // //
27 |
28 | class CPatternCompiler
29 | {
30 | public:
31 | CPatternCompiler(CFamiTrackerDoc *pDoc, unsigned int *pInstList, CCompilerLog *pLogger); // // //
32 | ~CPatternCompiler();
33 |
34 | void CompileData(int Track, int Pattern, int Channel);
35 |
36 | unsigned int GetHash() const;
37 | bool CompareData(const std::vector &data) const;
38 |
39 | const std::vector &GetData() const;
40 | const std::vector &GetCompressedData() const;
41 |
42 | unsigned int GetDataSize() const;
43 | unsigned int GetCompressedDataSize() const;
44 |
45 | private:
46 | struct stSpacingInfo {
47 | int SpaceCount;
48 | int SpaceSize;
49 | };
50 |
51 | private:
52 | unsigned int FindInstrument(int Instrument) const;
53 | // // //
54 |
55 | unsigned char Command(int cmd) const;
56 |
57 | void WriteData(unsigned char Value);
58 | void WriteDuration();
59 | void AccumulateDuration();
60 | void OptimizeString();
61 | int GetBlockSize(int Position);
62 | stSpacingInfo ScanNoteLengths(int Track, unsigned int StartRow, int Pattern, int Channel);
63 |
64 | // Debugging
65 | void Print(LPCTSTR text) const;
66 |
67 | private:
68 | std::vector m_vData;
69 | std::vector m_vCompressedData;
70 |
71 | unsigned int m_iDuration;
72 | unsigned int m_iCurrentDefaultDuration;
73 | // // //
74 | unsigned int m_iHash;
75 | unsigned int *m_pInstrumentList;
76 |
77 | // // //
78 |
79 | CFamiTrackerDoc *m_pDocument;
80 | CCompilerLog *m_pLogger;
81 | };
82 |
--------------------------------------------------------------------------------
/Source/SequenceEditor.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | enum {
24 | WM_SIZE_CHANGE = WM_USER,
25 | WM_CURSOR_CHANGE,
26 | WM_SEQUENCE_CHANGED
27 | };
28 |
29 | class CSequence;
30 | class CGraphEditor;
31 | class CSizeEditor;
32 | class CSequenceSetting;
33 |
34 | // Sequence editor
35 | class CSequenceEditor : public CWnd
36 | {
37 | DECLARE_DYNAMIC(CSequenceEditor)
38 | public:
39 | CSequenceEditor(CFamiTrackerDoc *pDoc);
40 | virtual ~CSequenceEditor();
41 |
42 | BOOL CreateEditor(CWnd *pParentWnd, const RECT &rect);
43 | void SelectSequence(CSequence *pSequence, int Type, int InstrumentType);
44 | void SetMaxValues(int MaxVol, int MaxDuty);
45 | void ChangedSetting();
46 |
47 | public:
48 | static const int SEQUENCE_EDIT_WIDTH = 540;
49 | static const int SEQUENCE_EDIT_HEIGHT = 237;
50 | private:
51 | CFamiTrackerDoc *m_pDocument;
52 | CWnd *m_pParent;
53 | CFont *m_pFont;
54 | CSizeEditor *m_pSizeEditor;
55 | CGraphEditor *m_pGraphEditor;
56 | CSequence *m_pSequence;
57 | CSequenceSetting *m_pSetting;
58 |
59 | int m_iSelectedSetting;
60 | int m_iInstrumentType;
61 | int m_iMaxVol;
62 | int m_iMaxDuty;
63 | private:
64 | void DestroyGraphEditor();
65 | void SequenceChangedMessage(bool Changed);
66 | protected:
67 | DECLARE_MESSAGE_MAP()
68 | public:
69 | afx_msg void OnPaint();
70 | //virtual BOOL PreTranslateMessage(MSG* pMsg);
71 | virtual BOOL DestroyWindow();
72 | afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
73 | afx_msg LRESULT OnSizeChange(WPARAM wParam, LPARAM lParam);
74 | afx_msg LRESULT OnCursorChange(WPARAM wParam, LPARAM lParam);
75 | afx_msg LRESULT OnSequenceChanged(WPARAM wParam, LPARAM lParam);
76 | };
77 |
--------------------------------------------------------------------------------
/Source/resampler/sinc.hpp:
--------------------------------------------------------------------------------
1 | /**This program is free software. It comes without any warranty, to
2 | **the extent permitted by applicable law. You can redistribute it
3 | **and/or modify it under the terms of the Do What The Fuck You Want
4 | **To Public License, Version 2, as published by Sam Hocevar. See
5 | **http://sam.zoy.org/wtfpl/COPYING for more details. **/
6 |
7 | /**Author: Jarhmander **/
8 |
9 | /**Description:
10 | This class has the sole purpose of calculating a point of a
11 | normalised sinc [ sin(pi * x) / (pi * x) ] using a combination of
12 | look-up table and linear interpolation. The table itself contains
13 | only half of the sinc values, as it uses the symetric property of
14 | the sinc function.
15 | Its domain is limited and the step size (resolution) of the sinc
16 | is configurable.
17 | A Hamming window is applied to the sinc to minimise spectral
18 | leakage and gain control is provided so when used as an impulse
19 | response of a filter, the DC gain can be controlled.
20 |
21 | Mainly intended for signal processing purposes.
22 | **/
23 |
24 | #ifndef SINC_HPP
25 | #define SINC_HPP
26 |
27 | //------------------------------------------------------------------------
28 | #include
29 | #include
30 | //------------------------------------------------------------------------
31 | #include
32 |
33 | namespace jarh
34 | {
35 |
36 |
37 |
38 | using std::size_t;
39 |
40 |
41 |
42 | class sinc
43 | {
44 | public:
45 | /** ctor:
46 | * calls resize.
47 | */
48 | sinc(size_t sz, size_t firstnull, float gain=1.f);
49 |
50 | /** resize:
51 | * resize internal table and recompute values in it
52 | * sz = size of the vector
53 | * firstnull = steps before the first null of sinc.
54 | * gain = the integral of the sinc will be this value.
55 | *
56 | */
57 | void resize(size_t sz, size_t firstnull, float gain=1.f);
58 |
59 | /** operator():
60 | * 'compute' the value sinc(x).
61 | * x = evaluate sinc at this value
62 | */
63 | float operator()(float x) const;
64 |
65 | /** range:
66 | * upper range of sinc. Anything outside [-range..range] yields 0.
67 | */
68 | float range() const { return tbl_.size() / convfactor_; };
69 |
70 | private:
71 | std::vector tbl_;
72 | float convfactor_;
73 |
74 | };
75 | //------------------------------------------------------------------------
76 |
77 |
78 |
79 | } // namespace jarh
80 |
81 |
82 |
83 | //------------------------------------------------------------------------
84 | #endif
85 |
--------------------------------------------------------------------------------
/Source/ChunkRenderBinary.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | //
24 | // Binary chunk renderers
25 | //
26 |
27 | // Base class
28 | class CBinaryFileWriter
29 | {
30 | protected:
31 | CBinaryFileWriter(CFile *pFile);
32 | void Store(const void *pData, unsigned int Size);
33 | void Fill(unsigned int Size);
34 | unsigned int GetWritten() const;
35 |
36 | private:
37 | CFile *m_pFile;
38 | unsigned int m_iDataWritten;
39 | };
40 |
41 | // Binary data render
42 | class CChunkRenderBinary : public CBinaryFileWriter
43 | {
44 | public:
45 | CChunkRenderBinary(CFile *pFile);
46 | void StoreChunks(const std::vector &Chunks);
47 | // // //
48 |
49 | private:
50 | void StoreChunk(CChunk *pChunk);
51 | // // //
52 | };
53 |
54 | // NSF render
55 | class CChunkRenderNSF : public CBinaryFileWriter
56 | {
57 | public:
58 | CChunkRenderNSF(CFile *pFile, unsigned int StartAddr);
59 |
60 | void StoreDriver(const char *pDriver, unsigned int Size);
61 | void StoreChunks(const std::vector &Chunks);
62 | void StoreChunksBankswitched(const std::vector &Chunks);
63 | // // //
64 | int GetBankCount() const;
65 |
66 | protected:
67 | void StoreChunk(const CChunk *pChunk);
68 | void StoreChunkBankswitched(const CChunk *pChunk);
69 | // // //
70 |
71 | int GetRemainingSize() const;
72 | void AllocateNewBank();
73 | int GetBank() const;
74 | int GetAbsoluteAddr() const;
75 |
76 | protected:
77 | unsigned int m_iStartAddr;
78 | // // //
79 | };
80 |
81 | // NES render
82 | class CChunkRenderNES : public CChunkRenderNSF
83 | {
84 | public:
85 | CChunkRenderNES(CFile *pFile, unsigned int StartAddr);
86 | void StoreCaller(const void *pData, unsigned int Size);
87 | };
88 |
--------------------------------------------------------------------------------
/Source/Document/TrackData.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** SnevenTracker is (C) HertzDevil 2016
6 | **
7 | ** This program is free software; you can redistribute it and/or modify
8 | ** it under the terms of the GNU General Public License as published by
9 | ** the Free Software Foundation; either version 2 of the License, or
10 | ** (at your option) any later version.
11 | **
12 | ** This program is distributed in the hope that it will be useful,
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | ** Library General Public License for more details. To obtain a
16 | ** copy of the GNU Library General Public License, write to the Free
17 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 | **
19 | ** Any permitted reproduction of these routines, in whole or in part,
20 | ** must bear this legend.
21 | */
22 |
23 | #include "TrackData.h"
24 | #include "PatternData_new.h"
25 |
26 | using namespace FTExt;
27 |
28 |
29 |
30 | const CPatternData *CTrackData::GetPattern(size_t Index) const
31 | {
32 | return m_pPatterns[Index];
33 | }
34 |
35 | CPatternData *CTrackData::GetPattern(size_t Index)
36 | {
37 | if (m_pPatterns.ContainsAt(Index))
38 | return m_pPatterns[Index];
39 | return m_pPatterns.Create(Index);
40 | }
41 |
42 | CPatternData *CTrackData::NewPattern(size_t Index, size_t Size)
43 | {
44 | return m_pPatterns.Create(Index, Size);
45 | }
46 |
47 |
48 |
49 | const CPatternData *CTrackData::GetPatternAtFrame(size_t Frame) const
50 | {
51 | return GetPattern(GetPatternIndex(Frame));
52 | }
53 |
54 | CPatternData *CTrackData::GetPatternAtFrame(size_t Frame)
55 | {
56 | return GetPattern(GetPatternIndex(Frame));
57 | }
58 |
59 |
60 | /*
61 | size_t CTrackData::GetTrackLength() const
62 | {
63 | return m_iLength;
64 | }
65 |
66 | void CTrackData::SetTrackLength(size_t Size)
67 | {
68 | m_iLength = Size;
69 | }
70 | */
71 |
72 |
73 | size_t CTrackData::GetPatternIndex(size_t Frame) const
74 | {
75 | return m_iFrameList[Frame];
76 | }
77 |
78 | void CTrackData::SetPatternIndex(size_t Frame, size_t Index)
79 | {
80 | m_iFrameList[Frame] = Index;
81 | }
82 |
83 |
84 |
85 | int CTrackData::GetEffectColumnCount() const
86 | {
87 | return m_iEffectColumnCount;
88 | }
89 |
90 | void CTrackData::SetEffectColumnCount(int Count)
91 | {
92 | if (Count < 1 || Count > MAX_EFFECT_COLUMNS)
93 | throw std::runtime_error {"Effect column count out of bounds"};
94 | m_iEffectColumnCount = Count;
95 | }
96 |
--------------------------------------------------------------------------------
/Source/Clipboard.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #include "stdafx.h"
22 | #include "Clipboard.h"
23 |
24 | // CClipboard //////////////////////////////////////////////////////////////////
25 |
26 | CClipboard::CClipboard(CWnd *pWnd, UINT Clipboard) : m_bOpened(pWnd->OpenClipboard() == TRUE), m_iClipboard(Clipboard), m_hMemory(NULL)
27 | {
28 | }
29 |
30 | CClipboard::~CClipboard()
31 | {
32 | if (m_hMemory != NULL)
33 | ::GlobalUnlock(m_hMemory);
34 |
35 | if (m_bOpened)
36 | ::CloseClipboard();
37 | }
38 |
39 | bool CClipboard::IsOpened() const
40 | {
41 | return m_bOpened;
42 | }
43 |
44 | HGLOBAL CClipboard::AllocMem(UINT Size) const
45 | {
46 | return ::GlobalAlloc(GMEM_MOVEABLE, Size);
47 | }
48 |
49 | void CClipboard::SetData(HGLOBAL hMemory) const
50 | {
51 | ASSERT(m_bOpened);
52 |
53 | ::EmptyClipboard();
54 | ::SetClipboardData(m_iClipboard, hMemory);
55 | }
56 |
57 | bool CClipboard::SetDataPointer(LPVOID pData, UINT Size) const
58 | {
59 | ASSERT(m_bOpened);
60 |
61 | HGLOBAL hMemory = AllocMem(Size);
62 | if (hMemory == NULL)
63 | return false;
64 |
65 | LPVOID pClipData = ::GlobalLock(hMemory);
66 | if (pClipData == NULL)
67 | return false;
68 |
69 | memcpy(pClipData, pData, Size);
70 |
71 | ::GlobalUnlock(hMemory);
72 | SetData(hMemory);
73 |
74 | return true;
75 | }
76 |
77 | HGLOBAL CClipboard::GetData() const
78 | {
79 | ASSERT(m_bOpened);
80 | return ::GetClipboardData(m_iClipboard);
81 | }
82 |
83 | LPVOID CClipboard::GetDataPointer()
84 | {
85 | ASSERT(m_bOpened);
86 |
87 | m_hMemory = GetData();
88 | if (m_hMemory == NULL)
89 | return NULL;
90 |
91 | return ::GlobalLock(m_hMemory);
92 | }
93 |
94 | bool CClipboard::IsDataAvailable() const
95 | {
96 | return ::IsClipboardFormatAvailable(m_iClipboard) == TRUE;
97 | }
98 |
--------------------------------------------------------------------------------
/Source/ControlPanelDlg.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routin, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 |
22 | #include "stdafx.h"
23 | #include "resource.h"
24 | #include "ControlPanelDlg.h"
25 |
26 | // This class is mainly used to forward messages to the parent window
27 |
28 | // CControlPanelDlg dialog
29 |
30 | IMPLEMENT_DYNAMIC(CControlPanelDlg, CDialog)
31 |
32 | CControlPanelDlg::CControlPanelDlg(CWnd* pParent /*=NULL*/)
33 | : CDialog(CControlPanelDlg::IDD, pParent), m_pMainFrame(NULL)
34 | {
35 |
36 | }
37 |
38 | CControlPanelDlg::~CControlPanelDlg()
39 | {
40 | }
41 |
42 | void CControlPanelDlg::DoDataExchange(CDataExchange* pDX)
43 | {
44 | CDialog::DoDataExchange(pDX);
45 | }
46 |
47 |
48 | BEGIN_MESSAGE_MAP(CControlPanelDlg, CDialog)
49 | END_MESSAGE_MAP()
50 |
51 |
52 | // CControlPanelDlg message handlers
53 |
54 | BOOL CControlPanelDlg::PreTranslateMessage(MSG* pMsg)
55 | {
56 | UpdateDialogControls(this, TRUE);
57 | return CDialog::PreTranslateMessage(pMsg);
58 | }
59 |
60 | BOOL CControlPanelDlg::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
61 | {
62 | // Route command messages to main frame
63 | // if (nID != IDC_KEYSTEP_SPIN) {
64 | if (m_pMainFrame->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
65 | return TRUE;
66 | // if (GetParent()->GetParent()->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
67 | // return TRUE;
68 | // }
69 | return CDialog::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
70 | }
71 |
72 | BOOL CControlPanelDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
73 | {
74 | // Route notify messages to main frame
75 | //*pResult = GetParent()->GetParent()->SendMessage(WM_NOTIFY, wParam, lParam);
76 | return CDialog::OnNotify(wParam, lParam, pResult);
77 | }
78 |
79 | void CControlPanelDlg::SetFrameParent(CWnd *pMainFrm)
80 | {
81 | // TODO: Use parent instead?
82 | m_pMainFrame = pMainFrm;
83 | }
84 |
--------------------------------------------------------------------------------
/Source/ChunkRenderText.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | //
24 | // Text chunk renderer
25 | //
26 |
27 | class CChunkRenderText;
28 |
29 | typedef void (CChunkRenderText::*renderFunc_t)(CChunk *pChunk, CFile *pFile);
30 |
31 | struct stChunkRenderFunc {
32 | chunk_type_t type;
33 | renderFunc_t function;
34 | };
35 |
36 | class CChunkRenderText
37 | {
38 | public:
39 | CChunkRenderText(CFile *pFile);
40 | void StoreChunks(const std::vector &Chunks);
41 | // // //
42 |
43 | private:
44 | static const stChunkRenderFunc RENDER_FUNCTIONS[];
45 |
46 | private:
47 | void DumpStrings(const CStringA &preStr, const CStringA &postStr, CStringArray &stringArray, CFile *pFile) const;
48 | void WriteFileString(const CStringA &str, CFile *pFile) const;
49 | void StoreByteString(const char *pData, int Len, CStringA &str, int LineBreak) const;
50 | void StoreByteString(const CChunk *pChunk, CStringA &str, int LineBreak) const;
51 |
52 | private:
53 | void StoreHeaderChunk(CChunk *pChunk, CFile *pFile);
54 | void StoreInstrumentListChunk(CChunk *pChunk, CFile *pFile);
55 | void StoreInstrumentChunk(CChunk *pChunk, CFile *pFile);
56 | void StoreSequenceChunk(CChunk *pChunk, CFile *pFile);
57 | // // //
58 | void StoreSongListChunk(CChunk *pChunk, CFile *pFile);
59 | void StoreSongChunk(CChunk *pChunk, CFile *pFile);
60 | void StoreFrameListChunk(CChunk *pChunk, CFile *pFile);
61 | void StoreFrameChunk(CChunk *pChunk, CFile *pFile);
62 | void StorePatternChunk(CChunk *pChunk, CFile *pFile);
63 | // // //
64 |
65 | private:
66 | CStringArray m_headerStrings;
67 | CStringArray m_instrumentListStrings;
68 | CStringArray m_instrumentStrings;
69 | CStringArray m_sequenceStrings;
70 | // // //
71 | CStringArray m_songListStrings;
72 | CStringArray m_songStrings;
73 | CStringArray m_songDataStrings;
74 | // // //
75 |
76 | CFile *m_pFile;
77 | };
78 |
--------------------------------------------------------------------------------
/Source/SpeedDlg.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #include "stdafx.h"
22 | #include "FamiTracker.h"
23 | #include "SpeedDlg.h"
24 |
25 | const int RATE_MIN = 25;
26 | const int RATE_MAX = 400;
27 |
28 | // CSpeedDlg dialog
29 |
30 | IMPLEMENT_DYNAMIC(CSpeedDlg, CDialog)
31 | CSpeedDlg::CSpeedDlg(CWnd* pParent /*=NULL*/)
32 | : CDialog(CSpeedDlg::IDD, pParent), m_iInitSpeed(0), m_iSpeed(0)
33 | {
34 | }
35 |
36 | CSpeedDlg::~CSpeedDlg()
37 | {
38 | }
39 |
40 | void CSpeedDlg::DoDataExchange(CDataExchange* pDX)
41 | {
42 | CDialog::DoDataExchange(pDX);
43 | }
44 |
45 |
46 | BEGIN_MESSAGE_MAP(CSpeedDlg, CDialog)
47 | ON_WM_HSCROLL()
48 | ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
49 | END_MESSAGE_MAP()
50 |
51 |
52 | // CSpeedDlg message handlers
53 |
54 |
55 | int CSpeedDlg::GetSpeedFromDlg(int InitialSpeed)
56 | {
57 | m_iSpeed = InitialSpeed;
58 | CDialog::DoModal();
59 | return m_iSpeed;
60 | }
61 |
62 | void CSpeedDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
63 | {
64 | CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
65 | m_iSpeed = ((CSliderCtrl*)pScrollBar)->GetPos();
66 | CString String;
67 | String.Format(_T("%i Hz"), m_iSpeed );
68 | SetDlgItemText(IDC_SPEED, String);
69 | }
70 |
71 | BOOL CSpeedDlg::OnInitDialog()
72 | {
73 | CDialog::OnInitDialog();
74 |
75 | CSliderCtrl *Slider = static_cast(GetDlgItem(IDC_SPEED_SLD));
76 | CString String;
77 |
78 | // TODO: Program will crash if speed is set below 25Hz, I don't know why
79 | Slider->SetRange(RATE_MIN, RATE_MAX);
80 | Slider->SetPos(m_iSpeed);
81 |
82 | String.Format(_T("%i Hz"), m_iSpeed);
83 | SetDlgItemText(IDC_SPEED, String);
84 |
85 | return TRUE; // return TRUE unless you set the focus to a control
86 | // EXCEPTION: OCX Property Pages should return FALSE
87 | }
88 |
89 | void CSpeedDlg::OnBnClickedCancel()
90 | {
91 | m_iSpeed = 0;
92 | OnCancel();
93 | }
94 |
--------------------------------------------------------------------------------
/Source/DocumentFile.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CDocumentFile, class for reading/writing document files
25 |
26 | class CDocumentFile : public CFile
27 | {
28 | public:
29 | CDocumentFile();
30 | virtual ~CDocumentFile();
31 |
32 | bool Finished() const;
33 |
34 | // Write functions
35 | bool BeginDocument();
36 | bool EndDocument();
37 |
38 | void CreateBlock(const char *ID, int Version);
39 | void WriteBlock(const char *pData, unsigned int Size);
40 | void WriteBlockInt(int Value);
41 | void WriteBlockChar(char Value);
42 | void WriteString(CString String);
43 | bool FlushBlock();
44 |
45 | // Read functions
46 | bool ValidateFile();
47 | unsigned int GetFileVersion() const;
48 |
49 | bool ReadBlock();
50 | void GetBlock(void *Buffer, int Size);
51 | int GetBlockVersion() const;
52 | bool BlockDone() const;
53 | char *GetBlockHeaderID() const;
54 | int GetBlockInt();
55 | char GetBlockChar();
56 |
57 | int GetBlockPos() const;
58 | int GetBlockSize() const;
59 |
60 | CString ReadString();
61 |
62 | void RollbackPointer(int count); // avoid this
63 |
64 | bool IsFileIncomplete() const;
65 |
66 | public:
67 | // Constants
68 | static const unsigned int FILE_VER;
69 | static const unsigned int COMPATIBLE_VER;
70 |
71 | static const char *FILE_HEADER_ID;
72 | static const char *FILE_END_ID;
73 |
74 | static const unsigned int MAX_BLOCK_SIZE;
75 | static const unsigned int BLOCK_SIZE;
76 |
77 | private:
78 | template void WriteBlockData(T Value);
79 |
80 | protected:
81 | void ReallocateBlock();
82 |
83 | protected:
84 | unsigned int m_iFileVersion;
85 | bool m_bFileDone;
86 | bool m_bIncomplete;
87 |
88 | char *m_cBlockID;
89 | unsigned int m_iBlockSize;
90 | unsigned int m_iBlockVersion;
91 | char *m_pBlockData;
92 |
93 | unsigned int m_iMaxBlockSize;
94 |
95 | unsigned int m_iBlockPointer;
96 | };
97 |
--------------------------------------------------------------------------------
/Source/Driver.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | //
24 | // The NSF driver binaries
25 | //
26 |
27 | // Change this for new versions
28 | const char DRIVER_ID[] = "NSF-driver v2.11";
29 |
30 | #pragma warning( disable : 4309 ) // disable warning 4309: 'initializing' : truncation of constant value
31 |
32 | const unsigned short NSF_CALLER_SIZE = 128; // bytes
33 |
34 | // NES program for running a NSF
35 | #pragma warning( disable : 4838 ) // // //
36 | const char NSF_CALLER_BIN[] = {
37 | 0x78,0xD8,0xAD,0x02,0x20,0x10,0xFB,0xAD,0x02,0x20,0x10,0xFB,0xA2,0x00,0x8A,0x9D,
38 | 0x00,0x02,0xE8,0xD0,0xFA,0xA9,0x0F,0x8D,0x15,0x40,0xA9,0x0A,0x8D,0x10,0x40,0xA9,
39 | 0x00,0xA2,0x00,0xA0,0x00,0x20,0x08,0x80,0xA9,0x80,0x8D,0x00,0x20,0xA9,0x00,0x8D,
40 | 0x01,0x20,0x4C,0xB2,0xFF,0x20,0x0B,0x80,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
41 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
42 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
43 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
44 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xB5,0xFF,0x80,0xFF,0xB8,0xFF
45 | };
46 |
47 | // // //
48 |
49 | //
50 | // The driver binaries
51 | //
52 | // created with a binary->c-array program
53 | //
54 | #include "drivers/drv_2a03.h"
55 | // // //
56 |
57 | #include "drivers/config.h"
58 |
59 | struct driver_t {
60 | const unsigned char *driver;
61 | const unsigned int driver_size;
62 | const int *word_reloc;
63 | const int word_reloc_size;
64 | const int *byte_reloc_low;
65 | const int *byte_reloc_high;
66 | const int byte_reloc_size;
67 | };
68 |
69 | const driver_t DRIVER_PACK_2A03 = {
70 | DRIVER_2A03,
71 | sizeof(DRIVER_2A03),
72 | DRIVER_RELOC_WORD_2A03,
73 | sizeof(DRIVER_RELOC_WORD_2A03),
74 | DRIVER_RELOC_LOW_2A03,
75 | DRIVER_RELOC_HIGH_2A03,
76 | sizeof(DRIVER_RELOC_LOW_2A03)
77 | };
78 |
79 | // // //
80 |
--------------------------------------------------------------------------------
/Source/Accelerator.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // Key accelerator class
25 |
26 | #define MOD_NONE 0
27 |
28 | struct stAccelEntry {
29 | LPCTSTR name;
30 | int mod;
31 | int key;
32 | int id;
33 | };
34 |
35 | class CAccelerator {
36 | public:
37 | CAccelerator();
38 | ~CAccelerator();
39 |
40 | LPCTSTR GetItemName(int Item) const; // Name of shortcut
41 | int GetItemKey(int Item) const; // Key for shortcut
42 | int GetItemMod(int Item) const; // Modifier for shortcut
43 | int GetDefaultKey(int Item) const; // Default key for shortcut
44 | int GetDefaultMod(int Item) const; // Default modifier for shortcut
45 | LPCTSTR GetItemModName(int Item) const; // Key string for shortcut
46 | LPCTSTR GetItemKeyName(int Item) const; // Modifier string for shortcut
47 | LPCTSTR GetVKeyName(int virtualKey) const; // Translates virtual key to a string
48 | void StoreShortcut(int Item, int Key, int Mod); // Store key and modifier for shortcut
49 |
50 | void SaveShortcuts(CSettings *pSettings) const; // Save to registry
51 | void LoadShortcuts(CSettings *pSettings); // Load from registry
52 | void LoadDefaults(); // Load defaults
53 |
54 | void Setup();
55 | void Shutdown();
56 | BOOL Translate(HWND hWnd, MSG *pMsg);
57 | void SetAccelerator(HACCEL hAccel);
58 |
59 | bool GetShortcutString(int id, CString &str) const;
60 |
61 | public:
62 | // Class member constants
63 | static LPCTSTR MOD_NAMES[]; // Strings for modifiers
64 | static const stAccelEntry DEFAULT_TABLE[]; // List of default shortcuts
65 | static const int ACCEL_COUNT; // Number of shortcuts
66 | static LPCTSTR SHORTCUTS_SECTION; // Registry section
67 |
68 | private:
69 | HACCEL m_hAccel;
70 | HACCEL m_hAdditionalAccel;
71 |
72 | // Shortcut table
73 | stAccelEntry *m_pEntriesTable;
74 |
75 | // Accelerator table
76 | ACCEL *m_pAccelTable;
77 | };
78 |
--------------------------------------------------------------------------------
/FamiTracker.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26228.9
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SnevenTracker", "FamiTracker.vcxproj", "{92FE0690-CE4F-4CCF-A52C-23265AE7429F}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTests", "UnitTests\UnitTests.vcxproj", "{E520B69D-9ADE-4CB5-A44D-7345ECC40ACD}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Win32 = Debug|Win32
13 | Debug|x64 = Debug|x64
14 | Release 64|Win32 = Release 64|Win32
15 | Release 64|x64 = Release 64|x64
16 | Release|Win32 = Release|Win32
17 | Release|x64 = Release|x64
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {92FE0690-CE4F-4CCF-A52C-23265AE7429F}.Debug|Win32.ActiveCfg = Debug|Win32
21 | {92FE0690-CE4F-4CCF-A52C-23265AE7429F}.Debug|Win32.Build.0 = Debug|Win32
22 | {92FE0690-CE4F-4CCF-A52C-23265AE7429F}.Debug|x64.ActiveCfg = Debug|x64
23 | {92FE0690-CE4F-4CCF-A52C-23265AE7429F}.Debug|x64.Build.0 = Debug|x64
24 | {92FE0690-CE4F-4CCF-A52C-23265AE7429F}.Release 64|Win32.ActiveCfg = Release 64|Win32
25 | {92FE0690-CE4F-4CCF-A52C-23265AE7429F}.Release 64|Win32.Build.0 = Release 64|Win32
26 | {92FE0690-CE4F-4CCF-A52C-23265AE7429F}.Release 64|x64.ActiveCfg = Release 64|x64
27 | {92FE0690-CE4F-4CCF-A52C-23265AE7429F}.Release 64|x64.Build.0 = Release 64|x64
28 | {92FE0690-CE4F-4CCF-A52C-23265AE7429F}.Release|Win32.ActiveCfg = Release|Win32
29 | {92FE0690-CE4F-4CCF-A52C-23265AE7429F}.Release|Win32.Build.0 = Release|Win32
30 | {92FE0690-CE4F-4CCF-A52C-23265AE7429F}.Release|x64.ActiveCfg = Release|x64
31 | {92FE0690-CE4F-4CCF-A52C-23265AE7429F}.Release|x64.Build.0 = Release|x64
32 | {E520B69D-9ADE-4CB5-A44D-7345ECC40ACD}.Debug|Win32.ActiveCfg = Debug|Win32
33 | {E520B69D-9ADE-4CB5-A44D-7345ECC40ACD}.Debug|Win32.Build.0 = Debug|Win32
34 | {E520B69D-9ADE-4CB5-A44D-7345ECC40ACD}.Debug|x64.ActiveCfg = Debug|x64
35 | {E520B69D-9ADE-4CB5-A44D-7345ECC40ACD}.Debug|x64.Build.0 = Debug|x64
36 | {E520B69D-9ADE-4CB5-A44D-7345ECC40ACD}.Release 64|Win32.ActiveCfg = Release|Win32
37 | {E520B69D-9ADE-4CB5-A44D-7345ECC40ACD}.Release 64|Win32.Build.0 = Release|Win32
38 | {E520B69D-9ADE-4CB5-A44D-7345ECC40ACD}.Release 64|x64.ActiveCfg = Release|x64
39 | {E520B69D-9ADE-4CB5-A44D-7345ECC40ACD}.Release 64|x64.Build.0 = Release|x64
40 | {E520B69D-9ADE-4CB5-A44D-7345ECC40ACD}.Release|Win32.ActiveCfg = Release|Win32
41 | {E520B69D-9ADE-4CB5-A44D-7345ECC40ACD}.Release|Win32.Build.0 = Release|Win32
42 | {E520B69D-9ADE-4CB5-A44D-7345ECC40ACD}.Release|x64.ActiveCfg = Release|x64
43 | {E520B69D-9ADE-4CB5-A44D-7345ECC40ACD}.Release|x64.Build.0 = Release|x64
44 | EndGlobalSection
45 | GlobalSection(SolutionProperties) = preSolution
46 | HideSolutionNode = FALSE
47 | EndGlobalSection
48 | EndGlobal
49 |
--------------------------------------------------------------------------------
/Source/Document/PatternData_new.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** SnevenTracker is (C) HertzDevil 2016
6 | **
7 | ** This program is free software; you can redistribute it and/or modify
8 | ** it under the terms of the GNU General Public License as published by
9 | ** the Free Software Foundation; either version 2 of the License, or
10 | ** (at your option) any later version.
11 | **
12 | ** This program is distributed in the hope that it will be useful,
13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | ** Library General Public License for more details. To obtain a
16 | ** copy of the GNU Library General Public License, write to the Free
17 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 | **
19 | ** Any permitted reproduction of these routines, in whole or in part,
20 | ** must bear this legend.
21 | */
22 |
23 | #include "PatternData_new.h"
24 | #include "PatternNote.h"
25 | #include
26 |
27 | using namespace FTExt;
28 |
29 |
30 |
31 | const size_t CPatternData::MAX_SIZE = MAX_PATTERN_LENGTH;
32 |
33 |
34 |
35 | CPatternData::CPatternData(size_t MaxSize) :
36 | m_pNotes(MaxSize),
37 | m_iActualSize {MaxSize}
38 | {
39 | if (m_iActualSize > MAX_SIZE)
40 | throw std::runtime_error {"Pattern is too large"};
41 | }
42 |
43 | CPatternData &CPatternData::operator=(CPatternData other)
44 | {
45 | swap(*this, other);
46 | return *this;
47 | }
48 |
49 | void FTExt::swap(CPatternData &a, CPatternData &b)
50 | {
51 | std::swap(a.m_iActualSize, b.m_iActualSize);
52 | a.m_pNotes.swap(b.m_pNotes);
53 | }
54 |
55 |
56 |
57 | CPatternNote CPatternData::GetNote(size_t Row) const
58 | {
59 | return m_pNotes[Row];
60 | }
61 |
62 | void CPatternData::SetNote(size_t Row, const CPatternNote &Note)
63 | {
64 | m_pNotes[Row] = Note;
65 | }
66 |
67 |
68 |
69 | size_t CPatternData::GetSize() const
70 | {
71 | return m_iActualSize;
72 | }
73 |
74 | void CPatternData::SetSize(size_t Size)
75 | {
76 | if (Size > MAX_SIZE)
77 | throw std::runtime_error {"Pattern size beyond limit"};
78 | m_iActualSize = Size;
79 | }
80 |
81 |
82 |
83 | bool CPatternData::IsEmpty() const
84 | {
85 | for (size_t i = 0u; i < m_iActualSize; ++i)
86 | if (m_pNotes[i])
87 | return false;
88 | return true;
89 | }
90 |
91 | void CPatternData::Clear()
92 | {
93 | for (auto &x : m_pNotes)
94 | x.Reset();
95 | }
96 |
97 |
98 |
99 | typename std::vector::iterator
100 | CPatternData::begin()
101 | {
102 | return m_pNotes.begin();
103 | }
104 |
105 | typename std::vector::iterator
106 | CPatternData::end()
107 | {
108 | return begin() + m_iActualSize;
109 | }
110 |
--------------------------------------------------------------------------------
/Source/DialogReBar.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #include "stdafx.h"
22 | #include "FamiTracker.h"
23 | #include "FamiTrackerDoc.h"
24 | #include "DialogReBar.h"
25 | #include "MainFrm.h"
26 |
27 | // COctaveDlgBar dialog
28 |
29 | IMPLEMENT_DYNAMIC(CDialogReBar, CDialogBar)
30 | CDialogReBar::CDialogReBar(CWnd* pParent /*=NULL*/)
31 | : CDialogBar(/*COctaveDlgBar::IDD, pParent*/)
32 | {
33 | }
34 |
35 | CDialogReBar::~CDialogReBar()
36 | {
37 | }
38 |
39 | BEGIN_MESSAGE_MAP(CDialogReBar, CDialogBar)
40 | ON_WM_ERASEBKGND()
41 | ON_WM_MOVE()
42 | ON_WM_CTLCOLOR()
43 | END_MESSAGE_MAP()
44 |
45 |
46 | // COctaveDlgBar message handlers
47 |
48 | BOOL CDialogReBar::OnEraseBkgnd(CDC* pDC)
49 | {
50 | if (!theApp.IsThemeActive()) {
51 | CDialogBar::OnEraseBkgnd(pDC);
52 | return TRUE;
53 | }
54 |
55 | CWnd* pParent = GetParent();
56 | ASSERT_VALID(pParent);
57 | CPoint pt(0, 0);
58 | MapWindowPoints(pParent, &pt, 1);
59 | pt = pDC->OffsetWindowOrg(pt.x, pt.y);
60 | LRESULT lResult = pParent->SendMessage(WM_ERASEBKGND, (WPARAM)pDC->m_hDC, 0L);
61 | pDC->SetWindowOrg(pt.x, pt.y);
62 | return (BOOL)lResult;
63 | }
64 |
65 | void CDialogReBar::OnMove(int x, int y)
66 | {
67 | Invalidate();
68 | }
69 |
70 | HBRUSH CDialogReBar::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
71 | {
72 | HBRUSH hbr = CDialogBar::OnCtlColor(pDC, pWnd, nCtlColor);
73 |
74 | if (nCtlColor == CTLCOLOR_STATIC && theApp.IsThemeActive()) {
75 | pDC->SetBkMode(TRANSPARENT);
76 | return (HBRUSH)GetStockObject(NULL_BRUSH);
77 | }
78 |
79 | return hbr;
80 | }
81 |
82 | BOOL CDialogReBar::Create(CWnd* pParentWnd, UINT nIDTemplate, UINT nStyle, UINT nID)
83 | {
84 | const int RANGE_MAX = 32; // Max value of highlight
85 |
86 | if (!CDialogBar::Create(pParentWnd, nIDTemplate, nStyle, nID))
87 | return FALSE;
88 |
89 | static_cast(GetDlgItem(IDC_HIGHLIGHTSPIN1))->SetRange(0, RANGE_MAX);
90 | static_cast(GetDlgItem(IDC_HIGHLIGHTSPIN2))->SetRange(0, RANGE_MAX);
91 |
92 | return TRUE;
93 | }
94 |
--------------------------------------------------------------------------------
/NOTES.md:
--------------------------------------------------------------------------------
1 | # Notes
2 |
3 | ~~i have no time to make a proper manual for this~~
4 |
5 | ## Sound Chips
6 |
7 | #### Texas Instruments SN76489
8 |
9 | - Square channel, 4-bit volume, 10-bit pitch (x3)
10 | - Noise channel, 4-bit volume, 3 pitches or pitch follows channel 3, long/short periodic noise with phase reset (x1)
11 |
12 | ###### Variants
13 |
14 | - _(TODO)_
15 |
16 |
17 | #### Game Gear (PSG)
18 |
19 | - Same as SN76489, except all channels have L/R hardpanning, and noise generation is slightly different
20 |
21 | #### T6W28 (NGP)
22 |
23 | - Square channel, 4-bit L/R volume, 10-bit pitch (x3)
24 | - Noise channel, 4-bit L/R volume, 10-bit pitch, long/short periodic noise with phase reset (x1)
25 |
26 | #### Yamaha YM2413 (OPLL)
27 |
28 | _(TODO)_
29 |
30 | #### Yamaha YM2612 (OPN2)
31 |
32 | _(TODO)_
33 |
34 | ## New Effects
35 |
36 | #### N00 - N1F
37 |
38 | - **Name:** Panning setting
39 | - **Target:** PSG, ~~T6W28~~
40 | - **Default:** `N10`
41 | - **Description:** Changes the volume balance for the left and right output channels. `N01` is left, `N10` is center, `N1F` is right. The special `N00` silences both output channels. ~~Intermediate values are supported only by the T6W28 chip; it effectively decreases the output volume in one of the output channels, but never silences it unless `N01` or `N1F` is used.~~
42 |
43 | #### NCx
44 |
45 | - **Name:** Channel swap
46 | - **Target:** SN76489
47 | - **Default:** `NC3`
48 | - **Description:** Exchanges Square `x` with Square 3. This allows any square channel to control the pitch of the noise channel. Doing so will cause a pop in the audio output as the channel registers must be rewritten.
49 |
50 | #### NE0, NE1
51 |
52 | - **Name:** Noise reset enable
53 | - **Target:** SN76489 Noise
54 | - **Default:** `NE0`
55 | - **Description:** Configures whether the noise channel resets its shift register state on new notes. `NE0` disables it, `NE1` enables it and additionally resets the noise state immediately. (Changing the pitch or duty always resets the noise state. This is normal SN76489 behaviour.)
56 |
57 |
63 |
64 | ## New features
65 |
66 | #### VGM Logging
67 |
68 | Under the **Tracker** menu is a new option called "Log VGM File...". Select it to save a VGM file, then play any song to start logging all audio events, and stop the player to finish logging.
69 |
70 | #### Stereo Separation
71 |
72 | The mixer menu can now configure the volume of each SN76489 output channel, as well as the stereo separation between them; 0% is effectively the same as mono audio, 100% is the default separation.
73 |
74 | ## Compatibility
75 |
76 | SnevenTracker modules (`.snm` files) share the same format with `.ftm` and `.0cc` files but are incompatible with them. Copying and pasting of frames and patterns still works across these trackers.
77 |
--------------------------------------------------------------------------------
/Source/ChannelsSN7.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | //
24 | // Derived channels, SN76489
25 | //
26 |
27 | class CChannelHandlerSN7 : public CChannelHandler { // // //
28 | public:
29 | CChannelHandlerSN7();
30 | virtual void ProcessChannel();
31 | virtual void ResetChannel();
32 |
33 | static void SwapChannels(int ID);
34 |
35 | protected:
36 | virtual void HandleNoteData(stChanNote *pNoteData, int EffColumns);
37 | virtual void HandleCustomEffects(int EffNum, int EffParam);
38 | virtual bool HandleInstrument(int Instrument, bool Trigger, bool NewInstrument);
39 | virtual void HandleEmptyNote();
40 | virtual void HandleCut();
41 | virtual void HandleRelease();
42 | virtual void HandleNote(int Note, int Octave);
43 | int CalculateVolume() const override; // // //
44 |
45 | void SetStereo(bool Left, bool Right) const;
46 |
47 | protected:
48 | unsigned char m_cSweep; // Sweep, used by pulse channels
49 |
50 | bool m_bManualVolume; // Flag for Exx
51 | int m_iInitVolume; // Initial volume
52 | // // //
53 | int m_iPostEffect;
54 | int m_iPostEffectParam;
55 |
56 | static int m_iRegisterPos[3]; // // //
57 | static uint8 m_cStereoFlag; // // //
58 | static uint8 m_cStereoFlagLast; // // //
59 | };
60 |
61 | // Square 1
62 | class CSquareChan : public CChannelHandlerSN7 { // // //
63 | public:
64 | CSquareChan() : CChannelHandlerSN7() { m_iDefaultDuty = 0; };
65 | virtual void RefreshChannel();
66 | protected:
67 | virtual void ClearRegisters();
68 | };
69 |
70 | // Noise
71 | class CNoiseChan : public CChannelHandlerSN7 {
72 | public:
73 | CNoiseChan();
74 | virtual void RefreshChannel();
75 | protected:
76 | virtual void HandleCustomEffects(int EffNum, int EffParam);
77 | virtual void ClearRegisters();
78 | virtual void HandleNote(int Note, int Octave);
79 | virtual void SetupSlide(int Type, int EffParam);
80 |
81 | int TriggerNote(int Note);
82 |
83 | private:
84 | int m_iLastCtrl; // // //
85 | bool m_bNoiseReset; // // //
86 | bool m_bTrigger; // // // 0CC-FT has this built-in
87 | };
88 |
89 | // // //
90 |
--------------------------------------------------------------------------------
/Source/ConfigAppearance.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | enum color_items_t {
24 | COL_BACKGROUND,
25 | COL_BACKGROUND_HILITE,
26 | COL_BACKGROUND_HILITE2,
27 | COL_PATTERN_TEXT,
28 | COL_PATTERN_TEXT_HILITE,
29 | COL_PATTERN_TEXT_HILITE2,
30 | COL_PATTERN_INSTRUMENT,
31 | COL_PATTERN_VOLUME,
32 | COL_PATTERN_EFF_NUM,
33 | COL_SELECTION,
34 | COL_CURSOR,
35 | COLOR_ITEM_COUNT
36 | };
37 |
38 | #include "ColorScheme.h"
39 |
40 | // CConfigAppearance dialog
41 |
42 | class CConfigAppearance : public CPropertyPage
43 | {
44 | DECLARE_DYNAMIC(CConfigAppearance)
45 |
46 | public:
47 | CConfigAppearance();
48 | virtual ~CConfigAppearance();
49 |
50 | void AddFontName(char *Name);
51 |
52 | // Dialog Data
53 | enum { IDD = IDD_CONFIG_APPEARANCE };
54 |
55 | protected:
56 | static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, DWORD FontType, LPARAM lParam);
57 |
58 | static const TCHAR *COLOR_ITEMS[];
59 | static const int NUM_COLOR_SCHEMES;
60 |
61 | static const COLOR_SCHEME *COLOR_SCHEMES[];
62 |
63 | static const int FONT_SIZES[];
64 | static const int FONT_SIZE_COUNT;
65 |
66 | protected:
67 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
68 |
69 | void SelectColorScheme(const COLOR_SCHEME *pColorScheme);
70 |
71 | void SetColor(int Index, int Color);
72 | int GetColor(int Index) const;
73 |
74 | protected:
75 | CString m_strFont;
76 |
77 | int m_iFontSize;
78 | int m_iSelectedItem;
79 | bool m_bPatternColors;
80 | bool m_bDisplayFlats;
81 |
82 | int m_iColors[COLOR_ITEM_COUNT];
83 |
84 | DECLARE_MESSAGE_MAP()
85 | public:
86 | afx_msg void OnPaint();
87 | virtual BOOL OnInitDialog();
88 | virtual BOOL OnApply();
89 | afx_msg void OnCbnSelchangeFont();
90 | virtual BOOL OnSetActive();
91 | afx_msg void OnBnClickedPickCol();
92 | afx_msg void OnCbnSelchangeColItem();
93 | afx_msg void OnCbnSelchangeScheme();
94 | afx_msg void OnCbnSelchangeFontSize();
95 | afx_msg void OnBnClickedPatterncolors();
96 | afx_msg void OnBnClickedDisplayFlats();
97 | };
98 |
--------------------------------------------------------------------------------
/Source/ConfigGeneral.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // CConfigGeneral dialog
25 |
26 | class CConfigGeneral : public CPropertyPage
27 | {
28 | DECLARE_DYNAMIC(CConfigGeneral)
29 |
30 | public:
31 | CConfigGeneral();
32 | virtual ~CConfigGeneral();
33 |
34 | // Dialog Data
35 | enum { IDD = IDD_CONFIG_GENERAL };
36 |
37 | protected:
38 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
39 |
40 | bool m_bWrapCursor;
41 | bool m_bWrapFrames;
42 | bool m_bFreeCursorEdit;
43 | bool m_bPreviewWAV;
44 | bool m_bKeyRepeat;
45 | bool m_bRowInHex;
46 | bool m_bFramePreview;
47 | int m_iEditStyle;
48 | // // //
49 | bool m_bNoStepMove;
50 | int m_iPageStepSize;
51 | bool m_bPullUpDelete;
52 | bool m_bBackups;
53 | bool m_bSingleInstance;
54 | bool m_bPreviewFullRow;
55 | bool m_bDisableDblClick;
56 | int m_iKeyNoteCut;
57 | int m_iKeyNoteRelease;
58 | int m_iKeyClear;
59 | int m_iKeyRepeat;
60 |
61 | CToolTipCtrl m_wndToolTip;
62 |
63 | DECLARE_MESSAGE_MAP()
64 | public:
65 | virtual BOOL OnSetActive();
66 | virtual void OnOK();
67 | virtual BOOL OnApply();
68 | virtual BOOL OnInitDialog();
69 | afx_msg void OnBnClickedOptWrapcursor();
70 | afx_msg void OnBnClickedOptWrapFrames();
71 | afx_msg void OnBnClickedOptFreecursor();
72 | afx_msg void OnBnClickedOptWavepreview();
73 | afx_msg void OnBnClickedOptKeyrepeat();
74 | afx_msg void OnBnClickedStyle1();
75 | afx_msg void OnBnClickedStyle2();
76 | afx_msg void OnBnClickedStyle3();
77 | afx_msg void OnBnClickedOptHexadecimal();
78 | afx_msg void OnBnClickedSquarehack();
79 | afx_msg void OnBnClickedOptFramepreview();
80 | // // //
81 | afx_msg void OnCbnEditupdatePagelength();
82 | afx_msg void OnCbnSelendokPagelength();
83 | afx_msg void OnBnClickedOptNostepmove();
84 | afx_msg void OnBnClickedOptPullupdelete();
85 | afx_msg void OnBnClickedOptBackups();
86 | afx_msg void OnBnClickedOptSingleInstance();
87 | afx_msg void OnBnClickedOptPreviewFullRow();
88 | afx_msg void OnBnClickedOptDisableDoubleClick();
89 | virtual BOOL PreTranslateMessage(MSG* pMsg);
90 |
91 | };
92 |
93 |
--------------------------------------------------------------------------------
/UnitTests/Source/testPattern.cpp:
--------------------------------------------------------------------------------
1 | #include "doctest.h"
2 |
3 | #include "Document/PatternData_new.h"
4 | #include "Document/TrackData.h"
5 |
6 | using namespace FTExt;
7 |
8 | TEST_SUITE("Pattern data");
9 |
10 | SCENARIO("Pattern data test") {
11 | GIVEN("A default-constructed pattern") {
12 | CPatternData p;
13 | auto &&cp = std::as_const(p);
14 |
15 |
16 | }
17 | }
18 |
19 | SCENARIO("Track data test") {
20 | GIVEN("A track object") {
21 | CTrackData t;
22 | auto &&ct = std::as_const(t);
23 |
24 | AND_GIVEN("It is default-constructed") {
25 | WHEN("At the beginning") {
26 | THEN("All pattern indices should be initially 00") {
27 | bool id = true;
28 | for (size_t i = 0; i < MAX_FRAMES; ++i)
29 | if (t.GetPatternIndex(i)) {
30 | id = false; break;
31 | }
32 | REQUIRE(id);
33 | AND_THEN("Track should contain 1 effect column") {
34 | REQUIRE(t.GetEffectColumnCount() == 1);
35 | }
36 | }
37 | }
38 |
39 | AND_WHEN("Pattern is accessed as const") {
40 | auto ptr = ct.GetPattern(0);
41 | THEN("No patterns should be created") {
42 | REQUIRE(ptr == nullptr);
43 | REQUIRE(ct.GetPattern(MAX_FRAMES) == nullptr);
44 | }
45 | }
46 |
47 | AND_WHEN("Pattern is accessed") {
48 | auto ptr = t.GetPattern(0);
49 | THEN("Pointer to created pattern should be returned") {
50 | REQUIRE(ptr != nullptr);
51 | AND_THEN("Patterns should be unique") {
52 | REQUIRE(ptr != t.GetPattern(1));
53 | REQUIRE(ptr != t.GetPattern(MAX_FRAMES - 1));
54 | }
55 | }
56 | AND_WHEN("The same pattern index is used to access it again") {
57 | auto p2 = t.GetPattern(0);
58 | THEN("The patterns should be identical") {
59 | REQUIRE(ptr == p2);
60 | }
61 | }
62 | }
63 |
64 | AND_WHEN("Out-of-bound pattern indices are accessed") {
65 | THEN("nullptr should be returned") {
66 | REQUIRE(t.GetPattern(MAX_FRAMES) == nullptr);
67 | REQUIRE(t.GetPattern((size_t)-1) == nullptr);
68 | REQUIRE(ct.GetPattern(MAX_FRAMES) == nullptr);
69 | REQUIRE(ct.GetPattern((size_t)-1) == nullptr);
70 | }
71 | }
72 |
73 | AND_WHEN("Effect column count is changed") {
74 | THEN("Track should be able to hold 1 - 4 columns") {
75 | t.SetEffectColumnCount(2);
76 | REQUIRE(t.GetEffectColumnCount() == 2);
77 | t.SetEffectColumnCount(4);
78 | REQUIRE(t.GetEffectColumnCount() == 4);
79 | t.SetEffectColumnCount(1);
80 | REQUIRE(t.GetEffectColumnCount() == 1);
81 | t.SetEffectColumnCount(3);
82 | REQUIRE(t.GetEffectColumnCount() == 3);
83 | const int Count = t.GetEffectColumnCount();
84 | AND_THEN("Column count should not change otherwise") {
85 | try { t.SetEffectColumnCount(5); } catch (...) { }
86 | REQUIRE(t.GetEffectColumnCount() == Count);
87 | try { t.SetEffectColumnCount(0); } catch (...) { }
88 | REQUIRE(t.GetEffectColumnCount() == Count);
89 | }
90 | }
91 | }
92 | }
93 | }
94 | }
95 |
96 | TEST_SUITE_END;
97 |
--------------------------------------------------------------------------------
/Source/Action.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // Undo / redo helper class
25 |
26 | //
27 | // Change MAX_LEVELS in the class CActionHandler if you want more undo levels
28 | //
29 |
30 | // Base class for action commands
31 | class CAction
32 | {
33 | public:
34 | CAction(int iAction);
35 | virtual ~CAction();
36 |
37 | // Save the undo state and perform the action. This method may reject the action by returning false
38 | virtual bool SaveState(CMainFrame *pMainFrm) = 0;
39 |
40 | // Undo the operation, using the saved state
41 | virtual void Undo(CMainFrame *pMainFrm) = 0;
42 |
43 | // Redo the operation
44 | virtual void Redo(CMainFrame *pMainFrm) = 0;
45 |
46 | // Get the action type
47 | int GetAction() const;
48 |
49 | protected:
50 | int m_iAction;
51 | };
52 |
53 | class CPatternEditor;
54 | class CFrameClipData;
55 | class CPatternClipData;
56 |
57 | // Stores action objects (a dual-stack, kind of)
58 | class CActionHandler
59 | {
60 | public:
61 | CActionHandler();
62 | ~CActionHandler();
63 |
64 | // Clear the undo list
65 | void Clear();
66 |
67 | // Add new action to undo list
68 | void Push(CAction *pAction);
69 |
70 | // Get first undo action object in queue
71 | CAction *PopUndo();
72 |
73 | // Get first redo action object in queue
74 | CAction *PopRedo();
75 |
76 | // Return last action in queue without changing the queue
77 | CAction *GetLastAction() const;
78 |
79 | // Get number of undo levels available
80 | int GetUndoLevel() const;
81 |
82 | // Get number of redo levels available
83 | int GetRedoLevel() const;
84 |
85 | // Returns true if there are undo objects available
86 | bool CanUndo() const;
87 |
88 | // Returns true if there are redo objects available
89 | bool CanRedo() const;
90 |
91 | public:
92 | // Levels of undo in the editor. Higher value requires more memory
93 | static const int MAX_LEVELS = 64;
94 |
95 | private:
96 | CAction *m_pActionStack[MAX_LEVELS + 1];
97 | int m_iUndoLevel;
98 | int m_iRedoLevel;
99 |
100 | };
101 |
102 |
--------------------------------------------------------------------------------
/Source/InstrumentEditDlg.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | class CInstrumentEditPanel;
24 |
25 | // CInstrumentEditDlg dialog
26 |
27 | class CInstrumentEditDlg : public CDialog
28 | {
29 | DECLARE_DYNAMIC(CInstrumentEditDlg)
30 |
31 | public:
32 | CInstrumentEditDlg(CWnd* pParent = NULL); // standard constructor
33 | virtual ~CInstrumentEditDlg();
34 |
35 | void ChangeNoteState(int Note);
36 | void SetCurrentInstrument(int Index);
37 | bool IsOpened() const;
38 | void EndDialog(int nResult);
39 |
40 | // Dialog Data
41 | enum { IDD = IDD_INSTRUMENT };
42 |
43 | protected:
44 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
45 |
46 | void InsertPane(CInstrumentEditPanel *pPanel, bool Show);
47 | void ClearPanels();
48 |
49 | void SwitchOnNote(int x, int y);
50 | void SwitchOffNote(bool ForceHalt);
51 |
52 | protected:
53 | // Constants
54 | static const int PANEL_COUNT = 2;
55 |
56 | static const int KEYBOARD_TOP;
57 | static const int KEYBOARD_LEFT;
58 | static const int KEYBOARD_WIDTH;
59 | static const int KEYBOARD_HEIGHT;
60 |
61 | static const char *CHIP_NAMES[];
62 |
63 | protected:
64 | // Variables for keyboard
65 | int m_iLastKey;
66 | int m_iActiveKey;
67 |
68 | // Variables for windows
69 | CInstrumentEditPanel *m_pPanels[PANEL_COUNT];
70 | CInstrumentEditPanel *m_pFocusPanel;
71 |
72 | bool m_bOpened;
73 | int m_iSelectedInstType;
74 | int m_iPanels;
75 | int m_iInstrument;
76 |
77 | DECLARE_MESSAGE_MAP()
78 | public:
79 | afx_msg void OnBnClickedClose();
80 | virtual BOOL OnInitDialog();
81 | afx_msg void OnTcnSelchangeInstTab(NMHDR *pNMHDR, LRESULT *pResult);
82 | afx_msg void OnPaint();
83 | void ChangeNoteOn(int Note, int Octave);
84 | afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
85 | afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
86 | afx_msg void OnMouseMove(UINT nFlags, CPoint point);
87 | afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
88 | virtual BOOL DestroyWindow();
89 | virtual void OnOK();
90 | virtual void OnCancel();
91 | afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
92 | virtual void PostNcDestroy();
93 | };
94 |
--------------------------------------------------------------------------------
/Source/Instrument.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #include "stdafx.h"
22 | #include "FamiTrackerDoc.h"
23 | #include "Instrument.h"
24 |
25 | /*
26 | * Class CInstrument, base class for instruments
27 | *
28 | */
29 |
30 | CInstrument::CInstrument() : CRefCounter(), m_iType(0)
31 | {
32 | memset(m_cName, 0, INST_NAME_MAX);
33 | }
34 |
35 | CInstrument::~CInstrument()
36 | {
37 | }
38 |
39 | void CInstrument::SetName(const char *Name)
40 | {
41 | strncpy(m_cName, Name, INST_NAME_MAX);
42 | }
43 |
44 | void CInstrument::GetName(char *Name) const
45 | {
46 | strncpy(Name, m_cName, INST_NAME_MAX);
47 | }
48 |
49 | const char *CInstrument::GetName() const
50 | {
51 | return m_cName;
52 | }
53 |
54 | void CInstrument::InstrumentChanged() const
55 | {
56 | // Set modified flag
57 | CFrameWnd *pFrameWnd = dynamic_cast(AfxGetMainWnd());
58 | if (pFrameWnd != NULL) {
59 | CDocument *pDoc = pFrameWnd->GetActiveDocument();
60 | if (pDoc != NULL)
61 | pDoc->SetModifiedFlag();
62 | }
63 | }
64 |
65 | // Reference counting
66 |
67 | CRefCounter::CRefCounter() : m_iRefCounter(1)
68 | {
69 | }
70 |
71 | CRefCounter::~CRefCounter()
72 | {
73 | ASSERT(m_iRefCounter == 0);
74 | }
75 |
76 | void CRefCounter::Retain()
77 | {
78 | ASSERT(m_iRefCounter > 0);
79 |
80 | InterlockedIncrement((volatile LONG*)&m_iRefCounter);
81 | }
82 |
83 | void CRefCounter::Release()
84 | {
85 | ASSERT(m_iRefCounter > 0);
86 |
87 | InterlockedDecrement((volatile LONG*)&m_iRefCounter);
88 |
89 | if (!m_iRefCounter)
90 | delete this;
91 | }
92 |
93 | // File load / store
94 |
95 | void CInstrumentFile::WriteInt(unsigned int Value)
96 | {
97 | Write(&Value, sizeof(int));
98 | }
99 |
100 | void CInstrumentFile::WriteChar(unsigned char Value)
101 | {
102 | Write(&Value, sizeof(char));
103 | }
104 |
105 | unsigned int CInstrumentFile::ReadInt()
106 | {
107 | unsigned int Value;
108 | Read(&Value, sizeof(int));
109 | return Value;
110 | }
111 |
112 | unsigned char CInstrumentFile::ReadChar()
113 | {
114 | unsigned char Value;
115 | Read(&Value, sizeof(char));
116 | return Value;
117 | }
118 |
--------------------------------------------------------------------------------
/Source/PerformanceDlg.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #include "stdafx.h"
22 | #include "FamiTracker.h"
23 | #include "PerformanceDlg.h"
24 | #include "FamiTrackerDoc.h"
25 | #include "SoundGen.h"
26 |
27 |
28 | // CPerformanceDlg dialog
29 |
30 | IMPLEMENT_DYNAMIC(CPerformanceDlg, CDialog)
31 | CPerformanceDlg::CPerformanceDlg(CWnd* pParent /*=NULL*/)
32 | : CDialog(CPerformanceDlg::IDD, pParent)
33 | {
34 | }
35 |
36 | CPerformanceDlg::~CPerformanceDlg()
37 | {
38 | }
39 |
40 | void CPerformanceDlg::DoDataExchange(CDataExchange* pDX)
41 | {
42 | CDialog::DoDataExchange(pDX);
43 | }
44 |
45 |
46 | BEGIN_MESSAGE_MAP(CPerformanceDlg, CDialog)
47 | ON_WM_TIMER()
48 | ON_BN_CLICKED(IDOK, OnBnClickedOk)
49 | END_MESSAGE_MAP()
50 |
51 |
52 | // CPerformanceDlg message handlers
53 |
54 | BOOL CPerformanceDlg::OnInitDialog()
55 | {
56 | CDialog::OnInitDialog();
57 |
58 | theApp.GetCPUUsage();
59 | theApp.GetSoundGenerator()->GetFrameRate();
60 |
61 | SetTimer(1, 1000, NULL);
62 |
63 | return TRUE; // return TRUE unless you set the focus to a control
64 | // EXCEPTION: OCX Property Pages should return FALSE
65 | }
66 |
67 | void CPerformanceDlg::OnTimer(UINT nIDEvent)
68 | {
69 | CProgressCtrl *pBar = static_cast(GetDlgItem(IDC_CPU_BAR));
70 | unsigned int Usage = theApp.GetCPUUsage();
71 | unsigned int Rate = theApp.GetSoundGenerator()->GetFrameRate();
72 | unsigned int Underruns = theApp.GetSoundGenerator()->GetUnderruns();
73 | CString Text;
74 |
75 | Text.Format(_T("%i%%"), Usage / 100);
76 | SetDlgItemText(IDC_CPU, Text);
77 |
78 | AfxFormatString1(Text, IDS_PERFORMANCE_FRAMERATE_FORMAT, MakeIntString(Rate));
79 | SetDlgItemText(IDC_FRAMERATE, Text);
80 |
81 | AfxFormatString1(Text, IDS_PERFORMANCE_UNDERRUN_FORMAT, MakeIntString(Underruns));
82 | SetDlgItemText(IDC_UNDERRUN, Text);
83 |
84 | pBar->SetRange(0, 100);
85 | pBar->SetPos(Usage / 100);
86 |
87 | CDialog::OnTimer(nIDEvent);
88 | }
89 |
90 | void CPerformanceDlg::OnBnClickedOk()
91 | {
92 | DestroyWindow();
93 | }
94 |
95 | BOOL CPerformanceDlg::DestroyWindow()
96 | {
97 | KillTimer(1);
98 | return CDialog::DestroyWindow();
99 | }
100 |
--------------------------------------------------------------------------------
/Source/FrameAction.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | #include "Action.h"
24 | #include "FrameEditor.h"
25 |
26 | // Frame commands
27 | class CFrameAction : public CAction
28 | {
29 | public:
30 | enum ACTIONS
31 | {
32 | ACT_ADD,
33 | ACT_REMOVE,
34 | ACT_DUPLICATE,
35 | ACT_DUPLICATE_PATTERNS,
36 | ACT_CHANGE_COUNT,
37 | ACT_SET_PATTERN,
38 | ACT_SET_PATTERN_ALL,
39 | ACT_CHANGE_PATTERN,
40 | ACT_CHANGE_PATTERN_ALL,
41 | ACT_MOVE_DOWN,
42 | ACT_MOVE_UP,
43 | ACT_PASTE,
44 | ACT_PASTE_NEW,
45 | ACT_DRAG_AND_DROP_MOVE,
46 | ACT_DRAG_AND_DROP_COPY,
47 | ACT_DRAG_AND_DROP_COPY_NEW,
48 | ACT_DELETE_SELECTION,
49 | ACT_MERGE_DUPLICATED_PATTERNS
50 | };
51 |
52 | public:
53 | CFrameAction(int iAction);
54 | virtual ~CFrameAction();
55 |
56 | bool SaveState(CMainFrame *pMainFrm);
57 | void Undo(CMainFrame *pMainFrm);
58 | void Redo(CMainFrame *pMainFrm);
59 |
60 | public:
61 | void SetFrameCount(unsigned int FrameCount);
62 | void SetPattern(unsigned int Pattern);
63 | void SetPatternDelta(int Delta, bool ChangeAll);
64 | void Update(CMainFrame *pMainFrm);
65 | void SetPasteData(CFrameClipData *pClipData);
66 | void SetDragInfo(int DragTarget, CFrameClipData *pClipData, bool Remove);
67 |
68 | private:
69 | void SaveFrame(CFamiTrackerDoc *pDoc);
70 | void RestoreFrame(CFamiTrackerDoc *pDoc);
71 |
72 | void SaveAllFrames(CFamiTrackerDoc *pDoc);
73 | void RestoreAllFrames(CFamiTrackerDoc *pDoc);
74 |
75 | int ClipPattern(int Pattern) const;
76 |
77 | void ClearPatterns(CFamiTrackerDoc *pDoc, int Target);
78 |
79 | private:
80 | unsigned int m_iUndoTrack;
81 | unsigned int m_iUndoFramePos;
82 | unsigned int m_iUndoChannelPos;
83 | unsigned int m_iRedoFramePos;
84 | unsigned int m_iRedoChannelPos;
85 |
86 | unsigned int m_iNewFrameCount;
87 | unsigned int m_iUndoFrameCount;
88 | unsigned int m_iNewPattern;
89 | unsigned int m_iOldPattern;
90 |
91 | int m_iPatternDelta;
92 | bool m_bChangeAll;
93 |
94 | unsigned int m_iPatterns[MAX_CHANNELS];
95 |
96 | bool m_bDragRemove;
97 | unsigned int m_iDragTarget;
98 |
99 | unsigned int *m_pAllPatterns;
100 |
101 | CFrameClipData *m_pClipData;
102 |
103 | stSelectInfo m_oSelInfo;
104 | };
105 |
--------------------------------------------------------------------------------
/Source/vgmtools/vgm_lib.h:
--------------------------------------------------------------------------------
1 | #define DELAY_60HZ 735
2 | #define DELAY_50HZ 882
3 |
4 | // checks if Dly is in range from (From + 0x00) to (From + Range)
5 | #define DELAY_CHECK(Dly, From, Range) ((Dly >= (From)) && (Dly <= (From + Range)))
6 |
7 | void VGMLib_WriteDelay(UINT8* DstData, UINT32* Pos, UINT32 Delay, bool* WroteCmd80)
8 | {
9 | UINT32 DstPos;
10 | UINT16 CurDly;
11 | UINT32 TempLng;
12 | bool WrtCmdPCM;
13 |
14 | DstPos = *Pos;
15 | WrtCmdPCM = (WroteCmd80 == NULL) ? false : *WroteCmd80;
16 |
17 | while(Delay)
18 | {
19 | if (Delay <= 0xFFFF)
20 | CurDly = (UINT16)Delay;
21 | else
22 | CurDly = 0xFFFF;
23 |
24 | if (WrtCmdPCM)
25 | {
26 | // highest delay compression - Example:
27 | // Delay 39 -> 8F 7F 77
28 | // Delay 1485 -> 8F 62 62 (instead of 80 61 CD 05)
29 | // Delay 910 -> 8F 63 7D (instead of 80 61 8E 03)
30 | if (DELAY_CHECK(CurDly, 0x20, 0x0F)) // 8F 7x
31 | CurDly -= 0x10;
32 | else if (DELAY_CHECK(CurDly, DELAY_60HZ, 0x1F)) // 8F 62 [7x]
33 | CurDly -= DELAY_60HZ;
34 | else if (DELAY_CHECK(CurDly, 2 * DELAY_60HZ, 0x0F)) // 8F 62 62
35 | CurDly -= 2 * DELAY_60HZ;
36 | else if (DELAY_CHECK(CurDly, DELAY_50HZ, 0x1F)) // 8F 63 [7x]
37 | CurDly -= DELAY_50HZ;
38 | else if (DELAY_CHECK(CurDly, 2 * DELAY_50HZ, 0x0F)) // 8F 63 63
39 | CurDly -= 2 * DELAY_50HZ;
40 | else if (DELAY_CHECK(CurDly, // 8F 62 63
41 | DELAY_60HZ + DELAY_50HZ, 0x0F))
42 | CurDly -= DELAY_60HZ + DELAY_50HZ;
43 |
44 | /*if (CurDly >= 0x10 && CurDly <= 0x1F)
45 | CurDly = 0x0F;
46 | else if (CurDly >= 0x20)
47 | CurDly = 0x00;*/
48 | if (CurDly >= 0x10)
49 | CurDly = 0x0F;
50 | DstData[DstPos - 1] |= CurDly;
51 | *WroteCmd80 = WrtCmdPCM = false;
52 | }
53 | else if (! CurDly)
54 | {
55 | // don't do anything - I just want to be safe
56 | }
57 | else if (CurDly <= 0x20)
58 | {
59 | if (CurDly <= 0x10)
60 | {
61 | DstData[DstPos] = 0x70 | (CurDly - 0x01);
62 | DstPos ++;
63 | }
64 | else
65 | {
66 | DstData[DstPos] = 0x7F;
67 | DstPos ++;
68 | DstData[DstPos] = 0x70 | (CurDly - 0x11);
69 | DstPos ++;
70 | }
71 | }
72 | else if (DELAY_CHECK(CurDly, DELAY_60HZ, 0x10) ||
73 | CurDly == 2 * DELAY_60HZ)
74 | {
75 | TempLng = CurDly;
76 | while(TempLng >= DELAY_60HZ)
77 | {
78 | DstData[DstPos] = 0x62;
79 | DstPos ++;
80 | TempLng -= DELAY_60HZ;
81 | }
82 | CurDly -= (UINT16)TempLng;
83 | }
84 | else if (DELAY_CHECK(CurDly, DELAY_50HZ, 0x10) ||
85 | CurDly == 2 * DELAY_50HZ)
86 | {
87 | TempLng = CurDly;
88 | while(TempLng >= DELAY_50HZ)
89 | {
90 | DstData[DstPos] = 0x63;
91 | DstPos ++;
92 | TempLng -= DELAY_50HZ;
93 | }
94 | CurDly -= (UINT16)TempLng;
95 | }
96 | else if (CurDly == (DELAY_60HZ + DELAY_50HZ))
97 | {
98 | DstData[DstPos] = 0x63;
99 | DstPos ++;
100 | DstData[DstPos] = 0x62;
101 | DstPos ++;
102 | }
103 | else
104 | {
105 | DstData[DstPos + 0x00] = 0x61;
106 | DstData[DstPos + 0x01] = (CurDly & 0x00FF) >> 0;
107 | DstData[DstPos + 0x02] = (CurDly & 0xFF00) >> 8;
108 | DstPos += 0x03;
109 | }
110 | Delay -= CurDly;
111 | }
112 |
113 | *Pos = DstPos;
114 | return;
115 | }
116 |
--------------------------------------------------------------------------------
/Source/APU/Mixer.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #ifndef MIXER_H
22 | #define MIXER_H
23 |
24 | #include "Types.h"
25 | #include "../Common.h"
26 | #include "../Blip_Buffer/blip_buffer.h"
27 |
28 | enum chip_level_t {
29 | CHIP_LEVEL_SN7L,
30 | CHIP_LEVEL_SN7R,
31 | CHIP_LEVEL_SN7Sep,
32 | // // //
33 | };
34 |
35 | class CMixer
36 | {
37 | public:
38 | CMixer();
39 | ~CMixer();
40 |
41 | void ExternalSound(int Chip);
42 | void AddValue(int ChanID, int Chip, int Left, int Right, int FrameCycles); // // //
43 | void UpdateSettings(int LowCut, int HighCut, int HighDamp, float OverallVol);
44 |
45 | bool AllocateBuffer(unsigned int Size, uint32 SampleRate, uint8 NrChannels);
46 | void SetClockRate(uint32 Rate);
47 | void ClearBuffer();
48 | int FinishBuffer(int t);
49 | int SamplesAvail() const;
50 | void MixSamples(blip_sample_t *pBuffer, uint32 Count);
51 | uint32 GetMixSampleCount(int t) const;
52 |
53 | void AddSample(int ChanID, int Value);
54 | int ReadBuffer(int Size, void *Buffer, bool Stereo);
55 |
56 | int32 GetChanOutput(uint8 Chan) const;
57 | void SetChipLevel(chip_level_t Chip, float Level);
58 | uint32 ResampleDuration(uint32 Time) const;
59 |
60 | private:
61 | // // //
62 |
63 | void StoreChannelLevel(int Channel, int Value);
64 | void ClearChannelLevels();
65 |
66 | float GetAttenuation() const;
67 |
68 | private:
69 | // Blip buffer synths
70 | Blip_Synth SynthSN76489Left; // // //
71 | Blip_Synth SynthSN76489Right;
72 | // // //
73 |
74 | // Blip buffer object
75 | Blip_Buffer BlipBufferLeft; // // //
76 | Blip_Buffer BlipBufferRight; // // //
77 |
78 | double m_dSumSS;
79 | double m_dSumTND;
80 |
81 | int32 m_iChannelsLeft[CHANNELS]; // // //
82 | int32 m_iChannelsRight[CHANNELS]; // // //
83 | uint8 m_iExternalChip;
84 | uint32 m_iSampleRate;
85 |
86 | float m_fChannelLevels[CHANNELS];
87 | uint32 m_iChanLevelFallOff[CHANNELS];
88 |
89 | int m_iLowCut;
90 | int m_iHighCut;
91 | int m_iHighDamp;
92 | float m_fOverallVol;
93 |
94 | float m_fLevelSN7Left; // // //
95 | float m_fLevelSN7Right; // // //
96 | float m_fLevelSN7SepHi; // // //
97 | float m_fLevelSN7SepLo; // // //
98 | };
99 |
100 | #endif /* MIXER_H */
101 |
--------------------------------------------------------------------------------
/Source/Sequence.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #include "stdafx.h"
22 | #include "Sequence.h"
23 | #include "DocumentFile.h"
24 |
25 | CSequence::CSequence()
26 | {
27 | Clear();
28 | }
29 |
30 | void CSequence::Clear()
31 | {
32 | m_iItemCount = 0;
33 | m_iLoopPoint = -1;
34 | m_iReleasePoint = -1;
35 | m_iSetting = 0;
36 |
37 | memset(m_cValues, 0, sizeof(char) * MAX_SEQUENCE_ITEMS);
38 |
39 | m_iPlaying = -1;
40 | }
41 |
42 | void CSequence::SetItem(int Index, signed char Value)
43 | {
44 | ASSERT(Index <= MAX_SEQUENCE_ITEMS);
45 | m_cValues[Index] = Value;
46 | }
47 |
48 | void CSequence::SetItemCount(unsigned int Count)
49 | {
50 | ASSERT(Count <= MAX_SEQUENCE_ITEMS);
51 |
52 | m_iItemCount = Count;
53 |
54 | if (m_iLoopPoint > m_iItemCount)
55 | m_iLoopPoint = -1;
56 | if (m_iReleasePoint > m_iItemCount)
57 | m_iReleasePoint = -1;
58 | }
59 |
60 | void CSequence::SetLoopPoint(unsigned int Point)
61 | {
62 | m_iLoopPoint = Point;
63 | // Loop point cannot be beyond release point (at the moment)
64 | if (m_iLoopPoint >= m_iReleasePoint)
65 | m_iLoopPoint = -1;
66 | }
67 |
68 | void CSequence::SetReleasePoint(unsigned int Point)
69 | {
70 | m_iReleasePoint = Point;
71 | // Loop point cannot be beyond release point (at the moment)
72 | if (m_iLoopPoint >= m_iReleasePoint)
73 | m_iLoopPoint = -1;
74 | }
75 |
76 | void CSequence::SetSetting(unsigned int Setting)
77 | {
78 | m_iSetting = Setting;
79 | }
80 |
81 | signed char CSequence::GetItem(int Index) const
82 | {
83 | ASSERT(Index <= MAX_SEQUENCE_ITEMS);
84 | return m_cValues[Index];
85 | }
86 |
87 | unsigned int CSequence::GetItemCount() const
88 | {
89 | return m_iItemCount;
90 | }
91 |
92 | unsigned int CSequence::GetLoopPoint() const
93 | {
94 | return m_iLoopPoint;
95 | }
96 |
97 | unsigned int CSequence::GetReleasePoint() const
98 | {
99 | return m_iReleasePoint;
100 | }
101 |
102 | unsigned int CSequence::GetSetting() const
103 | {
104 | return m_iSetting;
105 | }
106 |
107 | void CSequence::Copy(const CSequence *pSeq)
108 | {
109 | // Copy all values from pSeq
110 | m_iItemCount = pSeq->m_iItemCount;
111 | m_iLoopPoint = pSeq->m_iLoopPoint;
112 | m_iReleasePoint = pSeq->m_iReleasePoint;
113 | m_iSetting = pSeq->m_iSetting;
114 |
115 | memcpy(m_cValues, pSeq->m_cValues, MAX_SEQUENCE_ITEMS);
116 | }
117 |
--------------------------------------------------------------------------------
/Source/VisualizerWnd.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 |
24 | // Visualizer classes
25 |
26 | #include // Synchronization objects
27 |
28 | class CVisualizerBase
29 | {
30 | public:
31 | CVisualizerBase() : m_iWidth(0), m_iHeight(0), m_iSampleCount(0), m_pSamples(NULL) {}
32 | virtual ~CVisualizerBase() {}
33 |
34 | // Create the visualizer
35 | virtual void Create(int Width, int Height);
36 | // Set rate of samples
37 | virtual void SetSampleRate(int SampleRate) = 0;
38 | // Set new sample data
39 | virtual void SetSampleData(short *iSamples, unsigned int iCount);
40 | // Render an image from the sample data
41 | virtual void Draw() = 0;
42 | // Display the image
43 | virtual void Display(CDC *pDC, bool bPaintMsg) = 0;
44 |
45 | protected:
46 | BITMAPINFO m_bmi;
47 | int m_iWidth;
48 | int m_iHeight;
49 |
50 | unsigned int m_iSampleCount;
51 | short *m_pSamples;
52 | };
53 |
54 | // CVisualizerWnd
55 |
56 | class CVisualizerWnd : public CWnd
57 | {
58 | DECLARE_DYNAMIC(CVisualizerWnd)
59 |
60 | public:
61 | CVisualizerWnd();
62 | virtual ~CVisualizerWnd();
63 |
64 | void SetSampleRate(int SampleRate);
65 | void FlushSamples(short *Samples, int Count);
66 | void ReportAudioProblem();
67 |
68 | private:
69 | static UINT ThreadProcFunc(LPVOID pParam);
70 |
71 | private:
72 | void NextState();
73 | UINT ThreadProc();
74 |
75 | private:
76 | static const int STATE_COUNT = 4;
77 |
78 | private:
79 | CVisualizerBase *m_pStates[STATE_COUNT];
80 | unsigned int m_iCurrentState;
81 |
82 | int m_iBufferSize;
83 | short *m_pBuffer1;
84 | short *m_pBuffer2;
85 | short *m_pFillBuffer;
86 |
87 | HANDLE m_hNewSamples;
88 |
89 | bool m_bNoAudio;
90 |
91 | // Thread
92 | CWinThread *m_pWorkerThread;
93 | bool m_bThreadRunning;
94 |
95 | CCriticalSection m_csBufferSelect;
96 | CCriticalSection m_csBuffer;
97 |
98 | public:
99 | virtual BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
100 |
101 | protected:
102 | DECLARE_MESSAGE_MAP()
103 | afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
104 | afx_msg void OnPaint();
105 | afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
106 | afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
107 | afx_msg void OnDestroy();
108 | };
109 |
--------------------------------------------------------------------------------
/Source/WaveFile.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #include
22 | #include "WaveFile.h"
23 |
24 | bool CWaveFile::OpenFile(LPTSTR Filename, int SampleRate, int SampleSize, int Channels)
25 | {
26 | // Open a wave file for streaming
27 | //
28 |
29 | int nError;
30 |
31 | WaveFormat.wf.wFormatTag = WAVE_FORMAT_PCM;
32 | WaveFormat.wf.nChannels = Channels;
33 | WaveFormat.wf.nSamplesPerSec = SampleRate;
34 | WaveFormat.wf.nBlockAlign = (SampleSize / 8) * Channels;
35 | WaveFormat.wf.nAvgBytesPerSec = SampleRate * (SampleSize / 8) * Channels;
36 | WaveFormat.wBitsPerSample = SampleSize;
37 |
38 | hmmioOut = mmioOpen(Filename, NULL, MMIO_ALLOCBUF | MMIO_READWRITE | MMIO_CREATE);
39 |
40 | ckOutRIFF.fccType = mmioFOURCC('W', 'A', 'V', 'E');
41 | ckOutRIFF.cksize = 0;
42 |
43 | nError = mmioCreateChunk(hmmioOut, &ckOutRIFF, MMIO_CREATERIFF);
44 |
45 | if (nError != MMSYSERR_NOERROR)
46 | return false;
47 |
48 | ckOut.ckid = mmioFOURCC('f', 'm', 't', ' ');
49 | ckOut.cksize = sizeof(PCMWAVEFORMAT);
50 |
51 | nError = mmioCreateChunk(hmmioOut, &ckOut, 0);
52 |
53 | if (nError != MMSYSERR_NOERROR)
54 | return false;
55 |
56 | mmioWrite(hmmioOut, (HPSTR)&WaveFormat, sizeof(PCMWAVEFORMAT));
57 | mmioAscend(hmmioOut, &ckOut, 0);
58 |
59 | ckOut.ckid = mmioFOURCC('d', 'a', 't', 'a');
60 | ckOut.cksize = 0;
61 |
62 | nError = mmioCreateChunk(hmmioOut, &ckOut, 0);
63 |
64 | if (nError != MMSYSERR_NOERROR)
65 | return false;
66 |
67 | mmioGetInfo(hmmioOut, &mmioinfoOut, 0);
68 |
69 | return true;
70 | }
71 |
72 | void CWaveFile::CloseFile()
73 | {
74 | // Close the file
75 | //
76 |
77 | mmioinfoOut.dwFlags |= MMIO_DIRTY;
78 | mmioSetInfo(hmmioOut, &mmioinfoOut, 0);
79 |
80 | mmioAscend(hmmioOut, &ckOut, 0);
81 | mmioAscend(hmmioOut, &ckOutRIFF, 0);
82 |
83 | mmioSeek(hmmioOut, 0, SEEK_SET);
84 | mmioDescend(hmmioOut, &ckOutRIFF, NULL, 0);
85 |
86 | mmioClose(hmmioOut, 0);
87 | }
88 |
89 | void CWaveFile::WriteWave(char *Data, int Size)
90 | {
91 | // Save data to the file
92 | //
93 |
94 | int cT;
95 |
96 | for (cT = 0; cT < Size; cT++) {
97 | if (mmioinfoOut.pchNext == mmioinfoOut.pchEndWrite) {
98 | mmioinfoOut.dwFlags |= MMIO_DIRTY;
99 | mmioAdvance(hmmioOut, &mmioinfoOut, MMIO_WRITE);
100 | }
101 |
102 | *((BYTE*)mmioinfoOut.pchNext) = *((BYTE*)Data + cT);
103 | mmioinfoOut.pchNext++;
104 | }
105 | }
106 |
107 |
--------------------------------------------------------------------------------
/Source/stdafx.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | // stdafx.h : include file for standard system include files,
22 | // or project specific include files that are used frequently,
23 | // but are changed infrequently
24 |
25 | #pragma once
26 |
27 | #define _CRTDBG_MAPALLOC
28 | #define NOMINMAX
29 |
30 | // Get rid of warnings in VS 2005
31 | #define _CRT_SECURE_NO_DEPRECATE
32 | #define _CRT_SECURE_NO_WARNINGS
33 | #define NO_WARN_MBCS_MFC_DEPRECATION // // //
34 |
35 | #ifndef VC_EXTRALEAN
36 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
37 | #endif
38 |
39 | // Modify the following defines if you have to target a platform prior to the ones specified below.
40 | // Refer to MSDN for the latest info on corresponding values for different platforms.
41 | #ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
42 | #define WINVER 0x0501 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
43 | #endif
44 |
45 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
46 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
47 | #endif
48 |
49 | #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
50 | #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
51 | #endif
52 |
53 | #ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
54 | #define _WIN32_IE 0x0600 // Change this to the appropriate value to target IE 5.0 or later.
55 | #endif
56 |
57 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
58 |
59 | // turns off MFC's hiding of some common and often safely ignored warning messages
60 | #define _AFX_ALL_WARNINGS
61 |
62 | #include // MFC core and standard components
63 | #include // MFC extensions
64 |
65 | #include // MFC support for Internet Explorer 4 Common Controls
66 | #ifndef _AFX_NO_AFXCMN_SUPPORT
67 | #include // MFC support for Windows Common Controls
68 | #endif // _AFX_NO_AFXCMN_SUPPORT
69 | #include
70 | #include
71 | #include
72 |
73 | #include // MFC OLE support
74 |
75 | // Releasing pointers
76 | #define SAFE_RELEASE(p) \
77 | if (p != NULL) { \
78 | delete p; \
79 | p = NULL; \
80 | } \
81 |
82 | #define SAFE_RELEASE_ARRAY(p) \
83 | if (p != NULL) { \
84 | delete [] p; \
85 | p = NULL; \
86 | } \
87 |
88 | #define new DEBUG_NEW
89 |
--------------------------------------------------------------------------------
/Source/resampler/sinc.cpp:
--------------------------------------------------------------------------------
1 | /**This program is free software. It comes without any warranty, to
2 | **the extent permitted by applicable law. You can redistribute it
3 | **and/or modify it under the terms of the Do What The Fuck You Want
4 | **To Public License, Version 2, as published by Sam Hocevar. See
5 | **http://sam.zoy.org/wtfpl/COPYING for more details. **/
6 | //------------------------------------------------------------------------
7 | #include "sinc.hpp"
8 | //------------------------------------------------------------------------
9 | #include
10 | #include
11 | #include // // //
12 | //------------------------------------------------------------------------
13 |
14 | /** Implementation of the sinc class **/
15 |
16 |
17 |
18 | /**Anonymous namespace, internal linking**/
19 | namespace {
20 |
21 | // Well, this constant is quite ubiquitous...
22 | const float PI = 3.141592653589793238462643383279502884197169f;
23 |
24 | const float eps = std::numeric_limits::epsilon();
25 |
26 | inline float fetchval(const std::vector &v, size_t elem)
27 | {
28 | return elem >= v.size() ? 0.f : v[elem];
29 | }
30 |
31 | } // anonymous namespace
32 |
33 |
34 |
35 | namespace jarh
36 | {
37 |
38 |
39 |
40 | //------------------------------------------------------------------------
41 | // ctor -
42 | //------------------------------------------------------------------------
43 | sinc::sinc(size_t sz, size_t firstnull, float gain)
44 | {
45 | resize(sz, firstnull, gain);
46 | }
47 | //------------------------------------------------------------------------
48 | // resize(size_t sz, size_t firstnull, float gain) -
49 | //------------------------------------------------------------------------
50 | void
51 | sinc::resize(size_t sz, size_t firstnull, float gain)
52 | {
53 | using std::sin;
54 | using std::cos;
55 |
56 | // free and minimize vector.
57 | std::vector().swap(tbl_);
58 | tbl_.reserve(sz);
59 |
60 | // sanitize input
61 | sz = std::max(1, sz);
62 | firstnull = std::min(sz, firstnull);
63 |
64 | convfactor_ = (float)firstnull;
65 |
66 | size_t i;
67 | double sum = 0.;
68 | for (i = 0; i < sz; i++)
69 | {
70 | /*Evaluate Upper half of sinc(x) * Hamming window */
71 | const float f = eps + (PI*i) / firstnull;
72 | const float v = sin(f) / f * (.54f + .46f * cos(i*PI / sz));
73 | tbl_.push_back(v);
74 | sum += v;
75 | }
76 |
77 | const float adjust = gain * firstnull / (float)(2*sum - tbl_[0]);
78 |
79 | // adjust the 'gain' of the sinc
80 | for (i = 0; i < sz; i++)
81 | {
82 | tbl_[i] *= adjust;
83 | }
84 | }
85 | //------------------------------------------------------------------------
86 | // operator()(float) -
87 | // evaluate sinc at x, using our table and linear interpolation.
88 | //------------------------------------------------------------------------
89 | float
90 | sinc::operator()(float x) const
91 | {
92 | using std::abs;
93 | using std::floor;
94 |
95 | x = abs(x*convfactor_);
96 |
97 | const size_t ix1 = (size_t)floor(x), ix2 = ix1 + 1;
98 | const float v1 = fetchval(tbl_,ix1), v2 = fetchval(tbl_,ix2);
99 |
100 | return v1 + (x - ix1)*(v2-v1);
101 | }
102 | //------------------------------------------------------------------------
103 |
104 |
105 |
106 | } // namespace jarh
107 |
108 |
109 |
110 | //------------------------------------------------------------------------
111 |
--------------------------------------------------------------------------------
/Source/Action.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | // These classes implements a new more flexible undo system
22 |
23 | #include "stdafx.h"
24 | #include "resource.h"
25 | #include "FamiTrackerDoc.h"
26 | #include "FamiTrackerView.h"
27 | #include "MainFrm.h"
28 | #include "PatternEditor.h"
29 | #include "Action.h"
30 |
31 | // CAction ////////////////////////////////////////////////////////////////////////
32 |
33 | CAction::CAction(int iAction)
34 | {
35 | m_iAction = iAction;
36 | }
37 |
38 | CAction::~CAction()
39 | {
40 | }
41 |
42 | int CAction::GetAction() const
43 | {
44 | return m_iAction;
45 | }
46 |
47 |
48 | // CActionHandler /////////////////////////////////////////////////////////////////
49 |
50 | CActionHandler::CActionHandler()
51 | {
52 | m_iUndoLevel = 0;
53 | m_iRedoLevel = 0;
54 |
55 | for (int i = 0; i < MAX_LEVELS; ++i) {
56 | m_pActionStack[i] = NULL;
57 | }
58 | }
59 |
60 | CActionHandler::~CActionHandler()
61 | {
62 | Clear();
63 | }
64 |
65 | void CActionHandler::Clear()
66 | {
67 | m_iUndoLevel = 0;
68 | m_iRedoLevel = 0;
69 |
70 | for (int i = 0; i < MAX_LEVELS; ++i) {
71 | SAFE_RELEASE(m_pActionStack[i]);
72 | }
73 | }
74 |
75 | void CActionHandler::Push(CAction *pAction)
76 | {
77 | if (m_iUndoLevel < MAX_LEVELS) {
78 | SAFE_RELEASE(m_pActionStack[m_iUndoLevel]);
79 | m_pActionStack[m_iUndoLevel++] = pAction;
80 | }
81 | else {
82 | SAFE_RELEASE(m_pActionStack[0]);
83 | for (int i = 1; i < MAX_LEVELS; ++i)
84 | m_pActionStack[i - 1] = m_pActionStack[i];
85 | m_pActionStack[MAX_LEVELS - 1] = pAction;
86 | }
87 |
88 | m_iRedoLevel = 0;
89 | }
90 |
91 | CAction *CActionHandler::PopUndo()
92 | {
93 | if (!m_iUndoLevel)
94 | return NULL;
95 |
96 | m_iRedoLevel++;
97 | m_iUndoLevel--;
98 |
99 | return m_pActionStack[m_iUndoLevel];
100 | }
101 |
102 | CAction *CActionHandler::PopRedo()
103 | {
104 | if (!m_iRedoLevel)
105 | return NULL;
106 |
107 | m_iUndoLevel++;
108 | m_iRedoLevel--;
109 |
110 | return m_pActionStack[m_iUndoLevel - 1];
111 | }
112 |
113 | CAction *CActionHandler::GetLastAction() const
114 | {
115 | return (m_iUndoLevel == 0) ? NULL : m_pActionStack[m_iUndoLevel - 1];
116 | }
117 |
118 | int CActionHandler::GetUndoLevel() const
119 | {
120 | return m_iUndoLevel;
121 | }
122 |
123 | int CActionHandler::GetRedoLevel() const
124 | {
125 | return m_iRedoLevel;
126 | }
127 |
128 | bool CActionHandler::CanUndo() const
129 | {
130 | return m_iUndoLevel > 0;
131 | }
132 |
133 | bool CActionHandler::CanRedo() const
134 | {
135 | return m_iRedoLevel > 0;
136 | }
137 |
--------------------------------------------------------------------------------
/Source/InstrumentEditPanel.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | // std::string is required by this header file
24 |
25 | // List control states
26 | #define LCTRL_CHECKBOX_STATE 0x3000
27 | #define LCTRL_CHECKBOX_CHECKED 0x2000
28 | #define LCTRL_CHECKBOX_UNCHECKED 0x1000
29 |
30 | class CSequence;
31 |
32 | class CInstrumentEditPanel : public CDialog
33 | {
34 | DECLARE_DYNAMIC(CInstrumentEditPanel)
35 | public:
36 | CInstrumentEditPanel(UINT nIDTemplate, CWnd* pParent = NULL); // standard constructor
37 | virtual ~CInstrumentEditPanel();
38 | virtual int GetIDD() const = 0;
39 | virtual TCHAR *GetTitle() const = 0;
40 |
41 | // Select instrument for the editing
42 | virtual void SelectInstrument(int Instrument) = 0;
43 |
44 | protected:
45 | CFamiTrackerDoc *GetDocument() const;
46 |
47 | virtual void PreviewNote(unsigned char Key);
48 | virtual void PreviewRelease(unsigned char Key);
49 | virtual void OnKeyReturn();
50 |
51 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
52 |
53 | DECLARE_MESSAGE_MAP()
54 | public:
55 | virtual BOOL PreTranslateMessage(MSG* pMsg);
56 | afx_msg BOOL OnEraseBkgnd(CDC* pDC);
57 | afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
58 | afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
59 | afx_msg void OnSetFocus(CWnd* pOldWnd);
60 | };
61 |
62 | class CSequenceEditor;
63 |
64 | // Adds some functions for sequences
65 | class CSequenceInstrumentEditPanel : public CInstrumentEditPanel
66 | {
67 | DECLARE_DYNAMIC(CSequenceInstrumentEditPanel)
68 | public:
69 | CSequenceInstrumentEditPanel(UINT nIDTemplate, CWnd* pParent);
70 | virtual ~CSequenceInstrumentEditPanel();
71 |
72 | virtual void SetSequenceString(CString Sequence, bool Changed) = 0;
73 |
74 | // Static methods
75 | public:
76 | static int ReadStringValue(const std::string &str);
77 |
78 | // Member variables
79 | protected:
80 | CSequenceEditor *m_pSequenceEditor;
81 | CSequence *m_pSequence;
82 | CWnd *m_pParentWin;
83 |
84 | unsigned int m_iSelectedSetting;
85 |
86 | protected:
87 | // Setup default sequence dialog
88 | void SetupDialog(LPCTSTR *pListItems);
89 |
90 | // Virtual methods
91 | virtual void TranslateMML(CString String, CSequence *pSequence, int Max, int Min) const;
92 | virtual void PreviewNote(unsigned char Key);
93 | virtual void PreviewRelease(unsigned char Key);
94 |
95 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
96 |
97 | DECLARE_MESSAGE_MAP()
98 | public:
99 | afx_msg void OnRClickInstSettings(NMHDR* pNMHDR, LRESULT* pResult);
100 |
101 | };
102 |
--------------------------------------------------------------------------------
/Source/MIDI.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** FamiTracker - NES/Famicom sound tracker
3 | ** Copyright (C) 2005-2014 Jonathan Liss
4 | **
5 | ** This program is free software; you can redistribute it and/or modify
6 | ** it under the terms of the GNU General Public License as published by
7 | ** the Free Software Foundation; either version 2 of the License, or
8 | ** (at your option) any later version.
9 | **
10 | ** This program is distributed in the hope that it will be useful,
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | ** Library General Public License for more details. To obtain a
14 | ** copy of the GNU Library General Public License, write to the Free
15 | ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 | **
17 | ** Any permitted reproduction of these routines, in whole or in part,
18 | ** must bear this legend.
19 | */
20 |
21 | #pragma once
22 |
23 | #include
24 | #include
25 |
26 | const int MIDI_MSG_NOTE_OFF = 0x08;
27 | const int MIDI_MSG_NOTE_ON = 0x09;
28 | const int MIDI_MSG_AFTER_TOUCH = 0x0A;
29 | const int MIDI_MSG_CONTROL_CHANGE = 0x0B;
30 | const int MIDI_MSG_PROGRAM_CHANGE = 0x0C;
31 | const int MIDI_MSG_CHANNEL_PRESSURE = 0x0D;
32 | const int MIDI_MSG_PITCH_WHEEL = 0x0E;
33 |
34 | // CMIDI command target
35 |
36 | class CMIDI : public CObject
37 | {
38 | public:
39 | CMIDI();
40 | virtual ~CMIDI();
41 |
42 | bool Init(void);
43 | void Shutdown(void);
44 |
45 | bool OpenDevices(void);
46 | bool CloseDevices(void);
47 |
48 | bool ReadMessage(unsigned char & Message, unsigned char & Channel, unsigned char & Data1, unsigned char & Data2);
49 | void WriteNote(unsigned char Channel, unsigned char Note, unsigned char Octave, unsigned char Velocity);
50 | void ResetOutput();
51 | void ToggleInput();
52 |
53 | int GetQuantization() const;
54 |
55 | bool IsOpened() const;
56 | bool IsAvailable() const;
57 |
58 | void SetInputDevice(int Device, bool MasterSync);
59 | void SetOutputDevice(int Device);
60 |
61 | int GetInputDevice() const;
62 | int GetOutputDevice() const;
63 |
64 | // Device enumeration
65 | int GetNumInputDevices() const;
66 | int GetNumOutputDevices() const;
67 |
68 | void GetInputDeviceString(int Num, CString &Text) const;
69 | void GetOutputDeviceString(int Num, CString &Text) const;
70 |
71 | // Private methods
72 | private:
73 | void Event(unsigned char Status, unsigned char Data1, unsigned char Data2);
74 | void Enqueue(unsigned char MsgType, unsigned char MsgChannel, unsigned char Data1, unsigned char Data2);
75 |
76 | // Constants
77 | private:
78 | static const int MAX_QUEUE = 100;
79 |
80 | // Static functions & variables
81 | private:
82 | static void CALLBACK MidiInProc(HMIDIIN hMidiIn, UINT wMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2);
83 | static CMIDI *m_pInstance;
84 |
85 | // Private variables
86 | private:
87 | // Devices
88 | int m_iInDevice;
89 | int m_iOutDevice;
90 |
91 | bool m_bMasterSync;
92 | bool m_bInStarted;
93 |
94 | // MIDI queue
95 | int m_iQueueHead;
96 | int m_iQueueTail;
97 |
98 | char m_iMsgTypeQueue[MAX_QUEUE];
99 | char m_iMsgChanQueue[MAX_QUEUE];
100 | char m_iData1Queue[MAX_QUEUE];
101 | char m_iData2Queue[MAX_QUEUE];
102 | char m_iQuantization[MAX_QUEUE];
103 |
104 | int m_iQuant;
105 | int m_iTimingCounter;
106 |
107 | // Device handles
108 | HMIDIIN m_hMIDIIn;
109 | HMIDIOUT m_hMIDIOut;
110 |
111 | // Thread sync
112 | CCriticalSection m_csQueue;
113 | };
114 |
--------------------------------------------------------------------------------