|
jschell wrote: why do you consider that ideal rather than going directly to either cmd or a linux shell? I did not claim it is ideal, it is just another tool that I find useful at times. I run cmd, Powershell and Linux in "normal" windows also.
|
|
|
|
|
Using the cmd.exe window, the bug is gone.
|
|
|
|
|
I am trying to play an mp3 file from a WinAPI/C++ application. I'm using 32-bit MinGW on Windows 10.
I found an example program which uses the MCI (winmm) interface to play the file; I found an example command-line program which implements this using mciSendString() calls...
I had some problems handling paths to the mp3 file, and *thought* I had fixed it by converting the paths to 8.3 short format... the command-line program plays the files just fine, but when I import exactly the same code into my WinAPI dialog-box application, although the MCI functions all return success, no sound plays...
Does anyone have any idea what is missing here?? Or does this library just not work from a Windows dialog app?
Here's the code:
{
static char short_str[MAX_WAVE_FILE_LEN+1] = "" ;
CMP3_MCI MyMP3;
int result = GetShortPathName (wave_name, short_str, MAX_WAVE_FILE_LEN);
syslog("short: %d: [%s]\n", result, short_str);
DWORD lerror = MyMP3.Load(short_str);
DWORD serror = MyMP3.Play();
syslog("MCI: Load: %08X, Play: %08X\n", lerror, serror);
}
And here are the load and play functions from his MCI class:
inline MCIERROR Load()
{
std::string szCommand = "open \"" + GetFileName() + "\" type mpegvideo alias " + GetFileName();
return mciSendString(szCommand.c_str(), NULL, 0, 0);
}
inline MCIERROR Load(char *szFileName)
{
m_szFileName = szFileName;
return Load();
}
inline MCIERROR Play()
{
std::string szCommand = "play " + GetFileName() + " from 0";
return mciSendString(szCommand.c_str(), NULL, 0, 0);
}
|
|
|
|
|
This is a Simple C++ DirectShow MP3 Player Class for native C++ and .NET.
This is an example on how to use the Mp3 class.
<h1>include "Mp3.h"</h1>
void main()
{
::CoInitialize(NULL);
std::wcout<<L"Enter the MP3 path: ";
std::wstring path;
getline(wcin, path);
std::wcout<<path<<std::endl;
Mp3 mp3;
int status = 0;
if(mp3.Load(path.c_str()))
{
status = SV_LOADED;
}
else {
}
if(mp3.Play())
{
status = SV_PLAYING;
}
else {
}
if(mp3.Stop())
{
status = SV_STOPPED;
}
else {
}
::CoUninitialize();
}
modified 12-May-23 8:19am.
|
|
|
|
|
Well, all of the Windows-supported libraries present problems, especially if one is building using MinGW rather than Visual C++. Generally, they cannot be built at all without a massive amount of hacking the code bases to make them MinGW-compatible. No DirectShow apps will build, neither will the more-recent MS audio interface (don't recall the name at the moment).
However, I found a freeware library called zplay, which is easy to build, open source, and nice, compact code... it also has the ability to play other formats, such as flac... so I'll just go with that...
libZPlay multimedia library (Win32)[^]
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
Member 14968771 wrote: Here is definition of function taken from an example:
void SettingsDialog::pairingDone(QBluetoothAddress ,QBluetoothLocalDevice::Pairing)
I need to verify the actual address and having a tough time understanding this "syntax".
I do understand that the function parameters are "objects" but when I RTFM it really does not explain the syntax. All I get is "passing by value or by reference" - so what are the parameters actually passed to "pairingDone" ?
If possible
please show me how to get the address - post actual C code
point me to good resource to learn something about the syntax
recommend a C++ book so I can retire my "K&R" book
I can do without opinions and innuendos insults or RTFM replies.
Keep Calm and Carry On
modified 10-May-23 15:25pm.
|
|
|
|
|
You should have Stroustrups's "The C++ Programming Language", which is the C++ equivalent of K&R for C. https://www.amazon.com/C-Programming-Language-4th/dp/0321563840 It's not cheap, but its the bible of C++. Stroustrup invented it after all.
I lost my copy of K&R a long time ago. My version was pre-ANSI, which meant that there was no void , and no function prototypes, among other things, and function definitions looked like
foo(x, y)
int x;
int y;
{
} I'd be willing to bet even K&R that old explained the difference between "pass by value" and "pass by reference" i.e the difference between making a copy of an object and passing that to the function (pass by value, possibly expensive), and passing a pointer to a an object (pass by reference, usually cheap. But at least in C may lead to off-by-one and other assorted bugs. NB. An array is always passed by reference.). In C++ we have references . [Reference declaration - cppreference.com]
(https://en.cppreference.com/w/cpp/language/reference)
Keep Calm and Carry On
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
Member 14968771 wrote: So what is "QBluetoothAddress" - value or reference?
Who knows? It could be a reference, a pointer or an object. e.g.
class myClass;
using mc = myClass &; using mc = myClass *; typedef myClass mc; using mc = myClass &&
You need to check the documentation for whatever SettingsDialog::pairingDone() is to see. I tried, but googling for SettingsDialog::pairingDone did not return anything useful. Nor did looking at QBluetooth (or something similar).
Keep Calm and Carry On
|
|
|
|
|
k5054 wrote: I lost my copy of K&R a long time ago. My version was pre-ANSI, which meant that there was no void,
Well that is interesting and true.
The C Programming Language First Edition : Dennis Ritchie, Brian Kernighan : Free Download, Borrow, and Streaming : Internet Archive[^]
The copyright was 1978 and wikipedia states
"By the time Bjarne Stroustrup began his work on C++ in 1979–1980,[citation needed] void and void pointers were part of the C language dialect supported by AT&T-derived compilers"
Void type - Wikipedia[^]
So even though the book didn't have it, it seems likely that it was added very shortly after the book actually went to the printers.
When I was looking up the above the K&R has a 'Second Edition' but with version with pre and post ANSI C, which would seem confusing to me. I have the Pre edition.
But also appears there is no edition beyond that?
|
|
|
|
|
A QBluetoothAddress is presumably a bluetooth device address. So a 48-bit integer essentially, but with a specific interpretation as being a bluetooth address.
It being "an address" is orthogonal to being passed by reference or by value or pointers or anything like that. With the method signature being like that though, it will be passed by value.
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
This: QBluetoothAddress Class | Qt Bluetooth 5.15.13[^], the key detail being:
Quote: This class holds a Bluetooth address in a platform- and protocol-independent manner. .
But your function definition is incomplete, and would more likely be something like:
void SettingsDialog::pairingDone(QBluetoothAddress& qbaddr, QBluetoothLocalDevice::Pairing& pair)
where qbaddr is a reference to (i.e. address of) a QBluetoothAddress object, and pair is a reference to a QBluetoothLocalDevice::Pairing object, see QBluetoothLocalDevice Class | Qt Bluetooth 6.5.0[^].
It seems to me the main issue you need to address is gaining a good understanding of C++ and its syntax. The same probably holds true for Qt and its Bluetooth classes.
|
|
|
|
|
Member 14968771 wrote: All I get is "passing by value or by reference" - so what are the parameters actually passed to "pairingDone" ?
That refers to how they are passed.
You are asking what they are.
You have a method. It takes parameters.
To use the method you must do the following
1. Understand the execution flow required to use the method
2. Understand the type of the parameters.
3. Understand how to create the parameters.
4. Understand what the method does.
Member 14968771 wrote: point me to good resource to learn something about the syntax
Based on what you posted you do not have enough knowledge about C++ to begin to use the function you posted above. (Using bluetooth is not easy for an experienced programmer.)
Your questions are valid but even if someone provided an exact answer you would still need more information to use everything else required to correctly use the method that you posted.
But if you want you can use the following in google. Those examples do explain what the first parameter is and what to do with it. But then you need the other parameter. And everything else I mentioned above.
QBluetoothAddress examples
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
Member 14968771 wrote: I am NOT and never claim to be an expert in C++.
No one ever said you did, but your lack of understanding of the language means that you are wasting your time trying to work this project which is obviously well beyond your knowledge level.
Member 14968771 wrote: Here is what I got from Mrs Google example
void SettingsDialog::pairingDone(QBluetoothAddress ,QBluetoothLocalDevice::Pairing)
Where exactly did you get that, because as it stands it makes no sense?
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
You seem to be under the impression that everybody here is both out to get you and here to do your work for you: neither is the case.
Unfortunately for you everybody here is a volunteer, and most do not take kindly to having their time wasted and abuse HURLED at them and respond in an appropriate manner.
I hope that you can take your time here as a learning experience, but from your question and comment history, I guess that is unlikely. If this has been your attitude on the "other sites" that threw you off as well, I can understand why they didn't want you around either ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Member 14968771 wrote: PLEASE QUIT harassing me about my "lack of basic knowledge" - such continuing (!) harassment just does not fit this forum purpose . ( read how to answer the question INSTRUCTIONS and follow them PLEASE ) I am just learning as I go because I believe that it is better to start with coding a real application and if it does not perform as expected then RTFM and or ask for help.
I am not harassing you.
I am however trying to make sense of what you are asking from the context of what you posted.
I have about 15 years of C++ experience and with C experience before that (but quite a few years ago) along with with decades of experience in other programming language.
With that experience I would expect that getting bluetooth code to work would be a challenge for me.
Your lack of experience in understand fundamentals of programming, not just in C++, means that attempting to explain everything that you would need to know how to proceed with a bluetooth project is just not worth the time to even start. That is not a reflection on you. Anyone and everyone, even a super genius, would still need to know more fundamentals before they could even start.
But even so I did outline exactly what you would need to do to program the project.
Member 14968771 wrote: all I am asking - which way is up and WHY ?
No idea what you are asking. But my previous outline provides the framework for which you would need to proceed.
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
Well, the documentation[^] is written in English.
You may also find some tutorials on the web, check out, for instance: C++ Ranged for Loop (With Examples)[^].
Finally, in your scenario, it could be
QList<QBluetoothHostInfo> adapters = QBluetoothLocalDevice::allDevices()
for (auto & adapter : adapters)
{
} or
QList<QBluetoothHostInfo> adapters = QBluetoothLocalDevice::allDevices()
for (const auto & adapter : adapters)
{
}
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
In some ways it is just like an ordinary for loop. The difference being that the variable is intialised and incremented automatically. Given the following:
for (int foo : arayOfIntegers)
{
}
Think of it as:
foreach item in arayOfIntegers
BEGIN
set foo to the value of the next item in the list
do stuff with foo
END
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
It is just a loop variable, the same as in a standard for loop.
|
|
|
|