Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/formats/flacfile.cpp: Add support for cassette images in flac format. #11841

Merged
merged 8 commits into from
Dec 17, 2023

Conversation

wilbertpol
Copy link
Contributor

No description provided.

@ajrhacker
Copy link
Contributor

Adding ext_includedir("flac") to formats.lua may fix the link error here.

@ICEknigh7
Copy link
Contributor

Thank you so much for implementing this!

@wilbertpol
Copy link
Contributor Author

Adding ext_includedir("flac") to formats.lua may fix the link error here.

Thanks, that fixed the errors.

Comment on lines 18 to 19
cassette_image::error flacfile_identify(cassette_image *cassette, cassette_image::Options *opts)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this function static as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made flacfile_identify static

Comment on lines 60 to 62
std::unique_ptr<int16_t[]> samples[MAX_CHANNELS];
int16_t* channel_samples[MAX_CHANNELS];
for (int channel = 0; channel < channels; channel++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent formatting – the right-associative unary * qualifier should go to the right of the space.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 70 to 72
cassette_image::error err = cassette->put_samples(channel, 0.0,
(double)total_samples/decoder.sample_rate(), total_samples, 2,
channel_samples[channel], cassette_image::WAVEFORM_16BITLE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the decoder produce little Endian samples irrespective of host Endianness, or is it native word format? I’d rather avoid introducing more Endianness bugs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Looking at the code in flac.cpp, the flac library code produces data in host endianness. I have changed the decode call to swap endianness when the host is big endian so the generated samples should always be little endian.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code makes copies of the entire file into memory for identifying the format and decoding. Would it be better to add an accessor to cassette_image to obtain a util::random_read & so you can seek it to zero and give it to the FLAC decoder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would reduce some memory usage; updated the PR.

@cuavas cuavas merged commit b9fbc6e into mamedev:master Dec 17, 2023
5 checks passed
@wilbertpol wilbertpol deleted the cass_flac branch December 17, 2023 08:59
einstein95 pushed a commit to einstein95/mame that referenced this pull request Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants