floriscreyf / mp3-decoder Goto Github PK
View Code? Open in Web Editor NEWDecodes MPEG-1 Layer 3 files
License: GNU General Public License v2.0
Decodes MPEG-1 Layer 3 files
License: GNU General Public License v2.0
problem - cannot get length of buffer
you are using std::ifstream, why not use std::vector or std::string?
Also, such a mix is a sign of error-prone code style.
you may easily forget delete[] operator.
Do it modern way!
here is replacement version, 4 lines of code, each does bunch of things
Logic is extremely clear:
1. open file
2. create buffer
3. read file to buffer
4 return it
std::string get_file(const std::string& fileName) {
std::ifstream dataFile(dir, std::ios::in | std::ios::binary | std::ios::ate);
std::string dataBuffer(dataFile.tellg(),0);
dataFile.seekg(0, std::ios::beg).read(&dataBuffer[0], dataBuffer.size());
return std::move( dataBuffer );
}
Hi, I commented out stream()
definition and use in main.cpp
but that was not enough to make it compile.
Severity Code Description Project File Line Suppression State
Error LNK2005 "struct <unnamed-type-band_index_table> band_index_table" (?band_index_table@@3U<unnamed-type-band_index_table>@@A) already defined in main.obj mp3-decoder Z:\mp3-decoder-master\mp3.obj 1
Error LNK2005 "struct <unnamed-type-band_width_table> band_width_table" (?band_width_table@@3U<unnamed-type-band_width_table>@@A) already defined in main.obj mp3-decoder Z:\mp3-decoder-master\mp3.obj 1
Error LNK2005 "struct <unnamed-type-quad_table_1> quad_table_1" (?quad_table_1@@3U<unnamed-type-quad_table_1>@@A) already defined in main.obj mp3-decoder Z:\mp3-decoder-master\mp3.obj 1
Error LNK1169 one or more multiply defined symbols found mp3-decoder Z:\mp3-decoder-master\Debug\mp3-decoder.exe 1
I'm not experienced enough to be able to solve this. I'm guessing all these are related:
PS: also id3.cpp was causing failure in line 111 while (!std::regex_match((string){(char)buffer[i]}, re) && i < size) {
, which I turned into
string istep;
istep = (char)buffer[0];
while (!std::regex_match(istep, re) && i < size) {
istep = (char)buffer[i];
The offending line is
set_side_info(&buffer[4]);
which fails to consider the case in which the CRC bit is 0, which would make the index 6 instead of 4.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.