-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathio.cpccSound.h
79 lines (57 loc) · 1.79 KB
/
io.cpccSound.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* *****************************************
* File: io.cpccSound.h
* Purpose: Portable (cross-platform), light-weight, sound class
* *****************************************
* Library: Cross Platform C++ Classes (cpcc)
* Copyright: 2016 StarMessage software.
* License: Free for opensource projects.
* Commercial license for closed source projects.
* Web: http://www.StarMessageSoftware.com/cpcclibrary
* email: sales -at- starmessage.info
* *****************************************
*/
#pragma once
#include "cpccUnicodeSupport.h"
#ifdef _WIN32
//typedef int cpccSoundIdType;
#include <windows.h>
#elif defined(__APPLE__)
//typedef char * cpccSoundIdType;
#import <AppKit/AppKit.h>
#endif
class cpccSound
{
private: // data
#if defined(__APPLE__)
NSSound *nsSoundPtr = NULL;
#endif
public: // ctors
cpccSound()
{
#if defined(__APPLE__)
if (nsSoundPtr)
{ // [nsSoundPtr release];
nsSoundPtr = NULL;
}
#endif
}
~cpccSound(void) { stop(); }
public:
#ifdef _WIN32
void playResourceSound(const int aSoundResource, const bool loop);
#elif defined(__APPLE__)
void playResourceSound(NSString *aBundleClass, NSString *aResourceFile, const bool loop);
void playSoundFile(NSString *aFilename, const bool loop);
#endif
void playSoundFile(const cpcc_char *aFilename, const bool loop);
void stop(void);
static void beep(void)
{
#ifdef _WIN32
Beep( 750, 500 );
#elif defined(__APPLE__)
// NSBeep(); seems to have been forgotten and does not produce any sound
[[NSSound soundNamed:@"Basso"]play];
#endif
}
};