1 | /*
|
---|
2 | * (C) Chris Wohlgemuth 2002-2003
|
---|
3 | *
|
---|
4 | */
|
---|
5 | /*
|
---|
6 | * This program is free software; you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation; either version 2, or (at your option)
|
---|
9 | * any later version.
|
---|
10 | *
|
---|
11 | * This program is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 | *
|
---|
16 | * You should have received a copy of the GNU General Public License
|
---|
17 | * along with this program; see the file COPYING. If not, write to
|
---|
18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
19 | */
|
---|
20 | /*
|
---|
21 | * If you need another license for your project/product contact me at
|
---|
22 | *
|
---|
23 | * http://www.os2world.com/cdwriting
|
---|
24 | * http://www.geocities.com/SiliconValley/Sector/5785/
|
---|
25 | */
|
---|
26 |
|
---|
27 | /*
|
---|
28 | * This file was generated by the SOM Compiler and Emitter Framework.
|
---|
29 | * Generated using:
|
---|
30 | * SOM Emitter emitctm: 2.42
|
---|
31 | */
|
---|
32 |
|
---|
33 | #ifndef SOM_Module_cwaudio_Source
|
---|
34 | #define SOM_Module_cwaudio_Source
|
---|
35 | #endif
|
---|
36 | #define CWAudio_Class_Source
|
---|
37 | #define M_CWAudio_Class_Source
|
---|
38 |
|
---|
39 | #define INCL_PM
|
---|
40 | #define INCL_DOS
|
---|
41 | #define INCL_WINWORKPLACE
|
---|
42 | #define INCL_MMIOOS2
|
---|
43 | #define INCL_DOSDEVIOCTL
|
---|
44 | #define INCL_MCIOS2
|
---|
45 | #define INCL_ERRORS
|
---|
46 |
|
---|
47 | #include <os2.h>
|
---|
48 | #include <stdio.h>
|
---|
49 | #include <string.h>
|
---|
50 | #include "os2me.h"
|
---|
51 |
|
---|
52 | #define MRFALSE 1
|
---|
53 |
|
---|
54 | ULONG thisPtr=1234;
|
---|
55 | char chrDevice[20];
|
---|
56 |
|
---|
57 | int closeTrack(void)
|
---|
58 | {
|
---|
59 | char retMsg[20];
|
---|
60 | APIRET rc;
|
---|
61 | unsigned char chrCommand[CCHMAXPATH*2];
|
---|
62 |
|
---|
63 | fprintf(stderr, "Trying to close file...\n");
|
---|
64 | sprintf(chrCommand,"close wave%d wait", thisPtr);
|
---|
65 | rc=mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
66 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
67 | fprintf(stderr, " !!! Error while closing file.\n");
|
---|
68 | return 1;
|
---|
69 | }
|
---|
70 | return 0;
|
---|
71 | }
|
---|
72 |
|
---|
73 | int main()
|
---|
74 | {
|
---|
75 | unsigned char chrCommand[CCHMAXPATH*2];
|
---|
76 | char name[CCHMAXPATH]="J:\\MMOS2\\timiditymcd_2104\\midi\\impromptu.mid";
|
---|
77 | ULONG ulNameSize;
|
---|
78 | char retMsg[20];
|
---|
79 | APIRET rc;
|
---|
80 | int iTime;
|
---|
81 | ULONG hwnd=0;
|
---|
82 |
|
---|
83 | fprintf(stderr, "Started program...\n");
|
---|
84 |
|
---|
85 | strncpy(chrDevice,"SEQUENCER", sizeof(chrDevice));
|
---|
86 |
|
---|
87 | /* Open audio file */
|
---|
88 | fprintf(stderr, "Trying to open file %s...\n", name);
|
---|
89 | sprintf(chrCommand,"open \"%s\" type %s alias wave%d SHAREABLE wait",name, chrDevice, thisPtr);
|
---|
90 | rc = mciSendString( chrCommand, retMsg, sizeof(retMsg), hwnd, 0);
|
---|
91 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
92 | fprintf(stderr, " !!! Error while opening %s\n", name);
|
---|
93 | return MRFALSE;
|
---|
94 | }
|
---|
95 | fprintf(stderr, "File opened.\n");
|
---|
96 |
|
---|
97 | /* Set time format */
|
---|
98 | fprintf(stderr, "Setting time format.\n");
|
---|
99 | sprintf(chrCommand,"SET wave%d TIME FORMAT MILLISECONDS wait", thisPtr);
|
---|
100 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
101 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
102 | fprintf(stderr, " !!! Error while setting time format\n");
|
---|
103 | closeTrack();
|
---|
104 | return MRFALSE;
|
---|
105 | }
|
---|
106 |
|
---|
107 |
|
---|
108 | fprintf(stderr, "Getting length of audio track.\n");
|
---|
109 | sprintf(chrCommand,"STATUS wave%d LENGTH WAIT", thisPtr);
|
---|
110 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
111 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
112 | fprintf(stderr, " !!! Error while getting length\n");
|
---|
113 | closeTrack();
|
---|
114 | return MRFALSE;
|
---|
115 | }
|
---|
116 |
|
---|
117 | fprintf(stderr, "Starting track.\n");
|
---|
118 | sprintf(chrCommand,"play wave%d ", thisPtr);
|
---|
119 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
120 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
121 | fprintf(stderr, " !!! Error while playing\n");
|
---|
122 | closeTrack();
|
---|
123 | return MRFALSE;
|
---|
124 | }
|
---|
125 |
|
---|
126 | DosSleep(5000);
|
---|
127 | sprintf(chrCommand,"stop wave%d wait", thisPtr);
|
---|
128 | mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
129 |
|
---|
130 | #if 0
|
---|
131 | /* Set volume */
|
---|
132 | sprintf(chrCommand,"SET wave%d AUDIO VOLUME %d wait", thisPtr, globalClassVolume);
|
---|
133 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
134 | /* Not able to set the volume isn't that bad so don't quit in case of an error. */
|
---|
135 | #if 0
|
---|
136 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
137 | WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
|
---|
138 | return MRFALSE;
|
---|
139 | }
|
---|
140 | #endif
|
---|
141 | sprintf(chrCommand,"stop wave%d wait", thisPtr);
|
---|
142 | mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
143 | #endif
|
---|
144 |
|
---|
145 |
|
---|
146 | closeTrack();
|
---|
147 |
|
---|
148 | return 0;
|
---|
149 | }
|
---|
150 |
|
---|