annotate src/adplug/core/adtrack.cxx @ 3163:26a2c237ef53

alsa-ng: Destroy the ringbuffer when the plugin closes.
author William Pitcock <nenolod@atheme.org>
date Thu, 14 May 2009 21:08:03 -0500
parents fa9f85cebade
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
1 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
2 * Adplug - Replayer for many OPL2/OPL3 audio file formats.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
3 * Copyright (C) 1999 - 2003 Simon Peter <dn.tlp@gmx.net>, et al.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
4 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
8 * version 2.1 of the License, or (at your option) any later version.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
9 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
13 * Lesser General Public License for more details.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
14 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
18 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
19 * adtrack.cpp - Adlib Tracker 1.0 Loader by Simon Peter <dn.tlp@gmx.net>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
20 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
21 * NOTES:
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
22 * The original Adlib Tracker 1.0 is behaving a little different from the
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
23 * official spec: The 'octave' integer from the instrument file is stored
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
24 * "minus 1" from the actual value, underflowing from 0 to 0xffff.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
25 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
26 * I also noticed that my player is playing everything transposed a few tones
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
27 * higher than the original tracker. As far as i can see, my player perfectly
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
28 * follows the official spec, so it "must" be the tracker that does something
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
29 * wrong here...
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
30 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
31
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
32 #include <stdlib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
33 #include <string.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
34
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
35 #include "adtrack.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
36 #include "debug.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
37
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
38 /*** Public methods ***/
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
39
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
40 CPlayer *
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
41 CadtrackLoader::factory (Copl * newopl)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
42 {
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
43 return new CadtrackLoader (newopl);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
44 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
45
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
46 bool
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
47 CadtrackLoader::load (VFSFile * fd, const CFileProvider & fp)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
48 {
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
49 binistream *f = fp.open (fd);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
50 if (!f)
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
51 return false;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
52 binistream *instf;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
53 char note[2];
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
54 unsigned short rwp;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
55 unsigned char chp, octave, pnote = 0;
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
56 int i, j;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
57 AdTrackInst myinst;
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
58 std::string filename (fd->uri);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
59
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
60 // file validation
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
61 if (!fp.extension (filename, ".sng") || fp.filesize (f) != 36000)
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
62 {
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
63 fp.close (f);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
64 return false;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
65 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
66
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
67 // check for instruments file
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
68 std::string instfilename (filename, 0, filename.find_last_of ('.'));
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
69 instfilename += ".ins";
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
70 AdPlug_LogWrite ("CadtrackLoader::load(,\"%s\"): Checking for \"%s\"...\n",
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
71 filename.c_str (), instfilename.c_str ());
703
cae46214b8bf [svn] - rework AdPlug to use VFS properly
nenolod
parents: 12
diff changeset
72
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 955
diff changeset
73 VFSFile *instfd = aud_vfs_fopen (instfilename.c_str (), "rb");
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
74 instf = fp.open (instfd);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
75 if (!instf || fp.filesize (instf) != 468)
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
76 {
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
77 fp.close (f);
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 955
diff changeset
78 aud_vfs_fclose (instfd);
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
79 return false;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
80 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
81
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
82 // give CmodPlayer a hint on what we're up to
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
83 realloc_patterns (1, 1000, 9);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
84 realloc_instruments (9);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
85 realloc_order (1);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
86 init_trackord ();
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
87 flags = NoKeyOn;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
88 (*order) = 0;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
89 length = 1;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
90 restartpos = 0;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
91 bpm = 120;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
92 initspeed = 3;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
93
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
94 // load instruments from instruments file
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
95 for (i = 0; i < 9; i++)
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
96 {
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
97 for (j = 0; j < 2; j++)
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
98 {
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
99 myinst.op[j].appampmod = instf->readInt (2);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
100 myinst.op[j].appvib = instf->readInt (2);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
101 myinst.op[j].maintsuslvl = instf->readInt (2);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
102 myinst.op[j].keybscale = instf->readInt (2);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
103 myinst.op[j].octave = instf->readInt (2);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
104 myinst.op[j].freqrisevollvldn = instf->readInt (2);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
105 myinst.op[j].softness = instf->readInt (2);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
106 myinst.op[j].attack = instf->readInt (2);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
107 myinst.op[j].decay = instf->readInt (2);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
108 myinst.op[j].release = instf->readInt (2);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
109 myinst.op[j].sustain = instf->readInt (2);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
110 myinst.op[j].feedback = instf->readInt (2);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
111 myinst.op[j].waveform = instf->readInt (2);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
112 }
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
113 convert_instrument (i, &myinst);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
114 }
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
115 fp.close (instf);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
116
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
117 // load file
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
118 for (rwp = 0; rwp < 1000; rwp++)
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
119 for (chp = 0; chp < 9; chp++)
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
120 {
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
121 // read next record
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
122 f->readString (note, 2);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
123 octave = f->readInt (1);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
124 f->ignore ();
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
125 switch (*note)
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
126 {
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
127 case 'C':
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
128 if (note[1] == '#')
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
129 pnote = 2;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
130 else
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
131 pnote = 1;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
132 break;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
133 case 'D':
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
134 if (note[1] == '#')
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
135 pnote = 4;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
136 else
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
137 pnote = 3;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
138 break;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
139 case 'E':
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
140 pnote = 5;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
141 break;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
142 case 'F':
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
143 if (note[1] == '#')
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
144 pnote = 7;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
145 else
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
146 pnote = 6;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
147 break;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
148 case 'G':
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
149 if (note[1] == '#')
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
150 pnote = 9;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
151 else
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
152 pnote = 8;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
153 break;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
154 case 'A':
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
155 if (note[1] == '#')
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
156 pnote = 11;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
157 else
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
158 pnote = 10;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
159 break;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
160 case 'B':
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
161 pnote = 12;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
162 break;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
163 case '\0':
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
164 if (note[1] == '\0')
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
165 tracks[chp][rwp].note = 127;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
166 else
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
167 {
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
168 fp.close (f);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
169 return false;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
170 }
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
171 break;
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
172 default:
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
173 fp.close (f);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
174 return false;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
175 }
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
176 if ((*note) != '\0')
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
177 {
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
178 tracks[chp][rwp].note = pnote + (octave * 12);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
179 tracks[chp][rwp].inst = chp + 1;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
180 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
181 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
182
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
183 fp.close (f);
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
184 rewind (0);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
185 return true;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
186 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
187
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
188 float
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
189 CadtrackLoader::getrefresh ()
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
190 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
191 return 18.2f;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
192 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
193
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
194 /*** Private methods ***/
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
195
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
196 void
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
197 CadtrackLoader::convert_instrument (unsigned int n, AdTrackInst * i)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
198 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
199 // Carrier "Amp Mod / Vib / Env Type / KSR / Multiple" register
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
200 inst[n].data[2] = i->op[Carrier].appampmod ? 1 << 7 : 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
201 inst[n].data[2] += i->op[Carrier].appvib ? 1 << 6 : 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
202 inst[n].data[2] += i->op[Carrier].maintsuslvl ? 1 << 5 : 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
203 inst[n].data[2] += i->op[Carrier].keybscale ? 1 << 4 : 0;
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
204 inst[n].data[2] += (i->op[Carrier].octave + 1) & 0xffff; // Bug in original tracker
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
205 // Modulator...
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
206 inst[n].data[1] = i->op[Modulator].appampmod ? 1 << 7 : 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
207 inst[n].data[1] += i->op[Modulator].appvib ? 1 << 6 : 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
208 inst[n].data[1] += i->op[Modulator].maintsuslvl ? 1 << 5 : 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
209 inst[n].data[1] += i->op[Modulator].keybscale ? 1 << 4 : 0;
955
4709ce4e209e [svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
chainsaw
parents: 703
diff changeset
210 inst[n].data[1] += (i->op[Modulator].octave + 1) & 0xffff; // Bug in original tracker
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
211
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
212 // Carrier "Key Scaling / Level" register
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
213 inst[n].data[10] = (i->op[Carrier].freqrisevollvldn & 3) << 6;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
214 inst[n].data[10] += i->op[Carrier].softness & 63;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
215 // Modulator...
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
216 inst[n].data[9] = (i->op[Modulator].freqrisevollvldn & 3) << 6;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
217 inst[n].data[9] += i->op[Modulator].softness & 63;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
218
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
219 // Carrier "Attack / Decay" register
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
220 inst[n].data[4] = (i->op[Carrier].attack & 0x0f) << 4;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
221 inst[n].data[4] += i->op[Carrier].decay & 0x0f;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
222 // Modulator...
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
223 inst[n].data[3] = (i->op[Modulator].attack & 0x0f) << 4;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
224 inst[n].data[3] += i->op[Modulator].decay & 0x0f;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
225
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
226 // Carrier "Release / Sustain" register
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
227 inst[n].data[6] = (i->op[Carrier].release & 0x0f) << 4;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
228 inst[n].data[6] += i->op[Carrier].sustain & 0x0f;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
229 // Modulator...
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
230 inst[n].data[5] = (i->op[Modulator].release & 0x0f) << 4;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
231 inst[n].data[5] += i->op[Modulator].sustain & 0x0f;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
232
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
233 // Channel "Feedback / Connection" register
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
234 inst[n].data[0] = (i->op[Carrier].feedback & 7) << 1;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
235
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
236 // Carrier/Modulator "Wave Select" registers
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
237 inst[n].data[8] = i->op[Carrier].waveform & 3;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
238 inst[n].data[7] = i->op[Modulator].waveform & 3;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
239 }