Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Sound in games - Rooms

, 31 Jul 2012 CPOL
How to calculate a reverbration time in a room
WpfReverberationTime-noexe.zip
WpfReverberationTime
AbsorberList.xlsx
WpfReverberationTime.suo
WpfReverberationTime
AbsorberList.xlsx
bin
Debug
WpfReverberationTime.vshost.exe.manifest
My Project
MyExtensions
Settings.settings
obj
x86
Debug
frmAbsorber.baml
MainWindow.baml
WpfReverberationTime.g.resources
WpfReverberationTime.Resources.resources
WpfReverberationTime.vbproj.user
WpfReverberationTime.zip
AbsorberList.xlsx
WpfReverberationTime.suo
AbsorberList.xlsx
AmCharts.Windows.Design.dll
AmCharts.Windows.dll
WpfReverberationTime.exe
WpfReverberationTime.pdb
WpfReverberationTime.vshost.exe
WpfReverberationTime.vshost.exe.manifest
Release
Settings.settings
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
frmAbsorber.baml
Interop.Microsoft.Office.Core.dll
MainWindow.baml
TempPE
My Project.Resources.Designer.vb.dll
WpfReverberationTime.exe
WpfReverberationTime.g.resources
WpfReverberationTime.pdb
WpfReverberationTime.Resources.resources
WpfReverberationTime.vbproj.GenerateResource.Cache
WpfReverberationTime.vbproj.ResolveComReference.cache
WpfReverberationTime.vbprojResolveAssemblyReference.cache
WpfReverberationTime_MarkupCompile.cache
WpfReverberationTime_MarkupCompile.i.cache
Release
WpfReverberationTime.vbproj.user
Imports Microsoft.Office.Interop

Public Class frmAbsorber
    Private Abs As Absorber
    Private temp As New System.Collections.ObjectModel.ObservableCollection(Of Absorber)

    Private ImportedFromExcel As New System.Collections.ObjectModel.ObservableCollection(Of Absorber)

    Private Function GetParent(ByVal path As String) As String
            Dim directoryInfo As System.IO.DirectoryInfo
            directoryInfo = System.IO.Directory.GetParent(path)
            Return directoryInfo.FullName
    End Function

    Public Sub New(ByRef _Abs As Absorber)

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Abs = _Abs
        temp.Add(Abs)
        lstAbs.ItemsSource = temp
        Dim path As String = GetParent(GetParent(System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName)))
        Dim filename As String = path & "\AbsorberList.xlsx"

        ' Create new Application.
        Dim excel As Excel.Application = New Excel.Application

        ' Open Excel spreadsheet.
        Dim w As Excel.Workbook = excel.Workbooks.Open(filename)
        Dim sheet As Excel.Worksheet = w.Sheets(1)
        Dim usedRange As Excel.Range = sheet.UsedRange

        Dim darray(,) As Object
        darray = CType(usedRange.Value, Object(,))

        Dim rows As Integer = darray.GetUpperBound(0)
        Dim cols As Integer = darray.GetUpperBound(1)
        For ii As Integer = 2 To rows
            Dim g As New Absorber
            For j As Integer = 1 To cols
                If j = 1 Then
                    g.Name = darray(ii, j).ToString
                ElseIf j > 1 Then
                    g.SetItem(j - 2, CDbl(darray(ii, j).ToString))
                End If
            Next
            ImportedFromExcel.Add(g)
        Next
        w.Close()

        For i As Integer = 0 To ImportedFromExcel.Count - 1
            cmbSelectFromExcel.Items.Add(ImportedFromExcel(i).Name)
        Next

    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
        Abs.Name = temp(0).Name
        Abs.Area = temp(0).Area
        For i As Integer = 0 To temp(0).Count - 1
            Abs.SetItem(i, temp(0).GetItem(i))
        Next
        Me.DialogResult = True
        Me.Close()
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button2.Click
        Me.DialogResult = False
        Me.Close()
    End Sub

    Private Sub cmbSelectFromExcel_SelectionChanged(sender As System.Object, e As System.Windows.Controls.SelectionChangedEventArgs) Handles cmbSelectFromExcel.SelectionChanged
        Dim something As New Absorber
        something = ImportedFromExcel(cmbSelectFromExcel.SelectedIndex)
        temp(0) = something
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Kenneth Haugland
Engineer
Norway Norway
I hope that you like the stuff I have created and if you do wish to say thank you then a donation is always appreciated.
You can donate here[^].

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141223.1 | Last Updated 31 Jul 2012
Article Copyright 2012 by Kenneth Haugland
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid