I am building a simple real time delay system on my mac (2010-11 model; os x Mavericks; serial audio input) using Simulinks (Matlab 2014a) consisting of a 'Audio Input' block, an 'Audio Output' block a 'delay' block and an adder (to add the delayed signal to the original signal), but I receive the error: 'Error in 'untitled/From Audio Device': A given audio device may only be opened once.' twice for the audio input block.
When I try the same using a audio file as my input I get the desired results. Also the same diagram works fine on a windows machine.
Please help.
Thank you.
I think the issue is that you are trying to output a sound to the audio device, while at the same time to trying to read from the audio device. That won't work, you can't do that. See Keep playing a sound over and over again in Matlab? for a similar issue in MATLAB. You need to somehow wait for the reading part to complete before outputting the sound back to the audio device, or use two different devices, one for reading and one for writing.
I suspect the same model worked on a Windows machine because it probably had two audio devices (maybe a built-in and an external), and the model automatically detected this, reading from one device, and outputting to the other. The documentation for both blocks says:
Use the Device parameter to specify the device from which to acquire
audio. This parameter is automatically populated based on the audio
devices installed on your system.
which again, reinforces that theory. If you still have access to the Windows machine, you can double-check that this is the case.
Thanks for reading and any comments you may have.
Context:
I've been a UI/R&D dev (prototyping, etc.) for over 20 years and just started server/backend development.
I'm very new to Go - less than 2 months - and have 1) run through much of GoByExample and 2) set up a primitive, working web server on an Amazon EC2 instance.
I created a UI in another language which serves a HUD (Heads Up Display) for another 3rd party application - a game which spawns multiple windows. (Think multiple poker tables running in multiple windows.)
I connected the HUD to a Go client I created.
I use Go to grab OS information because of limitations in the first language.
I want to continue to use Go because I really enjoy it.
I'm on a Windows 7 machine.
Goal(s):
Big picture: When a User moves a window, I want the HUD to move with it.
To do this I need information about the main windows whos WindowText starts with "Game".
The ideal would be something like this:
windows: [ { windowHwnd:hwnd, windowText:windowText, windowX:x, windowY:y, windowWidth:width, windowHeight:height },
.
.
.
{ windowHwnd:hwnd, windowText:windowText, windowX:x, windowY:y, windowWidth:width, windowHeight:height } ]
Steps I've taken:
I've grabbed and modified github.com/AllenDang/w32 which I think formats syscall for Go.
When I need an unlisted function from user32.go, I add it.
Tried using GetForegroundWindow and GetWindowText with result, then GetWindow( hwnd, previous ) to just walkthrough everything
Read through:
syscall docs (http://golang.org/pkg/syscall/)
syscall/dll_windows.go
syscall/env_windows.go
syscall/exec_windows.go
syscall/syscall.go
syscall/syscall_windows.go
syscall/syscall_windows_386.go
syscall/syscall_windows_amd86.go
syscall/syscall_windows_test.go
syscall/zsyscall_windows_386.go
syscall/zsyscall_windows_amd86.go
syscall/ztypes_windows.go
syscall/ztypes_windows_386.go
syscall/ztypes_windows_amd86.go
Every potential Window Function at Windows Dev Center
Searched StackExchange, Google, DuckDuckGo
I can see there's something (TestEnumWindows)
line 125 in runtime/syscall_windows_test.go (http://golang.org/src/pkg/runtime/syscall_windows_test.go)
Though this function doesn't exist in syscall_windows_test.go
Questions:
Better solution? In my ignorance I could easily be overlooking some method like: GiveGeoffreyExactlyWhatHeWants()
Am I in the right ballpark?
Is this doable in Go?
What's the right direction to head?
Is this something anybody else needs?
It is not clear what you want , but perhaps http://play.golang.org/p/YfGDtIuuBw will help. It uses EnumWindows to find window with a particular title.
Alex
I'm trying to add sound to a Perl script to alert the user that the transaction was OK (user may not be looking at the screen all the time while working). I'd like to stay as portable as possible, as the script runs on Windows and Linux stations.
I can
use Win32::Sound;
Win32::Sound::Play('SystemDefault',SND_ASYNC);
for Windows. But I'm not sure how to call a generic sound on Linux (Gnome). So far, I've come up with
system('paplay /usr/share/sounds/gnome/default/alert/sonar.ogg');
But I'm not sure if I can count on that path being available.
So, three questions:
Is there a better way to call a default sound in Gnome
Is that path pretty universal (at least among Debain/Ubuntu flavors)
paplay takes a while to exit after playing a sound, is there a better way to call it?
I'd rather stay away from beeping the system speaker, it sounds awful (this is going to get played a lot) and Ubuntu blacklists the PC Speaker anyway.
Thanks!
A more portable way to get the path to paplay (assuming it's there) might be to use File::Which. Then you could get the path like:
use File::Which;
my $paplay_path = which 'paplay';
And to play the sound asynchronously, you can fork a subprocess:
my $pid = fork;
if ( !$pid ) {
# in the child process
system $paplay_path, '/usr/share/sounds/gnome/default/alert/sonar.ogg';
}
# parent proc continues here
Notice also that I've used the multi-argument form of system; doing so avoids the shell and runs the requested program directly. This avoids dangerous bugs (and is more efficient.)
Is there any software for the make which offers command line (or other scripting) utility to modify AudioUnit parameters?
The use case is this:
Default (Built-In) input
Attach better Gain Control
AudioUnit (the default OS-X gain
control is inadequate)
Attach L-R balance control (or
"pan")
Pass-through (link) to Default
Output a.k.a. LineIn.app
Script control of AudioUnit 2).
For a 0-100% volume control of the
input audio. In 1/16 increments
(6.5%) just like the main volume in
OS-X.
Script control of AudioUnit 3)
for L-R balance (pan) control.
The problem here for me is at steps 5 and 6.
Steps 1) through to 4) can be adequately achieved graphically in AudioHijackPro. The pass-through, and audio units can be created in there. It also comes with a really good gain control dial / knob. However all those effects are set exclusively through the GUI interface.
Desperately searching for a command-line tool (or "audiounit host") which can set the parameters values and send them to these audio units with the set parameter C api function(s).
Do any existing tools on the Mac offer this kind of functionality?
It sounds like you want Triumph. It can't be controlled from the command line but it is Applescript-able.
Spotify's Pedalbord is a Python library that can apply AU plugins:
https://github.com/spotify/pedalboard
With Fire, it's trivial to turn any Python script into a CLI tool:
https://github.com/google/python-fire
I have backups of files archived in optical media (CDs and DVDs). These all have par2 recovery files, stored on separate media. Even in cases where there are no par2 files, minor errors when reading on one optical drive can be read fine on another drive.
The thing is, when reading faulty media, the read time is very, very long, because devices tend to retry multiple times.
The question is: how can I control the number of retries (ie set to no retries or only one try)? Some system call? A library I can download? Do I have to work on the SCSI layer?
The question is mainly about Linux, but any Win32 pointers will be more than welcome too.
man readom, a program that comes with cdrecord:
-noerror
Do not abort if the high level error checking in readom found an
uncorrectable error in the data stream.
-nocorr
Switch the drive into a mode where it ignores read errors in
data sectors that are a result of uncorrectable ECC/EDC errors
before reading. If readom completes, the error recovery mode of
the drive is switched back to the remembered old mode.
...
retries=#
Set the retry count for high level retries in readom to #. The
default is to do 128 retries which may be too much if you like
to read a CD with many unreadable sectors.
The best tool avaliable is dd_rhelp. Just
dd_rhelp /dev/cdrecorder /home/myself/DVD.img
,take a cup of tea and watch the nice graphics.
The dd_rhelp rpm package info:
dd_rhelp uses ddrescue on your entire disc, and attempts to gather the maximum
valid data before trying for ages on badsectors. If you leave dd_rhelp work
for infinite time, it has a similar effect as a simple dd_rescue. But because
you may not have this infinite time, dd_rhelp jumps over bad sectors and rescue
valid data. In the long run, it parses all your device with dd_rescue.
You can Ctrl-C it whenever you want, and rerun-it at will, dd_rhelp resumes the
job as it depends on the log files dd_rescue creates. In addition, progress
is shown in an ASCII picture of your device being rescued.
I've used it a lot myself and Is very, very realiable.
You can install it from DAG to Red Hat like distributions.
Since dd was suggested, I should note that I know of the existence and have used sg_dd, but my question was not about commands (1) or (1m), but about system calls (2) or libraries (3).
EDIT
Another linux command-line utility that is of help, is sdparm. The following flag seems to disable hardware retries:
sudo sdparm --set=RRC=0 /dev/sr0
where /dev/sr0 is the device for the optical drive in my case.
While checking whether hdparm could modify the number of retries (doesn't seem so), I thought that, depending on the type of error, lowering the CD-ROM speed could potentially reduce the number of read errors, which could actually increase the average read speed. However, if some sectors are completely unreadable, then even lowering the CD-ROM speed won't help.
Since you are asking about driver level access, you should look into SCSI commands, or perhaps an ASPI like API. On windows VSO software (developers of blindread/blindwrite below) have developed a much better API, Patin-Couffin, that provides locked low level access:
http://en.wikipedia.org/wiki/Patin-Couffin
That might get you started. However, at the end of the day, the drive is interfaced with SCSI commands, even if it's actually USB, SATA, ATA, IDE, or otherwise. You might also look up terms related to ATAPI, which was one of the first specifications for this CD-ROM SCSI layer interface.
I'd be surprised if you couldn't find a suitable linux library or example of dealing with the lower level commands using the above search terms and concepts.
Older answer:
Blindread/blindwrite was developed in the heyday of cd-rom protection schemes often using intentionally bad sectors or error information to verify the original CD.
It will allow you to set a whole slew of parameters, including retries. Keep in mind that the CD-ROM drive itself determines how many times to retry, and I'm not sure that this is settable via software for many (most?) CD-ROM drives.
You can copy the disk to ISO format, ignoring the errors, and then use ISO utilities to read the data.
-Adam
Take a look at the ASPI interface. Available on both windows and linux.
dd(1) is your friend.
dd if=/dev/cdrom of=image bs=2352 conv=noerror,notrunc
The drive may still retry a bit, but I don't think you'll get any better without modifying firmware.