JeffAlyanak/pcm2pwm

Can i convert a 16-bit PCM to PWM by this tool?

yxdming opened this issue · 3 comments

I have a PCM file whild sample rate is 250000Hz and bits per sample is 16 bit.
Can i convert it to PCM with this tool. It seam that just change the type of "c" in convert.c.

int count = 0; // Count period between zero cross-overs.
int flipState = 1; // High or low state.
int oldState = 1; // Previous state.
int newLine = 0; // Used to limit each output line to 16 bytes.
int i = 1; // Byte position counter.

--------------------------- change this line to short in c = 0;
unsigned char c = 0; // Byte buffer.

It certain would be possible to detect bit-depths other that 8-bit and include logic for converting those as well.

However, since there are so many tools out there that already do these conversions, I decided to leave that feature out. "Write programs that do one thing and do it well."

Programs like Audacity can do this type of conversion very easily and they'll apply more advanced dithering algorithms to ensure the best quality conversion.

Thank you for replay so quickly.
@JeffAlyanak

No problem.