kopia lustrzana https://github.com/xdsopl/robot36
changed frames to seconds
rodzic
1da9331bb1
commit
2ceabe4081
6
encode.c
6
encode.c
|
@ -57,14 +57,12 @@ int main(int argc, char **argv)
|
|||
|
||||
uint8_t *pixel = (uint8_t *)ppm_p + strlen(ppm_head);
|
||||
|
||||
float rate = atoi(argv[3]);
|
||||
int frames = 37.5 * rate;
|
||||
if (!open_pcm_write(&pcm, argv[2], atoi(argv[3]), 1, frames)) {
|
||||
if (!open_pcm_write(&pcm, argv[2], atoi(argv[3]), 1, 37.5)) {
|
||||
fprintf(stderr, "couldnt open output %s\n", argv[2]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rate = rate_pcm(pcm);
|
||||
float rate = rate_pcm(pcm);
|
||||
channels = channels_pcm(pcm);
|
||||
|
||||
buff = (short *)malloc(sizeof(short)*channels);
|
||||
|
|
4
pcm.c
4
pcm.c
|
@ -53,12 +53,12 @@ int open_pcm_read(pcm_t **p, char *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int open_pcm_write(pcm_t **p, char *name, int rate, int channels, int frames)
|
||||
int open_pcm_write(pcm_t **p, char *name, int rate, int channels, float seconds)
|
||||
{
|
||||
if (strstr(name, "plughw:") == name || strstr(name, "hw:") == name || strstr(name, "default") == name)
|
||||
return open_alsa_write(p, name, rate, channels);
|
||||
if (strstr(name, ".wav") == (name + (strlen(name) - strlen(".wav"))))
|
||||
return open_wav_write(p, name, rate, channels, frames);
|
||||
return open_wav_write(p, name, rate, channels, seconds);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
2
pcm.h
2
pcm.h
|
@ -24,7 +24,7 @@ int channels_pcm(pcm_t *);
|
|||
int read_pcm(pcm_t *, short *, int);
|
||||
int write_pcm(pcm_t *, short *, int);
|
||||
int open_pcm_read(pcm_t **, char *);
|
||||
int open_pcm_write(pcm_t **, char *, int, int, int);
|
||||
int open_pcm_write(pcm_t **, char *, int, int, float);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
3
wav.c
3
wav.c
|
@ -123,7 +123,7 @@ int open_wav_read(pcm_t **p, char *name)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int open_wav_write(pcm_t **p, char *name, int rate, int channels, int frames)
|
||||
int open_wav_write(pcm_t **p, char *name, int rate, int channels, float seconds)
|
||||
{
|
||||
wav_t *wav = (wav_t *)malloc(sizeof(wav_t));
|
||||
wav->close = close_wav;
|
||||
|
@ -131,6 +131,7 @@ int open_wav_write(pcm_t **p, char *name, int rate, int channels, int frames)
|
|||
wav->rate = rate_wav;
|
||||
wav->channels = channels_wav;
|
||||
wav->rw = write_wav;
|
||||
int frames = seconds * rate;
|
||||
wav->size = frames * channels * sizeof(short) + sizeof(wav_head_t);
|
||||
if (!mmap_file_rw(&wav->p, name, wav->size)) {
|
||||
fprintf(stderr, "couldnt open wav file %s!\n", name);
|
||||
|
|
2
wav.h
2
wav.h
|
@ -10,5 +10,5 @@ You should have received a copy of the CC0 Public Domain Dedication along with t
|
|||
#define WAV_H
|
||||
#include "pcm.h"
|
||||
int open_wav_read(pcm_t **, char *);
|
||||
int open_wav_write(pcm_t **, char *, int, int, int);
|
||||
int open_wav_write(pcm_t **, char *, int, int, float);
|
||||
#endif
|
||||
|
|
Ładowanie…
Reference in New Issue