Strange error returned from mciSendString - Can anyone help? - audio

A few months ago I added audio recording to a MFC app that I'm working on. This turned out to be easy enough and after an hour or two the code was working on my PC and on a couple of the customers test machines (one running XP the other Vista). Recently however one of their test machines was upgraded and now the recording feature refuses to work.
The basic code to start the recording is ..
mcierr=mciSendString("open new type waveaudio alias mysound",tmpstr,80,NULL);
mcierr=mciSendString("set mysound time format ms bitspersample 8 samplespersec 11025",tmpstr,80,NULL);
mcierr=mciSendString("record mysound",tmpstr,80,NULL);
which appears to work fine. To stop recording the following code is executed ..
mcierr=mciSendString("stop mysound",tmpstr,80,NULL);
mcierr=mciSendString("save mysound C:\\filename.wav",tmpstr,80,NULL);
mcierr=mciSendString("close mysound",tmpstr,80,NULL);
The following error occurs when the "save mysound C:\filename.wav" instruction is sent. The error returned is ..
MCI Error A parameter or value was specified twice. Only specify it once.
But I can't see any error in what I am sending and that error doesn't make sense. Is it possible that the error is because the program is trying to record using a format the PC doesn't support ?
Thanks for your time
Ian

OK I managed to find a solution to this. This line in the code ..
mcierr=mciSendString("save mysound C:\\filename.wav",tmpstr,80,NULL);
works fine on my development PC running XP but causes errors on some test PC's running XP and on all of them running Vista. The error goes away however if the filename itself is put within quotes like this ..
mcierr=mciSendString("save mysound "C:\\filename.wav"",tmpstr,80,NULL);
Now the code runs fine on all the XP and Vista PC's it has been tested on.
Ian

