YARP
Yet Another Robot Platform
SoundFile.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_SIG_SOUNDFILE_H
11 #define YARP_SIG_SOUNDFILE_H
12 
13 #include <yarp/sig/Sound.h>
14 #include <cstdio>
15 
16 namespace yarp {
17  namespace sig{
18  namespace file {
25  bool YARP_sig_API read(Sound& dest, const char *src);
26 
33  bool YARP_sig_API write(const Sound& src, const char *dest);
34 
36  {
37  private:
38  FILE *fp;
39  size_t index;
40  char fname [255];
41  struct
42  {
43  int freq;
44  int channels;
45  int bits;
46  int samples;
48  } soundInfo;
49 
50  public:
52  {
53  fp = 0;
54  index=0;
55  fname[0]=0;
56  }
57 
59  {
60  if (fp)
61  {
62  close();
63  fp=0;
64  }
65  }
66 
67  bool open(const char *filename);
68  bool close();
69  size_t readBlock(Sound& dest, size_t block_size);
70  bool rewind(size_t sample_offset=0);
71  size_t getIndex();
72  };
73  }
74  }
75 }
76 
77 #endif // YARP_SIG_SOUNDFILE_H
yarp::sig::file::read
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:827
yarp::sig::file::soundStreamReader::freq
int freq
Definition: SoundFile.h:43
yarp::sig::file::soundStreamReader::channels
int channels
Definition: SoundFile.h:44
yarp::sig::file::soundStreamReader::bits
int bits
Definition: SoundFile.h:45
yarp::sig::file::soundStreamReader::samples
int samples
Definition: SoundFile.h:46
YARP_sig_API
#define YARP_sig_API
Definition: api.h:19
yarp::sig::file::soundStreamReader::~soundStreamReader
~soundStreamReader()
Definition: SoundFile.h:58
yarp::sig::file::soundStreamReader::data_start_offset
size_t data_start_offset
Definition: SoundFile.h:47
yarp::sig::file::soundStreamReader
Definition: SoundFile.h:36
yarp::sig::Sound
Class for storing sounds.
Definition: Sound.h:28
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::sig::file::soundStreamReader::soundStreamReader
soundStreamReader()
Definition: SoundFile.h:51
yarp::sig::file::write
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:971
Sound.h