|
Fix the program; what problem does it have?
|
|
|
|
|
Come on, when a program depends on some third party components, that's pretty normal. And nothing you can change!
|
|
|
|
|
Then make a note in the documentation to that effect and let the buyer beware.
|
|
|
|
|
please,
what is the equivalent of FileSystem.GetFIleinfo() in C#
thanks
|
|
|
|
|
Take a look here[^] and you will see how MSDN shows the differences between the various .NET languages.
It's time for a new signature.
|
|
|
|
|
Um. Difficult...
FileInfo fi = new FileInfo(@"C:\myFileName");
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Good morning.
I have created an Excel add-in to display a Import tab with several buttons designed to run VBA macros.
I only want this tab to display on the one workbook and not every instance of Excel. I am trying to test for the specific spreadsheet name, but the If statement keeps defaulting to the else condition. I have the following:
public RibbonCustom()
{
InitializeComponent();
this.tabImport.Visible = true;
if (Globals.ThisAddIn.Application.ThisWorkbook.FullName.ToString() == "ImportFile.xlsm") { this.tabImport.Visible = true; }
else { this.tabImport.Visible = false; }
}
The MessageBox.Show doesn't work.
Any suggestions? WHEELS
|
|
|
|
|
string theName = Globals.ThisAddIn.Application.ThisWorkbook.FullName.ToString();
if (theName == "ImportFile.xlsm")
{
this.tabImport.Visible = true;
}
else
{
this.tabImport.Visible = false;
}
Put a breakpoint on the declaration of theName , and run the code. Somehow, those two strings aren't the same.
I are Troll
|
|
|
|
|
Hi Eddy. I found one issue. I was using >FullName instead of .Name, but unfortunately it didn't fix the issue. Trying to figure out a way that I can see the contents of the code (variable).
|
|
|
|
|
Wheels012 wrote: Trying to figure out a way that I can see the contents of the code (variable).
That would be debugging[^]?
I are Troll
|
|
|
|
|
Won't debug unfortunately.
|
|
|
|
|
Wheels012 wrote: Won't debug unfortunately.
Tried to attach the debugger to Excel? If you can't debug, then you'd be limited to something like logging to a textfile.
I are Troll
|
|
|
|
|
Hi,
HOw can i insert a image to toolstrip using c#....through property i can do....i need to do through code.
Thanks.
krishna
|
|
|
|
|
toolStripButton2.Image = new Bitmap(fileName);
Or you can embed an image in your assembly and load it using the Manifest resource stream
toolStripButton2.Image = new Bitmap(GetType().Assembly.GetManifestResourceStream("assembly.name.image.name");
|
|
|
|
|
Hi,
Can you send an example code for the same....
Thanks
krishna
|
|
|
|
|
Dear Friends,
We have to get information of gsm connection level in c# (or vb) in windows mobile device
Is there anyway ?
Thanks in advance
|
|
|
|
|
I'm trying to produce a constant sound in a WAVE file.
Using this function (byte)(256 * Math.Sin(frequency * i)); it works and the WAV file correctly created, but it sounds like very bad quality. I tested it against the Beep function and the pitch seems the same.
If I remove the frequency variable from the function, the "quality" of the WAV is far better.
Did I do something wrong or is there a way to clean up the 'noise'?
(to create the file I used a pretty straightforward open source library that I found, which generally creates a header and a byte array and writes that to file)
thanks.
(I'm probably overlooking something very simple )
V.
|
|
|
|
|
I guess the cast to byte makes a problem - isn't 8bit mono sound written as unsigned bytes? Try 16bit sound, that's (signed) Int16.
|
|
|
|
|
It's all 16 bit sound, all info past as int . Why do you think it's 8 bit? I at least defined it as stereo, 16 bit, 44100KHz sample rate.
I tried to inverse the frequency (1/freq) which seems to clean up the noise, yet it remains dirty. (other frequency tests show that I at least have to inverse the freq, else the pitch is not the same at all)
thanks for the idea.
V.
|
|
|
|
|
V. wrote: Why do you think it's 8 bit?
Well the byte cast in your OP was a clue:
(byte)(256 * Math.Sin(frequency * i));
That may be your problem - if it is byte data you are handing to a function expecting 16 bit then it could go all odd...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
MMM, I don't think so, the entire thing is written to file as a byte array (logical, it's a binary file , but only when all else is set.
Here's the code:
public void PlayNoteWav(string note, int position)
{
Dictionary<int, double> played_note = guitar_strings[note];
if (position >= 0)
{
double frequency = played_note[position];
CreateWaveFile(frequency, duration);
}
else
{
System.Threading.Thread.Sleep(duration);
}
}
public void CreateWaveFile(double frequency, int duration)
{
bool whiteNoise = false;
Random rand = new Random();
file = new WaveFile(2, 16, 44100);
int samples = 44100;
byte[] data = new byte[file.NumChannels * (file.BitsPerSample / 8) * samples];
if (whiteNoise)
{
for (int i = 0; i < data.Length; i++)
{
data[i] = (byte)rand.Next(256);
}
}
else
{
for (int i = 0; i < data.Length; i++)
{
data[i] = (byte)(256 * Math.Sin(1/frequency * i));
}
}
file.SetData(data, samples);
file.WriteFile(@"C:\Test.wav");
}
Generally in the background it will hold all the information before writing to file.
Doesn't this statement:
byte[] data = new byte[file.NumChannels * (file.BitsPerSample / 8) * samples];<br /> take in account 16 bit sound (if bitspersample is set to 16) ?
In any case I'll have a go with setting to 8 bits mono, just for testing.
thanks.
V.
|
|
|
|
|
Yes, but if as your code indicates, it is 16 bits per sample, why are you generating 8 bit samples and loading them into successive bytes?
It means you file ends up with 16 bit samples made of two 8 bit bytes with the same frequency value. Should you not be using short or ushort values instead?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I'm pretty sure there are several errors here.
1.
if your samples are 16-bit you should use 16-bit quantities everywhere; so either work with a short array, or convert the intended short values to their upper and lower byte values; what you have basically is 8-bit samples.
2.
if your sound is to be stereophonic, you should generate two signals (e.g. two distinct sine waves) and alternate their samples; what you have is a single sine wave where consecutive samples are sent to the left and right channel, that isn't real stereo at all, there is just a small phase shift between left and right.
3.
if frequency is intended to indicate the tone pitch in Hertz, you need a conversion factor, probably 2*Math.Pi to make that happen. A sine wave goes one full cycle when its argument is increased by that amount, not by 1.
|
|
|
|
|
mmm, had to think about it a bit, but (i think) it starts to make sense .
1. OK, so 2 bytes for each value.
2. makes sense
3. I think it should be 1/frequency, 2*PI gave bad results, but maybe that was for another reason .
If I find the solution I'll let you know.
many thanks.
V.
|
|
|
|
|
Obviously for higher frequencies, the phase step has to be larger, not smaller, so F is in the numerator.
If you want N sine samples at frequency F spanning a period of 1 second, the phase step should be:
double deltaPhase=2*Math.Pi*F/N;
for(int i=0; i<N; i++) {
double phase=i*deltaPhase;
}
which means after N steps, your phase has increased by 2*Math.Pi*F, i.e. by F full circles.
|
|
|
|