A detail more is necessary to have it working.
Please watch the double "" before and after the file name:
mcierr=mciSendString("save mysound ""C:\\filename.wav""",tmpstr,80,NULL);
This is fine, too:
mcierr=mciSendString(#"save mysound ""C:\filename.wav""",tmpstr,80,NULL);
With these double quotation marks the code works on my Windows 7 now.

Related

Python 3.7: Pygsheets get all record stopped working

I have several scripts using pygsheets to get information from google sheets. Today they have stopped working without any errors or exceptions being noted.
Debuging Attempts:
Tried running in different ways
1. Visual Studio Code - just stops working no errors or exceptions. Debugged to line (wks = sh.worksheet('title', tabs))
2. command prompt - pops a window up that states "Python has stopped working: A problem caused the program to stop working correctly. Please close the program"
3. manually in IDLE - locks up at (wks = sh.worksheet('title', tabs))
4. Ran code on a different machine: worked fine.
So, I know it has to do with something on my machine, but not sure where to start looking. Any suggestions are welcome.
import pygsheets
from pygsheets import Worksheet
gsheet = pygsheets.authorize(service_file = 'client_secret2.json')
sh = gsheet.open('Google_file_name')
wks = sh.worksheet('title', 'tab_name')
results = wks.get_all_records()
The last line is where everything stops. Again, no errors or exceptions.
I know this doesn't really solve the issue, nor do I have experience with pygsheets, but from my experience with gspread the issue appears to be connection-related. I have had this exact issue with gspread's get_all_values module and, as you experienced, it suddenly stops working without any changes to the code and without terminating or returning any errors. The issue often disappears when the program is run again minutes or days later.
The only other time I have experienced freezing/hanging (recently in Python) is with TCP connections...

Cannot export Sketch file to Zeplin. Forbidden 403 Error

I am new to both Sketch and Zeplin.
When I am exporting my artboard by pressing cmd + E everything seems to be fine.
Zeplin prompts me to select a project. When I select a project to export into, I get a notification saying "Exported 1 screen(s) to ProjectName".
However a short time later it gives me a error dialog and I cannot see any screen in my Zeplin project.
Here is the error dialog:
Note: My sketch app is in its trial period. But it's functioning well, besides this problem.
Thanks to #zeplin_io's fast support on Twitter I solved my problem.
Adjusting my Mac's Date & Time Pref.s to Auto solved issue.

ADB debugging in Android Studio - some basic issues

Ok, I've squeaked by not needing to use ADB in the Studio, since back
in the 'beta' days of AS. (Just lucky, I guess.) But now, I need to
debug a crashing app.
I've gotten this far:
Learned how to put adb.exe on my Window's 'PATH'
(so that it's invokable from cmd-window):
My path-entry was: C:\Users\David\AppData\Local\Android\sdk\platform-tools
Am assuming that 'logcat' lives on Android device (I was incorrectly guessing it lives on the development machine). I'm assuming this, because when I dis-connect
the USB-cable and enter 'adb logcat' is says waiting for device.
Ok, now my (next) issue: When I fire up the app-being-developed, I'm getting
"Unfortunately has stopped"...which I'm assuming is an app-crash.
And, while I'm looking at 'logcat', I can see a stack-trace flow by. But
as I try to scroll-back to read it, logcat keeps dribbling in more data.
So, how do I tell it to shutup...so that I can look at a static copy
of logcat and see what has happened (without more data dribbling in)?
[If there is other beginner related info, beyond this question, feel free to
to add that info...I'm clearly in need of basic 'adb-related' enlightenment.]
TIA.
Cheers...

SQL CE 4.0 Error - ReleaseHandleFailed was detected

I keep getting this error in the dev environment - 'A SafeHandle or CriticalHandle of type 'System.Data.SqlServerCe.HasSafeHandle' failed to properly release the handle with value ...."
It is in a VS 2012 Winforms application and only seems to happen if a particular piece of code is run at some point. The error shows after the form is closed, but I can't understand why. It only happens in the dev environment and seems to be OK in the compiled version, but I don't want to just ignore it.
The error seems to be caused by this line of code, although weirdly at this point in time I have not opened a connection to the SQL ce database and the directory it is searching in does not have the SQL ce database in it. It is mearly reading in txt files that match a pattern
string[] fileNames = Directory.GetFiles(importDirectory, "BucketHistory*.txt")
I'll do some more digging tomorrow, it's late now, and I have no idea what is causing it.
Any pointers ??!
Turns out I was having a bit of brain fade yesterday. Been working too long hours !
For anyone interested, the problem was that I was opening a connection, then copying the file and running a shrink whilst the connection was still open. It had nothing to do with that line of code.
I would have expected the copy to have thrown an exception, but it didn't appear to. Oh, and opening another connection inside the using statement of the first one. Sigh.

Why this element is "undefined" -- it clearly exists

I am getting what seems to be a very odd error in a web page. This is happening in both VS2008 and VS2012. In the following:
<div class="content_header" onclick="tierMenu(menu2,img2)">
<img id="img2" alt="Colapse Trips" height="9" src="Images/plus.gif" width="9" />
Travel Summary
</div>
clicking the plus image is supposed to change the image to a minus (expanding the item to display data). The tierMenu javascript method is called upon clicking, and it exists. But I am getting an error:
0x800a1391 - Microsoft JScript runtime error: 'img2' is undefined
"Img2" definitely exists. There is similar code in other places in the page, and they all behave the same way -- getting the same error. Odd thing is, the code is working fine in production. It's calling:
function tierMenu(objMenu,objImage)
{
if(objMenu && objImage)
{
...
}
}
It happens that my dev machine is 64-bit Windows 7. I can't imagine that this would be a problem. Any ideas?
Edited to Add: A colleague whose workstation is Win XP tried this on VS2008 and the problem did not occur. Really odd. The problem occurs on my workstation even when running outside of Visual Studio, i.e. directly from the browser using localhost.
This turns out to be a browser compatibility issue. If I put IE9 into compatibility mode the problem goes away.
It isn't the first time compatibility has beat me over the head. I will have to learn to try that first thing as soon as something weird like this happens.
Thanks to everyone who looked at this and puzzled over it with me.

Resources