Sorry that this question is a bit vague but that's the problem, I've been pretty much shooting in the dark due to being unable to find ANY information on this specific area.
I'm hosting AUAudioUnits on OSX. That all works fine. I can find em, load em, instantiate em and use em. No probs.
But it seems there are more options buried somewhere and I've no idea where to even look to configure this.
So... the problem: I have a specific AU (Superior Drummer 3 in case it's relevant) that comes in 2 flavours: stereo and 16 channel. It seems that both come from the same component (I assume via AUAudioUnit.registerSubclass) and it has a configurationDictionary that seems to contain the information for the 16 channel version (configurationDictionary dump here):
configs: ["SupportedChannelLayoutTags": {
Output = (
6619138,
6684674,
6750210,
6946818
);
}, "HasCustomView": 1, "BusCountWritable": <__NSArrayI 0x600000cd3210>(
0,
0,
0
)
, "ChannelConfigurations": <__NSSingleObjectArrayI 0x600000006e00>(
<__NSArrayI 0x600000290620>(
0,
2
)
)
, "InitialOutputs": <__NSArrayI 0x600003025ef0>(
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
)
]
But I have absolutely no idea where to go from here and am utterly stumped. How is one supposed to extract that information from the dictionary (given that I have no idea of the type information - and bearing in mind I've no interest in hacking it, I want to know the proper flags etc to do this) and how is one supposed to reconfigure the subclass with that info?
Any help at all would be so appreciated I cannot tell you. Even just a pointer in the right direction.
Cheers
Related
I have two questions actually.
I am currently trying to use jpeg() with RMarkdown. It used to work quite well but stopped working and have no idea why. </p>
a. Here is my code:
attach(Hippocampus)
jpeg("Pictures_OnePlot.jpeg", width = 5, height = 3.5, units = "in", res = 600)
plot(Months_as_Taxi_Driver, Anterior_Hippocampus_Volume_mm3,
main = bold("Volume /")~ bold(mm^3) ~ bold("vs Months as a Taxi Driver"),
cex.main = 1.25,
cex.lab = 1,
xlab = "Anterior Hippocampus Volume" ~ (mm^3),
ylab = "Months as Taxi Driver")
graphics.off()
Code
Hippocampus Data
Moreover, now when I try running the code or knitting my file, it does not work at all.
Once the above gets fixed, how do I save this file into a different folder or into a subfolder within the same folder? Before, it would just save it in the same folder as the R-Markdown folder, but I'd like it to go into a sub-folder.
Thanks for the help, everyone. :)
I tried using dev.off() at the end instead and tried Googling with no avail. There was a similar thread though they used x11(), which doesn't work with R (and I am not even sure what x11() is, but that is a different story).
I know how to do the above via ggsave() when I use ggplot, but I'd like to know this method too (especially when using plot().
Thanks again!
I'm going to modify DRAW(Deep Recurrent Attentive Writer) code that other person shared here for variable length sequence using tf.scan function. So I need to change the for loop in the original code into a structure that is suitable for scan function. Below is original part of the code,
...
for t in range(T):
c_prev = tf.zeros((batch_size,img_size)) if t==0 else cs[t-1]
x_hat=x-tf.sigmoid(c_prev) # error image
r=read(x,x_hat,h_dec_prev)
h_enc,enc_state=encode(enc_state,tf.concat(1,[r,h_dec_prev]))
z,mus[t],logsigmas[t],sigmas[t]=sampleQ(h_enc)
h_dec,dec_state=decode(dec_state,z)
cs[t]=c_prev+write(h_dec) # store results
h_dec_prev=h_dec
DO_SHARE=True # from now on, share variables
...
In order to use tf.scan, I need to pass several previous states(c_prev, h_dec_prev...). However, as I know tf.scan only gets one tensor (is it right?) for the loop as an example in here
elems = np.array([1, 2, 3, 4, 5, 6])
sum = scan(lambda a, x: a + x, elems)
It seems there should be only one a and it should be a tensor. In this case, only possible way I can imagine is to flatten several different state tensors and concatenate it. But I'm worrying that it will mess up the code and make slow down the speed a lot especially when the state sizes are all different. Is there any efficient (and fast) way to handle this kind of problem?
I've had this strange thing happen in Pygame1.9.1's font module, where .get_linesize() returns 1 for fonts whose glyph height (let alone per-line height) renders greater than 1. It only happens with .fon fonts.
Here are two examples, plus a third font that does work, for the sake of a control. I've run these from IDLE's shell, but the same thing happens with proper modules.
In any case, Pygame has already been initialized.
>>> testfont = pygame.font.Font("C:/Windows/Fonts/vga850.fon", 12)
>>> testfont.get_linesize() # This one returns 1. For 'Terminal Regular'
1
>>> otherfont = pygame.font.Font("C:/Windows/Fonts/vgafix.fon", 18)
>>> otherfont.get_linesize() # This also returns 1. For 'Fixedsys Regular'
1
>>> lastfont = pygame.font.Font("C:/Windows/Fonts/OCRAStd.otf", 24)
>>> lastfont.get_linesize() # This returns the correct value. For 'OCR A Std Regular'
29
>>> textsurf = testfont.render("This is a nightmare!", True, (0,0,0))
>>> textsurf.get_size()[1] # Let's get the height of this surface...
12
>>> othersurf = otherfont.render("An inescapable nightmare!", False, (0,0,0))
>>> othersurf.get_size()[1] # This one, too. Antialiasing makes no difference.
15
>>> lastsurf = lastfont.render("You're okay, OCRA.", True, (0,0,0))
>>> lastsurf.get_size()[1] # And finally, the control...
25
The height of the render for the control is a little shorter, since get_linesize() includes a gap between lines for aesthetic reasons.
<Font>.size("sample string")[1] works correctly, so that's been my stopgap for line height.
All three fonts render correctly.
The common thread with the fonts that do not respond properly to <Font>.get_linesize() is that they all share the extension .fon, so the easy 'solution' is simply, "Do not use .get_linesize() with .fon fonts; use .size('sample')[1] + some_adjustment instead."
This, however, is somewhat inelegant and (worse still!) terribly boring, and I'm much more interested to know what causes this problem, and if there is a way to make these fonts work with get_linesize() as they should.
I looked through Pygame's documentation and couldn't find anything to do with this issue, and a number of web searches proved fruitless as well.
Pygame's Font support depends on SDL_ttf which in turn depends on freetype2. I suspect there's some problem in calculating the value for line height as the font goes through those layers (specifically the SDL_ttf layer, as freetype2 just reads the font data).
Consider using pygame.freetype.Font instead of pygame.Font. The freetype module skips the SDL_ttf layer and works with freetype directly. There is a much richer set of options for fonts there. I'd try get_sized_height() as a replacement for get_linesize().
If that still doesn't work, most likely it is a freetype bug in reading FON files, or possibly the FON files themselves don't have the value set correctly.
I primarily program in Java but I am taking a graphics course for which I need to use C++. I am trying to create an array of objects in order to loop through them and draw them to the screen, but I can't for the life of me figure out how to create this array. I have code now which does not produce any compiler errors, but it doesn't seem to work correctly either. The following code is at the top of my Main.cpp class:
Platform ground("wallstone.tga", 40, 16, 4, 144);
Platform platform1("wallstone.tga", 10, 16, 4, 20);
Platform platforms[2] = {ground, platform1}
When I try: fprintf(stdout, "Size of platforms array: %d", sizeof(platforms)/sizeof(Platform)); it prints out 0.0.
I've tried several ways of creating this array and they all seem to produce errors or that same output of 0.0, so I'm not sure what's going on. If any more of my code is necessary I will certainly be willing to post it. Of course, if there is a better way of approaching this I am grateful. Thanks!
It looks like you are doing everything right. My only guess is that size_t on your platform is larger than int, so providing a correct format specifier (%z instead of %d) may fix the problem:
fprintf(stdout, "Size of platforms array: %z", sizeof(platforms)/sizeof(Platform));
so I decided I would put my few R functions into a package and I'm reading/learning Writing R Extension.
it obviously complains about an amount of things I'm not doing right.
after enough googling, I'm firing a few questions here, this one is about testing style: I am using RUnit and I like having tests as close possible to the code being tested. this way I won't forget about the tests and I use the tests as part of the technical documentation.
for example:
fillInTheBlanks <- function(S) {
## NA in S are replaced with observed values
## accepts a vector possibly holding NA values and returns a vector
## where all observed values are carried forward and the first is
## carried backward. cfr na.locf from zoo library.
L <- !is.na(S)
c(S[L][1], S[L])[1 + cumsum(L)]
}
test.fillInTheBlanks <- function() {
checkEquals(fillInTheBlanks(c(1, NA, NA, 2, 3, NA, 4)), c(1, 1, 1, 2, 3, 3, 4))
checkEquals(fillInTheBlanks(c(1, 2, 3, 4)), c(1, 2, 3, 4))
checkEquals(fillInTheBlanks(c(NA, NA, 2, 3, NA, 4)), c(2, 2, 2, 3, 3, 4))
}
but R CMD check issues NOTE lines, like this one:
test.fillInTheBlanks: no visible global function definition for
‘checkEquals’
and it complains about me not documenting the test functions.
I don't really want to add documentation for the test functions and I definitely would prefer not having to add a dependency to the RUnit package.
how do you think I should look at this issue?
Where are you putting your unit tests? You may not want to put them into the R directory. A more standard approach is to put them under inst\unitTests. Have a look at this R-wiki page regarding the configuration.
Alternatively, you can specify what files will be exported in your NAMESPACE, and by extension, what functions should and should not be documented.
Beyond that, ideally you should have your tests run when R CMD CHECK is called; that's part of the design. In which case, you should create a test script to call your tests in a separate tests directory. And you will need to load the RUnit package in that script (but you don't need to make it a dependency of your package).
Edit 1:
Regarding your failure because it can't find the checkEquals function: I would change you function to be like this:
test.fillInTheBlanks <- function() {
require(RUnit)
checkEquals(fillInTheBlanks(c(1, NA, NA, 2, 3, NA, 4)), c(1, 1, 1, 2, 3, 3, 4))
checkEquals(fillInTheBlanks(c(1, 2, 3, 4)), c(1, 2, 3, 4))
checkEquals(fillInTheBlanks(c(NA, NA, 2, 3, NA, 4)), c(2, 2, 2, 3, 3, 4))
}
That way the package is loaded when the function is called or it will inform the user that the package is required.
Edit 2:
From "Writing R Extensions":
Note that all user-level objects in a package should be documented; if a package pkg contains user-level objects which are for “internal” use only, it should provide a file pkg-internal.Rd which documents all such objects, and clearly states that these are not meant to be called by the user. See e.g. the sources for package grid in the R distribution for an example. Note that packages which use internal objects extensively should hide those objects in a name space, when they do not need to be documented (see Package name spaces).
You can use the pkg-internal.Rd file as one option, but if you intend on having many hidden objects, this is usually handled in the declarations in the NAMESPACE.
Did you load the RUnit package?
Your best bet is probably to look at a package containing existing code using RUnit.