]>
Commit | Line | Data |
---|---|---|
1 | // -------------------------------------------------------------------------- | |
2 | // Name: test_med.cpp | |
3 | // Purpose: | |
4 | // Date: 08/11/1999 | |
5 | // Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999 | |
6 | // CVSID: $Id$ | |
7 | // -------------------------------------------------------------------------- | |
8 | #include <wx/app.h> | |
9 | #include <wx/wfstream.h> | |
10 | #include <wx/frame.h> | |
11 | #include "../lib/sndoss.h" | |
12 | #include "../lib/sndwav.h" | |
13 | #include "../lib/sndaiff.h" | |
14 | #include "../lib/sndulaw.h" | |
15 | ||
16 | wxSoundStreamOSS *oss_dev; | |
17 | wxInputStream *f_input; | |
18 | wxSoundStreamUlaw *ulaw_codec; | |
19 | ||
20 | class MySoundStream: public wxSoundStream { | |
21 | public: | |
22 | wxSoundStream& Read(void *buffer, size_t len) { return *this; } | |
23 | wxSoundStream& Write(const void *buffer, size_t len) { return *this; } | |
24 | ||
25 | bool StartProduction(int evt) { return FALSE; } | |
26 | bool StopProduction() { return FALSE; } | |
27 | ||
28 | void SetDuplexMode(bool on) {} | |
29 | ||
30 | void OnSoundEvent(int evt) { | |
31 | char buffer[2048]; | |
32 | ||
33 | f_input->Read(buffer, sizeof(buffer)); | |
34 | ulaw_codec->Write(buffer, sizeof(buffer)); | |
35 | } | |
36 | }; | |
37 | ||
38 | class MyApp: public wxApp { | |
39 | bool OnInit() { | |
40 | wxSoundFormatUlaw ulaw; | |
41 | MySoundStream strm; | |
42 | ||
43 | oss_dev = new wxSoundStreamOSS(); | |
44 | f_input = new wxFileInputStream(argv[1]); | |
45 | ||
46 | if (oss_dev->GetError() != wxSOUND_NOERR) { | |
47 | wxPrintf("No device\n"); | |
48 | return FALSE; | |
49 | } | |
50 | ||
51 | ulaw.SetSampleRate(8000); | |
52 | ulaw_codec = new wxSoundStreamUlaw(*oss_dev); | |
53 | ulaw_codec->SetSoundFormat(ulaw); | |
54 | ||
55 | oss_dev->SetEventHandler(&strm); | |
56 | oss_dev->StartProduction(wxSOUND_OUTPUT); | |
57 | ||
58 | while (1) { | |
59 | // wxYield(); | |
60 | strm.OnSoundEvent(0); | |
61 | } | |
62 | return TRUE; | |
63 | } | |
64 | }; | |
65 | ||
66 | IMPLEMENT_APP(MyApp) |